From 1b4a63fbf00b80169f96f8091e2b53c54a9a5c33 Mon Sep 17 00:00:00 2001
From: Martin Michel <dev@famic.de>
Date: Sat, 16 Jan 2021 15:33:34 +0100
Subject: [PATCH] My squashed CenterLine commits
---
lib/keybind.c | 1 +
lib/keybind.h | 1 +
misc/mc.default.keymap | 1 +
src/editor/edit.c | 19 +++++++++++++++++++
4 files changed, 22 insertions(+)
diff --git a/lib/keybind.c b/lib/keybind.c
index abd44d3e2..e441dcaa7 100644
a
|
b
|
static name_keymap_t command_names[] = { |
331 | 331 | ADD_KEYMAP_NAME (SyntaxOnOff), |
332 | 332 | ADD_KEYMAP_NAME (SyntaxChoose), |
333 | 333 | ADD_KEYMAP_NAME (ShowMargin), |
| 334 | ADD_KEYMAP_NAME (CenterLine), |
334 | 335 | ADD_KEYMAP_NAME (OptionsSaveMode), |
335 | 336 | ADD_KEYMAP_NAME (About), |
336 | 337 | /* An action to run external script from macro */ |
diff --git a/lib/keybind.h b/lib/keybind.h
index af019df09..ebb8e7211 100644
a
|
b
|
enum |
310 | 310 | CK_OptionsSaveMode, |
311 | 311 | CK_About, |
312 | 312 | CK_ShowMargin, |
| 313 | CK_CenterLine, |
313 | 314 | CK_ShowTabTws, |
314 | 315 | CK_SyntaxOnOff, |
315 | 316 | CK_SyntaxChoose, |
diff --git a/misc/mc.default.keymap b/misc/mc.default.keymap
index 2931ddd0a..c5a02e0e6 100644
a
|
b
|
ShowTabTws = alt-underline |
369 | 369 | SyntaxOnOff = ctrl-s |
370 | 370 | # SyntaxChoose = |
371 | 371 | # ShowMargin = |
| 372 | # CenterLine = |
372 | 373 | Find = alt-enter |
373 | 374 | FilePrev = alt-minus |
374 | 375 | FileNext = alt-plus |
diff --git a/src/editor/edit.c b/src/editor/edit.c
index edda1f832..710e11e75 100644
a
|
b
|
edit_execute_cmd (WEdit * edit, long command, int char_for_insertion) |
3764 | 3764 | } |
3765 | 3765 | } |
3766 | 3766 | break; |
| 3767 | case CK_CenterLine: |
3767 | 3768 | |
| 3769 | /* |
| 3770 | * Center cursor line in window, redraw window when cursor is in |
| 3771 | * bottom half of window |
| 3772 | */ |
| 3773 | if (edit->buffer.curs_line > edit->buffer.lines - w->lines / 2) |
| 3774 | { |
| 3775 | edit_save_size (edit); |
| 3776 | widget_set_size (w, w->y, w->x, w->lines / 2 + 2, w->cols); |
| 3777 | edit_move_display (edit, edit->buffer.curs_line - w->lines + 1); |
| 3778 | w->pos_flags = WPOS_KEEP_ALL; |
| 3779 | edit_update_screen (edit); |
| 3780 | widget_set_size_rect (w, &edit->loc_prev); |
| 3781 | } |
| 3782 | else if (edit->buffer.curs_line > edit->curs_row / 2) |
| 3783 | { |
| 3784 | edit_move_display (edit, edit->buffer.curs_line - w->lines / 2 + 1); |
| 3785 | } |
| 3786 | break; |
3768 | 3787 | case CK_Top: |
3769 | 3788 | case CK_MarkToFileBegin: |
3770 | 3789 | edit_move_to_top (edit); |