Ticket #319: flow_insert_col.diff

File flow_insert_col.diff, 4.8 KB (added by vit_r, 15 years ago)
  • edit/edit.c

    !diff -urN mc-4.6.2_MDC/edit/ChangeLog mc-2009-03-31/edit/ChangeLog
    !--- mc-4.6.2_MDC/edit/ChangeLog	2009-02-01 19:30:21.000000000 +0000
    !+++ mc-2009-03-31/edit/ChangeLog	2009-03-31 07:48:20.000000000 +0100
    !@@ -1,3 +1,16 @@
    !+2009-03-31  Vit Rosin   <vit_r@list.ru>
    !+        flow column insertion:
    !+        * edit.c (edit_insert_file):
    !+        When chars are inserted place cursor after inserted chars.
    !+        * edit.h (edit_copy_to_X_buf_cmd): Add new argument.
    !+        * editcmd.c (edit_copy_to_X_buf_cmd):
    !+        Add saving the insert-start clmn.
    !+        * edit.c (edit_execute_key_command):
    !+        If after insertion next key press is <Up-arrow>, <Down-arrow>,
    !+        <PageUp>, <PageDown>, <BeginText> or <EndText>, -
    !+        move cursor to the insert-start clmn.
    !+        Any other key press resets the insert-start clmn.
    !+        Its _NOT_ patch yet, - to test and discuss only.
    ! 2007-11-02  Vladimir Nadvornik  <nadvornik@suse.cz>
    ! 
    ! 	* editlock.c (lock_build_name): Check the return value of getpwuid().
    diff -urN mc-4.6.2_MDC/edit/edit.c mc-2009-03-31/edit/edit.c
    old new  
    7070int option_edit_left_extreme = 0; 
    7171int option_edit_top_extreme = 0; 
    7272int option_edit_bottom_extreme = 0; 
     73int flow_insert_col = -1; 
    7374 
    7475const char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_"; 
    7576char *option_backup_ext = NULL; 
     
    267268    char *p; 
    268269    if ((p = edit_get_filter (filename))) { 
    269270        FILE *f; 
    270         long current = edit->curs1; 
    271271        f = (FILE *) popen (p, "r"); 
    272272        if (f) { 
    273273            edit_insert_stream (edit, f); 
    274             edit_cursor_move (edit, current - edit->curs1); 
    275274            if (pclose (f) > 0) { 
    276275                GString *errmsg = g_string_new (NULL); 
    277276                g_string_sprintf (errmsg, _(" Error reading from pipe: %s "), p); 
     
    291290        g_free (p); 
    292291    } else { 
    293292        int i, file, blocklen; 
    294         long current = edit->curs1; 
    295293        unsigned char *buf; 
    296294        if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) 
    297295            return 0; 
     
    300298            for (i = 0; i < blocklen; i++) 
    301299                edit_insert (edit, buf[i]); 
    302300        } 
    303         edit_cursor_move (edit, current - edit->curs1); 
    304301        g_free (buf); 
    305302        mc_close (file); 
    306303        if (blocklen) 
     
    21252122        edit_push_key_press (edit); 
    21262123 
    21272124    edit_execute_cmd (edit, command, char_for_insertion); 
     2125         
     2126    if (CK_Beginning_Of_Text == command || CK_End_Of_Text == command 
     2127            || CK_Page_Up == command || CK_Page_Down == command 
     2128            || CK_Up == command || CK_Down == command) { 
     2129        if (flow_insert_col >= 0) { 
     2130            edit->force |= REDRAW_COMPLETELY; 
     2131            edit_update_screen (edit); 
     2132            if ((edit_eol (edit, edit->curs1) - edit_bol (edit, edit->curs1)) > flow_insert_col) { 
     2133                edit_cursor_move (edit, flow_insert_col - edit->curs_col); 
     2134                edit->force |= REDRAW_COMPLETELY; 
     2135                edit_update_screen (edit); 
     2136            } 
     2137        } 
     2138    } else if (CK_XStore != command && CK_XCut != command  
     2139            && CK_XPaste != command) { 
     2140        flow_insert_col = -1; 
     2141    } 
    21282142    if (column_highlighting) 
    21292143        edit->force |= REDRAW_PAGE; 
    21302144} 
     
    24532467        break; 
    24542468 
    24552469    case CK_XStore: 
    2456         edit_copy_to_X_buf_cmd (edit); 
     2470        edit_copy_to_X_buf_cmd (edit, &flow_insert_col); 
    24572471        break; 
    24582472    case CK_XCut: 
    24592473        edit_cut_to_X_buf_cmd (edit); 
     2474        flow_insert_col = edit_get_col (edit); 
    24602475        break; 
    24612476    case CK_XPaste: 
    24622477        edit_paste_from_X_buf_cmd (edit); 
  • edit/editcmd.c

    diff -urN mc-4.6.2_MDC/edit/editcmd.c mc-2009-03-31/edit/editcmd.c
    old new  
    22912291    edit_error_dialog (_(" Error "), _(" This function is not implemented. ")); 
    22922292} 
    22932293 
    2294 int edit_copy_to_X_buf_cmd (WEdit * edit) 
     2294int edit_copy_to_X_buf_cmd (WEdit * edit, int *flow_insert_col) 
    22952295{ 
    22962296    long start_mark, end_mark; 
    22972297    if (eval_marks (edit, &start_mark, &end_mark)) 
     
    23002300        edit_error_dialog (_(" Copy to clipboard "), get_sys_error (_(" Unable to save to file. "))); 
    23012301        return 1; 
    23022302    } 
     2303    if (start_mark == edit->mark1) 
     2304        *flow_insert_col = edit->column1; 
     2305    else 
     2306        *flow_insert_col = edit->column2; 
     2307 
    23032308    edit_mark_cmd (edit, 1); 
    23042309    return 0; 
    23052310} 
  • edit/edit.h

    diff -urN mc-4.6.2_MDC/edit/edit.h mc-2009-03-31/edit/edit.h
    old new  
    197197int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k); 
    198198void edit_delete_macro_cmd (WEdit * edit); 
    199199 
    200 int edit_copy_to_X_buf_cmd (WEdit * edit); 
     200int edit_copy_to_X_buf_cmd (WEdit * edit, int *flow_insert_col); 
    201201int edit_cut_to_X_buf_cmd (WEdit * edit); 
    202202void edit_paste_from_X_buf_cmd (WEdit * edit); 
    203203