From: Kevin McCarthy Date: Thu, 28 Apr 2016 00:56:53 +0000 (-0700) Subject: Modify enter.c routines to use windows. X-Git-Tag: neomutt-20160822~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3bda5a26ed2ac9b718219a6677033d04165d873;p=neomutt Modify enter.c routines to use windows. This modifies the mutt_enter_string() functions to use MuttMessageWindow. Thanks to Richard Russon for pointing out slang doesn't support getcurx. --- diff --git a/curs_lib.c b/curs_lib.c index 737d92069..562359662 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -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 532e47f01..df58111d6 100644 --- 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 23610ae5d..c7eeb97ca 100644 --- 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 (); diff --git a/protos.h b/protos.h index 8e5f7aa9d..06fab4135 100644 --- 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 *);