-
-
Save rubenwardy/787f72ec85cdfa8b66cb to your computer and use it in GitHub Desktop.
Prototype Language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import files | |
im gui.rlg | |
im io.rlg | |
# Globals | |
main_window :: Integer | |
textarea :: Integer | |
# Main function | |
() -> | |
init_gui() | |
main_window = gui_add_window("Text Editor") | |
gui_add_menu_bar(main_window, [0:"File", 1:"Edit", 2:"View", 3:"Help"]) | |
gui_add_menu_item(main_window, 0, [4:"New", 5:"Open", 6:"Save"]) | |
textarea = gui_add_text_field(main_window, true) | |
gui_set_dock_element(textarea, true) | |
gui_show_window(main_window) | |
# gui_event function when type == "menubar" | |
gui_event("menubar", e) -> | |
if (e.id == 4) -> | |
gui_set_text_field(textarea, "") | |
if (e.id == 5) -> | |
result :: String | |
result = gui_open_file_dialog(main_window, ["Text Files: *.txt", "All Files: *"], true) | |
if (result) -> | |
gui_set_text_field(textarea, io_read_file(result)) | |
if (e.id == 6) -> | |
result :: String | |
result = gui_save_file_dialog(main_window, ["Text Files: *.txt", "All Files: *"], true) | |
if (result) -> | |
io_write_file(result, textarea) | |
# gui_event function | |
gui_event(type, e) -> | |
print("Unknown event occured, event dropped") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment