Ticket #322: t322_auto-adding_space_after_comma.patch

File t322_auto-adding_space_after_comma.patch, 3.1 KB (added by vit_r, 10 years ago)

auto-adding_space_after_comma

  • edit/ChangeLog

    From 1074f386343c442bc90369d922ae5d7f4cfa27ac Mon Sep 17 00:00:00 2001
    From: Vit Rosin <vit_r@list.ru>
    Date: Wed, 8 Apr 2009 13:41:32 +0100
    Subject: [PATCH] ticket322_auto-adding_space_after_comma
    
    ---
     edit/ChangeLog |    8 ++++++++
     edit/edit.c    |   36 +++++++++++++++++++++++++++++++++++-
     edit/edit.h    |    3 ++-
     3 files changed, 45 insertions(+), 2 deletions(-)
    
    diff --git a/edit/ChangeLog b/edit/ChangeLog
    index a663358..c2a5d64 100644
    a b  
     12009-04-08  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/edit.c

    diff --git a/edit/edit.c b/edit/edit.c
    index e806fbd..7430a39 100644
    a b edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) 
    22012201            if (edit_get_byte (edit, edit->curs1) != '\n') 
    22022202                edit_delete (edit); 
    22032203        } 
    2204         edit_insert (edit, char_for_insertion); 
     2204        edit_an_ordinary_key_press (edit, char_for_insertion); 
    22052205        if (option_auto_para_formatting) { 
    22062206            format_paragraph (edit, 0); 
    22072207            edit->force |= REDRAW_PAGE; 
    user_menu (WEdit * edit) 
    27832783cleanup: 
    27842784    g_free (block_file); 
    27852785} 
     2786 
     2787void edit_an_ordinary_key_press (WEdit * edit, const int char_for_insertion) 
     2788{ 
     2789    int c0, c2; 
     2790    if (',' == char_for_insertion) { 
     2791        edit_insert (edit, char_for_insertion); 
     2792        c0 = edit_get_byte (edit, edit->curs1); 
     2793        if (isdigit ((unsigned char) c0) || '\'' == c0) 
     2794            return; 
     2795 
     2796        if (edit->curs1 > 1) { 
     2797            c2 = edit_get_byte (edit, edit->curs1 - 2); 
     2798            if (isdigit ((unsigned char) c2) || '\'' == c2) 
     2799                return; 
     2800        } 
     2801        if ( ! (' ' == c0 || '\t' == c0 || '\'' == c0)) 
     2802            edit_insert (edit, ' '); 
     2803 
     2804        return; 
     2805 
     2806    } else if (isdigit ((unsigned char) char_for_insertion)) { 
     2807        if (edit->curs1 > 2) { 
     2808            if (' ' == edit_get_byte (edit, edit->curs1 - 1)) { 
     2809                if (',' == edit_get_byte (edit, edit->curs1 - 2)) { 
     2810                    unsigned char c3 =  
     2811                    (unsigned char) edit_get_byte (edit, edit->curs1 - 3); 
     2812                    if (isdigit (c3)) 
     2813                        edit_backspace (edit); 
     2814                } 
     2815            } 
     2816        } 
     2817    } 
     2818    edit_insert (edit, char_for_insertion); 
     2819} 
  • edit/edit.h

    diff --git a/edit/edit.h b/edit/edit.h
    index f5d5767..42804de 100644
    a b void format_paragraph (WEdit *edit, int force); 
    245245 
    246246/* either command or char_for_insertion must be passed as -1 */ 
    247247void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion); 
    248  
     248void edit_an_ordinary_key_press (WEdit * edit, const int char_for_insertion); 
     249  
    249250#define get_sys_error(s) (s) 
    250251 
    251252#define edit_error_dialog(h,s) query_dialog (h, s, D_ERROR, 1, _("&Dismiss"))