F3, ShiftF3 search, works on main window
This commit is contained in:
@@ -383,13 +383,13 @@ void SaveBuffer(View *view) {
|
||||
Assert(view->active_buffer == buffer->id);
|
||||
}
|
||||
|
||||
{
|
||||
Scratch scratch;
|
||||
String16 string16 = GetString(*buffer);
|
||||
String string = ToString(scratch, string16);
|
||||
Buffer *temp_buffer = ExecAndWait(scratch, "clang-format", GetDir(buffer), string);
|
||||
Command_ReplaceWithoutMovingCarets(view, GetRange(*buffer), {temp_buffer->str, temp_buffer->len});
|
||||
}
|
||||
// {
|
||||
// Scratch scratch;
|
||||
// String16 string16 = GetString(*buffer);
|
||||
// String string = ToString(scratch, string16);
|
||||
// Buffer *temp_buffer = ExecAndWait(scratch, "clang-format", GetDir(buffer), string);
|
||||
// Command_ReplaceWithoutMovingCarets(view, GetRange(*buffer), {temp_buffer->str, temp_buffer->len});
|
||||
// }
|
||||
|
||||
Scratch scratch;
|
||||
String16 string16 = GetString(*buffer);
|
||||
@@ -671,7 +671,8 @@ void Command_FuzzySort(View *view, String16 needle) {
|
||||
|
||||
void WindowCommand(Event event, Window *window, View *view) {
|
||||
ProfileFunction();
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Int buffer_change_id = buffer->change_id;
|
||||
|
||||
if (Ctrl(SDLK_F2)) {
|
||||
LoadBigLine(buffer);
|
||||
@@ -788,13 +789,10 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
Command_MoveCursorsToSide(view, DIR_RIGHT);
|
||||
}
|
||||
|
||||
bool search = false;
|
||||
if (Shift(SDLK_TAB)) {
|
||||
Command_IndentSelectedLines(view, SHIFT_PRESSED);
|
||||
search = true;
|
||||
} else if (Press(SDLK_TAB)) {
|
||||
Command_IndentSelectedLines(view);
|
||||
search = true;
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_T)) {
|
||||
@@ -814,18 +812,14 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
|
||||
if (Ctrl(SDLK_BACKSPACE)) {
|
||||
Command_Delete(view, DIR_LEFT, CTRL_PRESSED);
|
||||
search = true;
|
||||
} else if (Press(SDLK_BACKSPACE)) {
|
||||
Command_Delete(view, DIR_LEFT);
|
||||
search = true;
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_DELETE)) {
|
||||
Command_Delete(view, DIR_RIGHT, CTRL_PRESSED);
|
||||
search = true;
|
||||
} else if (Press(SDLK_DELETE)) {
|
||||
Command_Delete(view, DIR_RIGHT);
|
||||
search = true;
|
||||
}
|
||||
|
||||
if (event.kind == EVENT_TEXT_INPUT) {
|
||||
@@ -833,7 +827,6 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
String string = event.text;
|
||||
String16 string16 = ToString16(scratch, string);
|
||||
Command_Replace(view, string16);
|
||||
search = true;
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_D)) {
|
||||
@@ -843,14 +836,20 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
MergeCarets(view);
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_F3)) {
|
||||
if (Shift(SDLK_F3)) {
|
||||
Scratch scratch;
|
||||
Window *window = GetActiveMainWindow();
|
||||
View *view = GetView(window->active_view);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
String16 search_string = ToString16(scratch, window->search_string);
|
||||
Caret caret = FindNext(buffer, search_string, view->carets[0]);
|
||||
Insert(&view->carets, caret, 0);
|
||||
MergeCarets(view);
|
||||
Caret caret = FindPrev(buffer, search_string, view->carets[0]);
|
||||
view->carets.len = 1;
|
||||
view->carets[0] = caret;
|
||||
} else if (Press(SDLK_F3)) {
|
||||
Scratch scratch;
|
||||
Window *window = GetActiveMainWindow();
|
||||
View *view = GetView(window->active_view);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
String16 search_string = ToString16(scratch, window->search_string);
|
||||
Caret caret = FindNext(buffer, search_string, view->carets[0]);
|
||||
view->carets.len = 1;
|
||||
@@ -921,9 +920,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
if (CtrlShift(SDLK_Q)) {
|
||||
Caret caret = view->carets[0];
|
||||
Range range = caret.range;
|
||||
if (GetSize(caret.range) == 0) {
|
||||
range = EncloseExecWord(buffer, GetFront(caret));
|
||||
}
|
||||
if (GetSize(caret.range) == 0) range = EncloseExecWord(buffer, GetFront(caret));
|
||||
String16 string = GetString(*buffer, range);
|
||||
|
||||
Command_EvalLua(view, string);
|
||||
@@ -936,6 +933,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
window->active_goto_list = view->id;
|
||||
Open(string);
|
||||
}
|
||||
|
||||
IF_DEBUG(AssertRanges(view->carets));
|
||||
}
|
||||
|
||||
|
||||
@@ -361,29 +361,20 @@ void InitLuaConfig() {
|
||||
|
||||
//
|
||||
|
||||
String16 EvalString(Allocator allocator, String16 string16) {
|
||||
bool EvalString(Allocator allocator, String16 string16) {
|
||||
Scratch scratch((Arena *)allocator.object);
|
||||
String string = ToString(scratch, string16);
|
||||
if (luaL_dostring(LuaState, string.data) != LUA_OK) {
|
||||
const char *error_message = lua_tostring(LuaState, -1);
|
||||
ReportWarningf("Execution error! %s", error_message);
|
||||
ReportConsolef("Execution error! %s", error_message);
|
||||
lua_pop(LuaState, 1);
|
||||
return {};
|
||||
}
|
||||
|
||||
const char *text = lua_tostring(LuaState, -1);
|
||||
if (text) {
|
||||
String s = text;
|
||||
String16 result = ToString16(allocator, s);
|
||||
lua_pop(LuaState, 1);
|
||||
return result;
|
||||
} else {
|
||||
return {};
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Command_EvalLua(View *view, String16 string) {
|
||||
bool Command_EvalLua(View *view, String16 string) {
|
||||
Scratch scratch;
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
EvalString(scratch, string);
|
||||
return EvalString(scratch, string);
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ String ExeDir;
|
||||
Arena Perm;
|
||||
float DPIScale = 1.0f;
|
||||
|
||||
String16 EvalString(Allocator allocator, String16 string16);
|
||||
bool EvalString(Allocator allocator, String16 string16);
|
||||
bool Command_EvalLua(View *view, String16 string);
|
||||
Rect2I GetVisibleCells(Window *window);
|
||||
void AfterEdit(View *view, Array<Edit> edits);
|
||||
Scroller ComputeScrollerRect(Window *window);
|
||||
void Command_EvalLua(View *view, String16 string);
|
||||
void MergeCarets(View *view);
|
||||
void Open(String path);
|
||||
void Open(String16 path);
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
- Execute enclosure which is going to execute on every keypress, modification
|
||||
- Store editor metadata in user accessible buffers? (read only)
|
||||
- Find matches using grep, change things in that buffer then apply those changes to all items
|
||||
- might need to remodel the buffer api to also adjust carets in remaining views
|
||||
- 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
|
||||
|
||||
- apply clang format
|
||||
- apply clang format on save
|
||||
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own
|
||||
|
||||
- ctrl + f - should find Search and select content or add Search
|
||||
|
||||
Reference in New Issue
Block a user