]> git.mdlowis.com Git - projs/tide.git/commitdiff
refactored tide.c a bit more to make global vars static
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Jan 2019 03:20:25 +0000 (22:20 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Jan 2019 03:20:25 +0000 (22:20 -0500)
inc/win.h
src/tide.c

index 5d555e70319f834ca5c43c0a8dc5dee689de336e..edfbd1a4d82861c4847514426a199b5c2fbdf014 100644 (file)
--- a/inc/win.h
+++ b/inc/win.h
@@ -140,10 +140,3 @@ Buf* win_buf(WinRegion id);
 bool win_keymodsset(int mask);
 bool win_sel_get(int selid, void(*cbfn)(char*));
 bool win_sel_set(int selid, char* str);
-
-/* move these to x11.c when possible */
-extern int SearchDir;
-extern char* SearchTerm;
-void exec(char* cmd);
-void cut(char* arg);
-void paste(char* arg);
index 47fa00bf234af797dd41796ccc7ffd395ac22c22..fae2364b878aa47fb37da8255f32902996cdfe60 100644 (file)
@@ -1,9 +1,3 @@
-//#include <limits.h>
-//#include <locale.h>
-//#include <sys/time.h>
-//#include <sys/types.h>
-//#include <ctype.h>
-
 #define _POSIX_C_SOURCE 200809L
 #define _XOPEN_SOURCE 700
 #include <stdc.h>
 #define INCLUDE_DEFS
 #include "config.h"
 
+/* predeclare some things */
+void exec(char* cmd);
+void cut(char* arg);
+void paste(char* arg);
+
 typedef struct {
     char* tag;
     void (*action)(char*);
@@ -34,8 +33,8 @@ static KeyBinding* Keys = NULL;
 static int Divider;
 static int FontSel;
 static bool SyncMouse = false;
-int SearchDir = DOWN;
-char* SearchTerm = NULL;
+static int SearchDir = DOWN;
+static char* SearchTerm = NULL;
 
 #define PRESSED(btn) \
     ((KeyBtnState & (1 << (btn + 7))) == (1 << (btn + 7)))
@@ -474,18 +473,6 @@ bool win_keymodsset(int mask) {
     return ((KeyBtnState & mask) == mask);
 }
 
-bool win_sel_get(int selid, void(*cbfn)(char*)) {
-    return x11_sel_get(&X, selid, cbfn);
-}
-
-bool win_sel_set(int selid, char* str) {
-    return x11_sel_set(&X, selid, str);
-}
-
-void win_syncmouse(void) {
-    SyncMouse = true;
-}
-
 /* Tag/Cmd Execution
  ******************************************************************************/
 static Tag* tag_lookup(char* cmd) {
@@ -593,13 +580,14 @@ void cut(char* arg) {
         select_line(arg);
     /* now perform the cut */
     char* str = view_getstr(view);
-    win_sel_set(CLIPBOARD, str);
+    x11_sel_set(&X, CLIPBOARD, str);
     if (str && *str) delete(arg);
 }
 
 void paste(char* arg) {
     (void)arg;
-    assert(win_sel_get(CLIPBOARD, onpaste));
+    int pasted = x11_sel_get(&X, CLIPBOARD, onpaste);
+    assert(pasted);
 }
 
 static void copy(char* arg) {
@@ -607,7 +595,7 @@ static void copy(char* arg) {
     if (!view_selsize(win_view(FOCUSED)))
         select_line(arg);
     char* str = view_getstr(win_view(FOCUSED));
-    win_sel_set(CLIPBOARD, str);
+    x11_sel_set(&X, CLIPBOARD, str);
 }
 
 static void del_to(void (*tofn)(View*, bool)) {
@@ -777,7 +765,7 @@ static void search(char* arg) {
     view_findstr(win_view(EDIT), SearchDir, str);
     free(SearchTerm);
     SearchTerm = str;
-    win_syncmouse();
+    SyncMouse = true;
 }
 
 static void execute(char* arg) {
@@ -818,7 +806,7 @@ static void jump_to(char* arg) {
         size_t line = strtoul(arg, NULL, 0);
         if (line) {
             view_setln(win_view(EDIT), line);
-            win_syncmouse();
+            SyncMouse = true;
         } else {
             pick_symbol(arg);
         }