Ticket #3211: 3_edit_lock.patch

File 3_edit_lock.patch, 7.8 KB (added by aurel, 8 years ago)
  • lib/keybind.c

    old new static name_keymap_t command_names[] = { 
    290290    {"BookmarkFlush", CK_BookmarkFlush}, 
    291291    {"BookmarkNext", CK_BookmarkNext}, 
    292292    {"BookmarkPrev", CK_BookmarkPrev}, 
     293    {"ChangeLockToggle", CK_ChangeLockToggle}, 
    293294    {"MarkPageUp", CK_MarkPageUp}, 
    294295    {"MarkPageDown", CK_MarkPageDown}, 
    295296    {"MarkToFileBegin", CK_MarkToFileBegin}, 
  • lib/keybind.h

    old new enum 
    246246    CK_BookmarkFlush, 
    247247    CK_BookmarkNext, 
    248248    CK_BookmarkPrev, 
     249    CK_ChangeLockToggle, 
    249250    /* mark commands */ 
    250251    CK_MarkColumn, 
    251252    CK_MarkWord, 
  • misc/mc.default.keymap

    old new Bookmark = alt-k 
    319319BookmarkFlush = alt-o 
    320320BookmarkNext = alt-j 
    321321BookmarkPrev = alt-i 
     322ChangeLockToggle = ctrl-alt-l 
    322323# History = 
    323324Shell = ctrl-o 
    324325InsertLiteral = ctrl-q 
  • misc/mc.emacs.keymap

    old new Menu = f9 
    318318# BookmarkFlush = 
    319319# BookmarkNext = 
    320320# BookmarkPrev = 
     321# ChangeLockToggle = 
    321322# History = 
    322323Shell = ctrl-o 
    323324InsertLiteral = ctrl-q 
  • src/editor/edit.c

    old new edit_move_updown (WEdit * edit, long lin 
    10531053static void 
    10541054edit_right_delete_word (WEdit * edit) 
    10551055{ 
     1056    if (edit->edit_locked) 
     1057        return; 
     1058 
    10561059    while (edit->buffer.curs1 < edit->buffer.size) 
    10571060    { 
    10581061        int c1, c2; 
    edit_right_delete_word (WEdit * edit) 
    10731076static void 
    10741077edit_left_delete_word (WEdit * edit) 
    10751078{ 
     1079    if (edit->edit_locked) 
     1080        return; 
     1081 
    10761082    while (edit->buffer.curs1 > 0) 
    10771083    { 
    10781084        int c1, c2; 
    edit_do_undo (WEdit * edit) 
    11001106    long ac; 
    11011107    long count = 0; 
    11021108 
     1109    if (edit->edit_locked) 
     1110        return; 
     1111 
    11031112    edit->undo_stack_disable = 1;       /* don't record undo's onto undo stack! */ 
    11041113    edit->over_col = 0; 
    11051114    while ((ac = edit_pop_undo_action (edit)) < KEY_PRESS) 
    edit_do_redo (WEdit * edit) 
    11831192    long ac; 
    11841193    long count = 0; 
    11851194 
     1195    if (edit->edit_locked) 
     1196        return; 
     1197 
    11861198    if (edit->redo_stack_reset) 
    11871199        return; 
    11881200 
    edit_group_undo (WEdit * edit) 
    12801292static void 
    12811293edit_delete_to_line_end (WEdit * edit) 
    12821294{ 
     1295    if (edit->edit_locked) 
     1296        return; 
     1297 
    12831298    while (edit_buffer_get_current_byte (&edit->buffer) != '\n' && edit->buffer.curs2 != 0) 
    12841299        edit_delete (edit, TRUE); 
    12851300} 
    edit_delete_to_line_end (WEdit * edit) 
    12891304static void 
    12901305edit_delete_to_line_begin (WEdit * edit) 
    12911306{ 
     1307    if (edit->edit_locked) 
     1308        return; 
     1309 
    12921310    while (edit_buffer_get_previous_byte (&edit->buffer) != '\n' && edit->buffer.curs1 != 0) 
    12931311        edit_backspace (edit, TRUE); 
    12941312} 
    edit_init (WEdit * edit, int y, int x, i 
    20962114 
    20972115    edit->loading_done = 1; 
    20982116    edit->modified = 0; 
     2117    edit->edit_locked = 0; 
    20992118    edit->locked = 0; 
    21002119    edit_load_syntax (edit, NULL, NULL); 
    21012120    edit_get_syntax_color (edit, -1); 
    edit_push_redo_action (WEdit * edit, lon 
    24502469void 
    24512470edit_insert (WEdit * edit, int c) 
    24522471{ 
     2472    if (edit->edit_locked) 
     2473        return; 
     2474 
    24532475    /* first we must update the position of the display window */ 
    24542476    if (edit->buffer.curs1 < edit->start_display) 
    24552477    { 
    edit_insert (WEdit * edit, int c) 
    24942516void 
    24952517edit_insert_ahead (WEdit * edit, int c) 
    24962518{ 
     2519    if (edit->edit_locked) 
     2520        return; 
     2521 
    24972522    if (edit->buffer.curs1 < edit->start_display) 
    24982523    { 
    24992524        edit->start_display++; 
    edit_delete (WEdit * edit, gboolean byte 
    25442569    int cw = 1; 
    25452570    int i; 
    25462571 
    2547     if (edit->buffer.curs2 == 0) 
     2572    if (edit->edit_locked || edit->buffer.curs2 == 0) 
    25482573        return 0; 
    25492574 
    25502575#ifdef HAVE_CHARSET 
    edit_backspace (WEdit * edit, gboolean b 
    26062631    int cw = 1; 
    26072632    int i; 
    26082633 
    2609     if (edit->buffer.curs1 == 0) 
     2634    if (edit->edit_locked || edit->buffer.curs1 == 0) 
    26102635        return 0; 
    26112636 
    26122637    if (edit->mark2 != edit->mark1) 
    edit_mark_current_line_cmd (WEdit * edit 
    30803105void 
    30813106edit_delete_line (WEdit * edit) 
    30823107{ 
     3108    if (edit->edit_locked) 
     3109        return; 
     3110 
    30833111    /* 
    30843112     * Delete right part of the line. 
    30853113     * Note that edit_buffer_get_byte() returns '\n' when byte position is 
    edit_execute_cmd (WEdit * edit, unsigned 
    36413669        edit_mark_current_line_cmd (edit); 
    36423670        break; 
    36433671 
     3672    case CK_ChangeLockToggle: 
     3673        edit->edit_locked = !edit->edit_locked; 
     3674        break; 
     3675 
    36443676    case CK_Bookmark: 
    36453677        book_mark_clear (edit, edit->buffer.curs_line, BOOK_MARK_FOUND_COLOR); 
    36463678        if (book_mark_query_color (edit, edit->buffer.curs_line, BOOK_MARK_COLOR)) 
  • src/editor/editdraw.c

    old new status_string (WEdit * edit, char *s, in 
    152152    /* The field lengths just prevent the status line from shortening too much */ 
    153153    if (simple_statusbar) 
    154154        g_snprintf (s, w, 
    155                     "%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s", 
     155                    "%c%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s", 
    156156                    edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-', 
    157157                    edit->modified ? 'M' : '-', 
    158158                    macro_index < 0 ? '-' : 'R', 
    159159                    edit->overwrite == 0 ? '-' : 'O', 
     160                    edit->edit_locked == 0 ? '-' : 'L', 
    160161                    edit->curs_col + edit->over_col, 
    161162                    edit->buffer.curs_line + 1, 
    162163                    edit->buffer.lines + 1, (long) edit->buffer.curs1, (long) edit->buffer.size, 
    status_string (WEdit * edit, char *s, in 
    167168                    ""); 
    168169    else 
    169170        g_snprintf (s, w, 
    170                     "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s  %s", 
     171                    "[%c%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s  %s", 
    171172                    edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-', 
    172173                    edit->modified ? 'M' : '-', 
    173174                    macro_index < 0 ? '-' : 'R', 
    174175                    edit->overwrite == 0 ? '-' : 'O', 
     176                    edit->edit_locked == 0 ? '-' : 'L', 
    175177                    edit->curs_col + edit->over_col, 
    176178                    edit->start_line + 1, 
    177179                    edit->curs_row, 
  • src/editor/editmenu.c

    old new create_command_menu (void) 
    154154    entries = 
    155155        g_list_prepend (entries, 
    156156                        menu_entry_create (_("Toggle s&yntax highlighting"), CK_SyntaxOnOff)); 
     157    entries = 
     158        g_list_prepend (entries, 
     159                        menu_entry_create (_("Toggle &change lock"), CK_ChangeLockToggle)); 
    157160    entries = g_list_prepend (entries, menu_separator_create ()); 
    158161    entries = g_list_prepend (entries, menu_entry_create (_("&Find declaration"), CK_Find)); 
    159162    entries = 
  • src/editor/editwidget.h

    old new struct WEdit 
    105105    long over_col;              /* pos after '\n' */ 
    106106    int force;                  /* how much of the screen do we redraw? */ 
    107107    unsigned int overwrite:1;   /* Overwrite on type mode (as opposed to insert) */ 
     108    unsigned int edit_locked:1; /* File modification is prohibited */ 
    108109    unsigned int modified:1;    /* File has been modified and needs saving */ 
    109110    unsigned int loading_done:1;        /* File has been loaded into the editor */ 
    110111    unsigned int locked:1;      /* We hold lock on current file */ 
  • src/keybind-defaults.c

    old new static const global_keymap_ini_t default 
    404404    {"BookmarkFlush", "alt-o"}, 
    405405    {"BookmarkNext", "alt-j"}, 
    406406    {"BookmarkPrev", "alt-i"}, 
     407    {"ChangeLockToggle", "ctrl-alt-l"}, 
    407408    {"MacroStartStopRecord", "ctrl-r"}, 
    408409    {"MacroExecute", "ctrl-a"}, 
    409410    {"ShowNumbers", "alt-n"},