Ticket #23: mc-old_esc_mode.patch

File mc-old_esc_mode.patch, 8.2 KB (added by slavazanko, 15 years ago)

added by ptsekov

  • src/key.c

    RCS file: /cvsroot/mc/mc/src/key.c,v
    retrieving revision 1.87
    diff -u -p -r1.87 key.c
     
    7272#define DIF_TIME(t1,t2) ((t2.tv_sec -t1.tv_sec) *1000+ \ 
    7373                         (t2.tv_usec-t1.tv_usec)/1000) 
    7474 
    75 /* timeout for old_esc_mode in usec */ 
    76 #define ESCMODE_TIMEOUT 1000000 
    77  
    7875/* Linux console keyboard modifiers */ 
    7976#define SHIFT_PRESSED           (1 << 0) 
    8077#define ALTR_PRESSED            (1 << 1) 
     
    8481int mou_auto_repeat = 100; 
    8582int double_click_speed = 250; 
    8683int old_esc_mode = 0; 
     84int old_esc_mode_timeout = 1000; /* timeout for old_esc_mode in msec */ 
    8785 
    8886int use_8th_bit_as_meta = 0; 
    8987 
    int get_key_code (int no_delay) 
    818819                if (esctime.tv_sec == -1) 
    819820                    return -1; 
    820821                GET_TIME (current); 
    821                 timeout.tv_sec = ESCMODE_TIMEOUT / 1000000 + esctime.tv_sec; 
    822                 timeout.tv_usec = ESCMODE_TIMEOUT % 1000000 + esctime.tv_usec; 
     822                timeout.tv_sec = old_esc_mode_timeout / 1000 + esctime.tv_sec; 
     823                timeout.tv_usec = (old_esc_mode_timeout % 1000) * 1000 + esctime.tv_usec; 
    823824                if (timeout.tv_usec > 1000000) { 
    824825                    timeout.tv_usec -= 1000000; 
    825826                    timeout.tv_sec++; 
    static int xgetch_second (void) 
    11461147    int c; 
    11471148    struct timeval timeout; 
    11481149 
    1149     timeout.tv_sec = ESCMODE_TIMEOUT / 1000000; 
    1150     timeout.tv_usec = ESCMODE_TIMEOUT % 1000000; 
     1150    timeout.tv_sec = old_esc_mode_timeout / 1000; 
     1151    timeout.tv_usec = (old_esc_mode_timeout % 1000) * 1000; 
    11511152    nodelay (stdscr, TRUE); 
    11521153    FD_ZERO (&Read_FD_Set); 
    11531154    FD_SET (input_fd, &Read_FD_Set); 
  • src/key.h

    RCS file: /cvsroot/mc/mc/src/key.h,v
    retrieving revision 1.23
    diff -u -p -r1.23 key.h
    int mi_getch (void); 
    2626 
    2727extern int double_click_speed; 
    2828extern int old_esc_mode; 
     29extern int old_esc_mode_timeout; 
    2930extern int irix_fn_keys; 
    3031extern int use_8th_bit_as_meta; 
    3132 
  • src/boxes.c

    RCS file: /cvsroot/mc/mc/src/boxes.c,v
    retrieving revision 1.95
    diff -u -p -r1.95 boxes.c
    vfs_smb_get_authinfo (const char *host,  
    11211121    return return_value; 
    11221122} 
    11231123#endif /* WITH_SMBFS */ 
     1124 
     1125#define KBD_MOUSE_SETUP_WIDGETS_COUNT 7 
     1126#define KBD_MOUSE_SETUP_DLG_X_OFFSET 2 /* Horizontal offset */ 
     1127#define KBD_MOUSE_SETUP_DLG_Y_OFFSET 2 /* Vertical offset */ 
     1128#define KBD_MOUSE_SETUP_DLG_EMPTY_LINES_COUNT 3 
     1129#define KBD_MOUSE_SETUP_LAST_LINE_Y 4 
     1130 
     1131void 
     1132keyboard_mouse_setup_box (void) 
     1133{ 
     1134    int dlg_width, dlg_height; 
     1135    int line_length; 
     1136    int cur_line; 
     1137    int old_esc_mode_val; 
     1138    char *old_esc_mode_timeout_val; 
     1139    QuickWidget *widgets, *w, *endw; 
     1140    QuickDialog *dlg; 
     1141    char old_esc_mode_timeout_str[BUF_TINY]; 
     1142 
     1143    old_esc_mode_val = old_esc_mode; 
     1144    g_snprintf (old_esc_mode_timeout_str, sizeof (old_esc_mode_timeout_str), 
     1145        " %4i", old_esc_mode_timeout); 
     1146 
     1147    widgets = g_new0 (QuickWidget, (KBD_MOUSE_SETUP_WIDGETS_COUNT + 1)); 
     1148    dlg = g_new0 (QuickDialog, 1); 
     1149 
     1150    endw = widgets + KBD_MOUSE_SETUP_WIDGETS_COUNT; 
     1151 
     1152    dlg->title = _(" Keayboard / Mouse Setup "); 
     1153    dlg_width = strlen (dlg->title); 
     1154    dlg_height = 0; 
     1155 
     1156    w = endw - 1; 
     1157 
     1158    /* First line of widgets */ 
     1159    w->widget_type = quick_checkbox; 
     1160    w->relative_y = 1; 
     1161    w->text = _("Escape key is cancel key"); 
     1162    w->result = &old_esc_mode_val; 
     1163    w--; 
     1164 
     1165    /* Next line of widgets */ 
     1166    w->widget_type = quick_label; 
     1167    w->relative_y = 2; 
     1168    w->text = _("Escape key timeout "); 
     1169    w--; 
     1170 
     1171    w->widget_type = quick_input; 
     1172    w->relative_y = 2; 
     1173    w->text = old_esc_mode_timeout_str; 
     1174    /* hotkey_pos contains is used to set the length of the input field. */ 
     1175    w->hotkey_pos = strlen (widgets[4].text); 
     1176    w->str_result = &old_esc_mode_timeout_val; 
     1177    w->histname = "escape-key-timeout"; 
     1178    w--; 
     1179 
     1180    w->widget_type = quick_label; 
     1181    w->relative_y = 2; 
     1182    w->text = _(" msec"); 
     1183    w--; 
     1184 
     1185    /* Last line of widgets */ 
     1186    w->widget_type = quick_button; 
     1187    w->relative_y = KBD_MOUSE_SETUP_LAST_LINE_Y; 
     1188    w->text = _("&OK"); 
     1189    w->value = B_ENTER; 
     1190    w--; 
     1191 
     1192    w->widget_type = quick_label; 
     1193    w->relative_y = KBD_MOUSE_SETUP_LAST_LINE_Y; 
     1194    w->text = "      "; /* padding */ 
     1195    w--; 
     1196 
     1197    w->widget_type = quick_button; 
     1198    w->relative_y = KBD_MOUSE_SETUP_LAST_LINE_Y; 
     1199    w->text = _("&Cancel"); 
     1200    w->value = B_CANCEL; 
     1201    w--; 
     1202 
     1203    /* Calculate the dialog width and height based on the dimensions 
     1204       of the enclosed widgets. */ 
     1205    w = endw - 1; 
     1206    line_length = 0; 
     1207    cur_line = w->relative_y; 
     1208    for (; w >= widgets; w--) { 
     1209        if (cur_line != w->relative_y) { 
     1210            dlg_height++; 
     1211 
     1212            if (line_length > dlg_width) 
     1213                dlg_width = line_length; 
     1214 
     1215            line_length = 0; 
     1216            cur_line = w->relative_y; 
     1217        } 
     1218 
     1219        w->relative_x = line_length; 
     1220 
     1221        if (w->widget_type == quick_button) { 
     1222            line_length += button_len (w->text, 
     1223                (w->value == B_ENTER ? DEFPUSH_BUTTON : NORMAL_BUTTON)); 
     1224        } else { 
     1225            line_length += strlen (w->text); 
     1226 
     1227            if (w->widget_type == quick_checkbox) 
     1228                line_length += 4; /* "[x] " */ 
     1229        } 
     1230    } 
     1231    dlg_height++; 
     1232    if (line_length > dlg_width) 
     1233        dlg_width = line_length; 
     1234    else { 
     1235        /* Special handling for the last line of widgets - assume 
     1236           that they must be centered. */ 
     1237        line_length = (dlg_width - line_length) / 2; 
     1238        for (w = widgets; w < endw; w++) { 
     1239            if (w->relative_y == KBD_MOUSE_SETUP_LAST_LINE_Y) 
     1240                w->relative_x += line_length; 
     1241        } 
     1242    } 
     1243 
     1244    dlg_width += KBD_MOUSE_SETUP_DLG_X_OFFSET * 2; 
     1245    dlg_height += KBD_MOUSE_SETUP_DLG_Y_OFFSET * 2 + 
     1246        KBD_MOUSE_SETUP_DLG_EMPTY_LINES_COUNT; 
     1247    for (w = widgets; w < endw; w++) { 
     1248        w->x_divisions = dlg_width; 
     1249        w->y_divisions = dlg_height; 
     1250        w->relative_x += KBD_MOUSE_SETUP_DLG_X_OFFSET; 
     1251        w->relative_y += KBD_MOUSE_SETUP_DLG_Y_OFFSET; 
     1252    } 
     1253 
     1254    dlg->xlen = dlg_width; 
     1255    dlg->ylen = dlg_height; 
     1256    dlg->xpos = dlg->ypos = -1; 
     1257    dlg->widgets = widgets; 
     1258    dlg->i18n = 1; 
     1259 
     1260    if (quick_dialog (dlg) != B_CANCEL) { 
     1261        old_esc_mode = old_esc_mode_val; 
     1262        if (strlen (old_esc_mode_timeout_val) > 4) /* i.e. 9999 */ 
     1263            old_esc_mode_timeout_val[4] = '\0'; 
     1264        old_esc_mode_timeout = atoi (old_esc_mode_timeout_val); 
     1265        g_free (old_esc_mode_timeout_val); 
     1266    } 
     1267 
     1268    g_free (widgets); 
     1269    g_free (dlg); 
     1270} 
  • src/boxes.h

    RCS file: /cvsroot/mc/mc/src/boxes.h,v
    retrieving revision 1.6
    diff -u -p -r1.6 boxes.h
    char *cd_dialog (void); 
    1616void    symlink_dialog   (const char *existing, const char *new, 
    1717                          char **ret_existing, char **ret_new); 
    1818char   *tree_box         (const char *current_dir); 
     19void    keyboard_mouse_setup_box (void); 
    1920 
    2021#endif 
  • src/main.c

    RCS file: /cvsroot/mc/mc/src/main.c,v
    retrieving revision 1.365
    diff -u -p -r1.365 main.c
    static menu_entry OptMenu[] = { 
    917935    {' ', N_("&Layout..."), 'L', layout_cmd}, 
    918936    {' ', N_("c&Onfirmation..."), 'O', confirm_box}, 
    919937    {' ', N_("&Display bits..."), 'D', display_bits_box}, 
     938    {' ', N_("Keyboard and &Mouse..."), 'M', keyboard_mouse_setup_box}, 
    920939    {' ', N_("learn &Keys..."), 'K', learn_keys}, 
    921940#ifdef USE_VFS 
    922941    {' ', N_("&Virtual FS..."), 'V', configure_vfs}, 
  • src/setup.c

    RCS file: /cvsroot/mc/mc/src/setup.c,v
    retrieving revision 1.92
    diff -u -p -r1.92 setup.c
    static const struct { 
    176176    { "drop_menus", &drop_menus }, 
    177177    { "wrap_mode",  &global_wrap_mode}, 
    178178    { "old_esc_mode", &old_esc_mode }, 
     179    { "old_esc_mode_timeout", &old_esc_mode_timeout }, 
    179180    { "cd_symlinks", &cd_symlinks }, 
    180181    { "show_all_if_ambiguous", &show_all_if_ambiguous }, 
    181182    { "max_dirt_limit", &max_dirt_limit },