lexgui 0.1.46 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/codeeditor.js +12 -10
- package/build/lexgui.css +345 -119
- package/build/lexgui.js +8313 -7874
- package/build/lexgui.min.css +1 -0
- package/build/lexgui.min.js +1 -0
- package/build/lexgui.module.js +624 -204
- package/build/lexgui.module.min.js +1 -0
- package/changelog.md +24 -2
- package/demo.js +89 -873
- package/package.json +1 -1
|
@@ -237,6 +237,8 @@ class CodeEditor {
|
|
|
237
237
|
static CODE_MIN_FONT_SIZE = 9;
|
|
238
238
|
static CODE_MAX_FONT_SIZE = 22;
|
|
239
239
|
|
|
240
|
+
static LINE_GUTTER_WIDTH = 48;
|
|
241
|
+
|
|
240
242
|
/**
|
|
241
243
|
* @param {*} options
|
|
242
244
|
* name:
|
|
@@ -380,7 +382,7 @@ class CodeEditor {
|
|
|
380
382
|
this.selections = {};
|
|
381
383
|
|
|
382
384
|
// Css char synchronization
|
|
383
|
-
this.xPadding = "
|
|
385
|
+
this.xPadding = CodeEditor.LINE_GUTTER_WIDTH + "px";
|
|
384
386
|
|
|
385
387
|
// Add main cursor
|
|
386
388
|
this._addCursor( 0, 0, true, true );
|
|
@@ -390,7 +392,6 @@ class CodeEditor {
|
|
|
390
392
|
this.codeScroller = this.tabs.area.root;
|
|
391
393
|
this.firstLineInViewport = 0;
|
|
392
394
|
this.lineScrollMargin = new LX.vec2( 20, 20 ); // [ mUp, mDown ]
|
|
393
|
-
window.scroller = this.codeScroller;
|
|
394
395
|
|
|
395
396
|
let lastScrollTopValue = -1;
|
|
396
397
|
|
|
@@ -2456,10 +2457,11 @@ class CodeEditor {
|
|
|
2456
2457
|
|
|
2457
2458
|
// We are out of the viewport and max length is different? Resize scrollbars...
|
|
2458
2459
|
const maxLineLength = this.getMaxLineLength();
|
|
2459
|
-
const numViewportChars = Math.floor( this.codeScroller.clientWidth / this.charWidth );
|
|
2460
|
+
const numViewportChars = Math.floor( ( this.codeScroller.clientWidth - CodeEditor.LINE_GUTTER_WIDTH ) / this.charWidth );
|
|
2460
2461
|
if( maxLineLength >= numViewportChars && maxLineLength != this._lastMaxLineLength )
|
|
2461
2462
|
{
|
|
2462
2463
|
this.resize( maxLineLength );
|
|
2464
|
+
this.setScrollLeft( 1e4 );
|
|
2463
2465
|
}
|
|
2464
2466
|
|
|
2465
2467
|
// Manage autocomplete
|
|
@@ -3478,7 +3480,7 @@ class CodeEditor {
|
|
|
3478
3480
|
// Add horizontal scroll
|
|
3479
3481
|
|
|
3480
3482
|
doAsync(() => {
|
|
3481
|
-
var viewportSizeX = ( this.codeScroller.clientWidth + this.getScrollLeft() ) -
|
|
3483
|
+
var viewportSizeX = ( this.codeScroller.clientWidth + this.getScrollLeft() ) - CodeEditor.LINE_GUTTER_WIDTH; // Gutter offset
|
|
3482
3484
|
if( (cursor.position * this.charWidth) >= viewportSizeX )
|
|
3483
3485
|
this.setScrollLeft( this.getScrollLeft() + this.charWidth );
|
|
3484
3486
|
});
|
|
@@ -3735,7 +3737,7 @@ class CodeEditor {
|
|
|
3735
3737
|
|
|
3736
3738
|
// Update max viewport
|
|
3737
3739
|
const maxLineLength = pMaxLength ?? this.getMaxLineLength();
|
|
3738
|
-
const scrollWidth = maxLineLength * this.charWidth;
|
|
3740
|
+
const scrollWidth = maxLineLength * this.charWidth + CodeEditor.LINE_GUTTER_WIDTH;
|
|
3739
3741
|
const scrollHeight = this.code.lines.length * this.lineHeight;
|
|
3740
3742
|
|
|
3741
3743
|
this._lastMaxLineLength = maxLineLength;
|
|
@@ -3750,9 +3752,9 @@ class CodeEditor {
|
|
|
3750
3752
|
|
|
3751
3753
|
resizeScrollBars() {
|
|
3752
3754
|
|
|
3753
|
-
const totalLinesInViewport = ((this.codeScroller.offsetHeight
|
|
3755
|
+
const totalLinesInViewport = ((this.codeScroller.offsetHeight) / this.lineHeight)|0;
|
|
3754
3756
|
|
|
3755
|
-
if( totalLinesInViewport
|
|
3757
|
+
if( totalLinesInViewport >= this.code.lines.length )
|
|
3756
3758
|
{
|
|
3757
3759
|
this.codeScroller.classList.remove( 'with-vscrollbar' );
|
|
3758
3760
|
this.vScrollbar.root.classList.add( 'scrollbar-unused' );
|
|
@@ -3765,10 +3767,10 @@ class CodeEditor {
|
|
|
3765
3767
|
this.vScrollbar.thumb.style.height = (this.vScrollbar.thumb.size * 100.0) + "%";
|
|
3766
3768
|
}
|
|
3767
3769
|
|
|
3768
|
-
const numViewportChars = Math.floor( this.codeScroller.clientWidth / this.charWidth );
|
|
3770
|
+
const numViewportChars = Math.floor( ( this.codeScroller.clientWidth - CodeEditor.LINE_GUTTER_WIDTH ) / this.charWidth );
|
|
3769
3771
|
const maxLineLength = this._lastMaxLineLength;
|
|
3770
3772
|
|
|
3771
|
-
if( numViewportChars
|
|
3773
|
+
if( numViewportChars >= maxLineLength )
|
|
3772
3774
|
{
|
|
3773
3775
|
this.codeScroller.classList.remove( 'with-hscrollbar' );
|
|
3774
3776
|
this.hScrollbar.root.classList.add( 'scrollbar-unused' );
|
|
@@ -4055,7 +4057,7 @@ class CodeEditor {
|
|
|
4055
4057
|
// Show box
|
|
4056
4058
|
this.autocomplete.classList.toggle('show', true);
|
|
4057
4059
|
this.autocomplete.classList.toggle('no-scrollbar', !(this.autocomplete.scrollHeight > this.autocomplete.offsetHeight));
|
|
4058
|
-
this.autocomplete.style.left = (cursor._left +
|
|
4060
|
+
this.autocomplete.style.left = (cursor._left + CodeEditor.LINE_GUTTER_WIDTH - this.getScrollLeft()) + "px";
|
|
4059
4061
|
this.autocomplete.style.top = (cursor._top + 28 + this.lineHeight - this.getScrollTop()) + "px";
|
|
4060
4062
|
|
|
4061
4063
|
this.isAutoCompleteActive = true;
|