@gjsify/gtksource-nativescript 0.57.0 → 0.59.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/README.md CHANGED
@@ -16,7 +16,8 @@ from the text `Layout` in `onDraw`, and `GtkSource.Buffer` / `LanguageManager` /
16
16
  spans, `android.graphics.Paint`/`Typeface` in its `native-api-usage.json` whitelist. Shared
17
17
  widget classes that come with `@gjsify/adwaita-nativescript` add `android.view.View`
18
18
  (`setTooltipText`, API 26; duck-typed, no `TooltipCompat`) to that list.
19
- - The platform half (`native-editor.android.ts`) is not verified on a device yet.
19
+ - The platform half (`native-editor.android.ts`) ran on a device (API 24 and 36) for `extend-selection` and
20
+ `copy-clipboard`. A triple tap selects nothing natively below API 28; see ADR 0094, last amendment.
20
21
 
21
22
  ## Using it from XML
22
23
 
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";var MultiTap=class{timeout;slop;count=0;time=0;x=0;y=0;constructor(e,t){this.timeout=e,this.slop=t}press(e,t,n){let r=Math.abs(t-this.x)<=this.slop&&Math.abs(n-this.y)<=this.slop;return this.count=this.count>0&&this.count<3&&e-this.time<=this.timeout&&r?this.count+1:1,this.time=e,this.x=t,this.y=n,this.count}};export{MultiTap};
@@ -1 +1 @@
1
- import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{GtkSourceView as t}from"../view.js";import{Buffer as n,Language as r,LanguageManager as i,StyleScheme as a,StyleSchemeManager as o,init as s}from"@gjsify/gtksource-core";var c=e({Buffer:()=>n,Language:()=>r,LanguageManager:()=>i,StyleScheme:()=>a,StyleSchemeManager:()=>o,View:()=>t,init:()=>s});export{n as Buffer,r as Language,i as LanguageManager,a as StyleScheme,o as StyleSchemeManager,t as View,c as gtksource_exports,s as init};
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{GtkSourceView as t}from"../view.js";import{Buffer as n,Gutter as r,GutterLines as i,GutterRenderer as a,GutterRendererText as o,Language as s,LanguageManager as c,StyleScheme as l,StyleSchemeManager as u,init as d}from"@gjsify/gtksource-core";var f=e({Buffer:()=>n,Gutter:()=>r,GutterLines:()=>i,GutterRenderer:()=>a,GutterRendererText:()=>o,Language:()=>s,LanguageManager:()=>c,StyleScheme:()=>l,StyleSchemeManager:()=>u,View:()=>t,init:()=>d});export{n as Buffer,r as Gutter,i as GutterLines,a as GutterRenderer,o as GutterRendererText,s as Language,c as LanguageManager,l as StyleScheme,u as StyleSchemeManager,t as View,f as gtksource_exports,d as init};
@@ -1,2 +1,2 @@
1
- import"./_virtual/_rolldown/runtime.js";import{LineStore as e,emphasisedLine as t,gutterWidth as n,visibleLines as r}from"@gjsify/gtksource-core";let i;function gutterEditText(){return i||(i=android.widget.EditText.extend({onDraw(e){let t=this.driver;t?.drawBehind(this,e),this.super.onDraw(e),t?.drawGutter(this,e)},onSelectionChanged(e,t){this.super.onSelectionChanged(e,t),this.driver?.selectionChanged(e,t)}}),i)}var AndroidEditorDriver=class{host=null;view=null;applying=!1;queue=[];keyListener=null;pendingText=``;selection={start:0,end:0};lineCount=1;layout=null;palette=null;runs=new e;spans=new e;fillPaint=null;textPaint=null;bind(e){this.host=e}createNativeView(e){let t=new(gutterEditText())(e);return t.driver=this,t}attach(e){let t=e;this.view=t,t.setInputType(android.text.InputType.TYPE_CLASS_TEXT|android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE|android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS),t.setHorizontallyScrolling(!0),t.setGravity(android.view.Gravity.TOP|android.view.Gravity.START),this.keyListener=t.getKeyListener(),t.addTextChangedListener(new android.text.TextWatcher({beforeTextChanged:()=>{},onTextChanged:(e,t,n,r)=>{this.applying||this.queue.push({start:t,removed:n,inserted:e.subSequence(t,t+r).toString()})},afterTextChanged:()=>this.flushEdits()})),this.applyLayout(),this.applyPalette(),this.applying=!0;try{t.setText(this.pendingText??``)}finally{this.applying=!1}this.pendingText=null,this.repaintAll(),this.applySelection()}detach(){this.view&&(this.pendingText=this.view.getText().toString()),this.view=null,this.spans.clear(),this.queue=[]}setText(e){if(this.removeAllSpans(),this.runs.clear(),!this.view){this.pendingText=e;return}this.applying=!0;try{this.view.setText(e)}finally{this.applying=!1}}replaceRange(e,t,n){let r=this.view;if(!r){let r=this.pendingText??``;this.pendingText=r.slice(0,e)+n+r.slice(t);return}let i=r.getText();this.applying=!0;try{i.replace(e,Math.min(t,i.length()),n)}finally{this.applying=!1}}setSelection(e,t){this.selection={start:e,end:t},this.applySelection()}setLineCount(e){this.lineCount=e,this.view&&this.layout?.showLineNumbers&&this.applyLayout()}setLayout(e){this.layout=e,this.applyLayout()}setPalette(e){this.palette=e,this.applyPalette()}spliceLines(e,t,n){let r=this.view?.getText();for(let i of this.spans.splice(e,t,n))if(r)for(let e of i)r.removeSpan(e);this.runs.splice(e,t,n)}paintLine(e,t,n){this.runs.set(e,n);let r=this.view?.getText();r&&this.applyRuns(r,e,t,n)}clearAll(){this.removeAllSpans(),this.runs.clear()}removeAllSpans(){let e=this.view?.getText(),t=this.spans.clear();if(e)for(let n of t)for(let t of n)e.removeSpan(t)}repaintAll(){let e=this.view?.getText();if(!e)return;let t=e.toString().split(`
2
- `),n=0;t.forEach((t,r)=>{let i=this.runs.get(r);i&&this.applyRuns(e,r,n,i),n+=t.length+1})}applyRuns(e,t,n,r){for(let n of this.spans.get(t)??[])e.removeSpan(n);let i=e.length(),a=android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE,{ForegroundColorSpan:o,BackgroundColorSpan:s,StyleSpan:c,UnderlineSpan:l,StrikethroughSpan:u}=android.text.style,d=android.graphics.Typeface,f=[],put=(t,n,r)=>{e.setSpan(t,n,r,a),f.push(t)};for(let e of r){let t=n+e.start,r=Math.min(n+e.end,i);if(t>=r)continue;let{style:a}=e;a.foreground!==void 0&&put(new o(a.foreground),t,r),a.background!==void 0&&put(new s(a.background),t,r),(a.bold||a.italic)&&put(new c(a.bold&&a.italic?d.BOLD_ITALIC:a.bold?d.BOLD:d.ITALIC),t,r),a.underline&&put(new l,t,r),a.strikethrough&&put(new u,t,r)}this.spans.set(t,f)}density(e){return e.getResources().getDisplayMetrics().density}gutterPixels(e){if(!this.layout?.showLineNumbers)return 0;let t=8*this.density(e);return n(this.lineCount,this.paintFor(e).measureText(`0`),t)}paintFor(e){return this.textPaint??=new android.graphics.Paint(1),this.textPaint.setTextSize(e.getTextSize()),this.textPaint.setTypeface(e.getTypeface()),this.textPaint.setTextAlign(android.graphics.Paint.Align.RIGHT),this.textPaint}applyLayout(){let e=this.view,t=this.layout;if(!e||!t)return;e.setTypeface(t.monospace?android.graphics.Typeface.MONOSPACE:android.graphics.Typeface.DEFAULT);let n=this.density(e);e.setPadding(Math.round(t.leftMargin*n)+this.gutterPixels(e),Math.round(t.topMargin*n),Math.round(t.rightMargin*n),Math.round(t.bottomMargin*n)),e.setKeyListener(t.editable?this.keyListener:null),e.setCursorVisible(t.cursorVisible),e.invalidate()}applyPalette(){let e=this.view,t=this.palette;!e||!t||(e.setBackgroundColor(t.background),e.setTextColor(t.foreground),e.setHighlightColor(t.selectionBackground),e.invalidate())}applySelection(){let e=this.view;if(!e)return;let t=e.getText().length(),n=Math.min(this.selection.start,t);e.getSelectionStart()===n&&e.getSelectionEnd()===Math.min(this.selection.end,t)||e.setSelection(n,Math.min(this.selection.end,t))}flushEdits(){let e=this.view,t=this.host;if(this.applying||!e||!t||this.queue.length===0)return;let n=this.queue;this.queue=[];for(let e of n)t.onNativeEdit(e.start,e.removed,e.inserted);t.onNativeSelection(e.getSelectionStart(),e.getSelectionEnd())}selectionChanged(e,t){this.applying||this.queue.length>0||(this.selection={start:e,end:t},this.host?.onNativeSelection(e,t),this.view?.invalidate())}fill(e,t,n,r,i,a){this.fillPaint??=new android.graphics.Paint(0),this.fillPaint.setColor(t),e.drawRect(n,r,i,a,this.fillPaint)}drawBehind(e,t){let n=this.palette,r=e.getLayout();if(!n||!r||!this.layout?.highlightCurrentLine||n.currentLineBackground===0)return;let i=r.getLineForOffset(e.getSelectionEnd()),a=e.getExtendedPaddingTop();this.fill(t,n.currentLineBackground,e.getScrollX(),a+r.getLineTop(i),e.getScrollX()+e.getWidth(),a+r.getLineBottom(i))}drawGutter(e,i){let a=this.palette,o=e.getLayout();if(!a||!o||!this.layout?.showLineNumbers)return;let s=this.paintFor(e),c=8*this.density(e),l=n(o.getLineCount(),s.measureText(`0`),c),u=e.getScrollX(),d=e.getScrollY(),f=e.getExtendedPaddingTop();this.fill(i,a.lineNumberBackground,u,d,u+l,d+e.getHeight());let p=r(o.getLineCount(),e=>f+o.getLineTop(e),e=>f+o.getLineBottom(e),d,d+e.getHeight());if(!p)return;let m=t(this.layout.highlightCurrentLine,o.getLineForOffset(e.getSelectionEnd()));for(let e=p.first;e<=p.last;e++){let t=e===m;t&&a.currentLineNumberBackground!==0&&this.fill(i,a.currentLineNumberBackground,u,f+o.getLineTop(e),u+l,f+o.getLineBottom(e)),s.setColor(t?a.currentLineNumberForeground:a.lineNumberForeground),i.drawText(String(e+1),u+l-c,f+o.getLineBaseline(e),s)}}};function createEditorDriver(){return new AndroidEditorDriver}export{createEditorDriver};
1
+ import"./_virtual/_rolldown/runtime.js";import{MultiTap as e}from"./multi-tap.js";import{LineStore as t,emphasisedLine as n,gutterWidth as r,visibleLines as i}from"@gjsify/gtksource-core";let a;function gutterEditText(){return a||(a=android.widget.EditText.extend({onDraw(e){let t=this.driver;t?.drawBehind(this,e),this.super.onDraw(e),t?.drawGutter(this,e)},onSelectionChanged(e,t){this.super.onSelectionChanged(e,t),this.driver?.selectionChanged(e,t)},onTouchEvent(e){return this.driver?.touching(this,e)?!0:this.super.onTouchEvent(e)},performLongClick(){return this.driver?.longPressing(this)?!0:this.super.performLongClick()},onTextContextMenuItem(e){let t=this.driver;return e!==16908321||!t?this.super.onTextContextMenuItem(e):t.copyRequested(()=>this.super.onTextContextMenuItem(e))}}),a)}var AndroidEditorDriver=class{host=null;view=null;applying=!1;queue=[];keyListener=null;pendingText=``;selection={start:0,end:0};lineCount=1;layout=null;palette=null;runs=new t;spans=new t;fillPaint=null;textPaint=null;measured=[];appliedGutter=-1;bind(e){this.host=e}platformCopy=null;copyRequested(e){this.platformCopy=e;try{this.host?.onNativeCopy()}finally{this.platformCopy=null}return!0}copySelection(){let e=this.platformCopy;this.platformCopy=null;let t=this.view;if(!e||!t)return;let{start:n,end:r}=this.selection;e(),(t.getSelectionStart()!==n||t.getSelectionEnd()!==r)&&t.setSelection(n,r)}taps=null;pressAt={x:0,y:0};swallowing=!1;touching(t,n){let{ACTION_DOWN:r,ACTION_UP:i,ACTION_CANCEL:a}=android.view.MotionEvent,o=n.getActionMasked();if(o!==r){let e=this.swallowing;return(o===i||o===a)&&(this.swallowing=!1),e}this.swallowing=!1,this.pressAt={x:n.getX(),y:n.getY()},this.taps??=new e(android.view.ViewConfiguration.getDoubleTapTimeout(),android.view.ViewConfiguration.get(t.getContext()).getScaledDoubleTapSlop());let s=this.taps.press(n.getEventTime(),n.getX(),n.getY());return s<2?!1:(this.swallowing=this.extendSelection(t,s===2?0:1),this.swallowing)}longPressing(e){return this.extendSelection(e,0)}extendSelection(e,t){let n=this.host;if(!n||this.applying)return!1;let r=n.onNativeExtendSelection(t,e.getOffsetForPosition(this.pressAt.x,this.pressAt.y));return r?(e.setSelection(r[0],r[1]),!0):!1}createNativeView(e){let t=new(gutterEditText())(e);return t.driver=this,t}attach(e){let t=e;this.view=t,t.setInputType(android.text.InputType.TYPE_CLASS_TEXT|android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE|android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS),t.setHorizontallyScrolling(!0),t.setGravity(android.view.Gravity.TOP|android.view.Gravity.START),this.keyListener=t.getKeyListener(),t.addTextChangedListener(new android.text.TextWatcher({beforeTextChanged:()=>{},onTextChanged:(e,t,n,r)=>{this.applying||this.queue.push({start:t,removed:n,inserted:e.subSequence(t,t+r).toString()})},afterTextChanged:()=>this.flushEdits()})),this.applyLayout(),this.applyPalette(),this.applying=!0;try{t.setText(this.pendingText??``)}finally{this.applying=!1}this.pendingText=null,this.repaintAll(),this.applySelection()}detach(){this.view&&(this.pendingText=this.view.getText().toString()),this.view=null,this.spans.clear(),this.queue=[]}setText(e){if(this.removeAllSpans(),this.runs.clear(),!this.view){this.pendingText=e;return}this.applying=!0;try{this.view.setText(e)}finally{this.applying=!1}}replaceRange(e,t,n){let r=this.view;if(!r){let r=this.pendingText??``;this.pendingText=r.slice(0,e)+n+r.slice(t);return}let i=r.getText();this.applying=!0;try{i.replace(e,Math.min(t,i.length()),n)}finally{this.applying=!1}}setSelection(e,t){this.selection={start:e,end:t},this.applySelection()}setLineCount(e){this.lineCount=e,this.view&&this.layout?.showLineNumbers&&this.applyLayout()}setLayout(e){this.layout=e,this.applyLayout()}setPalette(e){this.palette=e,this.applyPalette()}spliceLines(e,t,n){let r=this.view?.getText();for(let i of this.spans.splice(e,t,n))if(r)for(let e of i)r.removeSpan(e);this.runs.splice(e,t,n)}paintLine(e,t,n){this.runs.set(e,n);let r=this.view?.getText();r&&this.applyRuns(r,e,t,n)}clearAll(){this.removeAllSpans(),this.runs.clear()}removeAllSpans(){let e=this.view?.getText(),t=this.spans.clear();if(e)for(let n of t)for(let t of n)e.removeSpan(t)}repaintAll(){let e=this.view?.getText();if(!e)return;let t=e.toString().split(`
2
+ `),n=0;t.forEach((t,r)=>{let i=this.runs.get(r);i&&this.applyRuns(e,r,n,i),n+=t.length+1})}applyRuns(e,t,n,r){for(let n of this.spans.get(t)??[])e.removeSpan(n);let i=e.length(),a=android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE,{ForegroundColorSpan:o,BackgroundColorSpan:s,StyleSpan:c,UnderlineSpan:l,StrikethroughSpan:u}=android.text.style,d=android.graphics.Typeface,f=[],put=(t,n,r)=>{e.setSpan(t,n,r,a),f.push(t)};for(let e of r){let t=n+e.start,r=Math.min(n+e.end,i);if(t>=r)continue;let{style:a}=e;a.foreground!==void 0&&put(new o(a.foreground),t,r),a.background!==void 0&&put(new s(a.background),t,r),(a.bold||a.italic)&&put(new c(a.bold&&a.italic?d.BOLD_ITALIC:a.bold?d.BOLD:d.ITALIC),t,r),a.underline&&put(new l,t,r),a.strikethrough&&put(new u,t,r)}this.spans.set(t,f)}density(e){return e.getResources().getDisplayMetrics().density}columnPixels(e,t,n){return Math.ceil(Math.max(e.widthRequest*n,t)+(e.marginStart+e.marginEnd)*n)}numbersPixels(e,t){if(!this.layout?.showLineNumbers)return 0;let n=8*this.density(e);return r(t,this.paintFor(e).measureText(`0`),n)}gutterPixels(e,t=this.lineCount){let n=this.density(e),r=this.numbersPixels(e,t);return(this.host?.gutterColumns()??[]).forEach((e,t)=>{r+=this.columnPixels(e,this.measured[t]??0,n)}),r}paintFor(e){return this.textPaint??=new android.graphics.Paint(1),this.textPaint.setTextSize(e.getTextSize()),this.textPaint.setTypeface(e.getTypeface()),this.textPaint.setTextAlign(android.graphics.Paint.Align.RIGHT),this.textPaint}applyLayout(){let e=this.view,t=this.layout;if(!e||!t)return;e.setTypeface(t.monospace?android.graphics.Typeface.MONOSPACE:android.graphics.Typeface.DEFAULT);let n=this.density(e);e.setPadding(Math.round(t.leftMargin*n)+this.gutterPixels(e),Math.round(t.topMargin*n),Math.round(t.rightMargin*n),Math.round(t.bottomMargin*n)),e.setKeyListener(t.editable?this.keyListener:null),e.setCursorVisible(t.cursorVisible),this.appliedGutter=this.gutterPixels(e),e.invalidate()}applyPalette(){let e=this.view,t=this.palette;!e||!t||(e.setBackgroundColor(t.background),e.setTextColor(t.foreground),e.setHighlightColor(t.selectionBackground),e.invalidate())}applySelection(){let e=this.view;if(!e)return;let t=e.getText().length(),n=Math.min(this.selection.start,t);e.getSelectionStart()===n&&e.getSelectionEnd()===Math.min(this.selection.end,t)||e.setSelection(n,Math.min(this.selection.end,t))}flushEdits(){let e=this.view,t=this.host;if(this.applying||!e||!t||this.queue.length===0)return;let n=this.queue;this.queue=[];for(let e of n)t.onNativeEdit(e.start,e.removed,e.inserted);t.onNativeSelection(e.getSelectionStart(),e.getSelectionEnd())}selectionChanged(e,t){this.applying||this.queue.length>0||(this.selection={start:e,end:t},this.host?.onNativeSelection(e,t),this.view?.invalidate())}invalidateGutter(){let e=this.view;e&&(this.gutterPixels(e)===this.appliedGutter?e.invalidate():this.applyLayout())}fill(e,t,n,r,i,a){this.fillPaint??=new android.graphics.Paint(0),this.fillPaint.setColor(t),e.drawRect(n,r,i,a,this.fillPaint)}drawBehind(e,t){let n=this.palette,r=e.getLayout();if(!n||!r||!this.layout?.highlightCurrentLine||n.currentLineBackground===0)return;let i=r.getLineForOffset(e.getSelectionEnd()),a=e.getExtendedPaddingTop();this.fill(t,n.currentLineBackground,e.getScrollX(),a+r.getLineTop(i),e.getScrollX()+e.getWidth(),a+r.getLineBottom(i))}drawGutter(e,t){let r=this.palette,a=e.getLayout(),o=this.host;if(!r||!a||!o)return;let s=this.layout?.showLineNumbers===!0,c=this.density(e),l=e.getScrollY(),u=e.getExtendedPaddingTop(),d=i(a.getLineCount(),e=>u+a.getLineTop(e),e=>u+a.getLineBottom(e),l,l+e.getHeight()),f=d?o.queryGutter(d.first,d.last):o.gutterColumns().map(e=>({...e,cells:[]}));if(!s&&f.length===0)return;let p=this.paintFor(e);f.forEach((e,t)=>{let n=e.cells.reduce((e,t)=>Math.max(e,p.measureText(t.text)),0);this.measured[t]=Math.max(n,this.measured[t]??0)}),this.measured.length=f.length;let m=this.gutterPixels(e,a.getLineCount());m!==this.appliedGutter&&(this.appliedGutter=m,e.post(new java.lang.Runnable({run:()=>this.applyLayout()})));let h=e.getScrollX();if(this.fill(t,r.lineNumberBackground,h,l,h+m,l+e.getHeight()),!d)return;let g=8*c,_=n(this.layout?.highlightCurrentLine===!0,a.getLineForOffset(e.getSelectionEnd())),v=h,drawNumbers=()=>{let n=this.numbersPixels(e,a.getLineCount());p.setTextAlign(android.graphics.Paint.Align.RIGHT);for(let e=d.first;e<=d.last;e++){let i=e===_;i&&r.currentLineNumberBackground!==0&&this.fill(t,r.currentLineNumberBackground,v,u+a.getLineTop(e),v+n,u+a.getLineBottom(e)),p.setColor(i?r.currentLineNumberForeground:r.lineNumberForeground),t.drawText(String(e+1),v+n-g,u+a.getLineBaseline(e),p)}v+=n},y=!s;f.forEach((e,n)=>{!y&&e.position>=0&&(drawNumbers(),y=!0),p.setTextAlign(android.graphics.Paint.Align.LEFT),p.setColor(r.lineNumberForeground),e.cells.forEach((n,r)=>{if(n.text===``)return;let i=u+a.getLineBaseline(d.first+r);t.drawText(n.text,v+e.marginStart*c,i,p)}),v+=this.columnPixels(e,this.measured[n],c)}),y||drawNumbers()}};function createEditorDriver(){return new AndroidEditorDriver}export{createEditorDriver};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";var UnsupportedEditorDriver=class{bind(e){}createNativeView(){throw Error(`Platform not supported: GtkSource.View is implemented for Android only`)}attach(){}detach(){}setText(){}replaceRange(){}setSelection(){}setLineCount(){}setLayout(){}spliceLines(){}paintLine(){}clearAll(){}setPalette(){}};function createEditorDriver(){return new UnsupportedEditorDriver}export{createEditorDriver};
1
+ import"./_virtual/_rolldown/runtime.js";var UnsupportedEditorDriver=class{gutterSides=[3,4];bind(e){}createNativeView(){throw Error(`Platform not supported: GtkSource.View is implemented for Android only`)}attach(){}detach(){}setText(){}replaceRange(){}setSelection(){}setLineCount(){}setLayout(){}invalidateGutter(){}spliceLines(){}paintLine(){}clearAll(){}setPalette(){}};function createEditorDriver(){return new UnsupportedEditorDriver}export{createEditorDriver};
package/lib/esm/view.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{createEditorDriver as e}from"./native-editor.js";import{EditorSession as t,GtkSourceBuffer as n,toBoolean as r,toNumber as i}from"@gjsify/gtksource-core";import{View as a}from"@nativescript/core";import{adwaitaColorScheme as o,onAdwaitaColorSchemeChanged as s,withGtkWidgetLayout as c}from"@gjsify/adwaita-nativescript";import{Adjustment as l}from"@gjsify/adwaita-nativescript/gtk";var GtkSourceView=class extends c(a){static builderSlots=[`buffer`];driver=e();session;unsubscribe=null;vadj=new l;hadj=new l;direction=1;constructor(){super(),this.className=`gtksource-view`,this.session=new t(this.driver,void 0,o())}createNativeView(){return this.driver.createNativeView(this._context)}initNativeView(){super.initNativeView(),this.driver.attach(this.nativeViewProtected),this.unsubscribe=s(()=>this.session.setColorScheme(o())),this.session.setColorScheme(o())}disposeNativeView(){this.unsubscribe?.(),this.unsubscribe=null,this.driver.detach(),super.disposeNativeView()}_addChildFromBuilder(e,t){if(e!==`buffer`||!(t instanceof n))throw Error(`GtkSource.View takes only a \`buffer\` object child, not '${e}'.`);this.buffer=t}get buffer(){return this.session.buffer}set buffer(e){this.session.buffer=e}get autoIndent(){return this.session.autoIndent}set autoIndent(e){this.session.autoIndent=r(e,`GtkSource.View.autoIndent`)}get indentWidth(){return this.session.indentWidth}set indentWidth(e){this.session.indentWidth=i(e,`GtkSource.View.indentWidth`)}get showLineNumbers(){return this.session.showLineNumbers}set showLineNumbers(e){this.session.showLineNumbers=r(e,`GtkSource.View.showLineNumbers`)}get highlightCurrentLine(){return this.session.highlightCurrentLine}set highlightCurrentLine(e){this.session.highlightCurrentLine=r(e,`GtkSource.View.highlightCurrentLine`)}get monospace(){return this.session.monospace}set monospace(e){this.session.monospace=r(e,`GtkSource.View.monospace`)}get editable(){return this.session.editable}set editable(e){this.session.editable=r(e,`GtkSource.View.editable`)}get cursorVisible(){return this.session.cursorVisible}set cursorVisible(e){this.session.cursorVisible=r(e,`GtkSource.View.cursorVisible`)}get cursor_visible(){return this.cursorVisible}set cursor_visible(e){this.cursorVisible=e}get_cursor_visible(){return this.cursorVisible}set_cursor_visible(e){this.cursorVisible=e}get_editable(){return this.editable}set_editable(e){this.editable=e}get highlight_current_line(){return this.highlightCurrentLine}set highlight_current_line(e){this.highlightCurrentLine=e}get show_line_numbers(){return this.showLineNumbers}set show_line_numbers(e){this.showLineNumbers=e}get vadjustment(){return this.vadj}get hadjustment(){return this.hadj}get_vadjustment(){return this.vadj}get_hadjustment(){return this.hadj}set_direction(e){if(![0,1,2].includes(e))throw TypeError(`${e} is not a valid value for enum argument dir`);this.direction=e}get_direction(){return this.direction}get_first_child(){return null}get_next_sibling(){return null}get_parent(){return this.parent??null}get_gutter(e){throw Error(`GtkSource.View.get_gutter is not implemented`)}get leftMargin(){return this.session.leftMargin}set leftMargin(e){this.session.leftMargin=i(e,`GtkSource.View.leftMargin`)}get rightMargin(){return this.session.rightMargin}set rightMargin(e){this.session.rightMargin=i(e,`GtkSource.View.rightMargin`)}get topMargin(){return this.session.topMargin}set topMargin(e){this.session.topMargin=i(e,`GtkSource.View.topMargin`)}get bottomMargin(){return this.session.bottomMargin}set bottomMargin(e){this.session.bottomMargin=i(e,`GtkSource.View.bottomMargin`)}connect(e,t){return this.session.connect(e,t)}disconnect(e){this.session.disconnect(e)}};export{GtkSourceView};
1
+ import"./_virtual/_rolldown/runtime.js";import{createEditorDriver as e}from"./native-editor.js";import{EditorSession as t,GtkSourceBuffer as n,GutterSet as r,STOP_EMISSION as i,toBoolean as a,toNumber as o}from"@gjsify/gtksource-core";import{View as s}from"@nativescript/core";import{adwaitaColorScheme as c,onAdwaitaColorSchemeChanged as l,withGtkWidgetLayout as u}from"@gjsify/adwaita-nativescript";import{Adjustment as d}from"@gjsify/adwaita-nativescript/gtk";var GtkSourceView=class extends u(s){static builderSlots=[`buffer`];driver=e();session;unsubscribe=null;vadj=new d;hadj=new d;direction=1;gutters=new r(this);constructor(){super(),this.className=`gtksource-view`,this.session=new t(this.driver,void 0,c()),this.session.bindGutters(this.gutters)}createNativeView(){return this.driver.createNativeView(this._context)}initNativeView(){super.initNativeView(),this.driver.attach(this.nativeViewProtected),this.unsubscribe=l(()=>this.session.setColorScheme(c())),this.session.setColorScheme(c())}disposeNativeView(){this.unsubscribe?.(),this.unsubscribe=null,this.driver.detach(),super.disposeNativeView()}_addChildFromBuilder(e,t){if(e!==`buffer`||!(t instanceof n))throw Error(`GtkSource.View takes only a \`buffer\` object child, not '${e}'.`);this.buffer=t}get buffer(){return this.session.buffer}set buffer(e){this.session.buffer=e}get autoIndent(){return this.session.autoIndent}set autoIndent(e){this.session.autoIndent=a(e,`GtkSource.View.autoIndent`)}get indentWidth(){return this.session.indentWidth}set indentWidth(e){this.session.indentWidth=o(e,`GtkSource.View.indentWidth`)}get showLineNumbers(){return this.session.showLineNumbers}set showLineNumbers(e){this.session.showLineNumbers=a(e,`GtkSource.View.showLineNumbers`)}get highlightCurrentLine(){return this.session.highlightCurrentLine}set highlightCurrentLine(e){this.session.highlightCurrentLine=a(e,`GtkSource.View.highlightCurrentLine`)}get monospace(){return this.session.monospace}set monospace(e){this.session.monospace=a(e,`GtkSource.View.monospace`)}get editable(){return this.session.editable}set editable(e){this.session.editable=a(e,`GtkSource.View.editable`)}get cursorVisible(){return this.session.cursorVisible}set cursorVisible(e){this.session.cursorVisible=a(e,`GtkSource.View.cursorVisible`)}get cursor_visible(){return this.cursorVisible}set cursor_visible(e){this.cursorVisible=e}get_cursor_visible(){return this.cursorVisible}set_cursor_visible(e){this.cursorVisible=e}get_editable(){return this.editable}set_editable(e){this.editable=e}get highlight_current_line(){return this.highlightCurrentLine}set highlight_current_line(e){this.highlightCurrentLine=e}get show_line_numbers(){return this.showLineNumbers}set show_line_numbers(e){this.showLineNumbers=e}get vadjustment(){return this.vadj}get hadjustment(){return this.hadj}get_vadjustment(){return this.vadj}get_hadjustment(){return this.hadj}set_direction(e){if(![0,1,2].includes(e))throw TypeError(`${e} is not a valid value for enum argument dir`);this.direction=e}get_direction(){return this.direction}get_first_child(){return null}get_next_sibling(){return null}get_parent(){return this.parent??null}get_gutter(e){return this.gutters.get(e)}get leftMargin(){return this.session.leftMargin}set leftMargin(e){this.session.leftMargin=o(e,`GtkSource.View.leftMargin`)}get rightMargin(){return this.session.rightMargin}set rightMargin(e){this.session.rightMargin=o(e,`GtkSource.View.rightMargin`)}get topMargin(){return this.session.topMargin}set topMargin(e){this.session.topMargin=o(e,`GtkSource.View.topMargin`)}get bottomMargin(){return this.session.bottomMargin}set bottomMargin(e){this.session.bottomMargin=o(e,`GtkSource.View.bottomMargin`)}connect(e,t){return this.session.connect(e,((e,...n)=>t(this,...n)))}connect_after(e,t){return this.session.connect_after(e,((e,...n)=>t(this,...n)))}[i](e){this.session[i](e)}disconnect(e){this.session.disconnect(e)}};export{GtkSourceView};
@@ -35,6 +35,8 @@ export interface AndroidEditText {
35
35
  getScrollY(): number;
36
36
  getWidth(): number;
37
37
  getHeight(): number;
38
+ getOffsetForPosition(x: number, y: number): number;
39
+ getContext(): unknown;
38
40
  getSelectionStart(): number;
39
41
  getSelectionEnd(): number;
40
42
  getExtendedPaddingTop(): number;
@@ -60,6 +62,13 @@ export interface AndroidEditText {
60
62
  addTextChangedListener(watcher: unknown): void;
61
63
  removeTextChangedListener(watcher: unknown): void;
62
64
  invalidate(): void;
65
+ post(action: unknown): boolean;
66
+ }
67
+ export interface AndroidMotionEvent {
68
+ getActionMasked(): number;
69
+ getX(): number;
70
+ getY(): number;
71
+ getEventTime(): number;
63
72
  }
64
73
  export interface AndroidNamespace {
65
74
  widget: {
@@ -71,6 +80,7 @@ export interface AndroidNamespace {
71
80
  Paint: (new (flags: number) => AndroidPaint) & {
72
81
  Align: {
73
82
  RIGHT: unknown;
83
+ LEFT: unknown;
74
84
  };
75
85
  };
76
86
  Typeface: {
@@ -104,5 +114,16 @@ export interface AndroidNamespace {
104
114
  TOP: number;
105
115
  START: number;
106
116
  };
117
+ MotionEvent: {
118
+ ACTION_DOWN: number;
119
+ ACTION_UP: number;
120
+ ACTION_CANCEL: number;
121
+ };
122
+ ViewConfiguration: {
123
+ get(context: unknown): {
124
+ getScaledDoubleTapSlop(): number;
125
+ };
126
+ getDoubleTapTimeout(): number;
127
+ };
107
128
  };
108
129
  }
@@ -0,0 +1,11 @@
1
+ export declare class MultiTap {
2
+ private readonly timeout;
3
+ private readonly slop;
4
+ private count;
5
+ private time;
6
+ private x;
7
+ private y;
8
+ constructor(timeout: number, slop: number);
9
+ /** The press at `time` (ms) and `x`/`y` (px): 1 for a fresh press, 2 for a double, 3 for a triple. */
10
+ press(time: number, x: number, y: number): number;
11
+ }
@@ -0,0 +1 @@
1
+ export declare const MultiTapTest: () => Promise<void>;
@@ -2,4 +2,5 @@ export { Buffer } from '@gjsify/gtksource-core';
2
2
  export { LanguageManager, Language } from '@gjsify/gtksource-core';
3
3
  export { StyleSchemeManager, StyleScheme } from '@gjsify/gtksource-core';
4
4
  export { GtkSourceView as View } from '../view.js';
5
+ export { Gutter, GutterLines, GutterRenderer, GutterRendererText } from '@gjsify/gtksource-core';
5
6
  export { init } from '@gjsify/gtksource-core';
@@ -1,7 +1,7 @@
1
1
  import type { EditorDriver } from '@gjsify/gtksource-core';
2
2
  export interface NativeEditorDriver extends EditorDriver {
3
3
  /** Called from `createNativeView()` with the Android `Context`. */
4
- createNativeView(context: unknown): unknown;
4
+ createNativeView(context: unknown): object;
5
5
  /** The view `createNativeView()` returned is live: apply everything remembered so far. */
6
6
  attach(nativeView: unknown): void;
7
7
  detach(): void;
@@ -1,5 +1,6 @@
1
1
  import { View as NsView } from '@nativescript/core';
2
- import { type Buffer } from '@gjsify/gtksource-core';
2
+ import { type Buffer, type Gutter } from '@gjsify/gtksource-core';
3
+ import { STOP_EMISSION } from '@gjsify/gtksource-core';
3
4
  import { Adjustment as GtkAdjustment } from '@gjsify/adwaita-nativescript/gtk';
4
5
  declare const GtkSourceView_base: (abstract new (...args: any[]) => {
5
6
  get halign(): string;
@@ -41,8 +42,9 @@ export declare class GtkSourceView extends GtkSourceView_base {
41
42
  private readonly vadj;
42
43
  private readonly hadj;
43
44
  private direction;
45
+ private readonly gutters;
44
46
  constructor();
45
- createNativeView(): unknown;
47
+ createNativeView(): object;
46
48
  initNativeView(): void;
47
49
  disposeNativeView(): void;
48
50
  _addChildFromBuilder(name: string, child: object): void;
@@ -85,8 +87,8 @@ export declare class GtkSourceView extends GtkSourceView_base {
85
87
  get_first_child(): null;
86
88
  get_next_sibling(): null;
87
89
  get_parent(): unknown;
88
- /** Gutters are slice 6 (ADR 0094). */
89
- get_gutter(_window_type: number): never;
90
+ /** `null` for any side but LEFT and RIGHT, as in GtkSourceView (ADR 0103). */
91
+ get_gutter(window_type: number): Gutter | null;
90
92
  get leftMargin(): number;
91
93
  set leftMargin(value: number | string);
92
94
  get rightMargin(): number;
@@ -95,7 +97,11 @@ export declare class GtkSourceView extends GtkSourceView_base {
95
97
  set topMargin(value: number | string);
96
98
  get bottomMargin(): number;
97
99
  set bottomMargin(value: number | string);
98
- connect(name: string, callback: (self: GtkSourceView, ...args: never[]) => void): number;
100
+ connect(name: string, callback: (self: GtkSourceView, ...args: never[]) => unknown): number;
101
+ /** `g_signal_connect_after`: runs once the plain handlers and the default of the emission have run. */
102
+ connect_after(name: string, callback: (self: GtkSourceView, ...args: never[]) => unknown): number;
103
+ /** `GObject.signal_stop_emission_by_name(view, …)`: the session owns the emissions. */
104
+ [STOP_EMISSION](detailedSignal: string): void;
99
105
  disconnect(id: number): void;
100
106
  }
101
107
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/gtksource-nativescript",
3
- "version": "0.57.0",
3
+ "version": "0.59.0",
4
4
  "description": "GtkSource.View for NativeScript — an Android EditText with incremental syntax highlighting, a line-number gutter and GtkSourceView language/scheme managers, driven by @gjsify/gtksource-core",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -26,7 +26,8 @@
26
26
  ],
27
27
  "scripts": {
28
28
  "clear": "gjsify clear lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.trees.gjs.mjs test.trees.node.mjs",
29
- "check": "gjsify tsc --noEmit",
29
+ "check": "gjsify tsc --noEmit && gjsify run check:consumer",
30
+ "check:consumer": "gjsify tsc -p tsconfig.consumer.json",
30
31
  "build": "gjsify run build:gjsify && gjsify run build:types",
31
32
  "build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
32
33
  "build:types": "gjsify tsc",
@@ -48,8 +49,8 @@
48
49
  "editor"
49
50
  ],
50
51
  "dependencies": {
51
- "@gjsify/adwaita-nativescript": "^0.57.0",
52
- "@gjsify/gtksource-core": "^0.57.0"
52
+ "@gjsify/adwaita-nativescript": "^0.59.0",
53
+ "@gjsify/gtksource-core": "^0.59.0"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "@nativescript/core": "*"
@@ -60,8 +61,8 @@
60
61
  }
61
62
  },
62
63
  "devDependencies": {
63
- "@gjsify/cli": "^0.57.0",
64
- "@gjsify/unit": "^0.57.0",
64
+ "@gjsify/cli": "^0.59.0",
65
+ "@gjsify/unit": "^0.59.0",
65
66
  "@types/node": "^25.9.2",
66
67
  "typescript": "^6.0.3"
67
68
  },