EncloseFullLine and enclose scopes on multiple click
This commit is contained in:
@@ -363,6 +363,20 @@ Int GetLineEnd(Buffer *buffer, Int pos) {
|
|||||||
return range.max;
|
return range.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Int GetFullLineStart(Buffer *buffer, Int pos) {
|
||||||
|
pos = Clamp(pos, (Int)0, buffer->len);
|
||||||
|
Int line = PosToLine(*buffer, pos);
|
||||||
|
Range range = GetLineRange(*buffer, line);
|
||||||
|
return range.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
Int GetFullLineEnd(Buffer *buffer, Int pos) {
|
||||||
|
pos = Clamp(pos, (Int)0, buffer->len);
|
||||||
|
Int line = PosToLine(*buffer, pos);
|
||||||
|
Range range = GetLineRange(*buffer, line);
|
||||||
|
return range.max;
|
||||||
|
}
|
||||||
|
|
||||||
Int GetBufferEnd(Buffer *buffer) {
|
Int GetBufferEnd(Buffer *buffer) {
|
||||||
return buffer->len;
|
return buffer->len;
|
||||||
}
|
}
|
||||||
@@ -429,6 +443,11 @@ Range EncloseLine(Buffer *buffer, Int pos) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Range EncloseFullLine(Buffer *buffer, Int pos) {
|
||||||
|
Range result = {GetFullLineStart(buffer, pos), GetFullLineEnd(buffer, pos)};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Int OffsetByLine(Buffer *buffer, Int pos, Int line_offset) {
|
Int OffsetByLine(Buffer *buffer, Int pos, Int line_offset) {
|
||||||
XY xy = PosToXY(*buffer, pos);
|
XY xy = PosToXY(*buffer, pos);
|
||||||
Int result = XYToPosWithoutNL(*buffer, {xy.col, xy.line + line_offset});
|
Int result = XYToPosWithoutNL(*buffer, {xy.col, xy.line + line_offset});
|
||||||
|
|||||||
@@ -354,10 +354,25 @@ bool GlobalCommand(Event event) {
|
|||||||
}
|
}
|
||||||
} else if (event.clicks >= 2) {
|
} else if (event.clicks >= 2) {
|
||||||
view->carets.len = 1;
|
view->carets.len = 1;
|
||||||
|
|
||||||
if (InBounds({caret.range.min - 1, caret.range.max + 1}, p)) {
|
if (InBounds({caret.range.min - 1, caret.range.max + 1}, p)) {
|
||||||
Range range = EncloseWord(buffer, p);
|
Range range = EncloseWord(buffer, p);
|
||||||
if (event.clicks == 3) range = EncloseLoadWord(buffer, p);
|
wchar_t scope = GetChar(buffer, p);
|
||||||
if (event.clicks >= 4) range = EncloseExecWord(buffer, p);
|
if (scope == '{' || scope == '}') {
|
||||||
|
range = EncloseScope(buffer, p, '{', '}');
|
||||||
|
} else if (scope == '(' || scope == ')') {
|
||||||
|
range = EncloseScope(buffer, p, '(', ')');
|
||||||
|
} else {
|
||||||
|
if (event.clicks == 3) {
|
||||||
|
Range load_word_range = EncloseLoadWord(buffer, p);
|
||||||
|
if (AreEqual(load_word_range, range)) {
|
||||||
|
load_word_range = EncloseFullLine(buffer, p);
|
||||||
|
}
|
||||||
|
range = load_word_range;
|
||||||
|
}
|
||||||
|
if (event.clicks >= 4) range = EncloseFullLine(buffer, p);
|
||||||
|
}
|
||||||
|
|
||||||
caret = MakeCaret(range.max, range.min);
|
caret = MakeCaret(range.max, range.min);
|
||||||
} else {
|
} else {
|
||||||
caret = MakeCaret(p);
|
caret = MakeCaret(p);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
- I think the way sublime text and we display line highlights is confusing with multiple cursors (line highlight can be confused with selection)
|
- I think the way sublime text and we display line highlights is confusing with multiple cursors (line highlight can be confused with selection)
|
||||||
- ctrl + delete maybe should stop on new line but it keeps on going, sublime is much more careful with deleting
|
- ctrl + delete maybe should stop on new line but it keeps on going, sublime is much more careful with deleting
|
||||||
BUG: there is a click hang when switching windows sometimes, you click after select and it doesn't switch active window
|
BUG: there is a click hang when switching windows sometimes, you click after select and it doesn't switch active window
|
||||||
|
BUG: when redo and ctrl pressed a bugged enclosure rect is shown
|
||||||
|
|
||||||
- mouse execute
|
- mouse execute
|
||||||
- experiment with using multiple cursors to select command and it's input
|
- experiment with using multiple cursors to select command and it's input
|
||||||
@@ -9,8 +10,13 @@ BUG: there is a click hang when switching windows sometimes, you click after sel
|
|||||||
- each buffer needs a directory even the special ones: C:\a\b\c\+errors?
|
- each buffer needs a directory even the special ones: C:\a\b\c\+errors?
|
||||||
- open directories - resulting in buffer with dir listing and proper buffer name
|
- open directories - resulting in buffer with dir listing and proper buffer name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- clean \r\n into \n on trim and load
|
- clean \r\n into \n on trim and load
|
||||||
|
|
||||||
|
- Dump editor state to file
|
||||||
|
- make the editor replayable, store events and then replay, be careful about globals
|
||||||
|
|
||||||
- global config and local config
|
- global config and local config
|
||||||
- load all files in a directory
|
- load all files in a directory
|
||||||
|
|
||||||
@@ -19,7 +25,6 @@ BUG: there is a click hang when switching windows sometimes, you click after sel
|
|||||||
- Search and replace
|
- Search and replace
|
||||||
|
|
||||||
- select space between parens,braces but make it good
|
- select space between parens,braces but make it good
|
||||||
- make the editor replayable, store events and then replay, be careful about globals
|
|
||||||
- Implement shell interaction (here we also could use the coroutine library)
|
- Implement shell interaction (here we also could use the coroutine library)
|
||||||
- word complete
|
- word complete
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user