Ticket #4184: WindowCascade.patch
File WindowCascade.patch, 4.4 KB (added by psprint, 3 years 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[] = { 341 341 ADD_KEYMAP_NAME (WindowList), 342 342 ADD_KEYMAP_NAME (WindowNext), 343 343 ADD_KEYMAP_NAME (WindowPrev), 344 ADD_KEYMAP_NAME (WindowCascade), 344 345 #endif /* USE_INTERNAL_EDIT */ 345 346 346 347 /* viewer */ -
lib/keybind.h
diff --git a/lib/keybind.h b/lib/keybind.h index af019df09..0eae2c8bc 100644
a b enum 300 300 CK_WindowList, 301 301 CK_WindowNext, 302 302 CK_WindowPrev, 303 CK_WindowCascade, 303 304 /* misc commands */ 304 305 CK_SpellCheck, 305 306 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 386 386 # WindowList = 387 387 # WindowNext = 388 388 # WindowPrev = 389 WindowCascade = ctrl-alt-c 389 390 # ExtendedKeyMap = 390 391 391 392 [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) 292 292 293 293 /* --------------------------------------------------------------------------------------------- */ 294 294 295 static gboolean 296 edit_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 316 static void 317 edit_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 295 360 static void 296 361 edit_window_list (const WDialog * h) 297 362 { … … edit_dialog_command_execute (WDialog * h, long command) 459 524 case CK_WindowList: 460 525 edit_window_list (h); 461 526 break; 527 case CK_WindowCascade: 528 edit_window_cascade (h); 529 break; 462 530 case CK_WindowNext: 463 531 group_select_next_widget (g); 464 532 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[] = { 471 471 {"Sort", "alt-t"}, 472 472 {"Mail", "alt-m"}, 473 473 {"ExternalCommand", "alt-u"}, 474 {"WindowCascade", "alt-shift-c"}, 474 475 #ifdef HAVE_ASPELL 475 476 {"SpellCheckCurrentWord", "ctrl-p"}, 476 477 #endif