Skip to content

Commit 272b8ee

Browse files
committed
feat(statusbar): possibility to set the starting index
1 parent ca64a80 commit 272b8ee

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/main/java/de/f0rce/ace/AceEditor.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import de.f0rce.ace.enums.AceExportType;
2020
import de.f0rce.ace.enums.AceMarkerColor;
2121
import de.f0rce.ace.enums.AceMode;
22+
import de.f0rce.ace.enums.AceStatusbarIndexing;
2223
import de.f0rce.ace.enums.AceTheme;
2324
import de.f0rce.ace.events.AceBlurChanged;
2425
import de.f0rce.ace.events.AceChanged;
@@ -36,7 +37,6 @@
3637
/** @author David "F0rce" Dodlek */
3738
@SuppressWarnings("serial")
3839
@Tag("lit-ace")
39-
@NpmPackage(value = "@f0rce/lit-ace", version = "1.9.0")
4040
@NpmPackage(value = "@f0rce/lit-ace", version = "1.10.0")
4141
@JsModule("./@f0rce/lit-ace/lit-ace.js")
4242
public class AceEditor extends Component implements HasSize, HasStyle, Focusable<AceEditor> {
@@ -67,6 +67,7 @@ public class AceEditor extends Component implements HasSize, HasStyle, Focusable
6767
private List<String> customAutocompletion = new ArrayList<String>();
6868
private List<AceMarker> markers = new ArrayList<AceMarker>();
6969
private boolean statusbarEnabled = true;
70+
private AceStatusbarIndexing statusbarIndexing = AceStatusbarIndexing.ONE_BASED;
7071

7172
// Some internal checking
7273
private boolean hasBeenDetached = false;
@@ -108,6 +109,10 @@ protected void onAttach(AttachEvent attachEvent) {
108109
this.setSelection(this.selection);
109110
}
110111
}
112+
if (this.statusbarIndexing != AceStatusbarIndexing.ONE_BASED) {
113+
this.setStatusbarIndexing(this.statusbarIndexing);
114+
}
115+
this.hasBeenDetached = false;
111116
}
112117
}
113118

@@ -1470,4 +1475,24 @@ public Registration addValueChangeListener(ComponentEventListener<AceValueChange
14701475
public void print(AceExportType exportType) {
14711476
this.getElement().callJsFunction("print", exportType.getType());
14721477
}
1478+
1479+
/**
1480+
* Change the indexing (starting index) of the statusbar.
1481+
*
1482+
* @param statusbarIndexing {@link AceStatusbarIndexing}
1483+
*/
1484+
public void setStatusbarIndexing(AceStatusbarIndexing statusbarIndexing) {
1485+
this.getElement().callJsFunction("setStatusbarIndexing", statusbarIndexing.getIntValue());
1486+
this.statusbarIndexing = statusbarIndexing;
1487+
}
1488+
1489+
/**
1490+
* Returns the current set indexing of the statusbar (defaults to {@link
1491+
* AceStatusbarIndexing#ONE_BASED}).
1492+
*
1493+
* @return {@link AceStatusbarIndexing}
1494+
*/
1495+
public AceStatusbarIndexing getStatusbarIndexing() {
1496+
return this.statusbarIndexing;
1497+
}
14731498
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.f0rce.ace.enums;
2+
3+
public enum AceStatusbarIndexing {
4+
/** StatusBar */
5+
ZERO_BASED(0),
6+
ONE_BASED(1);
7+
8+
private int index;
9+
10+
private AceStatusbarIndexing(int index) {
11+
this.index = index;
12+
}
13+
14+
public int getIntValue() {
15+
return this.index;
16+
}
17+
}

0 commit comments

Comments
 (0)