EncloseSpace, EncloseScope changes
This commit is contained in:
@@ -496,15 +496,15 @@ Int FindScopeEnd(Buffer *buffer, Int seek, Int max_seek, char16_t open, char16_t
|
||||
return seek;
|
||||
}
|
||||
|
||||
Range EncloseScope(Buffer *buffer, Int pos, char16_t open, char16_t close) {
|
||||
Range result = {pos, pos};
|
||||
for (Int i = pos; i >= 0; i -= 1) {
|
||||
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; i < buffer->len; i += 1) {
|
||||
for (Int i = pos_max; i < buffer->len; i += 1) {
|
||||
if (buffer->str[i] == close) {
|
||||
result.max = i + 1;
|
||||
break;
|
||||
|
||||
@@ -667,6 +667,7 @@ void ApplyClangFormat(Buffer *buffer) {
|
||||
Buffer *temp_buffer = ExecAndWait(scratch, "clang-format", GetDir(buffer), string);
|
||||
ReplaceWithoutMovingCarets(buffer, GetRange(buffer), {temp_buffer->str, temp_buffer->len});
|
||||
}
|
||||
|
||||
int Lua_ApplyClangFormat(lua_State *L) {
|
||||
lua_Integer buffer_id = luaL_checkinteger(L, 1);
|
||||
lua_pop(L, 1);
|
||||
@@ -731,6 +732,23 @@ 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 EncloseSpace(View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
For (view->carets) {
|
||||
it.range.min = GetPrevEmptyLineStart(buffer, it.range.min);
|
||||
it.range.max = GetNextEmptyLineStart(buffer, it.range.max);
|
||||
}
|
||||
}
|
||||
|
||||
void Command_Delete(View *view, int direction, bool ctrl = false) {
|
||||
Assert(direction == DIR_LEFT || direction == DIR_RIGHT);
|
||||
Scratch scratch;
|
||||
|
||||
@@ -399,10 +399,6 @@ void OnCommand(Event event) {
|
||||
ToggleVisibility(DebugWindowID);
|
||||
}
|
||||
|
||||
if (Press(SDLK_F5)) {
|
||||
AppIsRunning = false;
|
||||
}
|
||||
|
||||
if (Press(SDLK_F11)) {
|
||||
Command_ToggleFullscreen();
|
||||
}
|
||||
@@ -688,7 +684,9 @@ void OnCommand(Event event) {
|
||||
}
|
||||
|
||||
|
||||
if (CtrlPress(SDLK_L)) {
|
||||
if (CtrlShiftPress(SDLK_L)) {
|
||||
EncloseSpace(active.view);
|
||||
} else if (CtrlPress(SDLK_L)) {
|
||||
EncloseLine(active.view);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
- Delete directory/file on disk command
|
||||
- Check. Convert more commands to taking buffer instead of view
|
||||
- Check. Rewrite more commands to use already implemented commands?
|
||||
- Lua OnCommand should be able to comunicate that we don't want C handling and do only the Lua handling
|
||||
- Easily programmable F1-F12 commands
|
||||
- Lua namespaces for different kinds of commands (by ids, using main_set, using active_set)?
|
||||
|
||||
- Set window layout using project file
|
||||
- Split command
|
||||
@@ -15,11 +18,10 @@
|
||||
- Fix jump scroll, the query ends up the last line on screen, kind of wacky
|
||||
- Fix Ctrl+1 Ctrl+2 (choosing window)
|
||||
- Fix search, should have an anchor
|
||||
|
||||
- Use project file as working dir instead of scratch buffer path, separate project dir and project file
|
||||
|
||||
- Enclose line (Ctrl + L)
|
||||
- Enclose most outer scope (but without the last chars, this would be for eval)
|
||||
- Remedybg integration
|
||||
- GetLine()
|
||||
- in lua start debugging, jump to line, start debugger on file
|
||||
- Enclose scope
|
||||
|
||||
- save all relevant buffers and build
|
||||
|
||||
Reference in New Issue
Block a user