Add 'src/jexer/' from commit 'cf01c92f5809a0732409e280fb0f32f27393618d'
[nikiroo-utils.git] / src / jexer / TEditorWidget.java
index 0f8f7715d8bf30d632c133d721b4e96a579ca4bb..a694533bf6df0ed3ee4d6e694f0d1b507deab7a3 100644 (file)
@@ -277,7 +277,6 @@ public class TEditorWidget extends TWidget {
             && !keypress.getKey().isCtrl()
         ) {
             // Plain old keystroke, process it
-            // TODO: fix document to use ints, not chars
             document.addChar(keypress.getKey().getChar());
             alignCursor();
         } else {
@@ -462,6 +461,29 @@ public class TEditorWidget extends TWidget {
         }
     }
 
+    /**
+     * Set the current visible column number.  1-based.
+     *
+     * @return the visible column number.  Column 1 is the first column.
+     */
+    public int getVisibleColumnNumber() {
+        return leftColumn + 1;
+    }
+
+    /**
+     * Set the current visible column number.  1-based.
+     *
+     * @param column the new visible column number.  Column 1 is the first
+     * column.
+     */
+    public void setVisibleColumnNumber(final int column) {
+        assert (column > 0);
+        if ((column > 0) && (column < document.getLineLengthMax())) {
+            leftColumn = column - 1;
+            alignDocument(true);
+        }
+    }
+
     /**
      * Get the current editing column number.  1-based.
      *