Compare commits
3 Commits
1a6159e0ec
...
ecbc800fdd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecbc800fdd | ||
|
|
753c9199b6 | ||
|
|
eb19ba6037 |
@@ -9,7 +9,6 @@
|
|||||||
- Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option)
|
- Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option)
|
||||||
- On Linux: Try to implement is_debugger_present()
|
- On Linux: Try to implement is_debugger_present()
|
||||||
- Probably shouldn't emit (Key pressed when ctrl etc. is not clicked!!)
|
- Probably shouldn't emit (Key pressed when ctrl etc. is not clicked!!)
|
||||||
- Brace, bracket, paren indenting?
|
|
||||||
|
|
||||||
- OnUpdate view hooks!
|
- OnUpdate view hooks!
|
||||||
- OnSave buffer hooks which will execute the config on save
|
- OnSave buffer hooks which will execute the config on save
|
||||||
|
|||||||
@@ -519,47 +519,20 @@ API Int SkipSpaces(Buffer *buffer, Int seek) {
|
|||||||
return seek;
|
return seek;
|
||||||
}
|
}
|
||||||
|
|
||||||
API Int FindScopeEnd(Buffer *buffer, Int seek, Int max_seek, char16_t open, char16_t close) {
|
API Int FindAnyScopeBegin(Buffer *buffer, Int pos) {
|
||||||
char16_t right = GetChar(buffer, seek);
|
int inner_scope = 0;
|
||||||
if (right == open) {
|
for (Int i = pos - 1; i >= 0; i -= 1) {
|
||||||
int scope = 1;
|
if (buffer->str[i] == '{' || buffer->str[i] == '[' || buffer->str[i] == '(') {
|
||||||
Int i = seek + 1;
|
if (inner_scope == 0) {
|
||||||
for (; i < seek + max_seek && i < buffer->len; i += 1) {
|
return i;
|
||||||
char16_t c = GetChar(buffer, i);
|
|
||||||
|
|
||||||
if (open == close && c == '\\') {
|
|
||||||
i += 1;
|
|
||||||
} else if (open == close && c == open) {
|
|
||||||
scope -= 1;
|
|
||||||
} else if (c == open) {
|
|
||||||
scope += 1;
|
|
||||||
} else if (c == close) {
|
|
||||||
scope -= 1;
|
|
||||||
}
|
}
|
||||||
|
inner_scope -= 1;
|
||||||
if (c == u'\n' || scope == 0) break;
|
|
||||||
}
|
}
|
||||||
|
if (buffer->str[i] == '}' || buffer->str[i] == ']' || buffer->str[i] == ')') {
|
||||||
if (scope == 0) seek = i;
|
inner_scope += 1;
|
||||||
}
|
|
||||||
return seek;
|
|
||||||
}
|
|
||||||
|
|
||||||
API Range EncloseScope(Buffer *buffer, Int pos_min, Int pos_max, char16_t open, char16_t close) {
|
|
||||||
Range result = {pos_min, pos_max};
|
|
||||||
for (Int i = pos_min - 1; i >= 0; i -= 1) {
|
|
||||||
if (buffer->str[i] == open) {
|
|
||||||
result.min = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Int i = pos_max; i < buffer->len; i += 1) {
|
return 0;
|
||||||
if (buffer->str[i] == close) {
|
|
||||||
result.max = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
API Range EncloseLine(Buffer *buffer, Int pos) {
|
API Range EncloseLine(Buffer *buffer, Int pos) {
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ API Int GetPrevEmptyLineStart(Buffer *buffer, Int pos);
|
|||||||
API Range EncloseWord(Buffer *buffer, Int pos);
|
API Range EncloseWord(Buffer *buffer, Int pos);
|
||||||
API Int SkipSpaces(Buffer *buffer, Int seek);
|
API Int SkipSpaces(Buffer *buffer, Int seek);
|
||||||
API Int FindScopeEnd(Buffer *buffer, Int seek, Int max_seek, char16_t open, char16_t close);
|
API Int FindScopeEnd(Buffer *buffer, Int seek, Int max_seek, char16_t open, char16_t close);
|
||||||
API Range EncloseScope(Buffer *buffer, Int pos_min, Int pos_max, char16_t open, char16_t close);
|
|
||||||
API Range EncloseLine(Buffer *buffer, Int pos);
|
API Range EncloseLine(Buffer *buffer, Int pos);
|
||||||
API Range EncloseFullLine(Buffer *buffer, Int pos);
|
API Range EncloseFullLine(Buffer *buffer, Int pos);
|
||||||
API Int OffsetByLine(Buffer *buffer, Int pos, Int line_offset);
|
API Int OffsetByLine(Buffer *buffer, Int pos, Int line_offset);
|
||||||
|
|||||||
@@ -1365,20 +1365,22 @@ void CMD_DeleteForwardBoundary() {
|
|||||||
|
|
||||||
void CMD_InsertNewLineUp() {
|
void CMD_InsertNewLineUp() {
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
|
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||||
MoveCursorToSide(active.view, DIR_LEFT);
|
MoveCursorToSide(active.view, DIR_LEFT);
|
||||||
IdentedNewLine(active.view);
|
IndentedNewLine(active.view);
|
||||||
MoveCarets(active.view, DIR_UP);
|
MoveCarets(active.view, DIR_UP);
|
||||||
} RegisterCommand(CMD_InsertNewLineUp, "ctrl-shift-enter");
|
} RegisterCommand(CMD_InsertNewLineUp, "ctrl-shift-enter");
|
||||||
|
|
||||||
void CMD_InsertNewLineDown() {
|
void CMD_InsertNewLineDown() {
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
|
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||||
MoveCursorToSide(active.view, DIR_RIGHT);
|
MoveCursorToSide(active.view, DIR_RIGHT);
|
||||||
IdentedNewLine(active.view);
|
IndentedNewLine(active.view);
|
||||||
} RegisterCommand(CMD_InsertNewLineDown, "ctrl-enter");
|
} RegisterCommand(CMD_InsertNewLineDown, "ctrl-enter");
|
||||||
|
|
||||||
void CMD_NewLine() {
|
void CMD_NewLine() {
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
IdentedNewLine(active.view);
|
IndentedNewLine(active.view);
|
||||||
} RegisterCommand(CMD_NewLine, "enter | shift-enter");
|
} RegisterCommand(CMD_NewLine, "enter | shift-enter");
|
||||||
|
|
||||||
void CMD_CreateCaretOnNextFind() {
|
void CMD_CreateCaretOnNextFind() {
|
||||||
|
|||||||
@@ -134,16 +134,17 @@ String16 FetchFuzzyViewLoadLine(View *view) {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentedNewLine(View *view) {
|
void IndentedNewLine(View *view) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
||||||
MergeCarets(buffer, &view->carets);
|
MergeCarets(buffer, &view->carets);
|
||||||
For(view->carets) {
|
For(view->carets) {
|
||||||
Int front = GetFront(it);
|
Int front = GetFront(it);
|
||||||
Int line = PosToLine(buffer, front);
|
Int scope_begin = FindAnyScopeBegin(buffer, front); // @todo: this could be problematic in large source files!
|
||||||
Int indent = GetLineIndent(buffer, line);
|
Int line = PosToLine(buffer, scope_begin);
|
||||||
String string = Format(scratch, "\n%.*s", (int)indent, " ");
|
Int indent = GetLineIndent(buffer, line) + IndentSize;
|
||||||
|
String string = Format(scratch, "\n%.*s", (int)indent, " ");
|
||||||
String16 string16 = ToString16(scratch, string);
|
String16 string16 = ToString16(scratch, string);
|
||||||
AddEdit(&edits, it.range, string16);
|
AddEdit(&edits, it.range, string16);
|
||||||
}
|
}
|
||||||
@@ -662,15 +663,6 @@ void EncloseLine(View *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncloseScope(View *view) {
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
For (view->carets) {
|
|
||||||
it.range = EncloseScope(buffer, it.range.min - 1, it.range.max + 1, u'(', u')');
|
|
||||||
it.range.min = Clamp(buffer, it.range.min + 1);
|
|
||||||
it.range.max = Clamp(buffer, it.range.max - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SelectAllOccurences(View *view, String16 needle) {
|
void SelectAllOccurences(View *view, String16 needle) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void JumpBack(Window *window) {
|
|||||||
window->active_view = c.view_id;
|
window->active_view = c.view_id;
|
||||||
View *view = GetView(c.view_id);
|
View *view = GetView(c.view_id);
|
||||||
view->carets[0] = c.caret;
|
view->carets[0] = c.caret;
|
||||||
UpdateScroll(window, true);
|
CenterView(window->id);
|
||||||
|
|
||||||
if (window->goto_history.len) {
|
if (window->goto_history.len) {
|
||||||
GotoCrumb *next = GetLast(window->goto_history);
|
GotoCrumb *next = GetLast(window->goto_history);
|
||||||
@@ -294,7 +294,7 @@ void JumpForward(Window *window) {
|
|||||||
window->active_view = c.view_id;
|
window->active_view = c.view_id;
|
||||||
View *view = GetView(c.view_id);
|
View *view = GetView(c.view_id);
|
||||||
view->carets[0] = c.caret;
|
view->carets[0] = c.caret;
|
||||||
UpdateScroll(window, true);
|
CenterView(window->id);
|
||||||
|
|
||||||
if (window->goto_redo.len) {
|
if (window->goto_redo.len) {
|
||||||
GotoCrumb *next = GetLast(window->goto_redo);
|
GotoCrumb *next = GetLast(window->goto_redo);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void CMD_ShowDebugBufferList() {
|
|||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
||||||
} RegisterCommand(CMD_ShowDebugBufferList, "", "Show full list of buffers, including the special ones that normally just clutter list");
|
} RegisterCommand(CMD_ShowDebugBufferList, "ctrl-shift-alt-p", "Show full list of buffers, including the special ones that normally just clutter list");
|
||||||
|
|
||||||
void CMD_ShowBufferList() {
|
void CMD_ShowBufferList() {
|
||||||
if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowBufferList) {
|
if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowBufferList) {
|
||||||
|
|||||||
Reference in New Issue
Block a user