@gjsify/gtksource-nativescript 0.58.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,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;measured=[];appliedGutter=-1;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}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 r=8*this.density(e);return n(t,this.paintFor(e).measureText(`0`),r)}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,n){let i=this.palette,a=e.getLayout(),o=this.host;if(!i||!a||!o)return;let s=this.layout?.showLineNumbers===!0,c=this.density(e),l=e.getScrollY(),u=e.getExtendedPaddingTop(),d=r(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(n,i.lineNumberBackground,h,l,h+m,l+e.getHeight()),!d)return;let g=8*c,_=t(this.layout?.highlightCurrentLine===!0,a.getLineForOffset(e.getSelectionEnd())),v=h,drawNumbers=()=>{let t=this.numbersPixels(e,a.getLineCount());p.setTextAlign(android.graphics.Paint.Align.RIGHT);for(let e=d.first;e<=d.last;e++){let r=e===_;r&&i.currentLineNumberBackground!==0&&this.fill(n,i.currentLineNumberBackground,v,u+a.getLineTop(e),v+t,u+a.getLineBottom(e)),p.setColor(r?i.currentLineNumberForeground:i.lineNumberForeground),n.drawText(String(e+1),v+t-g,u+a.getLineBaseline(e),p)}v+=t},y=!s;f.forEach((e,t)=>{!y&&e.position>=0&&(drawNumbers(),y=!0),p.setTextAlign(android.graphics.Paint.Align.LEFT),p.setColor(i.lineNumberForeground),e.cells.forEach((t,r)=>{if(t.text===``)return;let i=u+a.getLineBaseline(d.first+r);n.drawText(t.text,v+e.marginStart*c,i,p)}),v+=this.columnPixels(e,this.measured[t],c)}),y||drawNumbers()}};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(){}invalidateGutter(){}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,GutterSet as r,toBoolean as i,toNumber as a}from"@gjsify/gtksource-core";import{View as o}from"@nativescript/core";import{adwaitaColorScheme as s,onAdwaitaColorSchemeChanged as c,withGtkWidgetLayout as l}from"@gjsify/adwaita-nativescript";import{Adjustment as u}from"@gjsify/adwaita-nativescript/gtk";var GtkSourceView=class extends l(o){static builderSlots=[`buffer`];driver=e();session;unsubscribe=null;vadj=new u;hadj=new u;direction=1;gutters=new r(this);constructor(){super(),this.className=`gtksource-view`,this.session=new t(this.driver,void 0,s()),this.session.bindGutters(this.gutters)}createNativeView(){return this.driver.createNativeView(this._context)}initNativeView(){super.initNativeView(),this.driver.attach(this.nativeViewProtected),this.unsubscribe=c(()=>this.session.setColorScheme(s())),this.session.setColorScheme(s())}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=i(e,`GtkSource.View.autoIndent`)}get indentWidth(){return this.session.indentWidth}set indentWidth(e){this.session.indentWidth=a(e,`GtkSource.View.indentWidth`)}get showLineNumbers(){return this.session.showLineNumbers}set showLineNumbers(e){this.session.showLineNumbers=i(e,`GtkSource.View.showLineNumbers`)}get highlightCurrentLine(){return this.session.highlightCurrentLine}set highlightCurrentLine(e){this.session.highlightCurrentLine=i(e,`GtkSource.View.highlightCurrentLine`)}get monospace(){return this.session.monospace}set monospace(e){this.session.monospace=i(e,`GtkSource.View.monospace`)}get editable(){return this.session.editable}set editable(e){this.session.editable=i(e,`GtkSource.View.editable`)}get cursorVisible(){return this.session.cursorVisible}set cursorVisible(e){this.session.cursorVisible=i(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=a(e,`GtkSource.View.leftMargin`)}get rightMargin(){return this.session.rightMargin}set rightMargin(e){this.session.rightMargin=a(e,`GtkSource.View.rightMargin`)}get topMargin(){return this.session.topMargin}set topMargin(e){this.session.topMargin=a(e,`GtkSource.View.topMargin`)}get bottomMargin(){return this.session.bottomMargin}set bottomMargin(e){this.session.bottomMargin=a(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;
@@ -62,6 +64,12 @@ export interface AndroidEditText {
62
64
  invalidate(): void;
63
65
  post(action: unknown): boolean;
64
66
  }
67
+ export interface AndroidMotionEvent {
68
+ getActionMasked(): number;
69
+ getX(): number;
70
+ getY(): number;
71
+ getEventTime(): number;
72
+ }
65
73
  export interface AndroidNamespace {
66
74
  widget: {
67
75
  EditText: new (context: unknown) => AndroidEditText & {
@@ -106,5 +114,16 @@ export interface AndroidNamespace {
106
114
  TOP: number;
107
115
  START: number;
108
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
+ };
109
128
  };
110
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>;
@@ -1,5 +1,6 @@
1
1
  import { View as NsView } from '@nativescript/core';
2
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;
@@ -96,7 +97,11 @@ export declare class GtkSourceView extends GtkSourceView_base {
96
97
  set topMargin(value: number | string);
97
98
  get bottomMargin(): number;
98
99
  set bottomMargin(value: number | string);
99
- 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;
100
105
  disconnect(id: number): void;
101
106
  }
102
107
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/gtksource-nativescript",
3
- "version": "0.58.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",
@@ -49,8 +49,8 @@
49
49
  "editor"
50
50
  ],
51
51
  "dependencies": {
52
- "@gjsify/adwaita-nativescript": "^0.58.0",
53
- "@gjsify/gtksource-core": "^0.58.0"
52
+ "@gjsify/adwaita-nativescript": "^0.59.0",
53
+ "@gjsify/gtksource-core": "^0.59.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@nativescript/core": "*"
@@ -61,8 +61,8 @@
61
61
  }
62
62
  },
63
63
  "devDependencies": {
64
- "@gjsify/cli": "^0.58.0",
65
- "@gjsify/unit": "^0.58.0",
64
+ "@gjsify/cli": "^0.59.0",
65
+ "@gjsify/unit": "^0.59.0",
66
66
  "@types/node": "^25.9.2",
67
67
  "typescript": "^6.0.3"
68
68
  },