Add load/save option editor_persistent_block to ~/.mc/ini;

Add option editor_persistent_block to Options/General dialog;
Make persistent/nonpersistent blocks if mcedit;
Enlarged height of Options/General dialog from 17 to 19 lines;
This commit is contained in:
Ilia Maslakov 2009-03-26 11:32:18 +00:00
parent 72d0a117b6
commit 3cc9aac553
4 changed files with 77 additions and 35 deletions

View File

@ -63,6 +63,7 @@ int option_fake_half_tabs = 1;
int option_save_mode = EDIT_QUICK_SAVE; int option_save_mode = EDIT_QUICK_SAVE;
int option_save_position = 1; int option_save_position = 1;
int option_max_undo = 32768; int option_max_undo = 32768;
int option_persistent_blocks = 0;
int option_edit_right_extreme = 0; int option_edit_right_extreme = 0;
int option_edit_left_extreme = 0; int option_edit_left_extreme = 0;
@ -2212,6 +2213,25 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_find_bracket (edit); edit_find_bracket (edit);
return; return;
} }
switch (command) {
case CK_Begin_Page:
case CK_End_Page:
case CK_Begin_Page_Highlight:
case CK_End_Page_Highlight:
case CK_Word_Left:
case CK_Word_Right:
case CK_Up:
case CK_Down:
case CK_Left:
case CK_Right:
if ( !option_persistent_blocks ) {
if (column_highlighting)
edit_push_action (edit, COLUMN_ON);
column_highlighting = 0;
edit_mark_cmd (edit, 1);
}
}
switch (command) { switch (command) {
case CK_Begin_Page: case CK_Begin_Page:
case CK_End_Page: case CK_End_Page:
@ -2237,6 +2257,13 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
/* basic cursor key commands */ /* basic cursor key commands */
switch (command) { switch (command) {
case CK_BackSpace: case CK_BackSpace:
/* if non persistent block and text selected */
if ( !option_persistent_blocks ) {
if ( edit->mark1 != edit->mark2 ) {
edit_block_delete_cmd (edit);
break;
}
}
if (option_backspace_through_tabs && is_in_indent (edit)) { if (option_backspace_through_tabs && is_in_indent (edit)) {
while (edit_get_byte (edit, edit->curs1 - 1) != '\n' while (edit_get_byte (edit, edit->curs1 - 1) != '\n'
&& edit->curs1 > 0) && edit->curs1 > 0)
@ -2255,6 +2282,13 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_backspace (edit); edit_backspace (edit);
break; break;
case CK_Delete: case CK_Delete:
/* if non persistent block and text selected */
if ( !option_persistent_blocks ) {
if ( edit->mark1 != edit->mark2 ) {
edit_block_delete_cmd (edit);
break;
}
}
if (option_fake_half_tabs) { if (option_fake_half_tabs) {
int i; int i;
if (is_in_indent (edit) && left_of_four_spaces (edit)) { if (is_in_indent (edit) && left_of_four_spaces (edit)) {

View File

@ -282,6 +282,7 @@ extern int option_fill_tabs_with_spaces;
extern int option_return_does_auto_indent; extern int option_return_does_auto_indent;
extern int option_backspace_through_tabs; extern int option_backspace_through_tabs;
extern int option_fake_half_tabs; extern int option_fake_half_tabs;
extern int option_persistent_blocks;
typedef enum { typedef enum {
EDIT_QUICK_SAVE = 0, EDIT_QUICK_SAVE = 0,

View File

@ -43,7 +43,7 @@
#include "../src/dialog.h" /* B_CANCEL */ #include "../src/dialog.h" /* B_CANCEL */
#include "../src/wtools.h" /* QuickDialog */ #include "../src/wtools.h" /* QuickDialog */
#define OPT_DLG_H 17 #define OPT_DLG_H 19
#define OPT_DLG_W 72 #define OPT_DLG_W 72
#ifndef USE_INTERNAL_EDIT #ifndef USE_INTERNAL_EDIT
@ -76,6 +76,7 @@ edit_options_dialog (void)
int toption_save_position = option_save_position; int toption_save_position = option_save_position;
int tedit_confirm_save = edit_confirm_save; int tedit_confirm_save = edit_confirm_save;
int tedit_syntax_highlighting = option_syntax_highlighting; int tedit_syntax_highlighting = option_syntax_highlighting;
int tedit_persistent_blocks = option_persistent_blocks;
int toption_return_does_auto_indent = option_return_does_auto_indent; int toption_return_does_auto_indent = option_return_does_auto_indent;
int toption_backspace_through_tabs = option_backspace_through_tabs; int toption_backspace_through_tabs = option_backspace_through_tabs;
int toption_fake_half_tabs = option_fake_half_tabs; int toption_fake_half_tabs = option_fake_half_tabs;
@ -89,10 +90,10 @@ edit_options_dialog (void)
{quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), 0, {quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), 0,
B_ENTER, 0, 0, NULL}, B_ENTER, 0, 0, NULL},
/* 2 */ /* 2 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H, {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H,
N_("Word wrap line length: "), 0, 0, 0, 0, NULL}, N_("Word wrap line length: "), 0, 0, 0, 0, NULL},
/* 3 */ /* 3 */
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5, {quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 7,
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, "edit-word-wrap"}, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, "edit-word-wrap"},
/* 4 */ /* 4 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H, {quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
@ -102,38 +103,41 @@ edit_options_dialog (void)
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0,
"edit-tab-spacing"}, "edit-tab-spacing"},
/* 6 */ /* 6 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9,
OPT_DLG_H, N_("Pers&istent blocks"), 8, 0, 0, 0, NULL},
/* 7 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10,
OPT_DLG_H, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL}, OPT_DLG_H, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL},
/* 7 */ /* 7 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9,
OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL},
/* 8 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10,
OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL},
/* 9 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11,
OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL}, OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL},
/* 10 */ /* 9 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12,
OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL}, OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL},
/* 11 */ /* 10 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13,
OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL}, OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL},
/* 12 */ /* 11 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14,
OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL}, OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL},
/* 12 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15,
OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL},
/* 13 */ /* 13 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, "", 3, 0, 0, {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16,
const_cast(char **, wrap_str), "wrapm"}, OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL},
/* 14 */ /* 14 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, wrap_str), "wrapm"},
/* 15 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H,
N_("Wrap mode"), 0, 0, N_("Wrap mode"), 0, 0,
0, 0, NULL}, 0, 0, NULL},
/* 15 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, key_emu_str), "keyemu"},
/* 16 */ /* 16 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H, {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 15, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, key_emu_str), "keyemu"},
/* 17 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 16, OPT_DLG_H,
N_("Key emulation"), 0, 0, 0, 0, NULL}, N_("Key emulation"), 0, 0, 0, 0, NULL},
NULL_QuickWidget NULL_QuickWidget
}; };
@ -156,13 +160,14 @@ edit_options_dialog (void)
quick_widgets[3].str_result = &p; quick_widgets[3].str_result = &p;
quick_widgets[5].text = tab_spacing; quick_widgets[5].text = tab_spacing;
quick_widgets[5].str_result = &q; quick_widgets[5].str_result = &q;
quick_widgets[6].result = &tedit_syntax_highlighting; quick_widgets[6].result = &tedit_persistent_blocks;
quick_widgets[7].result = &toption_save_position; quick_widgets[7].result = &tedit_syntax_highlighting;
quick_widgets[8].result = &tedit_confirm_save; quick_widgets[8].result = &toption_save_position;
quick_widgets[9].result = &toption_fill_tabs_with_spaces; quick_widgets[9].result = &tedit_confirm_save;
quick_widgets[10].result = &toption_return_does_auto_indent; quick_widgets[10].result = &toption_fill_tabs_with_spaces;
quick_widgets[11].result = &toption_backspace_through_tabs; quick_widgets[11].result = &toption_return_does_auto_indent;
quick_widgets[12].result = &toption_fake_half_tabs; quick_widgets[12].result = &toption_backspace_through_tabs;
quick_widgets[13].result = &toption_fake_half_tabs;
if (option_auto_para_formatting) if (option_auto_para_formatting)
wrap_mode = 1; wrap_mode = 1;
@ -171,11 +176,11 @@ edit_options_dialog (void)
else else
wrap_mode = 0; wrap_mode = 0;
quick_widgets[13].result = &wrap_mode; quick_widgets[14].result = &wrap_mode;
quick_widgets[13].value = wrap_mode; quick_widgets[14].value = wrap_mode;
quick_widgets[15].result = &tedit_key_emulation; quick_widgets[16].result = &tedit_key_emulation;
quick_widgets[15].value = tedit_key_emulation; quick_widgets[16].value = tedit_key_emulation;
Quick_options.widgets = quick_widgets; Quick_options.widgets = quick_widgets;
@ -195,6 +200,7 @@ edit_options_dialog (void)
g_free (q); g_free (q);
} }
option_persistent_blocks = tedit_persistent_blocks;
option_syntax_highlighting = tedit_syntax_highlighting; option_syntax_highlighting = tedit_syntax_highlighting;
edit_confirm_save = tedit_confirm_save; edit_confirm_save = tedit_confirm_save;
option_save_position = toption_save_position; option_save_position = toption_save_position;

View File

@ -216,6 +216,7 @@ static const struct {
{ "editor_option_typewriter_wrap", &option_typewriter_wrap }, { "editor_option_typewriter_wrap", &option_typewriter_wrap },
{ "editor_edit_confirm_save", &edit_confirm_save }, { "editor_edit_confirm_save", &edit_confirm_save },
{ "editor_syntax_highlighting", &option_syntax_highlighting }, { "editor_syntax_highlighting", &option_syntax_highlighting },
{ "editor_persistent_blocks", &option_persistent_blocks },
{ "editor_visible_tabs", &visible_tabs }, { "editor_visible_tabs", &visible_tabs },
{ "editor_visible_spaces", &visible_tws }, { "editor_visible_spaces", &visible_tws },
#endif /* USE_INTERNAL_EDIT */ #endif /* USE_INTERNAL_EDIT */