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