From a54e9188df69cd3dda84f1e1c7933f8c948eb755 Mon Sep 17 00:00:00 2001 From: Bernard Jungen Date: Thu, 14 May 2009 21:01:55 +0200 Subject: [PATCH] Fix the 'x lines selected' message (v3) Number of lines was one too much in the case the selection end was at the start of a line Added separate message for the one-line case + French translation Fixed the indent/unindent code that was operating on one extra line too --- EditWindow.py | 37 ++++++++++++++++--------- Messages/fr.po | 86 +++++++++++++++++++++++++++++++++------------------------- 2 files changed, 73 insertions(+), 50 deletions(-) diff --git a/EditWindow.py b/EditWindow.py index bade2d2..0fdeb1f 100644 --- a/EditWindow.py +++ b/EditWindow.py @@ -345,23 +345,28 @@ class EditWindow(rox.Window, XDSLoader, Saveable): ##self.spell.set_language ("en_US") def update_current_line(*unused): - cursor = self.buffer.get_iter_at_mark(self.insert_mark) - bound = self.buffer.get_iter_at_mark(self.selection_bound_mark) - if cursor.compare(bound) == 0: + start, end = self.get_selection_range() + if start.compare(end) == 0: n_lines = self.buffer.get_line_count() - self.status_label.set_text(_('Line %s of %d') % (cursor.get_line() + 1, n_lines)) + self.status_label.set_text(_('Line %s of %d') % (start.get_line() + 1, n_lines)) else: - n_lines = abs(cursor.get_line() - bound.get_line()) + 1 - if n_lines == 1: - n_chars = abs(cursor.get_line_offset() - bound.get_line_offset()) + n_lines = end.get_line() - start.get_line() + if n_lines == 0: + n_chars = end.get_line_offset() - start.get_line_offset() if n_chars == 1: - bytes = to_utf8(self.buffer.get_text(cursor, bound, False))[0] + bytes = to_utf8(self.buffer.get_text(start, end, False))[0] self.status_label.set_text(_('One character selected (%s)') % ' '.join(map(lambda x: '0x%2x' % ord(x), bytes))) else: self.status_label.set_text(_('%d characters selected') % n_chars) else: - self.status_label.set_text(_('%d lines selected') % n_lines) + # Count an additional partial line only if not empty + if end.get_line_offset() != 0: + n_lines = n_lines + 1 + if n_lines == 1: + self.status_label.set_text(_('One line selected')) + else: + self.status_label.set_text(_('%d lines selected') % n_lines) self.buffer.connect('mark-set', update_current_line) self.buffer.connect('changed', update_current_line) @@ -451,11 +456,14 @@ class EditWindow(rox.Window, XDSLoader, Saveable): def indent_block(self): try: - (start, end) = self.buffer.get_selection_bounds() + start, end = self.buffer.get_selection_bounds() + start, end = self.get_selection_range() start_line = start.get_line() end_line = end.get_line() + if end.get_line_offset() != 0: + end_line = end_line + 1; self.buffer.begin_user_action() - for i in range(start_line, end_line+1): + for i in range(start_line, end_line): iter = self.buffer.get_iter_at_line(i) self.buffer.insert(iter, '\t') self.buffer.end_user_action() @@ -465,11 +473,14 @@ class EditWindow(rox.Window, XDSLoader, Saveable): def unindent_block(self): try: - (start, end) = self.buffer.get_selection_bounds() + start, end = self.buffer.get_selection_bounds() + start, end = self.get_selection_range() start_line = start.get_line() end_line = end.get_line() + if end.get_line_offset() != 0: + end_line = end_line + 1; self.buffer.begin_user_action() - for i in range(start_line, end_line+1): + for i in range(start_line, end_line): iter = self.buffer.get_iter_at_line(i) if iter.get_char() == '\t': next_char = iter.copy() diff --git a/Messages/fr.po b/Messages/fr.po index 7a549b0..4cfdc78 100644 --- a/Messages/fr.po +++ b/Messages/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Edit 2.1\n" -"POT-Creation-Date: 2009-04-25 18:36+CEST\n" +"POT-Creation-Date: 2009-05-09 16:58+CEST\n" "PO-Revision-Date: 2004-01-28 12:00+0100\n" "Last-Translator: Bernard Jungen \n" "MIME-Version: 1.0\n" @@ -134,52 +134,55 @@ msgstr "Enregistrer sous" msgid "Up" msgstr "Ouvrir le dossier père" -#: EditWindow.py:352 +#: EditWindow.py:351 msgid "Line %s of %d" msgstr "Ligne %s sur %d" -#: EditWindow.py:359 +#: EditWindow.py:358 msgid "One character selected (%s)" msgstr "Un caractère sélectionné (%s)" -#: EditWindow.py:362 +#: EditWindow.py:361 msgid "%d characters selected" msgstr "%d caractères sélectionnés" -#: EditWindow.py:364 +#: EditWindow.py:367 +msgid "One line selected" +msgstr "Une ligne sélectionnée" + +#: EditWindow.py:369 msgid "%d lines selected" msgstr "%d lignes sélectionnées" -#: EditWindow.py:537 +#: EditWindow.py:546 msgid "Untitled" msgstr "SansNom" -#: EditWindow.py:569 +#: EditWindow.py:578 msgid "Encoding:" msgstr "Encodage : " -#: EditWindow.py:575 +#: EditWindow.py:584 msgid "Ignore errors" msgstr "Ignorer les erreurs" -#: EditWindow.py:601 +#: EditWindow.py:610 msgid "Unknown encoding '%s'" msgstr "Encodage de caractères '%s' inconnu" -#: EditWindow.py:625 +#: EditWindow.py:634 msgid "" "Data is not valid %s. Please select the file's encoding. Turn on 'ignore " "errors' to try and load it anyway." msgstr "" -"Ce fichier contient du texte non %s. " -"Choisissez un encodage pour ce fichier. " +"Ce fichier contient du texte non %s. Choisissez un encodage pour ce fichier. " "Cochez 'Ignorer les erreurs' pour essayer de l'ouvrir quand même." -#: EditWindow.py:666 +#: EditWindow.py:675 msgid "File is not saved to disk yet" msgstr "Le fichier n'a pas encore été enregistré" -#: EditWindow.py:691 +#: EditWindow.py:700 msgid "" "This file has never been saved; nothing to compare it to!\n" "Note: you can drop a file onto the toolbar button to see the changes from " @@ -189,11 +192,11 @@ msgstr "" "Note : vous pouvez glisser un fichier sur le bouton de la barre d'outils " "pour afficher les différences." -#: EditWindow.py:740 +#: EditWindow.py:749 msgid "TextFile" msgstr "FichierTexte" -#: EditWindow.py:899 +#: EditWindow.py:908 msgid "Minibuffer help" msgstr "Aide du Minibuffer" @@ -203,7 +206,8 @@ msgstr "Différences sur %s" #: diff.py:128 msgid "There is no difference between this version and the saved one." -msgstr "Il n'y a aucune différence entre cette version et la dernière enregistrée." +msgstr "" +"Il n'y a aucune différence entre cette version et la dernière enregistrée." #: goto.py:10 msgid "Goto line:" @@ -231,7 +235,8 @@ msgstr "N'importe quelle lettre minuscule" #: search.py:8 msgid "Any character listed (- must be first)" -msgstr "Un des caractères spécifiés entre crochets (\"-\" doit être le premier)" +msgstr "" +"Un des caractères spécifiés entre crochets (\"-\" doit être le premier)" #: search.py:9 msgid "A only at the start of a line" @@ -299,7 +304,8 @@ msgstr "Autres" #: search.py:24 msgid "See the Python regular expression documentation for more" -msgstr "Voir la documentation sur les expressions régulières Python pour plus d'info" +msgstr "" +"Voir la documentation sur les expressions régulières Python pour plus d'info" #: search.py:26 msgid "Examples:" @@ -362,10 +368,11 @@ msgid "" "Type a string to search for. The display will scroll to show the next match " "as you type. Use the Up and Down cursor keys to move to the next or previous " "match. Press Escape or Return to finish." -msgstr "Tapez une chaîne de caractères à rechercher. Pendant que vous tapez, " -"l'affichage se déplacera pour montrer la prochaine chaîne trouvée. " -"Utilisez les touches de curseur Haut et Bas pour voir le résultat suivant ou précédent. " -"Tapez Échap ou Entrée pour terminer." +msgstr "" +"Tapez une chaîne de caractères à rechercher. Pendant que vous tapez, " +"l'affichage se déplacera pour montrer la prochaine chaîne trouvée. Utilisez " +"les touches de curseur Haut et Bas pour voir le résultat suivant ou " +"précédent. Tapez Échap ou Entrée pour terminer." #: search.py:89 msgid " Find: " @@ -447,8 +454,9 @@ msgstr "Découper les longues lignes de texte" msgid "" "Control whether lines wider than the window are wrapped to multiple display " "lines." -msgstr "Décide si les lignes plus larges que la fenêtre sont affichées " -"sur plusieurs lignes" +msgstr "" +"Décide si les lignes plus larges que la fenêtre sont affichées sur plusieurs " +"lignes" #: tips:13 msgid "Toolbar" @@ -460,7 +468,8 @@ msgstr "Montrer la barre d'outils" #: tips:15 tips:16 tips:17 msgid "Display a toolbar along the top of each window with common tools." -msgstr "Afficher une barre avec les outils habituels sur le haut de chaque fenêtre." +msgstr "" +"Afficher une barre avec les outils habituels sur le haut de chaque fenêtre." #: tips:18 msgid "Spacing" @@ -523,8 +532,8 @@ msgid "" "You need the gtksourceview Python module (pysourceview\n" "or gnome-python-extras) to use these" msgstr "" -"Vous avez besoin du module Python gtksourceview " -"(pysourceview ou gnome-python-extras) pour les utiliser" +"Vous avez besoin du module Python gtksourceview (pysourceview ou gnome-" +"python-extras) pour les utiliser" #: tips:36 msgid "Show Print Margin" @@ -548,8 +557,9 @@ msgstr "Touches Début/Fin intelligentes" #: tips:41 msgid "Move to the first/last actual character on the line, ignoring spaces." -msgstr "Les touches Début/Fin servent à aller au premier/dernier " -"caractère réel sur la ligne, en ignorant les espaces." +msgstr "" +"Les touches Début/Fin servent à aller au premier/dernier caractère réel sur " +"la ligne, en ignorant les espaces." #: tips:42 msgid "Show Line Numbers" @@ -565,8 +575,9 @@ msgstr "Montrer les signets" #: tips:45 msgid "Add a column in the left margin showing which lines are bookmarked." -msgstr "Ajouter une colonne dans la marge gauche pour montrer quelles " -"lignes ont un signet." +msgstr "" +"Ajouter une colonne dans la marge gauche pour montrer quelles lignes ont un " +"signet." #: tips:46 msgid "Use spaces instead of Tabs" @@ -576,8 +587,9 @@ msgstr "Utiliser des espaces à la place des tabulations" msgid "" "Pressing the Tab key inserts multiple spaces, instead of a single Tab " "character." -msgstr "Enfoncer la touche de tabulation insère de multiples espaces " -" au lieu d'un simple caractère de tabulation." +msgstr "" +"Enfoncer la touche de tabulation insère de multiples espaces au lieu d'un " +"simple caractère de tabulation." #: tips:48 msgid "Tab width" @@ -587,9 +599,9 @@ msgstr "Largeur de tabulation" msgid "" "Show one tab as this number of spaces or, when 'Use spaces instead of Tabs' " "is on, insert this many spaces." -msgstr "Une tabulation correspond à ce nombre d'espaces ou, si " -"'Utiliser des espaces à la place des tabulations' est coché, " -"insérer ce nombre d'espaces." +msgstr "" +"Une tabulation correspond à ce nombre d'espaces ou, si 'Utiliser des espaces " +"à la place des tabulations' est coché, insérer ce nombre d'espaces." #: tips:54 msgid "Changes" -- 2.11.4.GIT