Fix view centering
This commit is contained in:
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
Use session 3:
|
Use session 3:
|
||||||
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
||||||
- Upload sublime settings to git and also install script / update config script
|
|
||||||
|
|
||||||
|
|
||||||
How to go about search/replace, opening code and other considerations
|
How to go about search/replace, opening code and other considerations
|
||||||
- We can use sed + find to search and replace, the automatic reopen should do the job
|
- We can use sed + find to search and replace, the automatic reopen should do the job
|
||||||
@@ -17,7 +15,6 @@ How to go about search/replace, opening code and other considerations
|
|||||||
Use session 2
|
Use session 2
|
||||||
- Need configs I can't change browser or vcvarsall currently, maybe syntax like :Set InternetBrowser "firefox"
|
- Need configs I can't change browser or vcvarsall currently, maybe syntax like :Set InternetBrowser "firefox"
|
||||||
- Tutorial
|
- Tutorial
|
||||||
- When jumping should center the view!!!
|
|
||||||
|
|
||||||
Debug session:
|
Debug session:
|
||||||
- Report errorf - use coroutine dialogs
|
- Report errorf - use coroutine dialogs
|
||||||
@@ -49,7 +46,6 @@ Commands TODO:
|
|||||||
- Special: non editable, hotkeys don't work etc.
|
- Special: non editable, hotkeys don't work etc.
|
||||||
|
|
||||||
backlog
|
backlog
|
||||||
FEATURE commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top
|
|
||||||
FEATURE Some decl/function indexing in fuzzy format
|
FEATURE Some decl/function indexing in fuzzy format
|
||||||
ISSUE? Fix jump scroll, the query ends up the last line on screen, kind of wacky
|
ISSUE? Fix jump scroll, the query ends up the last line on screen, kind of wacky
|
||||||
FEATURE dump text editor state to file, restore state
|
FEATURE dump text editor state to file, restore state
|
||||||
|
|||||||
@@ -204,6 +204,19 @@ void ReportDebugf(const char *fmt, ...) {
|
|||||||
RawAppendf(TraceBuffer, "%S\n", string);
|
RawAppendf(TraceBuffer, "%S\n", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Command_CenterView() {
|
||||||
|
BSet set = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
Caret c = set.view->carets[0];
|
||||||
|
Int front = GetFront(c);
|
||||||
|
XY xy = PosToXY(set.buffer, front);
|
||||||
|
Vec2I size = GetSize(set.window->document_rect);
|
||||||
|
Int y = size.y / 2 / set.window->font->line_spacing;
|
||||||
|
set.view->scroll.x = 0;
|
||||||
|
if (xy.line > y) {
|
||||||
|
set.view->scroll.y = (xy.line) * set.window->font->line_spacing - (size.y / 2);
|
||||||
|
}
|
||||||
|
} RegisterCommand(Command_CenterView, "");
|
||||||
|
|
||||||
void MoveCursorByPageSize(Window *window, int direction, bool shift = false) {
|
void MoveCursorByPageSize(Window *window, int direction, bool shift = false) {
|
||||||
Assert(direction == DIR_UP || direction == DIR_DOWN);
|
Assert(direction == DIR_UP || direction == DIR_DOWN);
|
||||||
BSet set = GetBSet(window);
|
BSet set = GetBSet(window);
|
||||||
@@ -589,6 +602,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
|||||||
for (FileIter it = IterateFiles(scratch, o.path); IsValid(it); Advance(&it)) {
|
for (FileIter it = IterateFiles(scratch, o.path); IsValid(it); Advance(&it)) {
|
||||||
RawAppendf(buffer, "%S\n", it.filename);
|
RawAppendf(buffer, "%S\n", it.filename);
|
||||||
}
|
}
|
||||||
|
SelectRange(view, GetBufferBeginAsRange(buffer));
|
||||||
} else {
|
} else {
|
||||||
View *view = WindowOpenBufferView(set.window, o.path);
|
View *view = WindowOpenBufferView(set.window, o.path);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
@@ -598,7 +612,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
|||||||
view->carets[0] = MakeCaret(pos);
|
view->carets[0] = MakeCaret(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateScroll(set.window, true);
|
Command_CenterView();
|
||||||
} else if (o.kind == OpenKind_Exec) {
|
} else if (o.kind == OpenKind_Exec) {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
NextActiveWindowID = set.window->id;
|
NextActiveWindowID = set.window->id;
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ void SetMouseCursor(Event event) {
|
|||||||
}
|
}
|
||||||
SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
SetMouseCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateScroll(Window *window, bool update_caret_scrolling) {
|
void UpdateScroll(Window *window, bool update_caret_scrolling) {
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
BSet set = GetBSet(window);
|
BSet set = GetBSet(window);
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ void Command_CommandWindowOpen() {
|
|||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
NextActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
OpenCommand(active);
|
OpenCommand(active);
|
||||||
SelectRange(main.view, Range{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||||
|
|||||||
Reference in New Issue
Block a user