From: Michael D. Lowis Date: Thu, 12 Apr 2018 02:14:45 +0000 (-0400) Subject: more refactoring X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=67ca6adad6bdac6e1192e76f522fb3ca32fdefe1;p=projs%2Ftide.git more refactoring --- diff --git a/inc/win.h b/inc/win.h index c7573b1..e4a532a 100644 --- a/inc/win.h +++ b/inc/win.h @@ -142,8 +142,6 @@ void win_loop(void); void win_quit(void); View* win_view(WinRegion id); Buf* win_buf(WinRegion id); -WinRegion win_getregion(void); -void win_setregion(WinRegion id); /* move these to x11.c when possible */ extern int SearchDir; diff --git a/lib/x11.c b/lib/x11.c index 75ed919..45409a0 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -26,6 +26,7 @@ struct XFont { ((KeyBtnState & (1 << (btn + 7))) == (1 << (btn + 7))) /******************************************************************************/ + static void die(const char* msg); static XFont x11_font_load(char* name); @@ -156,14 +157,6 @@ void win_loop(void) { while (1) job_poll(Timeout); } -WinRegion win_getregion(void) { - return Focused; -} - -void win_setregion(WinRegion id) { - Focused = id; -} - View* win_view(WinRegion id) { return &(Regions[id == FOCUSED ? Focused : id]); } @@ -272,7 +265,7 @@ XFont x11_font_load(char* name) { FcResult result; FcPattern* match = XftFontMatch(X.display, X.screen, pattern, &result); if (!match || !(font->match = XftFontOpenPattern(X.display, match))) - die("could not load base font"); + die("could not load base font\n"); font->height = font->match->ascent + font->match->descent; return font; } @@ -431,7 +424,7 @@ static void xfocus(XEvent* e) { static void xkeypress(XEvent* e) { X.now = e->xkey.time; - win_setregion(getregion(e->xkey.x, e->xkey.y)); + Focused = getregion(e->xkey.x, e->xkey.y); uint32_t key = getkey(e); if (key == RUNE_ERR) return; KeyBtnState = e->xkey.state, LastKey = key; @@ -587,15 +580,14 @@ static uint32_t getkey(XEvent* e) { static void mouse_click(int btn, bool pressed, int x, int y) { size_t row, col; - WinRegion id = getregion(x, y); - win_setregion(id); - get_position(id, x, y, &row, &col); + Focused = getregion(x, y); + get_position(Focused, x, y, &row, &col); switch(btn) { - case MouseLeft: mouse_left(id, pressed, row, col); break; - case MouseMiddle: mouse_middle(id, pressed, row, col); break; - case MouseRight: mouse_right(id, pressed, row, col); break; - case MouseWheelUp: view_scroll(win_view(id), -ScrollBy); break; - case MouseWheelDn: view_scroll(win_view(id), +ScrollBy); break; + case MouseLeft: mouse_left(Focused, pressed, row, col); break; + case MouseMiddle: mouse_middle(Focused, pressed, row, col); break; + case MouseRight: mouse_right(Focused, pressed, row, col); break; + case MouseWheelUp: view_scroll(win_view(Focused), -ScrollBy); break; + case MouseWheelDn: view_scroll(win_view(Focused), +ScrollBy); break; } } diff --git a/tide.c b/tide.c index 96da7d8..88b0ed3 100644 --- a/tide.c +++ b/tide.c @@ -263,7 +263,7 @@ static void select_prev(char* arg) { } static void change_focus(char* arg) { - win_setregion(win_getregion() == TAGS ? EDIT : TAGS); + /* move the mouse to the region */ } static void undo(char* arg) { @@ -347,7 +347,7 @@ static void jump_to(char* arg) { size_t line = strtoul(arg, NULL, 0); if (line) { view_setln(win_view(EDIT), line); - win_setregion(EDIT); + /* move mouse to edit region */ } else { pick_symbol(arg); }