GoToNextInList scans multiple lines, EncloseExecWord looks for an anchor, Add Ctrl Period chop path open
This commit is contained in:
@@ -476,7 +476,29 @@ Int FindScopeEnd(Buffer *buffer, Int seek, Int max_seek, wchar_t open, wchar_t c
|
|||||||
return seek;
|
return seek;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Range EncloseScope(Buffer *buffer, Int pos, wchar_t open, wchar_t close) {
|
||||||
|
Range result = {pos, pos};
|
||||||
|
for (Int i = pos; i >= 0; i -= 1) {
|
||||||
|
if (buffer->str[i] == open) {
|
||||||
|
result.min = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Int i = pos; i < buffer->len; i += 1) {
|
||||||
|
if (buffer->str[i] == close) {
|
||||||
|
result.max = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
Range EncloseExecWord(Buffer *buffer, Int pos) {
|
Range EncloseExecWord(Buffer *buffer, Int pos) {
|
||||||
|
for (Int i = pos; i >= 0 && i >= pos - 1024; i -= 1) {
|
||||||
|
if (GetChar(buffer, i) == L'#') {
|
||||||
|
pos = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Range result = {GetWordStart(buffer, pos), GetWordEnd(buffer, pos)};
|
Range result = {GetWordStart(buffer, pos), GetWordEnd(buffer, pos)};
|
||||||
|
|
||||||
Int seek = SkipSpaces(buffer, result.max);
|
Int seek = SkipSpaces(buffer, result.max);
|
||||||
@@ -539,20 +561,3 @@ Range GetIndentRangeAtPos(Buffer *buffer, Int pos) {
|
|||||||
Range range = GetLineRangeWithoutNL(*buffer, line);
|
Range range = GetLineRangeWithoutNL(*buffer, line);
|
||||||
return {range.min, range.min + indent};
|
return {range.min, range.min + indent};
|
||||||
}
|
}
|
||||||
|
|
||||||
Range EncloseScope(Buffer *buffer, Int pos, wchar_t open, wchar_t close) {
|
|
||||||
Range result = {pos, pos};
|
|
||||||
for (Int i = pos; i >= 0; i -= 1) {
|
|
||||||
if (buffer->str[i] == open) {
|
|
||||||
result.min = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Int i = pos; i < buffer->len; i += 1) {
|
|
||||||
if (buffer->str[i] == close) {
|
|
||||||
result.max = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -113,6 +113,12 @@ void PreBeginEdit_SaveCaretHistory(Buffer *buffer, Array<Caret> &carets) {
|
|||||||
BeginEdit({}, buffer, carets);
|
BeginEdit({}, buffer, carets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssertRanges(Array<Caret> carets) {
|
||||||
|
For(carets) {
|
||||||
|
Assert(it.range.max >= it.range.min);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AdjustCarets(Array<Edit> edits, Array<Caret> *carets, bool kill_selection = false) {
|
void AdjustCarets(Array<Edit> edits, Array<Caret> *carets, bool kill_selection = false) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Array<Caret> new_carets = TightCopy(scratch, *carets);
|
Array<Caret> new_carets = TightCopy(scratch, *carets);
|
||||||
@@ -146,11 +152,7 @@ void AdjustCarets(Array<Edit> edits, Array<Caret> *carets, bool kill_selection =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_BUILD
|
IF_DEBUG(AssertRanges(*carets));
|
||||||
For(*carets) {
|
|
||||||
Assert(it.range.max >= it.range.min);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KILL_SELECTION = true;
|
bool KILL_SELECTION = true;
|
||||||
|
|||||||
@@ -584,9 +584,12 @@ void Command_Find(View *seek_view, String16 needle, bool forward = true) {
|
|||||||
if (!forward) caret = FindPrev(seek_buffer, needle, caret);
|
if (!forward) caret = FindPrev(seek_buffer, needle, caret);
|
||||||
seek_view->carets.len = 1;
|
seek_view->carets.len = 1;
|
||||||
seek_view->carets[0] = caret;
|
seek_view->carets[0] = caret;
|
||||||
|
|
||||||
|
IF_DEBUG(AssertRanges(seek_view->carets));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
||||||
|
Assert(line_offset == 1 || line_offset == -1);
|
||||||
ViewID active_view = window->active_view;
|
ViewID active_view = window->active_view;
|
||||||
CheckpointBeforeGoto(window->id);
|
CheckpointBeforeGoto(window->id);
|
||||||
|
|
||||||
@@ -596,14 +599,24 @@ void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
Buffer *buffer_goto = GetBuffer(view_goto->active_buffer);
|
Buffer *buffer_goto = GetBuffer(view_goto->active_buffer);
|
||||||
int64_t pos = GetFront(view_goto->carets[0]);
|
int64_t pos = GetFront(view_goto->carets[0]);
|
||||||
Int line = PosToLine(*buffer_goto, pos);
|
Int line = PosToLine(*buffer_goto, pos);
|
||||||
if (line + line_offset < buffer_goto->line_starts.len) {
|
|
||||||
|
bool opened = false;
|
||||||
|
for (Int i = line + line_offset; line + line_offset < buffer_goto->line_starts.len && line + line_offset >= 0; i += line_offset) {
|
||||||
Range line_range = GetLineRangeWithoutNL(*buffer_goto, line + line_offset);
|
Range line_range = GetLineRangeWithoutNL(*buffer_goto, line + line_offset);
|
||||||
String16 line = GetString(*buffer_goto, line_range);
|
String16 line = GetString(*buffer_goto, line_range);
|
||||||
view_goto->carets[0] = MakeCaret(line_range.min);
|
view_goto->carets[0] = MakeCaret(line_range.min);
|
||||||
|
line = Trim(line);
|
||||||
|
|
||||||
|
MergeCarets(view_goto);
|
||||||
|
IF_DEBUG(AssertRanges(view_goto->carets));
|
||||||
|
if (line.len == 0) continue;
|
||||||
|
|
||||||
Open(line);
|
Open(line);
|
||||||
} else {
|
opened = true;
|
||||||
window->active_view = active_view;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!opened) window->active_view = active_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowCommand(Event event, Window *window, View *view) {
|
void WindowCommand(Event event, Window *window, View *view) {
|
||||||
@@ -787,12 +800,17 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
Insert(&view->carets, caret, 0);
|
Insert(&view->carets, caret, 0);
|
||||||
MergeCarets(view);
|
MergeCarets(view);
|
||||||
} else if (Press(SDLK_F3)) {
|
} else if (Press(SDLK_F3)) {
|
||||||
// Scratch scratch;
|
Scratch scratch;
|
||||||
// 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;
|
||||||
// view->carets[0] = caret;
|
view->carets[0] = caret;
|
||||||
Command_GotoNextInList(window);
|
}
|
||||||
|
|
||||||
|
if (Shift(SDLK_F4)) {
|
||||||
|
Command_GotoNextInList(window, -1);
|
||||||
|
} else if (Press(SDLK_F4)) {
|
||||||
|
Command_GotoNextInList(window, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view->fuzzy_search && search) {
|
if (view->fuzzy_search && search) {
|
||||||
@@ -863,9 +881,17 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Ctrl(SDLK_PERIOD)) {
|
||||||
|
Window *window = GetWindow(GetLastActiveWindow());
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|
||||||
|
String name = ChopLastSlash(buffer->name);
|
||||||
|
Open(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (CtrlShift(SDLK_G)) {
|
if (CtrlShift(SDLK_G)) {
|
||||||
Window *titlebar = window;
|
Window *titlebar = GetTitlebarWindow(window->id);
|
||||||
if (!window->is_title_bar) titlebar = GetWindow(window->title_bar_window);
|
|
||||||
View *titlebar_view = GetView(titlebar->active_view);
|
View *titlebar_view = GetView(titlebar->active_view);
|
||||||
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
||||||
SetActiveWindow(titlebar->id);
|
SetActiveWindow(titlebar->id);
|
||||||
@@ -883,8 +909,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Ctrl(SDLK_G)) {
|
} else if (Ctrl(SDLK_G)) {
|
||||||
Window *titlebar = window;
|
Window *titlebar = GetTitlebarWindow(window->id);
|
||||||
if (!window->is_title_bar) titlebar = GetWindow(window->title_bar_window);
|
|
||||||
View *titlebar_view = GetView(titlebar->active_view);
|
View *titlebar_view = GetView(titlebar->active_view);
|
||||||
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
||||||
SetActiveWindow(titlebar->id);
|
SetActiveWindow(titlebar->id);
|
||||||
@@ -912,6 +937,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
} else if (Alt(SDLK_Q)) {
|
} else if (Alt(SDLK_Q)) {
|
||||||
GotoBackward(GetLastActiveWindow());
|
GotoBackward(GetLastActiveWindow());
|
||||||
}
|
}
|
||||||
|
IF_DEBUG(AssertRanges(view->carets));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateScroll(Window *window, bool update_caret_scrolling) {
|
void UpdateScroll(Window *window, bool update_caret_scrolling) {
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ View *FindViewWithBufferName(String name) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window *GetTitlebarWindow(WindowID id) {
|
||||||
|
Window *window = GetWindow(id);
|
||||||
|
if (!window->is_title_bar) window = GetWindow(window->title_bar_window);
|
||||||
|
Assert(window->is_title_bar);
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
Window *GetCurrentWindow() {
|
Window *GetCurrentWindow() {
|
||||||
Window *window = GetWindow(ActiveWindow);
|
Window *window = GetWindow(ActiveWindow);
|
||||||
if (window->is_title_bar) {
|
if (window->is_title_bar) {
|
||||||
|
|||||||
@@ -135,4 +135,10 @@ void Command_Append(ViewID view_id, String16 string, bool scroll_to_end_if_curso
|
|||||||
void Command_Append(ViewID view_id, String string, bool scroll_to_end_if_cursor_on_last_line);
|
void Command_Append(ViewID view_id, String string, bool scroll_to_end_if_cursor_on_last_line);
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...);
|
void ReportErrorf(const char *fmt, ...);
|
||||||
void ReportWarningf(const char *fmt, ...);
|
void ReportWarningf(const char *fmt, ...);
|
||||||
|
|
||||||
|
#if DEBUG_BUILD
|
||||||
|
#define IF_DEBUG(x) x
|
||||||
|
#else
|
||||||
|
#define IF_DEBUG(x)
|
||||||
|
#endif
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
||||||
|
- Remove console and command window, provide alternatives but unify the interface?
|
||||||
|
|
||||||
|
- Ctrl + . to chop a path from buffer name and open that
|
||||||
|
- apply clang format
|
||||||
|
- apply clang format on save
|
||||||
|
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own
|
||||||
|
- How to remove memory issues? Maybe just store ids and pointers in arrays, rest should be allocated off of arena. Then maybe garbage collected and reclaimed.
|
||||||
|
|
||||||
- ctrl + f - should find Search and select content or add Search
|
- ctrl + f - should find Search and select content or add Search
|
||||||
- some split selection commands
|
- some split selection commands
|
||||||
- assign commands or lua functions to F1-F8 keys
|
- assign commands or lua functions to F1-F8 keys
|
||||||
- generate the lua function table for all functions prefixed with Lua_
|
- generate the lua function table for all functions prefixed with Lua_
|
||||||
|
|
||||||
- Cycle up and down through a list of filenames and jump to every filename listed and remember the last buffer which we jumped from which contains the list
|
|
||||||
- A lister which is going to show project without the full path and sorted by recency
|
- A lister which is going to show project without the full path and sorted by recency
|
||||||
- Fix fuzzy search look
|
- Fix fuzzy search look
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user