jankily make the command palette work
parent
895a269bce
commit
0039da5c42
|
@ -395,26 +395,50 @@ function M.open_buffer_search_window(ctx)
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
function render_command_search(ctx)
|
function M.open_command_palette(ctx)
|
||||||
if CommandSearchOpen or CommandSearchOpenElapsed > 0 then
|
-- if CommandSearchOpen or CommandSearchOpenElapsed > 0 then
|
||||||
if CommandSearchOpen and CommandSearchOpenElapsed < numFrames then
|
-- if CommandSearchOpen and CommandSearchOpenElapsed < numFrames then
|
||||||
CommandSearchOpenElapsed = CommandSearchOpenElapsed + 1
|
-- CommandSearchOpenElapsed = CommandSearchOpenElapsed + 1
|
||||||
elseif not CommandSearchOpen and CommandSearchOpenElapsed > 0 then
|
-- elseif not CommandSearchOpen and CommandSearchOpenElapsed > 0 then
|
||||||
CommandSearchOpenElapsed = CommandSearchOpenElapsed - 1
|
-- CommandSearchOpenElapsed = CommandSearchOpenElapsed - 1
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
if CommandSearchOpen or CommandSearchOpenElapsed > 0 then
|
-- if CommandSearchOpen or CommandSearchOpenElapsed > 0 then
|
||||||
window_percent_width = 75
|
-- window_percent_width = 75
|
||||||
window_percent_height = 25
|
-- window_percent_height = 25
|
||||||
if CommandSearchOpenElapsed > 0 then
|
-- if CommandSearchOpenElapsed > 0 then
|
||||||
window_percent_width = ((CommandSearchOpenElapsed/numFrames) * 75)
|
-- window_percent_width = ((CommandSearchOpenElapsed/numFrames) * 75)
|
||||||
window_percent_height = ((CommandSearchOpenElapsed/numFrames) * 25)
|
-- window_percent_height = ((CommandSearchOpenElapsed/numFrames) * 25)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
UI.push_parent(ctx, UI.push_floating(ctx, "buffer search canvas", 0, 0))
|
-- 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),
|
-- 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 ()
|
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.spawn_floating_window(input, function(ctx)
|
||||||
list(ctx, "command list", CommandSearchIndex, CommandList,
|
list(ctx, "command list", CommandSearchIndex, CommandList,
|
||||||
function(ctx, cmd, is_selected)
|
function(ctx, cmd, is_selected)
|
||||||
flags = {"DrawText"}
|
flags = {"DrawText"}
|
||||||
|
@ -426,10 +450,10 @@ function render_command_search(ctx)
|
||||||
interaction = UI.advanced_button(ctx, " "..cmd.name..": "..cmd.description.." ", flags, UI.Fill, UI.FitText)
|
interaction = UI.advanced_button(ctx, " "..cmd.name..": "..cmd.description.." ", flags, UI.Fill, UI.FitText)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end)
|
||||||
)
|
-- )
|
||||||
UI.pop_parent(ctx)
|
-- UI.pop_parent(ctx)
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
function render_log_window(ctx)
|
function render_log_window(ctx)
|
||||||
|
@ -488,29 +512,8 @@ function M.OnLoad()
|
||||||
CommandSearchIndex = 1
|
CommandSearchIndex = 1
|
||||||
|
|
||||||
CommandList = Editor.query_command_group("nl.spacegirl.editor.core")
|
CommandList = Editor.query_command_group("nl.spacegirl.editor.core")
|
||||||
|
M.open_command_palette()
|
||||||
end),
|
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}
|
{Editor.Key.B, "Buffer Search", M.open_buffer_search_window}
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1062,8 +1062,8 @@ main :: proc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// context.logger = core.new_logger(&state.log_buffer);
|
context.logger = core.new_logger(&state.log_buffer);
|
||||||
context.logger = log.create_console_logger();
|
// context.logger = log.create_console_logger();
|
||||||
state.ctx = context;
|
state.ctx = context;
|
||||||
|
|
||||||
// TODO: don't use this
|
// TODO: don't use this
|
||||||
|
@ -1353,7 +1353,6 @@ main :: proc() {
|
||||||
state.window.draw(state.plugin_vtable, state.window.user_data);
|
state.window.draw(state.plugin_vtable, state.window.user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if window, ok := &state.new_window.(core.NewWindow); ok {
|
if window, ok := &state.new_window.(core.NewWindow); ok {
|
||||||
floating, interaction := ui.push_floating(&ui_context, "floating_window", {0,0})
|
floating, interaction := ui.push_floating(&ui_context, "floating_window", {0,0})
|
||||||
ui.push_parent(&ui_context, floating)
|
ui.push_parent(&ui_context, floating)
|
||||||
|
|
Loading…
Reference in New Issue