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
|
|
| 1 | 2009-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 | |
1 | 9 | 2007-11-02 Vladimir Nadvornik <nadvornik@suse.cz> |
2 | 10 | |
3 | 11 | * editlock.c (lock_build_name): Check the return value of getpwuid(). |
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) |
2201 | 2201 | if (edit_get_byte (edit, edit->curs1) != '\n') |
2202 | 2202 | edit_delete (edit); |
2203 | 2203 | } |
2204 | | edit_insert (edit, char_for_insertion); |
| 2204 | edit_an_ordinary_key_press (edit, char_for_insertion); |
2205 | 2205 | if (option_auto_para_formatting) { |
2206 | 2206 | format_paragraph (edit, 0); |
2207 | 2207 | edit->force |= REDRAW_PAGE; |
… |
… |
user_menu (WEdit * edit) |
2783 | 2783 | cleanup: |
2784 | 2784 | g_free (block_file); |
2785 | 2785 | } |
| 2786 | |
| 2787 | void 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 | } |
diff --git a/edit/edit.h b/edit/edit.h
index f5d5767..42804de 100644
a
|
b
|
void format_paragraph (WEdit *edit, int force); |
245 | 245 | |
246 | 246 | /* either command or char_for_insertion must be passed as -1 */ |
247 | 247 | void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion); |
248 | | |
| 248 | void edit_an_ordinary_key_press (WEdit * edit, const int char_for_insertion); |
| 249 | |
249 | 250 | #define get_sys_error(s) (s) |
250 | 251 | |
251 | 252 | #define edit_error_dialog(h,s) query_dialog (h, s, D_ERROR, 1, _("&Dismiss")) |