From 5390e7b8d4f6fe50c37e94683b021e1319b70e28 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 11 Oct 2018 20:57:50 -0400 Subject: [PATCH] implemented focus toggle shortcut --- TODO.md | 4 ++-- inc/win.h | 2 ++ src/lib/x11.c | 5 +++++ src/tide.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 9347ba5..42567fd 100644 --- a/TODO.md +++ b/TODO.md @@ -2,15 +2,15 @@ ## STAGING -* centering logic in view.c seems broken +* implement mouse warping on search, jump to line, and focus change * implement new version of tfetch (plumb) * implement tide registrar * implement tctl command -* implement mouse warping on search, jump to line, and focus change * gap buffer does not handle UTF-8 currently * Line - Get the current line number(s) containing the selection * refactor selection handling to avoid swapping manually (use buf_selbeg and buf_selend) * encode EOL setting in log entries? +* centering logic in view.c seems slightly broken ## BACKLOG diff --git a/inc/win.h b/inc/win.h index 9610219..342e31a 100644 --- a/inc/win.h +++ b/inc/win.h @@ -138,6 +138,8 @@ void win_prop_set(char* xname, char* ename, char* value); void win_update(int ms); void win_loop(void); void win_quit(void); +void win_togglefocus(void); + View* win_view(WinRegion id); Buf* win_buf(WinRegion id); bool win_keymodsset(int mask); diff --git a/src/lib/x11.c b/src/lib/x11.c index 0d32430..722629b 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -639,6 +639,11 @@ void win_quit(void) { before = X.now; } +void win_togglefocus(void) { + int ypos = (Focused == EDIT ? Divider/2 : (X.height - ((X.height-Divider) / 2))); + XWarpPointer(X.display, X.self, X.self, 0, 0, X.width, X.height, X.width/2, ypos); +} + View* win_view(WinRegion id) { return &(Regions[id == FOCUSED ? Focused : id]); } diff --git a/src/tide.c b/src/tide.c index 4233ddb..d71d92b 100644 --- a/src/tide.c +++ b/src/tide.c @@ -238,7 +238,7 @@ static void select_prev(char* arg) { } static void change_focus(char* arg) { - /* move the mouse to the region */ + win_togglefocus(); } static void undo(char* arg) { -- 2.52.0