Ticket #4185: WindowTile.patch

File WindowTile.patch, 4.0 KB (added by psprint, 3 years ago)
  • lib/keybind.c

    From 278f6020f20a675926b3a9a6867ce41393dd37a4 Mon Sep 17 00:00:00 2001
    From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
    Date: Sat, 23 Jan 2021 21:41:57 -0600
    Subject: WindowTile
    
    ---
     lib/keybind.c           |  1 +
     lib/keybind.h           |  1 +
     misc/mc.default.keymap  |  1 +
     src/editor/editwidget.c | 51 +++++++++++++++++++++++++++++++++++++++++
     src/keybind-defaults.c  |  1 +
     5 files changed, 55 insertions(+)
    
    diff --git a/lib/keybind.c b/lib/keybind.c
    index 6f63a072a..4d735ed43 100644
    a b static name_keymap_t command_names[] = { 
    342342    ADD_KEYMAP_NAME (WindowNext), 
    343343    ADD_KEYMAP_NAME (WindowPrev), 
    344344    ADD_KEYMAP_NAME (WindowCascade), 
     345    ADD_KEYMAP_NAME (WindowTile), 
    345346#endif /* USE_INTERNAL_EDIT */ 
    346347 
    347348    /* viewer */ 
  • lib/keybind.h

    diff --git a/lib/keybind.h b/lib/keybind.h
    index 0eae2c8bc..a3828e68d 100644
    a b enum 
    301301    CK_WindowNext, 
    302302    CK_WindowPrev, 
    303303    CK_WindowCascade, 
     304    CK_WindowTile, 
    304305    /* misc commands */ 
    305306    CK_SpellCheck, 
    306307    CK_SpellCheckCurrentWord, 
  • misc/mc.default.keymap

    diff --git a/misc/mc.default.keymap b/misc/mc.default.keymap
    index 493d5346e..1cd6ab5b3 100644
    a b SpellCheckCurrentWord = ctrl-p 
    387387# WindowNext = 
    388388# WindowPrev = 
    389389WindowCascade = ctrl-alt-c 
     390WindowTile = ctrl-alt-t 
    390391# ExtendedKeyMap = 
    391392 
    392393[viewer] 
  • src/editor/editwidget.c

    diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c
    index 26998d406..41d9bc5da 100644
    a b edit_window_cascade (const WDialog * h) 
    357357 
    358358/* --------------------------------------------------------------------------------------------- */ 
    359359 
     360static void 
     361edit_window_tile (const WDialog * h) 
     362{ 
     363    const WGroup *g = CONST_GROUP (h); 
     364    const Widget *wid = CONST_WIDGET (h); 
     365    const size_t offset = 3;    /* skip menu and buttonbar */ 
     366    int cur_y, orig_lines, lines, dlg_num; 
     367    GList *w; 
     368 
     369    dlg_num = g_list_length (g->widgets) - offset; 
     370 
     371    cur_y = 1; 
     372    lines = wid->lines / dlg_num; 
     373    if (lines < 5) 
     374        lines = 5; 
     375    orig_lines = lines; 
     376 
     377    for (w = g->widgets; w != NULL; w = g_list_next (w)) 
     378    { 
     379        if (w == g->current) 
     380            continue; 
     381        /* Detect overflow and use space for final window (in series). */ 
     382        if (cur_y + 2 * orig_lines - 1 > wid->lines) 
     383            lines = wid->lines - cur_y - 1; 
     384 
     385        /* Resize and unfullscreen window. */ 
     386        if (edit_window_leave_fullscreen_resize (WIDGET (w->data), cur_y, 0, lines, wid->cols)) 
     387        { 
     388            cur_y += orig_lines; 
     389            /* Overflow - cycle back to the first size and position. */ 
     390            if (cur_y + orig_lines - 1 > wid->lines) 
     391            { 
     392                cur_y = 1; 
     393                lines = orig_lines; 
     394            } 
     395        } 
     396    } 
     397 
     398    /* Ensure that the currently edited file is positioned last. */ 
     399    w = g->current; 
     400    if (cur_y + orig_lines > wid->lines - 1) 
     401        lines = wid->lines - cur_y - 1; 
     402    edit_window_leave_fullscreen_resize (WIDGET (w->data), cur_y, 0, lines, wid->cols); 
     403    repaint_screen (); 
     404} 
     405 
     406/* --------------------------------------------------------------------------------------------- */ 
     407 
    360408static void 
    361409edit_window_list (const WDialog * h) 
    362410{ 
    edit_dialog_command_execute (WDialog * h, long command) 
    527575    case CK_WindowCascade: 
    528576        edit_window_cascade (h); 
    529577        break; 
     578    case CK_WindowTile: 
     579        edit_window_tile (h); 
     580        break; 
    530581    case CK_WindowNext: 
    531582        group_select_next_widget (g); 
    532583        break; 
  • src/keybind-defaults.c

    diff --git a/src/keybind-defaults.c b/src/keybind-defaults.c
    index bbc88f49a..dbed20014 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    {"WindowTile", "alt-shift-t"}, 
    474475    {"WindowCascade", "alt-shift-c"}, 
    475476#ifdef HAVE_ASPELL 
    476477    {"SpellCheckCurrentWord", "ctrl-p"},