X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWidget.java;h=a694533bf6df0ed3ee4d6e694f0d1b507deab7a3;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=94f1a3be545b2a401f8e32d2920faf3268c5fc1a;hpb=615a0d99fd0aa4437116dd083147f9150d5e6527;p=fanfix.git diff --git a/src/jexer/TEditorWidget.java b/src/jexer/TEditorWidget.java index 94f1a3b..a694533 100644 --- a/src/jexer/TEditorWidget.java +++ b/src/jexer/TEditorWidget.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -207,6 +207,16 @@ public class TEditorWidget extends TWidget { } else if (keypress.equals(kbRight)) { document.right(); alignTopLine(true); + } else if (keypress.equals(kbAltLeft) + || keypress.equals(kbCtrlLeft) + ) { + document.backwardsWord(); + alignTopLine(false); + } else if (keypress.equals(kbAltRight) + || keypress.equals(kbCtrlRight) + ) { + document.forwardsWord(); + alignTopLine(true); } else if (keypress.equals(kbUp)) { document.up(); alignTopLine(false); @@ -247,7 +257,9 @@ public class TEditorWidget extends TWidget { } else if (keypress.equals(kbDel)) { document.del(); alignCursor(); - } else if (keypress.equals(kbBackspace)) { + } else if (keypress.equals(kbBackspace) + || keypress.equals(kbBackspaceDel) + ) { document.backspace(); alignTopLine(false); } else if (keypress.equals(kbTab)) { @@ -449,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. *