Auto enclose

This commit is contained in:
Krzosa Karol
2024-08-15 08:22:56 +02:00
parent a3e87b2508
commit 5e51e2fbad
4 changed files with 9 additions and 6 deletions

View File

@@ -888,9 +888,10 @@ void Command_FuzzySort(View *view, String16 needle) {
}
void Command_SelectTitlebarCommand(Window *window, String16 needle) {
BSet title = GetTitleSet(window);
String16 buffer_string = GetString(title.buffer);
ActiveWindow = title.window->id;
BSet title = GetTitleSet(window);
String16 buffer_string = GetString(title.buffer);
ActiveWindow = title.window->id;
title.window->auto_enclose = true;
Scratch scratch;
String16 quoted16 = {};

View File

@@ -261,7 +261,8 @@ void GlobalCommand(Event event) {
if (window) ActiveWindow = window->id;
}
BSet active = GetActiveSet();
BSet active = GetActiveSet();
Int buffer_change_id = active.buffer->change_id;
if (event.kind == EVENT_DROP_FILE) {
WindowOpenBufferView(active.window, event.text);
@@ -456,7 +457,8 @@ void GlobalCommand(Event event) {
GotoBackward(GetActiveMainSet().window);
}
if (CtrlShift(SDLK_Q)) {
bool should_enclose = active.window->auto_enclose && (active.buffer->change_id != buffer_change_id);
if (should_enclose || CtrlShift(SDLK_Q)) {
Caret caret = active.view->carets[0];
Range range = caret.range;
if (GetSize(caret.range) == 0) range = EncloseExecWord(active.buffer, GetFront(caret));

View File

@@ -95,6 +95,7 @@ struct Window {
bool is_title_bar : 1;
bool is_column : 1;
bool auto_enclose : 1;
bool deactivate_on_escape : 1;
};
};

View File

@@ -6,7 +6,6 @@
- group history entries so the you can rollback through multiple ones at once and not waste time on skipping whitespace trimming or deleting every character
- Fuzzy search buffer which uses titlebar as query!
- Gotos, jumping between views should preserve cursors, maybe just scroll
- ReportWarning should be signaled visibly but you should be able to do things! no focus switching
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own