Ticket #4184: WindowCascade.patch

File WindowCascade.patch, 4.4 KB (added by psprint, 8 months ago)
  • lib/keybind.c

    From e2c6f91335e82ef7c912db144b3b6ae202f7f71c Mon Sep 17 00:00:00 2001
    From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
    Date: Sat, 23 Jan 2021 21:26:07 -0600
    Subject: WindowCascade
    
    ---
     lib/keybind.c           |  1 +
     lib/keybind.h           |  1 +
     misc/mc.default.keymap  |  1 +
     src/editor/editwidget.c | 68 +++++++++++++++++++++++++++++++++++++++++
     src/keybind-defaults.c  |  1 +
     5 files changed, 72 insertions(+)
    
    diff --git a/lib/keybind.c b/lib/keybind.c
    index abd44d3e2..6f63a072a 100644
    a b static name_keymap_t command_names[] = { 
    341341    ADD_KEYMAP_NAME (WindowList), 
    342342    ADD_KEYMAP_NAME (WindowNext), 
    343343    ADD_KEYMAP_NAME (WindowPrev), 
     344    ADD_KEYMAP_NAME (WindowCascade), 
    344345#endif /* USE_INTERNAL_EDIT */ 
    345346 
    346347    /* viewer */ 
  • lib/keybind.h

    diff --git a/lib/keybind.h b/lib/keybind.h
    index af019df09..0eae2c8bc 100644
    a b enum 
    300300    CK_WindowList, 
    301301    CK_WindowNext, 
    302302    CK_WindowPrev, 
     303    CK_WindowCascade, 
    303304    /* misc commands */ 
    304305    CK_SpellCheck, 
    305306    CK_SpellCheckCurrentWord, 
  • misc/mc.default.keymap

    diff --git a/misc/mc.default.keymap b/misc/mc.default.keymap
    index 2931ddd0a..493d5346e 100644
    a b SpellCheckCurrentWord = ctrl-p 
    386386# WindowList = 
    387387# WindowNext = 
    388388# WindowPrev = 
     389WindowCascade = ctrl-alt-c 
    389390# ExtendedKeyMap = 
    390391 
    391392[viewer] 
  • src/editor/editwidget.c

    diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
    index 3eafff2b8..26998d406 100644
    a b get_hotkey (int n) 
    292292 
    293293/* --------------------------------------------------------------------------------------------- */ 
    294294 
     295static gboolean 
     296edit_window_leave_fullscreen_resize (Widget * w, int y, int x, int lines, int cols) 
     297{ 
     298    WRect resize_rect; 
     299    gboolean ret = FALSE; 
     300 
     301    if (edit_widget_is_editor (w)) 
     302    { 
     303        WEdit *e = (WEdit *) w; 
     304        if (e->fullscreen) 
     305            edit_toggle_fullscreen (e); 
     306        rect_init (&resize_rect, y, x, lines, cols); 
     307        e->force |= REDRAW_COMPLETELY; 
     308        send_message (WIDGET (e), NULL, MSG_RESIZE, 0, &resize_rect); 
     309        ret = TRUE; 
     310    } 
     311    return ret; 
     312} 
     313 
     314/* --------------------------------------------------------------------------------------------- */ 
     315 
     316static void 
     317edit_window_cascade (const WDialog * h) 
     318{ 
     319    const WGroup *g = CONST_GROUP (h); 
     320    const Widget *wid = CONST_WIDGET (h); 
     321    int diff = 5; 
     322    int cur_y, cur_x, lines, cols; 
     323    GList *w; 
     324 
     325    cur_x = 0; 
     326    cur_y = 1; 
     327    lines = wid->lines - 2; 
     328    cols = wid->cols; 
     329 
     330    for (w = g->widgets; w != NULL; w = g_list_next (w)) 
     331    { 
     332        if (w == g->current) 
     333            continue; 
     334        if (edit_window_leave_fullscreen_resize (WIDGET (w->data), cur_y, cur_x, lines, cols)) 
     335        { 
     336            cur_y += diff; 
     337            cur_x += diff; 
     338            lines -= diff; 
     339            cols -= diff; 
     340            /* Underflow – cycle back to the first size and position. */ 
     341            if (lines < 7 || cols < 30) 
     342            { 
     343                /* Second and following series are more dense. */ 
     344                diff -= diff > 1 ? 1 : 0; 
     345                /* Use a little degrading shift for the next series of windows. */ 
     346                cur_x = 0 + diff - 1; 
     347                cur_y = 1 + diff - 1; 
     348                lines = wid->lines - diff - 1; 
     349                cols = wid->cols - diff + 1; 
     350            } 
     351        } 
     352    } 
     353    w = g->current; 
     354    edit_window_leave_fullscreen_resize (WIDGET (w->data), cur_y, cur_x, lines, cols); 
     355    repaint_screen (); 
     356} 
     357 
     358/* --------------------------------------------------------------------------------------------- */ 
     359 
    295360static void 
    296361edit_window_list (const WDialog * h) 
    297362{ 
    edit_dialog_command_execute (WDialog * h, long command) 
    459524    case CK_WindowList: 
    460525        edit_window_list (h); 
    461526        break; 
     527    case CK_WindowCascade: 
     528        edit_window_cascade (h); 
     529        break; 
    462530    case CK_WindowNext: 
    463531        group_select_next_widget (g); 
    464532        break; 
  • src/keybind-defaults.c

    diff --git a/src/keybind-defaults.c b/src/keybind-defaults.c
    index 7b87c2f5a..bbc88f49a 100644
    a b static const global_keymap_ini_t default_editor_keymap[] = { 
    471471    {"Sort", "alt-t"}, 
    472472    {"Mail", "alt-m"}, 
    473473    {"ExternalCommand", "alt-u"}, 
     474    {"WindowCascade", "alt-shift-c"}, 
    474475#ifdef HAVE_ASPELL 
    475476    {"SpellCheckCurrentWord", "ctrl-p"}, 
    476477#endif