Ticket #4184: WindowCascadeTiled___-w_-T_opts___menus___man_doc.patch
File WindowCascadeTiled___-w_-T_opts___menus___man_doc.patch, 9.5 KB (added by psprint, 3 years ago) |
---|
-
doc/man/mcedit.1.in
From 9ec735f2a3ed7f091dda2c48331403b8898d58bc Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski <sgniazdowski@gmail.com> Date: Sat, 23 Jan 2021 21:26:07 -0600 Subject: WindowCascade WindowTile Add -w/-T options and menu entries. --- doc/man/mcedit.1.in | 6 ++ lib/keybind.c | 2 + lib/keybind.h | 2 + misc/mc.default.keymap | 2 + src/args.c | 20 +++++++ src/args.h | 2 + src/editor/editmenu.c | 2 + src/editor/editwidget.c | 128 ++++++++++++++++++++++++++++++++++++++++ src/keybind-defaults.c | 2 + 9 files changed, 166 insertions(+) diff --git a/doc/man/mcedit.1.in b/doc/man/mcedit.1.in index 33e5f34b7..df1680b63 100644
a b Display the version of the program. 54 54 .I "\-x" 55 55 Force xterm mode. Used when running on xterm\-capable terminals (two 56 56 screen modes, and able to send mouse escape sequences). 57 .TP 58 .I "\-w/\-\-cascade" 59 Start with file windows arranged in cascade (not fullscreen). 60 .TP 61 .I "\-T/\-\-tile" 62 Start with file windows tiled (not fullscreen). 57 63 .SH FEATURES 58 64 The internal file editor is a full\-featured windowed editor. It can 59 65 edit several files at the same time. Maximum size of each file is 64 -
lib/keybind.c
diff --git a/lib/keybind.c b/lib/keybind.c index abd44d3e2..4d735ed43 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), 345 ADD_KEYMAP_NAME (WindowTile), 344 346 #endif /* USE_INTERNAL_EDIT */ 345 347 346 348 /* viewer */ -
lib/keybind.h
diff --git a/lib/keybind.h b/lib/keybind.h index af019df09..a3828e68d 100644
a b enum 300 300 CK_WindowList, 301 301 CK_WindowNext, 302 302 CK_WindowPrev, 303 CK_WindowCascade, 304 CK_WindowTile, 303 305 /* misc commands */ 304 306 CK_SpellCheck, 305 307 CK_SpellCheckCurrentWord, -
misc/mc.default.keymap
diff --git a/misc/mc.default.keymap b/misc/mc.default.keymap index 2931ddd0a..1cd6ab5b3 100644
a b SpellCheckCurrentWord = ctrl-p 386 386 # WindowList = 387 387 # WindowNext = 388 388 # WindowPrev = 389 WindowCascade = ctrl-alt-c 390 WindowTile = ctrl-alt-t 389 391 # ExtendedKeyMap = 390 392 391 393 [viewer] -
src/args.c
diff --git a/src/args.c b/src/args.c index 3f6a8b2a4..c52afa8b2 100644
a b 46 46 47 47 /*** global variables ****************************************************************************/ 48 48 49 gboolean mc_args__cascade = FALSE; 50 gboolean mc_args__tile = FALSE; 51 49 52 /* If true, assume we are running on an xterm terminal */ 50 53 gboolean mc_args__force_xterm = FALSE; 51 54 … … static const GOptionEntry argument_main_table[] = { 178 181 }, 179 182 #endif /* ENABLE_VFS_SMB */ 180 183 184 #ifdef USE_INTERNAL_EDIT 185 /* options for non-fullscreen mcedit startup */ 186 { 187 "cascade", 'w', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, 188 &mc_args__cascade, 189 N_("Start editor with windows arranged in cascade"), 190 NULL 191 }, 192 193 { 194 "tile", 'T', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, 195 &mc_args__tile, 196 N_("Start editor with windows tiled"), 197 NULL 198 }, 199 #endif 200 181 201 { 182 202 /* handle arguments manually */ 183 203 "view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, -
src/args.h
diff --git a/src/args.h b/src/args.h index 616864d00..69b25ec16 100644
a b extern gboolean mc_args__force_xterm; 22 22 extern gboolean mc_args__nomouse; 23 23 extern gboolean mc_args__force_colors; 24 24 extern gboolean mc_args__nokeymap; 25 extern gboolean mc_args__cascade; 26 extern gboolean mc_args__tile; 25 27 extern char *mc_args__last_wd_file; 26 28 extern char *mc_args__netfs_logfile; 27 29 extern char *mc_args__keymap_file; -
src/editor/editmenu.c
diff --git a/src/editor/editmenu.c b/src/editor/editmenu.c index 489893849..c20e9fb7e 100644
a b create_window_menu (void) 232 232 entries = g_list_prepend (entries, menu_entry_create (_("&Resize"), CK_WindowResize)); 233 233 entries = 234 234 g_list_prepend (entries, menu_entry_create (_("&Toggle fullscreen"), CK_WindowFullscreen)); 235 entries = g_list_prepend (entries, menu_entry_create (_("&Cascade"), CK_WindowCascade)); 236 entries = g_list_prepend (entries, menu_entry_create (_("T&iled"), CK_WindowTile)); 235 237 entries = g_list_prepend (entries, menu_separator_create ()); 236 238 entries = g_list_prepend (entries, menu_entry_create (_("&Next"), CK_WindowNext)); 237 239 entries = g_list_prepend (entries, menu_entry_create (_("&Previous"), CK_WindowPrev)); -
src/editor/editwidget.c
diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index 3eafff2b8..d1a41de45 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 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 295 408 static void 296 409 edit_window_list (const WDialog * h) 297 410 { … … edit_dialog_command_execute (WDialog * h, long command) 459 572 case CK_WindowList: 460 573 edit_window_list (h); 461 574 break; 575 case CK_WindowCascade: 576 edit_window_cascade (h); 577 break; 578 case CK_WindowTile: 579 edit_window_tile (h); 580 break; 462 581 case CK_WindowNext: 463 582 group_select_next_widget (g); 464 583 break; … … edit_files (const GList * files) 1268 1387 ok = ok || f_ok; 1269 1388 } 1270 1389 1390 if (mc_args__cascade) 1391 { 1392 edit_window_cascade (edit_dlg); 1393 } 1394 else if (mc_args__tile) 1395 { 1396 edit_window_tile (edit_dlg); 1397 } 1398 1271 1399 if (ok) 1272 1400 dlg_run (edit_dlg); 1273 1401 -
src/keybind-defaults.c
diff --git a/src/keybind-defaults.c b/src/keybind-defaults.c index 7b87c2f5a..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"}, 475 {"WindowCascade", "alt-shift-c"}, 474 476 #ifdef HAVE_ASPELL 475 477 {"SpellCheckCurrentWord", "ctrl-p"}, 476 478 #endif