86 lines
3.2 KiB
C++
86 lines
3.2 KiB
C++
WindowID CommandWindowID;
|
|
|
|
void CMD_ShowCommands() {
|
|
BSet command_bar = GetBSet(CommandWindowID);
|
|
command_bar.window->visible = true;
|
|
NextActiveWindowID = command_bar.window->id;
|
|
ResetBuffer(command_bar.buffer);
|
|
For (GlobalCommands) {
|
|
RawAppendf(command_bar.buffer, "\n:%-30S <|| ", it.name);
|
|
if (it.docs.len) {
|
|
RawAppendf(command_bar.buffer, "%S", it.docs);
|
|
}
|
|
}
|
|
command_bar.view->update_scroll = true;
|
|
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
|
} RegisterCommand(CMD_ShowCommands, "ctrl-shift-p", "List available commands and their documentation inside the command window");
|
|
|
|
void CMD_ShowDebugBufferList() {
|
|
BSet command_bar = GetBSet(CommandWindowID);
|
|
command_bar.window->visible = true;
|
|
NextActiveWindowID = command_bar.window->id;
|
|
ResetBuffer(command_bar.buffer);
|
|
For (Buffers) {
|
|
bool is_special = it->special || it->temp || it->dont_try_to_save_in_bulk_ops;
|
|
#if PLUGIN_DIRECTORY_NAVIGATION
|
|
is_special |= it->is_dir;
|
|
#endif
|
|
if (!is_special) {
|
|
continue;
|
|
}
|
|
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
|
}
|
|
command_bar.view->update_scroll = true;
|
|
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
|
} RegisterCommand(CMD_ShowDebugBufferList, "ctrl-shift-alt-p", "Show full list of buffers, including the special ones that normally just clutter list");
|
|
|
|
void CMD_ShowBufferList() {
|
|
BSet command_bar = GetBSet(CommandWindowID);
|
|
command_bar.window->visible = true;
|
|
NextActiveWindowID = command_bar.window->id;
|
|
ResetBuffer(command_bar.buffer);
|
|
For (Buffers) {
|
|
bool is_special = it->special || it->temp || it->dont_try_to_save_in_bulk_ops;
|
|
#if PLUGIN_DIRECTORY_NAVIGATION
|
|
is_special |= it->is_dir;
|
|
#endif
|
|
if (is_special) {
|
|
continue;
|
|
}
|
|
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
|
}
|
|
command_bar.view->update_scroll = true;
|
|
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
|
} RegisterCommand(CMD_ShowBufferList, "ctrl-p", "List open buffers inside the command window that you can fuzzy search over");
|
|
|
|
void LayoutCommandWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
|
Window *window = GetWindow(CommandWindowID);
|
|
Rect2I copy_rect = *rect;
|
|
if (!window->visible) {
|
|
rect = ©_rect;
|
|
}
|
|
Int barsize = Clamp((Int)window->font->line_spacing*10, (Int)0, (Int)wx - 100);
|
|
window->document_rect = window->total_rect = CutBottom(rect, barsize);
|
|
}
|
|
|
|
void InitCommandWindow() {
|
|
Window *window = CreateWind();
|
|
CommandWindowID = window->id;
|
|
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "command_bar"));
|
|
buffer->special = true;
|
|
buffer->no_history = true;
|
|
View *view = CreateView(buffer->id);
|
|
view->special = true;
|
|
SetFuzzy(view);
|
|
window->active_view = view->id;
|
|
window->draw_line_numbers = false;
|
|
window->draw_scrollbar = false;
|
|
window->secondary_window_style = true;
|
|
window->draw_line_highlight = true;
|
|
window->primary = false;
|
|
window->visible = false;
|
|
window->sync_visibility_with_focus = true;
|
|
window->lose_focus_on_escape = true;
|
|
window->jump_history = false;
|
|
}
|