]> granicus.if.org Git - neomutt/commitdiff
Modify enter.c routines to use windows.
authorKevin McCarthy <kevin@8t8.us>
Thu, 28 Apr 2016 00:56:53 +0000 (17:56 -0700)
committerKevin McCarthy <kevin@8t8.us>
Thu, 28 Apr 2016 00:56:53 +0000 (17:56 -0700)
This modifies the mutt_enter_string() functions to use MuttMessageWindow.

Thanks to Richard Russon for pointing out slang doesn't support getcurx.

curs_lib.c
edit.c
enter.c
protos.h

index 737d92069f9efafc38d6fd1b72da6ca561dd9ea5..5623596624cb5c58f3128542d369d5f26ce971d5 100644 (file)
@@ -154,7 +154,7 @@ event_t mutt_getch (void)
 int _mutt_get_field (const char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles)
 {
   int ret;
-  int x, y;
+  int x;
 
   ENTER_STATE *es = mutt_new_enter_state();
   
@@ -165,8 +165,8 @@ int _mutt_get_field (const char *field, char *buf, size_t buflen, int complete,
     addstr ((char *)field); /* cast to get around bad prototypes */
     NORMAL_COLOR;
     mutt_refresh ();
-    getyx (stdscr, y, x);
-    ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, numfiles, es);
+    mutt_window_getyx (MuttMessageWindow, &ret, &x);  /* don't care about y: avoiding unused var warning */
+    ret = _mutt_enter_string (buf, buflen, x, complete, multiple, files, numfiles, es);
   }
   while (ret == 1);
   mutt_window_clearline (MuttMessageWindow, 0);
diff --git a/edit.c b/edit.c
index 532e47f01057c3389b6dd365b352e38b0a08ab19..df58111d6ce60b87c2ad98bc99722ec3336281f5 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -242,7 +242,7 @@ static void be_edit_header (ENVELOPE *e, int force)
   rfc822_write_address (tmp, sizeof (tmp), e->to, 0);
   if (!e->to || force)
   {
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 4, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 4, 0) == 0)
     {
       rfc822_free_address (&e->to);
       e->to = mutt_parse_adrlist (e->to, tmp);
@@ -264,7 +264,7 @@ static void be_edit_header (ENVELOPE *e, int force)
   {
     addstr ("Subject: ");
     strfcpy (tmp, e->subject ? e->subject: "", sizeof (tmp));
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 9, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 9, 0) == 0)
       mutt_str_replace (&e->subject, tmp);
     addch ('\n');
   }
@@ -275,7 +275,7 @@ static void be_edit_header (ENVELOPE *e, int force)
     tmp[0] = 0;
     mutt_addrlist_to_local (e->cc);
     rfc822_write_address (tmp, sizeof (tmp), e->cc, 0);
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 4, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 4, 0) == 0)
     {
       rfc822_free_address (&e->cc);
       e->cc = mutt_parse_adrlist (e->cc, tmp);
@@ -296,7 +296,7 @@ static void be_edit_header (ENVELOPE *e, int force)
     tmp[0] = 0;
     mutt_addrlist_to_local (e->bcc);
     rfc822_write_address (tmp, sizeof (tmp), e->bcc, 0);
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 5, 0) == 0)
+    if (mutt_enter_string (tmp, sizeof (tmp), 5, 0) == 0)
     {
       rfc822_free_address (&e->bcc);
       e->bcc = mutt_parse_adrlist (e->bcc, tmp);
@@ -333,7 +333,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur)
   tmp[0] = 0;
   while (!done)
   {
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 0, 0) == -1)
+    if (mutt_enter_string (tmp, sizeof (tmp), 0, 0) == -1)
     {
       tmp[0] = 0;
       continue;
diff --git a/enter.c b/enter.c
index 23610ae5dc074b451329af0e47fedad1e361457e..c7eeb97caef1f65be9aa1ec26042d08ed981d7bb 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -210,20 +210,20 @@ static inline int is_shell_char(wchar_t ch)
  *     -1 if abort.
  */
 
-int  mutt_enter_string(char *buf, size_t buflen, int y, int x, int flags)
+int  mutt_enter_string(char *buf, size_t buflen, int col, int flags)
 {
   int rv;
   ENTER_STATE *es = mutt_new_enter_state ();
-  rv = _mutt_enter_string (buf, buflen, y, x, flags, 0, NULL, NULL, es);
+  rv = _mutt_enter_string (buf, buflen, col, flags, 0, NULL, NULL, es);
   mutt_free_enter_state (&es);
   return rv;
 }
 
-int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
+int _mutt_enter_string (char *buf, size_t buflen, int col,
                        int flags, int multiple, char ***files, int *numfiles,
                        ENTER_STATE *state)
 {
-  int width = COLS - x - 1;
+  int width = MuttMessageWindow->cols - col - 1;
   int redraw;
   int pass = (flags & M_PASS);
   int first = 1;
@@ -280,7 +280,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
       if (state->curpos < state->begin ||
          my_wcswidth (state->wbuf + state->begin, state->curpos - state->begin) >= width)
        state->begin = width_ceiling (state->wbuf, state->lastchar, my_wcswidth (state->wbuf, state->curpos) - width / 2);
-      move (y, x);
+      mutt_window_move (MuttMessageWindow, 0, col);
       w = 0;
       for (i = state->begin; i < state->lastchar; i++)
       {
@@ -289,8 +289,9 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
          break;
        my_addwch (state->wbuf[i]);
       }
-      clrtoeol ();
-      move (y, x + my_wcswidth (state->wbuf + state->begin, state->curpos - state->begin));
+      mutt_window_clrtoeol (MuttMessageWindow);
+      mutt_window_move (MuttMessageWindow, 0,
+          col + my_wcswidth (state->wbuf + state->begin, state->curpos - state->begin));
     }
     mutt_refresh ();
 
index 8e5f7aa9d6ba86bdfb531680103eee1d40ca7ef9..06fab41352899d7b388877b153136de535931f4c 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -301,8 +301,8 @@ int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short);
 int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
 int _mutt_enter_fname (const char *, char *, size_t, int *, int, int, char ***, int *);
-int  mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
-int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, ENTER_STATE *);
+int  mutt_enter_string (char *buf, size_t buflen, int col, int flags);
+int _mutt_enter_string (char *, size_t, int, int, int, char ***, int *, ENTER_STATE *);
 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
 int _mutt_get_field (const char *, char *, size_t, int, int, char ***, int *);
 int mutt_get_hook_type (const char *);