Mercurial Hosting > luan
changeset 1911:cd4c11d7dc7e default tip
tab size
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 16 Apr 2025 09:59:48 -0600 |
parents | bb58f0d24f22 |
children | |
files | src/luan/modules/editor/menu.luan src/luan/modules/swing/Option_pane.luan |
diffstat | 2 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/editor/menu.luan Wed Apr 16 09:38:28 2025 -0600 +++ b/src/luan/modules/editor/menu.luan Wed Apr 16 09:59:48 2025 -0600 @@ -20,7 +20,8 @@ end local function add_menu_bar(window) - local document = window.text_area.document + local text_area = window.text_area + local document = text_area.document local status_bar = window.status_bar local revert = new_menu_item{ text = "Revert" @@ -90,17 +91,17 @@ new_menu_item{ text = "Cut" accelerator = "meta X" - action_listener = action_listener(window.text_area.cut) + action_listener = action_listener(text_area.cut) } new_menu_item{ text = "Copy" accelerator = "meta C" - action_listener = action_listener(window.text_area.copy) + action_listener = action_listener(text_area.copy) } new_menu_item{ text = "Paste" accelerator = "meta V" - action_listener = action_listener(window.text_area.paste) + action_listener = action_listener(text_area.paste) } separator new_menu_item{ @@ -117,7 +118,7 @@ new_menu_item{ text = "Select All" accelerator = "meta A" - action_listener = action_listener(window.text_area.select_all) + action_listener = action_listener(text_area.select_all) } } } @@ -144,15 +145,15 @@ menu_items = { new_check_box_menu_item{ text = "Word Wrap" - state = window.text_area.line_wrap + state = text_area.line_wrap action_listener = function(event) - window.text_area.line_wrap = event.source.state + text_area.line_wrap = event.source.state end } new_check_box_menu_item{ text = "Show Whitespace" action_listener = function(event) - window.text_area.show_whitespace(event.source.state) + text_area.show_whitespace(event.source.state) end } new_menu_item{ @@ -171,15 +172,28 @@ return end local line = to_number(input) - if line ~= nil then - try - window.goto(line) - status_bar.text = "Went to line "..line - return - catch e - end + try + window.goto(line) + status_bar.text = "Went to line "..line + catch e + status_bar.text = "Invalid line: "..input end - status_bar.text = "Invalid line: "..input + end + } + new_menu_item{ + text = "Tab Size" + action_listener = function(_) + local input = show_input_dialog( window.frame, "Tab size", text_area.tab_size ) + if input == nil then + return + end + local size = to_number(input) + try + text_area.tab_size = size + status_bar.text = "Set tab size to "..size + catch e + status_bar.text = "Invalid tab size: "..input + end end } }
--- a/src/luan/modules/swing/Option_pane.luan Wed Apr 16 09:38:28 2025 -0600 +++ b/src/luan/modules/swing/Option_pane.luan Wed Apr 16 09:59:48 2025 -0600 @@ -9,8 +9,8 @@ JOptionPane.showMessageDialog( frame.java, message, "", JOptionPane.PLAIN_MESSAGE ) end -function Option_pane.show_input_dialog(frame,message) - return JOptionPane.showInputDialog( frame.java, message, "", JOptionPane.PLAIN_MESSAGE ) +function Option_pane.show_input_dialog(frame,message,value) + return JOptionPane.showInputDialog( frame.java, message, "", JOptionPane.PLAIN_MESSAGE, nil, nil, value ) end return Option_pane