LuaSearch
This commit is contained in:
@@ -262,3 +262,18 @@ Int ChopNumber(String16 *string) {
|
||||
Int result = strtoll(num_string.data, NULL, 10) - 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
String16 ChopWhitespace(String16 *string) {
|
||||
String16 new_string = *string;
|
||||
String16 whitespace = {string->data, 0};
|
||||
for (int64_t i = 0; i < string->len; i += 1) {
|
||||
if (IsWhitespace(string->data[i])) {
|
||||
new_string = Skip(new_string, 1);
|
||||
whitespace.len += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*string = new_string;
|
||||
return whitespace;
|
||||
}
|
||||
|
||||
@@ -580,6 +580,13 @@ void Command_IdentedNewLine(View *view) {
|
||||
EndEdit(buffer, &edits, &view->carets);
|
||||
}
|
||||
|
||||
void Command_FindNext(View *seek_view, String16 needle) {
|
||||
Buffer *seek_buffer = GetBuffer(seek_view->active_buffer);
|
||||
Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true);
|
||||
seek_view->carets.len = 1;
|
||||
seek_view->carets[0] = caret;
|
||||
}
|
||||
|
||||
void WindowCommand(Event event, Window *window, View *view) {
|
||||
ProfileFunction();
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
|
||||
@@ -193,10 +193,6 @@ int LuaGetCurrentBufferDir(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void OpenFilesHereRecursive(Window *window, String path) {
|
||||
Scratch scratch;
|
||||
}
|
||||
|
||||
int LuaOpenFilesHere(lua_State *L) {
|
||||
Window *window = GetWindow(GetLastActiveWindow());
|
||||
|
||||
@@ -204,7 +200,17 @@ int LuaOpenFilesHere(lua_State *L) {
|
||||
for (FileIter it = IterateFiles(scratch, GetCurrentBufferDir()); IsValid(it); Advance(&it)) {
|
||||
WindowOpenBufferView(window, it.absolute_path);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaSearch(lua_State *L) {
|
||||
Window *seek_window = GetCurrentWindow();
|
||||
seek_window->search_string = lua_tostring(L, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
View *seek_view = GetView(seek_window->active_view);
|
||||
Scratch scratch;
|
||||
Command_FindNext(seek_view, ToString16(scratch, seek_window->search_string));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -230,6 +236,7 @@ luaL_Reg LuaFunctions[] = {
|
||||
{ "NewC", LuaNewCmd},
|
||||
{ "AppendC", LuaAppendCmd},
|
||||
{ "OpenFilesHere", LuaOpenFilesHere},
|
||||
{ "Search", LuaSearch},
|
||||
{ NULL, NULL},
|
||||
};
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ struct Window {
|
||||
Array<GotoCrumb> goto_history;
|
||||
Array<GotoCrumb> goto_redo;
|
||||
|
||||
String search_string;
|
||||
|
||||
double mouse_scroller_offset;
|
||||
int z;
|
||||
|
||||
|
||||
@@ -125,6 +125,8 @@ void ReplaceTitleBarData(Window *window) {
|
||||
AdjustCarets(edits, &caret_copy);
|
||||
}
|
||||
|
||||
// String search_string = last_window->search_string;
|
||||
// if (search_string.len) search_string = Format(scratch, " /%.*s", FmtString(search_string));
|
||||
String s = Format(scratch, "%.*s:%lld:%lld", FmtString(last_buffer->name), (long long)xy.line + 1ll, (long long)xy.col + 1ll);
|
||||
String16 string = ToString16(scratch, s);
|
||||
String16 string_to_replace = GetString(*buffer, replace_range);
|
||||
|
||||
Reference in New Issue
Block a user