Ticket #322: after_comma_space_add.diff

File after_comma_space_add.diff, 2.5 KB (added by vit_r, 10 years ago)
  • ChangeLog

    diff -urN mc-4.6.2_mcDC/ChangeLog mc-2009-04-05/ChangeLog
    old new  
     12009-04-05  Vit Rosin   <vit_r@list.ru> 
     2 
     3        * edit.c, edit.h : Add edit_an_ordinary_key_press () 
     4        Usually after typing comma-key (prints comma char ',') 
     5        spacebar press follows to insert space ' '. 
     6        With this patch typing comma-key prints two chars 
     7        comma char ',' and space ' ' (except some cases). 
     8 
    192007-11-02  Vladimir Nadvornik  <nadvornik@suse.cz> 
    210 
    311        * editlock.c (lock_build_name): Check the return value of getpwuid(). 
  • edit.c

    diff -urN mc-4.6.2_MCDC/edit.c mc-2009-04-05/edit.c
    old new  
    21762176            if (edit_get_byte (edit, edit->curs1) != '\n') 
    21772177                edit_delete (edit); 
    21782178        } 
    2179         edit_insert (edit, char_for_insertion); 
     2179        edit_an_ordinary_key_press (edit, char_for_insertion); 
    21802180        if (option_auto_para_formatting) { 
    21812181            format_paragraph (edit, 0); 
    21822182            edit->force |= REDRAW_PAGE; 
     
    27012701cleanup: 
    27022702    g_free (block_file); 
    27032703} 
     2704 
     2705void edit_an_ordinary_key_press (WEdit * edit, const int char_for_insertion) 
     2706{ 
     2707    int c0, c2; 
     2708    if (',' == char_for_insertion) { 
     2709        edit_insert (edit, char_for_insertion); 
     2710        c0 = edit_get_byte (edit, edit->curs1); 
     2711        if (isdigit (c0) || '\'' == c0) 
     2712            return; 
     2713 
     2714        if (edit->curs1 > 1) { 
     2715            c2 = edit_get_byte (edit, edit->curs1 - 2); 
     2716            if (isdigit (c2) || '\'' == c2) 
     2717                return; 
     2718        } 
     2719        if ( ! (' ' == c0 || '\t' == c0 || '\'' == c0)) 
     2720            edit_insert (edit, ' '); 
     2721 
     2722        return; 
     2723 
     2724    } else if (isdigit (char_for_insertion)) { 
     2725        if (edit->curs1 > 2) { 
     2726            if (' ' == edit_get_byte (edit, edit->curs1 - 1) 
     2727                    && ',' == edit_get_byte (edit, edit->curs1 - 2) 
     2728                    && isdigit (edit_get_byte (edit, edit->curs1 - 3))) 
     2729                edit_backspace (edit); 
     2730        } 
     2731    } 
     2732    edit_insert (edit, char_for_insertion); 
     2733} 
  • edit.h

    diff -urN mc-4.6.2_MCDC/edit.h mc-2009-04-05/edit.h
    old new  
    234234 
    235235/* either command or char_for_insertion must be passed as -1 */ 
    236236void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion); 
     237void edit_an_ordinary_key_press (WEdit * edit, const int char_for_insertion); 
    237238 
    238239#define get_sys_error(s) (s) 
    239240