diff --git a/plugins/lua/view.lua b/plugins/lua/view.lua index 5c36de6..d2834b8 100644 --- a/plugins/lua/view.lua +++ b/plugins/lua/view.lua @@ -395,41 +395,65 @@ function M.open_buffer_search_window(ctx) -- end end -function render_command_search(ctx) - if CommandSearchOpen or CommandSearchOpenElapsed > 0 then - if CommandSearchOpen and CommandSearchOpenElapsed < numFrames then - CommandSearchOpenElapsed = CommandSearchOpenElapsed + 1 - elseif not CommandSearchOpen and CommandSearchOpenElapsed > 0 then - CommandSearchOpenElapsed = CommandSearchOpenElapsed - 1 - end - end +function M.open_command_palette(ctx) + -- if CommandSearchOpen or CommandSearchOpenElapsed > 0 then + -- if CommandSearchOpen and CommandSearchOpenElapsed < numFrames then + -- CommandSearchOpenElapsed = CommandSearchOpenElapsed + 1 + -- elseif not CommandSearchOpen and CommandSearchOpenElapsed > 0 then + -- CommandSearchOpenElapsed = CommandSearchOpenElapsed - 1 + -- end + -- end - if CommandSearchOpen or CommandSearchOpenElapsed > 0 then - window_percent_width = 75 - window_percent_height = 25 - if CommandSearchOpenElapsed > 0 then - window_percent_width = ((CommandSearchOpenElapsed/numFrames) * 75) - window_percent_height = ((CommandSearchOpenElapsed/numFrames) * 25) - end + -- if CommandSearchOpen or CommandSearchOpenElapsed > 0 then + -- window_percent_width = 75 + -- window_percent_height = 25 + -- if CommandSearchOpenElapsed > 0 then + -- window_percent_width = ((CommandSearchOpenElapsed/numFrames) * 75) + -- window_percent_height = ((CommandSearchOpenElapsed/numFrames) * 25) + -- end - UI.push_parent(ctx, UI.push_floating(ctx, "buffer search canvas", 0, 0)) - centered(ctx, "command search window", UI.Horizontal, UI.PercentOfParent(window_percent_width), UI.PercentOfParent(window_percent_height), + -- UI.push_parent(ctx, UI.push_floating(ctx, "buffer search canvas", 0, 0)) + -- centered(ctx, "command search window", UI.Horizontal, UI.PercentOfParent(window_percent_width), UI.PercentOfParent(window_percent_height), + -- function () + local input = { + {Editor.Key.Escape, "Close Window", ( + function () + Editor.request_window_close() + CommandSearchOpen = false + end + )}, + {Editor.Key.Enter, "Run Command", ( function () - list(ctx, "command list", CommandSearchIndex, CommandList, - function(ctx, cmd, is_selected) - flags = {"DrawText"} + if CommandList[CommandSearchIndex] ~= nil then + Editor.run_command("nl.spacegirl.editor.core", CommandList[CommandSearchIndex]["name"]) + CommandList = {} - if is_selected then - table.insert(flags, 1, "DrawBorder") - end - - interaction = UI.advanced_button(ctx, " "..cmd.name..": "..cmd.description.." ", flags, UI.Fill, UI.FitText) - end - ) + Editor.request_window_close() + CommandSearchOpen = false + end end - ) - UI.pop_parent(ctx) - end + )}, + -- TODO: don't scroll past selections + {Editor.Key.K, "Move Selection Up", (function () CommandSearchIndex = CommandSearchIndex - 1 end)}, + {Editor.Key.J, "Move Selection Down", (function () CommandSearchIndex = CommandSearchIndex + 1 end)}, + } + + Editor.spawn_floating_window(input, function(ctx) + list(ctx, "command list", CommandSearchIndex, CommandList, + function(ctx, cmd, is_selected) + flags = {"DrawText"} + + if is_selected then + table.insert(flags, 1, "DrawBorder") + end + + interaction = UI.advanced_button(ctx, " "..cmd.name..": "..cmd.description.." ", flags, UI.Fill, UI.FitText) + end + ) + end) + -- ) + -- UI.pop_parent(ctx) + -- end end function render_log_window(ctx) @@ -488,29 +512,8 @@ function M.OnLoad() CommandSearchIndex = 1 CommandList = Editor.query_command_group("nl.spacegirl.editor.core") + M.open_command_palette() end), - { - {Editor.Key.Escape, "Close Window", ( - function () - Editor.request_window_close() - CommandSearchOpen = false - end - )}, - {Editor.Key.Enter, "Run Command", ( - function () - if CommandList[CommandSearchIndex] ~= nil then - Editor.run_command("nl.spacegirl.editor.core", CommandList[CommandSearchIndex]["name"]) - CommandList = {} - - Editor.request_window_close() - CommandSearchOpen = false - end - end - )}, - -- TODO: don't scroll past selections - {Editor.Key.K, "Move Selection Up", (function () CommandSearchIndex = CommandSearchIndex - 1 end)}, - {Editor.Key.J, "Move Selection Down", (function () CommandSearchIndex = CommandSearchIndex + 1 end)}, - } }, {Editor.Key.B, "Buffer Search", M.open_buffer_search_window} }} diff --git a/src/main.odin b/src/main.odin index b03ac2b..87efc8e 100644 --- a/src/main.odin +++ b/src/main.odin @@ -1062,8 +1062,8 @@ main :: proc() { } } - // context.logger = core.new_logger(&state.log_buffer); - context.logger = log.create_console_logger(); + context.logger = core.new_logger(&state.log_buffer); + // context.logger = log.create_console_logger(); state.ctx = context; // TODO: don't use this @@ -1353,7 +1353,6 @@ main :: proc() { state.window.draw(state.plugin_vtable, state.window.user_data); } - if window, ok := &state.new_window.(core.NewWindow); ok { floating, interaction := ui.push_floating(&ui_context, "floating_window", {0,0}) ui.push_parent(&ui_context, floating)