Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Red [
- title: "Red basic Editor"
- author: "Didier Cadieu"
- version: 0.1.0
- date: "24-01-2017"
- ]
- script: make string! 10000
- saved?: true
- f-file: f-script: file: none
- new-file: has [stop?] [
- unless any [empty? script saved?] [
- view/flags [Text "Do you want to save your script first ?" button "Yes, for sure" [save-file unview] button "No, discard it" [saved?: true unview]] 'modal
- ]
- if saved? [
- file: none
- append clear f-file/text "(new file)"
- clear head script
- ]
- ]
- load-file: has [f] [
- if f: request-file/title/filter "Select a Red file to load" [{Red or Red/system file (*.red *.reds)} "*.red;*.reds" {All files (*.*)} "*.*"] [
- append clear f-file/text file: f
- append clear script read file
- saved?: true
- ]
- ]
- save-as-file: has [f] [
- if f: request-file/save/title/filter "Chosse a folder and name for your file to save" [{Red file (*.red)} "*.red" {Red/system file (*.reds)} "*.reds" {All files (*.*)} "*.*"] [
- unless suffix? f [append f %.red] ; Not good enough : request-file/save must add suffix itself if missing regarding the selected filter IMO
- file: f
- save-file
- ]
- ]
- save-file: does [
- unless file [save-as-file exit]
- write file head script
- saved?: true
- ]
- view/no-wait/flags main: layout [
- title "Red basic editor"
- origin 2x2 space 2x2
- style btn: button 80x20
- btn "New" [new-file]
- btn "Load..." [load-file]
- btn "Save" [save-file]
- btn "Save as..." [save-as-file]
- return
- text 30x20 "File :" f-file: text "(new file)" bold 568x20
- return
- f-script: area script 600x600 on-change [saved?: false]
- ] 'resize
- insert-event-func [
- if event/type = 'resize [
- f-file/size/y: event/window/size/y - 2 - f-file/offset/y
- f-script/size: event/window/size - 2x2 - f-script/offset
- 'done
- ]
- ]
- do-events
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement