diff --git a/src/dialog.c b/src/dialog.c index af42f57d4..6ed443556 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -32,6 +32,7 @@ #include "global.h" #include "../src/tty/tty.h" +#include "../src/tty/color.h" #include "../src/tty/mouse.h" #include "../src/tty/key.h" /* mi_getch() */ @@ -752,7 +753,7 @@ void dlg_run_done (Dlg_head *h) void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event) { if (key == EV_NONE){ - if (got_interrupt ()) + if (tty_got_interrupt ()) key = XCTRL('g'); else return; @@ -790,7 +791,7 @@ frontend_run_dlg (Dlg_head *h) update_cursor (h); /* Clear interrupt flag */ - got_interrupt (); + tty_got_interrupt (); d_key = get_event (&event, h->mouse_status == MOU_REPEAT, 1); dlg_process_event (h, d_key, &event); diff --git a/src/find.c b/src/find.c index ce6fdee79..fd23018e0 100644 --- a/src/find.c +++ b/src/find.c @@ -667,8 +667,8 @@ search_content (Dlg_head *h, const char *directory, const char *filename) status_update (buffer); tty_refresh (); - enable_interrupt_key (); - got_interrupt (); + tty_enable_interrupt_key (); + tty_got_interrupt (); { int line = 1; @@ -727,7 +727,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename) } } - disable_interrupt_key (); + tty_disable_interrupt_key (); mc_close (file_fd); return ret_val; } diff --git a/src/screen.c b/src/screen.c index 17bf37b7a..743fc413b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -567,7 +567,7 @@ format_file (char *dest, int limit, WPanel *panel, int file_index, int width, in tty_setcolor (SELECTED_COLOR); else tty_setcolor (NORMAL_COLOR); - one_vline (); + tty_print_one_vline (); length++; } } @@ -620,7 +620,7 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus) addch (' '); else { tty_setcolor (NORMAL_COLOR); - one_vline (); + tty_print_one_vline (); } } } @@ -1224,7 +1224,7 @@ paint_frame (WPanel *panel) if (side){ tty_setcolor (NORMAL_COLOR); - one_vline (); + tty_print_one_vline (); width = panel->widget.cols - panel->widget.cols/2 - 1; } else if (panel->split) width = panel->widget.cols/2 - 3; @@ -1249,8 +1249,8 @@ paint_frame (WPanel *panel) width -= format->field_len; } else { tty_setcolor (NORMAL_COLOR); - one_vline (); - width --; + tty_print_one_vline (); + width--; continue; } } diff --git a/src/subshell.c b/src/subshell.c index 15fb09f48..dedc5d7df 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -518,11 +518,11 @@ init_subshell (void) /* Wait until the subshell has started up and processed the command */ subshell_state = RUNNING_COMMAND; - enable_interrupt_key (); + tty_enable_interrupt_key (); if (!feed_subshell (QUIETLY, TRUE)) { use_subshell = FALSE; } - disable_interrupt_key (); + tty_disable_interrupt_key (); if (!subshell_alive) use_subshell = FALSE; /* Subshell died instantly, so don't use it */ } diff --git a/src/tty/key.c b/src/tty/key.c index 2183cfe0e..c5502bd6f 100644 --- a/src/tty/key.c +++ b/src/tty/key.c @@ -1143,9 +1143,9 @@ get_event (struct Gpm_Event *event, int redo_event, int block) timeout.tv_sec = 0; timeout.tv_usec = 0; } - enable_interrupt_key (); + tty_enable_interrupt_key (); flag = select (maxfdp + 1, &select_set, NULL, NULL, time_addr); - disable_interrupt_key (); + tty_disable_interrupt_key (); /* select timed out: it could be for any of the following reasons: * redo_event -> it was because of the MOU_REPEAT handler diff --git a/src/tty/tty.h b/src/tty/tty.h index 2b36c3974..93052f593 100644 --- a/src/tty/tty.h +++ b/src/tty/tty.h @@ -51,18 +51,8 @@ extern void tty_print_vline(int top, int left, int length); extern void tty_print_hline(int top, int left, int length); extern void tty_draw_box (int y, int x, int rows, int cols); - extern char *tty_tgetstr (const char *name); -/* legacy interface */ - -#define start_interrupt_key() tty_start_interrupt_key() -#define enable_interrupt_key() tty_enable_interrupt_key() -#define disable_interrupt_key() tty_disable_interrupt_key() -#define got_interrupt() tty_got_interrupt() -#define one_hline() tty_print_one_hline() -#define one_vline() tty_print_one_vline() - #define KEY_KP_ADD 4001 #define KEY_KP_SUBTRACT 4002 #define KEY_KP_MULTIPLY 4003 diff --git a/src/view.c b/src/view.c index 4ace247a7..97a33bce4 100644 --- a/src/view.c +++ b/src/view.c @@ -3198,7 +3198,7 @@ do_search (WView *view) search_update_steps (view); view->update_activate = 0; - enable_interrupt_key (); + tty_enable_interrupt_key (); do { @@ -3240,8 +3240,8 @@ do_search (WView *view) view->dirty++; view_update (view); + tty_disable_interrupt_key (); - disable_interrupt_key (); if (verbose) { dlg_run_done (d); destroy_dlg (d); diff --git a/src/widget.c b/src/widget.c index aad8345f9..b5def7f4f 100644 --- a/src/widget.c +++ b/src/widget.c @@ -1848,7 +1848,7 @@ listbox_drawscroll (WListbox *l) /* Are we at the top? */ widget_move (&l->widget, 0, l->width); if (l->list == l->top) - one_vline (); + tty_print_one_vline (); else addch ('^'); @@ -1856,7 +1856,7 @@ listbox_drawscroll (WListbox *l) widget_move (&l->widget, max_line, l->width); top = listbox_cdiff (l->list, l->top); if ((top + l->height == l->count) || l->height >= l->count) - one_vline (); + tty_print_one_vline (); else addch ('v'); @@ -1869,7 +1869,7 @@ listbox_drawscroll (WListbox *l) for (i = 1; i < max_line; i++){ widget_move (&l->widget, i, l->width); if (i != line) - one_vline (); + tty_print_one_vline (); else addch ('*'); } diff --git a/vfs/direntry.c b/vfs/direntry.c index a1aadc71b..f7a8bfb25 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -969,8 +969,8 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) goto error_3; /* Clear the interrupt status */ - got_interrupt (); - enable_interrupt_key (); + tty_got_interrupt (); + tty_enable_interrupt_key (); while ((n = MEDATA->linear_read (me, &fh, buffer, sizeof (buffer)))) { int t; @@ -981,7 +981,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) vfs_s_print_stats (me->name, _("Getting file"), ino->ent->name, total, stat_size); - if (got_interrupt ()) + if (tty_got_interrupt ()) goto error_1; t = write (handle, buffer, n); @@ -994,13 +994,13 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) MEDATA->linear_close (me, &fh); close (handle); - disable_interrupt_key (); + tty_disable_interrupt_key (); return 0; error_1: MEDATA->linear_close (me, &fh); error_3: - disable_interrupt_key (); + tty_disable_interrupt_key (); close (handle); unlink (ino->localname); error_4: @@ -1241,10 +1241,10 @@ vfs_s_get_line_interruptible (struct vfs_class *me, char *buffer, int size, int (void) me; - enable_interrupt_key (); + tty_enable_interrupt_key (); for (i = 0; i < size-1; i++){ n = read (fd, buffer+i, 1); - disable_interrupt_key (); + tty_disable_interrupt_key (); if (n == -1 && errno == EINTR){ buffer [i] = 0; return EINTR; diff --git a/vfs/fish.c b/vfs/fish.c index 981806088..d5dc0d6a6 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -157,12 +157,12 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, fflush (logfile); } - enable_interrupt_key (); + tty_enable_interrupt_key (); status = write (SUP.sockw, str, strlen (str)); g_free (str); - disable_interrupt_key (); + tty_disable_interrupt_key (); if (status < 0) return TRANSIENT; @@ -749,7 +749,7 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc while (1) { int t; while ((n = read(h, buffer, sizeof(buffer))) < 0) { - if ((errno == EINTR) && got_interrupt()) + if ((errno == EINTR) && tty_got_interrupt ()) continue; print_vfs_message(_("fish: Local read failed, sending zeros") ); close(h); @@ -765,7 +765,7 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc } goto error_return; } - disable_interrupt_key(); + tty_disable_interrupt_key (); total += n; print_vfs_message(_("fish: storing %s %d (%lu)"), was_error ? _("zeros") : _("file"), total, @@ -861,13 +861,13 @@ fish_linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len) struct vfs_s_super *super = FH_SUPER; int n = 0; len = MIN( fh->u.fish.total - fh->u.fish.got, len ); - disable_interrupt_key(); + tty_disable_interrupt_key (); while (len && ((n = read (SUP.sockr, buf, len))<0)) { - if ((errno == EINTR) && !got_interrupt()) + if ((errno == EINTR) && !tty_got_interrupt ()) continue; break; } - enable_interrupt_key(); + tty_enable_interrupt_key(); if (n>0) fh->u.fish.got += n; if (n<0) fish_linear_abort(me, fh); diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 2f4766bdb..a7d21cc50 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -358,7 +358,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } got_sigpipe = 0; - enable_interrupt_key (); + tty_enable_interrupt_key (); status = write (SUP.sock, cmdstr, cmdlen); if (status < 0) { @@ -377,12 +377,12 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, got_sigpipe = 1; } g_free (cmdstr); - disable_interrupt_key (); + tty_disable_interrupt_key (); return TRANSIENT; } retry = 0; ok: - disable_interrupt_key (); + tty_disable_interrupt_key (); if (wait_reply) { @@ -679,8 +679,8 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) free_host = 1; } - enable_interrupt_key(); /* clear the interrupt flag */ - + tty_enable_interrupt_key(); /* clear the interrupt flag */ + /* Get host address */ memset ((char *) &server_address, 0, sizeof (server_address)); server_address.sin_family = AF_INET; @@ -688,7 +688,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) if (server_address.sin_addr.s_addr == INADDR_NONE) { hp = gethostbyname (host); if (hp == NULL){ - disable_interrupt_key(); + tty_disable_interrupt_key (); print_vfs_message (_("ftpfs: Invalid host address.")); ftpfs_errno = EINVAL; if (free_host) @@ -705,7 +705,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) /* Connect */ if ((my_socket = socket (AF_INET, SOCK_STREAM, 0)) < 0) { - disable_interrupt_key(); + tty_disable_interrupt_key (); ftpfs_errno = errno; if (free_host) g_free (host); @@ -719,16 +719,16 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) if (connect (my_socket, (struct sockaddr *) &server_address, sizeof (server_address)) < 0){ ftpfs_errno = errno; - if (errno == EINTR && got_interrupt ()) + if (errno == EINTR && tty_got_interrupt ()) print_vfs_message (_("ftpfs: connection interrupted by user")); else print_vfs_message (_("ftpfs: connection to server failed: %s"), unix_error_string(errno)); - disable_interrupt_key(); + tty_disable_interrupt_key (); close (my_socket); return -1; } - disable_interrupt_key(); + tty_disable_interrupt_key (); return my_socket; } @@ -761,17 +761,17 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) } if (ftpfs_retry_seconds){ retry_seconds = ftpfs_retry_seconds; - enable_interrupt_key (); + tty_enable_interrupt_key (); for (count_down = retry_seconds; count_down; count_down--){ print_vfs_message (_("Waiting to retry... %d (Control-C to cancel)"), count_down); sleep (1); - if (got_interrupt ()){ + if (tty_got_interrupt ()) { /* ftpfs_errno = E; */ - disable_interrupt_key (); + tty_disable_interrupt_key (); return 0; } } - disable_interrupt_key (); + tty_disable_interrupt_key (); } } } while (retry_seconds); @@ -986,7 +986,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd); if (j != PRELIM) ERRNOR (EPERM, -1); - enable_interrupt_key(); + tty_enable_interrupt_key (); if (SUP.use_passive_connection) data = s; else { @@ -997,8 +997,8 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con return -1; } close (s); - } - disable_interrupt_key(); + } + tty_disable_interrupt_key (); return data; } @@ -1148,7 +1148,7 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super, print_vfs_message(_("ftpfs: couldn't resolve symlink")); return; } - enable_interrupt_key(); + tty_enable_interrupt_key (); flist = dir->file_list->next; while (1) { do { @@ -1164,7 +1164,7 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super, fputs (buffer, MEDATA->logfile); fflush (MEDATA->logfile); } -vfs_die("This code should be commented out\n"); + vfs_die("This code should be commented out\n"); if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) { int r = strcmp(fe->name, filename); g_free(filename); @@ -1188,7 +1188,7 @@ vfs_die("This code should be commented out\n"); } done: while (fgets(buffer, sizeof(buffer), fp) != NULL); - disable_interrupt_key(); + tty_disable_interrupt_key (); fclose(fp); ftpfs_get_reply(me, SUP.sock, NULL, 0); } @@ -1255,7 +1255,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path goto fallback; /* Clear the interrupt flag */ - enable_interrupt_key (); + tty_enable_interrupt_key (); while (1) { int i; @@ -1268,7 +1268,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path if (res == EINTR) { me->verrno = ECONNRESET; close (sock); - disable_interrupt_key (); + tty_disable_interrupt_key (); ftpfs_get_reply (me, SUP.sock, NULL, 0); print_vfs_message (_("%s: failure"), me->name); return -1; @@ -1368,11 +1368,11 @@ ftpfs_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, #endif n_stored = 0; - enable_interrupt_key (); + tty_enable_interrupt_key (); while (1) { while ((n_read = read (h, buffer, sizeof (buffer))) == -1) { if (errno == EINTR) { - if (got_interrupt ()) { + if (tty_got_interrupt ()) { ftpfs_errno = EINTR; goto error_return; } else @@ -1387,7 +1387,7 @@ ftpfs_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, w_buf = buffer; while ((n_written = write (sock, w_buf, n_read)) != n_read) { if (n_written == -1) { - if (errno == EINTR && !got_interrupt ()) { + if (errno == EINTR && !tty_got_interrupt ()) { continue; } ftpfs_errno = errno; @@ -1399,14 +1399,14 @@ ftpfs_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, print_vfs_message (_("ftpfs: storing file %lu (%lu)"), (unsigned long) n_stored, (unsigned long) s.st_size); } - disable_interrupt_key (); + tty_disable_interrupt_key (); close (sock); close (h); if (ftpfs_get_reply (me, SUP.sock, NULL, 0) != COMPLETE) ERRNOR (EIO, -1); return 0; error_return: - disable_interrupt_key (); + tty_disable_interrupt_key (); close (sock); close (h); ftpfs_get_reply (me, SUP.sock, NULL, 0); @@ -1437,7 +1437,7 @@ ftpfs_linear_read (struct vfs_class *me, struct vfs_s_fh *fh, void *buf, int len struct vfs_s_super *super = FH_SUPER; while ((n = read (FH_SOCK, buf, len))<0) { - if ((errno == EINTR) && !got_interrupt()) + if ((errno == EINTR) && !tty_got_interrupt ()) continue; break; }