]> granicus.if.org Git - neomutt/commitdiff
refactor: mutt_window_getxy() to mutt_window_get_coords() 1860/head
authorRichard Russon <rich@flatcap.org>
Fri, 27 Sep 2019 23:18:02 +0000 (00:18 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 28 Sep 2019 02:18:42 +0000 (03:18 +0100)
Encapsulate a curses function to reduce dependencies.

curs_lib.c
mutt_window.c
mutt_window.h
sidebar.c

index 797323fc349f197823f43059395d3d642b2c7412..a11b282b935db8f47189e9a89ddb67d69bf7cebe 100644 (file)
@@ -258,7 +258,7 @@ int mutt_get_field_full(const char *field, char *buf, size_t buflen, CompletionF
                         bool multiple, char ***files, int *numfiles)
 {
   int ret;
-  int x;
+  int col;
 
   struct EnterState *es = mutt_enter_state_new();
 
@@ -276,8 +276,8 @@ int mutt_get_field_full(const char *field, char *buf, size_t buflen, CompletionF
     mutt_window_addstr(field);
     mutt_curses_set_color(MT_COLOR_NORMAL);
     mutt_refresh();
-    mutt_window_getxy(MuttMessageWindow, &x, NULL);
-    ret = mutt_enter_string_full(buf, buflen, x, complete, multiple, files, numfiles, es);
+    mutt_window_get_coords(MuttMessageWindow, NULL, &col);
+    ret = mutt_enter_string_full(buf, buflen, col, complete, multiple, files, numfiles, es);
   } while (ret == 1);
   mutt_window_clearline(MuttMessageWindow, 0);
   mutt_enter_state_free(&es);
index 909aaf8c02398bc77c6d1d21ce1529b2390dec74..71404864d93b34043b17951adbd9c68e873ec6b8 100644 (file)
@@ -152,24 +152,24 @@ void mutt_window_free_all(void)
 }
 
 /**
- * mutt_window_getxy - Get the cursor position in the Window
+ * mutt_window_get_coords - Get the cursor position in the Window
  * @param[in]  win Window
- * @param[out] x   X-Coordinate
- * @param[out] y   Y-Coordinate
+ * @param[out] row Row in Window
+ * @param[out] col Column in Window
  *
  * Assumes the current position is inside the window.  Otherwise it will
  * happily return negative or values outside the window boundaries
  */
-void mutt_window_getxy(struct MuttWindow *win, int *x, int *y)
+void mutt_window_get_coords(struct MuttWindow *win, int *row, int *col)
 {
-  int row = 0;
-  int col = 0;
-
-  getyx(stdscr, row, col);
-  if (x)
-    *x = col - win->col_offset;
-  if (y)
-    *y = row - win->row_offset;
+  int x = 0;
+  int y = 0;
+
+  getyx(stdscr, y, x);
+  if (col)
+    *col = x - win->col_offset;
+  if (row)
+    *row = y - win->row_offset;
 }
 
 /**
index 05345164fe412d14b8b6d4f6f5ee5f67bc3bb92f..483c3cc0779d881da4d2daa83de85e9fef94711b 100644 (file)
@@ -50,7 +50,7 @@ extern struct MuttWindow *MuttStatusWindow;
 void               mutt_window_copy_size          (const struct MuttWindow *win_src, struct MuttWindow *win_dst);
 void               mutt_window_free               (struct MuttWindow **ptr);
 void               mutt_window_free_all           (void);
-void               mutt_window_getxy              (struct MuttWindow *win, int *x, int *y);
+void               mutt_window_get_coords         (struct MuttWindow *win, int *col, int *row);
 void               mutt_window_init               (void);
 struct MuttWindow *mutt_window_new                (void);
 void               mutt_window_reflow             (void);
index b0ead8acb9e537d3afb0b5a4ebd1316713a29d83..c94706dd03f7979ebf9f764cf52568ecdcc8c597 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -968,13 +968,8 @@ void mutt_sb_draw(void)
   if (!C_SidebarVisible)
     return;
 
-#ifdef USE_SLANG_CURSES
-  int x = SLsmg_get_column();
-  int y = SLsmg_get_row();
-#else
-  int x = getcurx(stdscr);
-  int y = getcury(stdscr);
-#endif
+  int row = 0, col = 0;
+  mutt_window_get_coords(MuttSidebarWindow, &row, &col);
 
   int num_rows = MuttSidebarWindow->rows;
   int num_cols = MuttSidebarWindow->cols;
@@ -999,7 +994,7 @@ void mutt_sb_draw(void)
   }
 
   draw_sidebar(num_rows, num_cols, div_width);
-  mutt_window_move_abs(y, x);
+  mutt_window_move(MuttSidebarWindow, row, col);
 }
 
 /**