X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWindow.java;h=9f1ae67aeb8eec6151ef79cca8ba861e3a0b8ef4;hb=be9987235887cb73637b91ab6921158ecaef9d95;hp=5bf664d254e515f95d41418ef383ae01559dcdb4;hpb=fe0770f988e64fc0ccafd3d3b086b4a0eb559d3b;p=fanfix.git diff --git a/src/jexer/TEditorWindow.java b/src/jexer/TEditorWindow.java index 5bf664d..9f1ae67 100644 --- a/src/jexer/TEditorWindow.java +++ b/src/jexer/TEditorWindow.java @@ -30,6 +30,8 @@ package jexer; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; +import java.util.ResourceBundle; import java.util.Scanner; import jexer.TApplication; @@ -52,6 +54,11 @@ import static jexer.TKeypress.*; */ public class TEditorWindow extends TScrollableWindow { + /** + * Translated strings. + */ + private static final ResourceBundle i18n = ResourceBundle.getBundle(TEditorWindow.class.getName()); + /** * Hang onto my TEditor so I can resize it with the window. */ @@ -75,11 +82,15 @@ public class TEditorWindow extends TScrollableWindow { setLeftValue(1); setRightValue(editField.getMaximumColumnNumber()); - statusBar = newStatusBar("Editor"); - statusBar.addShortcutKeypress(kbF1, cmHelp, "Help"); - statusBar.addShortcutKeypress(kbF2, cmSave, "Save"); - statusBar.addShortcutKeypress(kbF3, cmOpen, "Open"); - statusBar.addShortcutKeypress(kbF10, cmMenu, "Menu"); + statusBar = newStatusBar(i18n.getString("statusBar")); + statusBar.addShortcutKeypress(kbF1, cmHelp, + i18n.getString("statusBarHelp")); + statusBar.addShortcutKeypress(kbF2, cmSave, + i18n.getString("statusBarSave")); + statusBar.addShortcutKeypress(kbF3, cmOpen, + i18n.getString("statusBarOpen")); + statusBar.addShortcutKeypress(kbF10, cmMenu, + i18n.getString("statusBarMenu")); } /** @@ -140,7 +151,7 @@ public class TEditorWindow extends TScrollableWindow { * @param parent the main application */ public TEditorWindow(final TApplication parent) { - this(parent, "New Text Document"); + this(parent, i18n.getString("newTextDocument")); } /** @@ -228,13 +239,13 @@ public class TEditorWindow extends TScrollableWindow { if (mouseOnEditor(mouse)) { // The editor might have changed, update the scollbars. setBottomValue(editField.getMaximumRowNumber()); - setVerticalValue(editField.getEditingRowNumber()); + setVerticalValue(editField.getVisibleRowNumber()); setRightValue(editField.getMaximumColumnNumber()); setHorizontalValue(editField.getEditingColumnNumber()); } else { if (mouse.isMouseWheelUp() || mouse.isMouseWheelDown()) { // Vertical scrollbar actions - editField.setEditingRowNumber(getVerticalValue()); + editField.setVisibleRowNumber(getVerticalValue()); } } } @@ -251,7 +262,7 @@ public class TEditorWindow extends TScrollableWindow { if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) { // Clicked on vertical scrollbar - editField.setEditingRowNumber(getVerticalValue()); + editField.setVisibleRowNumber(getVerticalValue()); } // TODO: horizontal scrolling @@ -270,13 +281,13 @@ public class TEditorWindow extends TScrollableWindow { if (mouseOnEditor(mouse) && mouse.isMouse1()) { // The editor might have changed, update the scollbars. setBottomValue(editField.getMaximumRowNumber()); - setVerticalValue(editField.getEditingRowNumber()); + setVerticalValue(editField.getVisibleRowNumber()); setRightValue(editField.getMaximumColumnNumber()); setHorizontalValue(editField.getEditingColumnNumber()); } else { if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) { // Clicked/dragged on vertical scrollbar - editField.setEditingRowNumber(getVerticalValue()); + editField.setVisibleRowNumber(getVerticalValue()); } // TODO: horizontal scrolling @@ -296,7 +307,7 @@ public class TEditorWindow extends TScrollableWindow { // The editor might have changed, update the scollbars. setBottomValue(editField.getMaximumRowNumber()); - setVerticalValue(editField.getEditingRowNumber()); + setVerticalValue(editField.getVisibleRowNumber()); setRightValue(editField.getMaximumColumnNumber()); setHorizontalValue(editField.getEditingColumnNumber()); } @@ -340,13 +351,15 @@ public class TEditorWindow extends TScrollableWindow { String contents = readFileData(filename); new TEditorWindow(getApplication(), filename, contents); } catch (IOException e) { - messageBox("Error", "Error reading file: " + - e.getMessage()); + messageBox(i18n.getString("errorDialogTitle"), + MessageFormat.format(i18n. + getString("errorReadingFile"), e.getMessage())); } } } catch (IOException e) { - messageBox("Error", "Error opening file dialog: " + - e.getMessage()); + messageBox(i18n.getString("errorDialogTitle"), + MessageFormat.format(i18n. + getString("errorOpeningFileDialog"), e.getMessage())); } return; } @@ -356,7 +369,9 @@ public class TEditorWindow extends TScrollableWindow { try { editField.saveToFilename(filename); } catch (IOException e) { - messageBox("Error", "Error saving file: " + e.getMessage()); + messageBox(i18n.getString("errorDialogTitle"), + MessageFormat.format(i18n. + getString("errorSavingFile"), e.getMessage())); } } return;