Skip to content

Commit

Permalink
feat(statusbar): possibility to set the starting index
Browse files Browse the repository at this point in the history
  • Loading branch information
F0rce committed Jul 20, 2022
1 parent 94fc7a6 commit 3164fa1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/java/de/f0rce/ace/AceEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import de.f0rce.ace.enums.AceExportType;
import de.f0rce.ace.enums.AceMarkerColor;
import de.f0rce.ace.enums.AceMode;
import de.f0rce.ace.enums.AceStatusbarIndexing;
import de.f0rce.ace.enums.AceTheme;
import de.f0rce.ace.events.AceBlurChanged;
import de.f0rce.ace.events.AceChanged;
Expand All @@ -36,7 +37,6 @@
/** @author David "F0rce" Dodlek */
@SuppressWarnings("serial")
@Tag("lit-ace")
@NpmPackage(value = "@f0rce/lit-ace", version = "1.9.0")
@NpmPackage(value = "@f0rce/lit-ace", version = "1.10.0")
@JsModule("./@f0rce/lit-ace/lit-ace.js")
public class AceEditor extends Component implements HasSize, HasStyle, Focusable<AceEditor> {
Expand Down Expand Up @@ -67,6 +67,7 @@ public class AceEditor extends Component implements HasSize, HasStyle, Focusable
private List<String> customAutocompletion = new ArrayList<String>();
private List<AceMarker> markers = new ArrayList<AceMarker>();
private boolean statusbarEnabled = true;
private AceStatusbarIndexing statusbarIndexing = AceStatusbarIndexing.ONE_BASED;

// Some internal checking
private boolean hasBeenDetached = false;
Expand Down Expand Up @@ -108,6 +109,10 @@ protected void onAttach(AttachEvent attachEvent) {
this.setSelection(this.selection);
}
}
if (this.statusbarIndexing != AceStatusbarIndexing.ONE_BASED) {
this.setStatusbarIndexing(this.statusbarIndexing);
}
this.hasBeenDetached = false;
}
}

Expand Down Expand Up @@ -1470,4 +1475,24 @@ public Registration addValueChangeListener(ComponentEventListener<AceValueChange
public void print(AceExportType exportType) {
this.getElement().callJsFunction("print", exportType.getType());
}

/**
* Change the indexing (starting index) of the statusbar.
*
* @param statusbarIndexing {@link AceStatusbarIndexing}
*/
public void setStatusbarIndexing(AceStatusbarIndexing statusbarIndexing) {
this.getElement().callJsFunction("setStatusbarIndexing", statusbarIndexing.getIntValue());
this.statusbarIndexing = statusbarIndexing;
}

/**
* Returns the current set indexing of the statusbar (defaults to {@link
* AceStatusbarIndexing#ONE_BASED}).
*
* @return {@link AceStatusbarIndexing}
*/
public AceStatusbarIndexing getStatusbarIndexing() {
return this.statusbarIndexing;
}
}
17 changes: 17 additions & 0 deletions src/main/java/de/f0rce/ace/enums/AceStatusbarIndexing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.f0rce.ace.enums;

public enum AceStatusbarIndexing {
/** StatusBar */
ZERO_BASED(0),
ONE_BASED(1);

private int index;

private AceStatusbarIndexing(int index) {
this.index = index;
}

public int getIntValue() {
return this.index;
}
}

0 comments on commit 3164fa1

Please sign in to comment.