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[] = { 342 342 ADD_KEYMAP_NAME (WindowNext), 343 343 ADD_KEYMAP_NAME (WindowPrev), 344 344 ADD_KEYMAP_NAME (WindowCascade), 345 ADD_KEYMAP_NAME (WindowTile), 345 346 #endif /* USE_INTERNAL_EDIT */ 346 347 347 348 /* viewer */ -
lib/keybind.h
diff --git a/lib/keybind.h b/lib/keybind.h index 0eae2c8bc..a3828e68d 100644
a b enum 301 301 CK_WindowNext, 302 302 CK_WindowPrev, 303 303 CK_WindowCascade, 304 CK_WindowTile, 304 305 /* misc commands */ 305 306 CK_SpellCheck, 306 307 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 387 387 # WindowNext = 388 388 # WindowPrev = 389 389 WindowCascade = ctrl-alt-c 390 WindowTile = ctrl-alt-t 390 391 # ExtendedKeyMap = 391 392 392 393 [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) 357 357 358 358 /* --------------------------------------------------------------------------------------------- */ 359 359 360 static void 361 edit_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 360 408 static void 361 409 edit_window_list (const WDialog * h) 362 410 { … … edit_dialog_command_execute (WDialog * h, long command) 527 575 case CK_WindowCascade: 528 576 edit_window_cascade (h); 529 577 break; 578 case CK_WindowTile: 579 edit_window_tile (h); 580 break; 530 581 case CK_WindowNext: 531 582 group_select_next_widget (g); 532 583 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[] = { 471 471 {"Sort", "alt-t"}, 472 472 {"Mail", "alt-m"}, 473 473 {"ExternalCommand", "alt-u"}, 474 {"WindowTile", "alt-shift-t"}, 474 475 {"WindowCascade", "alt-shift-c"}, 475 476 #ifdef HAVE_ASPELL 476 477 {"SpellCheckCurrentWord", "ctrl-p"},