Mercurial Hosting > editor
changeset 41:f7e8c1f532c8 default tip
start list window
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 17 May 2025 22:20:57 -0600 (14 hours ago) |
parents | 38bc1cdf77c8 |
children | |
files | src/luan_editor/menu.luan src/luan_editor/window.luan |
diffstat | 2 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan_editor/menu.luan Thu May 15 19:12:46 2025 -0600 +++ b/src/luan_editor/menu.luan Sat May 17 22:20:57 2025 -0600 @@ -245,6 +245,11 @@ end end } + new_menu_item{ + text = "List Windows" + accelerator = "meta L" + action_listener = action_listener(window.show_list_window) + } } } }
--- a/src/luan_editor/window.luan Thu May 15 19:12:46 2025 -0600 +++ b/src/luan_editor/window.luan Sat May 17 22:20:57 2025 -0600 @@ -10,6 +10,7 @@ local Io = require "luan:Io.luan" local new_text_area = require("luan:swing/Text_area.luan").new or error() local new_frame = require("luan:swing/Frame.luan").new or error() +local new_dialog = require("luan:swing/Dialog.luan").new or error() local new_panel = require("luan:swing/Component.luan").new_panel or error() local Layout = require "luan:swing/Layout.luan" local new_mig_layout = Layout.new_mig_layout or error() @@ -26,6 +27,8 @@ local choose_file = File_chooser.awt_choose_file or error() local Option_pane = require "luan:swing/Option_pane.luan" local show_message_dialog = Option_pane.show_message_dialog or error() +local new_radio_button = require("luan:swing/Radio_button.luan").new or error() +local new_button_group = require("luan:swing/Button_group.luan").new or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "editor/window" @@ -59,6 +62,32 @@ config_file.write_text( stringify(config).."\n" ) end +local list_view = new_panel{ + --layout = new_mig_layout("insets 0,wrap,fill") + layout = new_mig_layout("wrap","[grow]") +} +local list_scroll_pane = new_scroll_pane{ + view = list_view +} +local list_window = new_dialog{ + preferred_size = { width=200, height=400 } + content_pane = list_scroll_pane +} +local list_group = new_button_group() +local function new_list_window_item(text) + local rb = new_radio_button{ + constraints = "grow" + text = text + horizontal_text_position = "left" + horizontal_alignment = "right" + } + list_view.add(rb) + list_group.add(rb) + list_scroll_pane.scroll_to_right() + list_window.pack() + return rb +end + local function new_window(file,document) local window = {} if file == nil or not file.exists() then @@ -147,6 +176,7 @@ s = s.." *" end frame.title = s + new_list_window_item(title) end set_title() window.set_title = set_title -- dont gc @@ -264,6 +294,10 @@ local new = new_window(file,text_area.document) new.text_area.set_selection( text_area.get_selection() ) end + function window.show_list_window() + list_window.visible = true + list_scroll_pane.scroll_to_right() + end add_menu_bar(window) frame.pack() if config.location ~= nil then