Revision: 1603 http://svn.sourceforge.net/geany/?rev=1603&view=rev Author: eht16 Date: 2007-06-09 05:11:18 -0700 (Sat, 09 Jun 2007)
Log Message: ----------- Apply from Fran?\195?\167ois Cami and Guillaume Duviol to improve replacement of tabs by spaces (thank you).
Modified Paths: -------------- trunk/ChangeLog trunk/THANKS trunk/src/document.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-08 19:09:35 UTC (rev 1602) +++ trunk/ChangeLog 2007-06-09 12:11:18 UTC (rev 1603) @@ -1,3 +1,10 @@ +2007-06-09 Enrico Tröger enrico.troeger@uvena.de + + * THANKS, src/document.c: + Apply from François Cami and Guillaume Duviol to improve replacement + of tabs by spaces (thank you). + + 2007-06-08 Frank Lanitz frank@frank.uvena.de
* THANKS, src/about.c: Added new translator Adrovane Marques Kade.
Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-06-08 19:09:35 UTC (rev 1602) +++ trunk/THANKS 2007-06-09 12:11:18 UTC (rev 1603) @@ -30,6 +30,7 @@ Guillaume Hoffmann <guillaumh(at)gmail(dot)com> - Haskell filetype patch Peter Strand <peter(at)zarquon(dot)se> - Haskell CTags patch Dave Moore <wrex006(at)gmail(dot)com> - code navigation patch +François Cami <francois.cami(at)free(dot)fr>, Guillaume Duviol - tab replacement patch
Translators: ----------------------------------
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2007-06-08 19:09:35 UTC (rev 1602) +++ trunk/src/document.c 2007-06-09 12:11:18 UTC (rev 1603) @@ -1800,7 +1800,7 @@
void document_replace_tabs(gint idx) { - gint search_pos; + gint search_pos, pos_in_line, current_tab_true_length; gint tab_len; gchar *tab_str; struct TextToFind ttf; @@ -1811,22 +1811,25 @@ tab_len = sci_get_tab_width(doc_list[idx].sci); ttf.chrg.cpMin = 0; ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci); - ttf.lpstrText = (gchar*)"\t"; - tab_str = g_strnfill(tab_len, ' '); + ttf.lpstrText = (gchar*) "\t";
while (TRUE) { search_pos = sci_find_text(doc_list[idx].sci, SCFIND_MATCHCASE, &ttf); - if (search_pos == -1) break; + if (search_pos == -1) + break;
+ pos_in_line = sci_get_col_from_position(doc_list[idx].sci,search_pos); + current_tab_true_length = tab_len - (pos_in_line % tab_len); + tab_str = g_strnfill(current_tab_true_length, ' '); sci_target_start(doc_list[idx].sci, search_pos); sci_target_end(doc_list[idx].sci, search_pos + 1); sci_target_replace(doc_list[idx].sci, tab_str, FALSE); - ttf.chrg.cpMin = search_pos + tab_len - 1; // next search starts after replacement - ttf.chrg.cpMax += tab_len - 1; // update end of range now text has changed + ttf.chrg.cpMin = search_pos + current_tab_true_length - 1; // next search starts after replacement + ttf.chrg.cpMax += current_tab_true_length - 1; // update end of range now text has changed + g_free(tab_str); } sci_end_undo_action(doc_list[idx].sci); - g_free(tab_str); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.