@gtkx/react 0.15.0 → 0.17.1
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 +1 -0
- package/dist/animation/css-builder.d.ts +3 -0
- package/dist/animation/css-builder.js +53 -0
- package/dist/animation/types.d.ts +120 -0
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/fiber-root.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1672 -1483
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +26 -11
- package/dist/jsx.d.ts +136 -166
- package/dist/jsx.js +58 -69
- package/dist/node.d.ts +4 -1
- package/dist/node.js +14 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/virtual-container.d.ts +21 -0
- package/dist/nodes/abstract/virtual-container.js +68 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +55 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +22 -12
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation.js +252 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +17 -43
- package/dist/nodes/color-dialog-button.d.ts +1 -0
- package/dist/nodes/color-dialog-button.js +70 -0
- package/dist/nodes/column-view-column.d.ts +3 -3
- package/dist/nodes/column-view-column.js +1 -1
- package/dist/nodes/column-view.js +36 -39
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.js +24 -7
- package/dist/nodes/event-controller.d.ts +22 -0
- package/dist/nodes/event-controller.js +96 -0
- package/dist/nodes/expander-row-child.d.ts +0 -14
- package/dist/nodes/expander-row-child.js +22 -12
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.js +90 -0
- package/dist/nodes/grid-child.js +43 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +18 -12
- package/dist/nodes/index.js +18 -12
- package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
- package/dist/nodes/internal/base-item-renderer.js +88 -0
- package/dist/nodes/internal/child-attachment.d.ts +26 -0
- package/dist/nodes/internal/child-attachment.js +48 -0
- package/dist/nodes/internal/deferred-action.d.ts +9 -0
- package/dist/nodes/internal/deferred-action.js +22 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
- package/dist/nodes/internal/list-item-renderer.js +51 -77
- package/dist/nodes/internal/list-store.d.ts +5 -6
- package/dist/nodes/internal/list-store.js +29 -38
- package/dist/nodes/internal/predicates.d.ts +25 -2
- package/dist/nodes/internal/predicates.js +53 -41
- package/dist/nodes/internal/selection-model.d.ts +30 -0
- package/dist/nodes/internal/selection-model.js +87 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -5
- package/dist/nodes/internal/signal-store.js +31 -31
- package/dist/nodes/internal/simple-list-store.js +6 -9
- package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
- package/dist/nodes/internal/text-buffer-controller.js +287 -0
- package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
- package/dist/nodes/internal/text-tag-styles.js +52 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +15 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
- package/dist/nodes/internal/tree-store.d.ts +8 -11
- package/dist/nodes/internal/tree-store.js +70 -72
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +19 -54
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +17 -12
- package/dist/nodes/menu.d.ts +3 -3
- package/dist/nodes/menu.js +3 -3
- package/dist/nodes/models/list.d.ts +11 -13
- package/dist/nodes/models/list.js +16 -73
- package/dist/nodes/models/menu.d.ts +8 -7
- package/dist/nodes/models/menu.js +43 -50
- package/dist/nodes/models/tree-list.d.ts +6 -12
- package/dist/nodes/models/tree-list.js +30 -93
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.js +27 -32
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +3 -3
- package/dist/nodes/notebook-page-tab.js +11 -14
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +45 -25
- package/dist/nodes/notebook.js +2 -2
- package/dist/nodes/overlay-child.js +90 -30
- package/dist/nodes/pack-child.d.ts +0 -13
- package/dist/nodes/pack-child.js +22 -12
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -45
- package/dist/nodes/scrolled-window.js +7 -6
- package/dist/nodes/search-bar.d.ts +1 -0
- package/dist/nodes/search-bar.js +40 -0
- package/dist/nodes/shortcut-controller.d.ts +1 -37
- package/dist/nodes/shortcut-controller.js +8 -47
- package/dist/nodes/shortcut.d.ts +5 -4
- package/dist/nodes/shortcut.js +11 -5
- package/dist/nodes/simple-list-view.js +2 -3
- package/dist/nodes/slot.d.ts +6 -9
- package/dist/nodes/slot.js +27 -42
- package/dist/nodes/source-view.js +80 -29
- package/dist/nodes/stack-page.js +20 -22
- package/dist/nodes/stack.js +19 -5
- package/dist/nodes/text-anchor.d.ts +41 -0
- package/dist/nodes/text-anchor.js +59 -0
- package/dist/nodes/text-content.d.ts +10 -0
- package/dist/nodes/text-content.js +1 -0
- package/dist/nodes/text-paintable.d.ts +17 -0
- package/dist/nodes/text-paintable.js +34 -0
- package/dist/nodes/text-segment.d.ts +15 -0
- package/dist/nodes/text-segment.js +29 -0
- package/dist/nodes/text-tag.d.ts +136 -0
- package/dist/nodes/text-tag.js +202 -0
- package/dist/nodes/text-view.d.ts +30 -0
- package/dist/nodes/text-view.js +49 -21
- package/dist/nodes/toggle-group.js +24 -32
- package/dist/nodes/toggle.d.ts +1 -15
- package/dist/nodes/toggle.js +40 -32
- package/dist/nodes/toolbar-child.js +22 -31
- package/dist/nodes/tree-list-item.d.ts +7 -5
- package/dist/nodes/tree-list-item.js +24 -36
- package/dist/nodes/tree-list-view.js +9 -7
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/web-view.d.ts +1 -0
- package/dist/nodes/web-view.js +29 -0
- package/dist/nodes/widget.d.ts +2 -16
- package/dist/nodes/widget.js +105 -294
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +29 -15
- package/dist/registry.d.ts +1 -1
- package/dist/render.js +9 -7
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -136
- package/package.json +4 -4
- package/dist/nodes/action-row.js +0 -46
- package/dist/nodes/adjustment.d.ts +0 -48
- package/dist/nodes/adjustment.js +0 -70
- package/dist/nodes/calendar-mark.d.ts +0 -15
- package/dist/nodes/calendar-mark.js +0 -29
- package/dist/nodes/expander-row.js +0 -55
- package/dist/nodes/internal/constants.d.ts +0 -1
- package/dist/nodes/internal/constants.js +0 -24
- package/dist/nodes/level-bar-offset.d.ts +0 -13
- package/dist/nodes/level-bar-offset.js +0 -35
- package/dist/nodes/pack.js +0 -46
- package/dist/nodes/scale-mark.d.ts +0 -17
- package/dist/nodes/scale-mark.js +0 -38
- package/dist/nodes/source-buffer.d.ts +0 -73
- package/dist/nodes/source-buffer.js +0 -149
- package/dist/nodes/text-buffer.d.ts +0 -43
- package/dist/nodes/text-buffer.js +0 -81
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
- /package/dist/{nodes/action-row.d.ts → animation/types.js} +0 -0
- /package/dist/nodes/{expander-row.d.ts → alert-dialog-response.d.ts} +0 -0
- /package/dist/nodes/{pack.d.ts → animation.d.ts} +0 -0
package/dist/nodes/scale-mark.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
export class ScaleMarkNode extends VirtualNode {
|
|
5
|
-
static priority = 1;
|
|
6
|
-
scale;
|
|
7
|
-
onRebuild;
|
|
8
|
-
static matches(type) {
|
|
9
|
-
return type === "ScaleMark";
|
|
10
|
-
}
|
|
11
|
-
setScale(scale, onRebuild) {
|
|
12
|
-
this.scale = scale;
|
|
13
|
-
this.onRebuild = onRebuild;
|
|
14
|
-
}
|
|
15
|
-
addMark() {
|
|
16
|
-
if (!this.scale)
|
|
17
|
-
return;
|
|
18
|
-
const { value, position, label } = this.props;
|
|
19
|
-
this.scale.addMark(value, position ?? Gtk.PositionType.BOTTOM, label);
|
|
20
|
-
}
|
|
21
|
-
updateProps(oldProps, newProps) {
|
|
22
|
-
super.updateProps(oldProps, newProps);
|
|
23
|
-
if (oldProps && this.scale) {
|
|
24
|
-
const changed = oldProps.value !== newProps.value ||
|
|
25
|
-
oldProps.position !== newProps.position ||
|
|
26
|
-
oldProps.label !== newProps.label;
|
|
27
|
-
if (changed) {
|
|
28
|
-
this.onRebuild?.();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
unmount() {
|
|
33
|
-
this.scale = undefined;
|
|
34
|
-
this.onRebuild = undefined;
|
|
35
|
-
super.unmount();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
registerNodeClass(ScaleMarkNode);
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import * as GtkSource from "@gtkx/ffi/gtksource";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
/**
|
|
5
|
-
* Props for the SourceBuffer virtual element.
|
|
6
|
-
*
|
|
7
|
-
* Used to declaratively configure the text buffer for a GtkSourceView with syntax highlighting,
|
|
8
|
-
* bracket matching, and other source code editing features.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <GtkSourceView>
|
|
13
|
-
* <x.SourceBuffer
|
|
14
|
-
* text={sourceCode}
|
|
15
|
-
* language="typescript"
|
|
16
|
-
* styleScheme="Adwaita-dark"
|
|
17
|
-
* highlightSyntax
|
|
18
|
-
* highlightMatchingBrackets
|
|
19
|
-
* onTextChanged={(text) => console.log("Code:", text)}
|
|
20
|
-
* />
|
|
21
|
-
* </GtkSourceView>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export type SourceBufferProps = {
|
|
25
|
-
/** Text content */
|
|
26
|
-
text?: string;
|
|
27
|
-
/** Whether to enable undo/redo */
|
|
28
|
-
enableUndo?: boolean;
|
|
29
|
-
/** Callback when the text content changes */
|
|
30
|
-
onTextChanged?: (text: string) => void;
|
|
31
|
-
/** Callback when can-undo state changes */
|
|
32
|
-
onCanUndoChanged?: (canUndo: boolean) => void;
|
|
33
|
-
/** Callback when can-redo state changes */
|
|
34
|
-
onCanRedoChanged?: (canRedo: boolean) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Language for syntax highlighting.
|
|
37
|
-
* Can be a language ID string (e.g., "typescript", "python", "rust") or a GtkSource.Language object.
|
|
38
|
-
*/
|
|
39
|
-
language?: string | GtkSource.Language;
|
|
40
|
-
/**
|
|
41
|
-
* Style scheme for syntax highlighting colors.
|
|
42
|
-
* Can be a scheme ID string (e.g., "Adwaita-dark", "classic") or a GtkSource.StyleScheme object.
|
|
43
|
-
*/
|
|
44
|
-
styleScheme?: string | GtkSource.StyleScheme;
|
|
45
|
-
/** Whether to enable syntax highlighting. Defaults to true when language is set. */
|
|
46
|
-
highlightSyntax?: boolean;
|
|
47
|
-
/** Whether to highlight matching brackets when cursor is on a bracket. Defaults to true. */
|
|
48
|
-
highlightMatchingBrackets?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Whether the buffer has an implicit trailing newline.
|
|
51
|
-
* When true (default), trailing newlines are handled automatically during file load/save.
|
|
52
|
-
*/
|
|
53
|
-
implicitTrailingNewline?: boolean;
|
|
54
|
-
/** Callback when the cursor position changes */
|
|
55
|
-
onCursorMoved?: () => void;
|
|
56
|
-
/** Callback when syntax highlighting is updated for a region */
|
|
57
|
-
onHighlightUpdated?: (start: Gtk.TextIter, end: Gtk.TextIter) => void;
|
|
58
|
-
};
|
|
59
|
-
export declare class SourceBufferNode extends VirtualNode<SourceBufferProps> {
|
|
60
|
-
static priority: number;
|
|
61
|
-
private sourceView?;
|
|
62
|
-
private buffer?;
|
|
63
|
-
static matches(type: string): boolean;
|
|
64
|
-
setSourceView(sourceView: GtkSource.View): void;
|
|
65
|
-
private resolveLanguage;
|
|
66
|
-
private resolveStyleScheme;
|
|
67
|
-
private setupBuffer;
|
|
68
|
-
private applySourceProps;
|
|
69
|
-
private getBufferText;
|
|
70
|
-
private updateSignalHandlers;
|
|
71
|
-
updateProps(oldProps: SourceBufferProps | null, newProps: SourceBufferProps): void;
|
|
72
|
-
unmount(): void;
|
|
73
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { batch } from "@gtkx/ffi";
|
|
2
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import * as GtkSource from "@gtkx/ffi/gtksource";
|
|
4
|
-
import { registerNodeClass } from "../registry.js";
|
|
5
|
-
import { signalStore } from "./internal/signal-store.js";
|
|
6
|
-
import { VirtualNode } from "./virtual.js";
|
|
7
|
-
export class SourceBufferNode extends VirtualNode {
|
|
8
|
-
static priority = 1;
|
|
9
|
-
sourceView;
|
|
10
|
-
buffer;
|
|
11
|
-
static matches(type) {
|
|
12
|
-
return type === "SourceBuffer";
|
|
13
|
-
}
|
|
14
|
-
setSourceView(sourceView) {
|
|
15
|
-
this.sourceView = sourceView;
|
|
16
|
-
this.setupBuffer();
|
|
17
|
-
}
|
|
18
|
-
resolveLanguage(language) {
|
|
19
|
-
if (typeof language === "string") {
|
|
20
|
-
const langManager = GtkSource.LanguageManager.getDefault();
|
|
21
|
-
return langManager.getLanguage(language);
|
|
22
|
-
}
|
|
23
|
-
return language;
|
|
24
|
-
}
|
|
25
|
-
resolveStyleScheme(scheme) {
|
|
26
|
-
if (typeof scheme === "string") {
|
|
27
|
-
const schemeManager = GtkSource.StyleSchemeManager.getDefault();
|
|
28
|
-
return schemeManager.getScheme(scheme);
|
|
29
|
-
}
|
|
30
|
-
return scheme;
|
|
31
|
-
}
|
|
32
|
-
setupBuffer() {
|
|
33
|
-
if (!this.sourceView)
|
|
34
|
-
return;
|
|
35
|
-
this.buffer = new GtkSource.Buffer();
|
|
36
|
-
this.sourceView.setBuffer(this.buffer);
|
|
37
|
-
if (this.props.enableUndo !== undefined) {
|
|
38
|
-
this.buffer.setEnableUndo(this.props.enableUndo);
|
|
39
|
-
}
|
|
40
|
-
if (this.props.text !== undefined) {
|
|
41
|
-
this.buffer.setText(this.props.text, -1);
|
|
42
|
-
}
|
|
43
|
-
this.applySourceProps();
|
|
44
|
-
this.updateSignalHandlers();
|
|
45
|
-
}
|
|
46
|
-
applySourceProps() {
|
|
47
|
-
if (!this.buffer)
|
|
48
|
-
return;
|
|
49
|
-
if (this.props.language !== undefined) {
|
|
50
|
-
const language = this.resolveLanguage(this.props.language);
|
|
51
|
-
this.buffer.setLanguage(language);
|
|
52
|
-
}
|
|
53
|
-
if (this.props.styleScheme !== undefined) {
|
|
54
|
-
const scheme = this.resolveStyleScheme(this.props.styleScheme);
|
|
55
|
-
this.buffer.setStyleScheme(scheme);
|
|
56
|
-
}
|
|
57
|
-
const highlightSyntax = this.props.highlightSyntax ?? this.props.language !== undefined;
|
|
58
|
-
this.buffer.setHighlightSyntax(highlightSyntax);
|
|
59
|
-
const highlightMatchingBrackets = this.props.highlightMatchingBrackets ?? true;
|
|
60
|
-
this.buffer.setHighlightMatchingBrackets(highlightMatchingBrackets);
|
|
61
|
-
if (this.props.implicitTrailingNewline !== undefined) {
|
|
62
|
-
this.buffer.setImplicitTrailingNewline(this.props.implicitTrailingNewline);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
getBufferText() {
|
|
66
|
-
const buffer = this.buffer;
|
|
67
|
-
if (!buffer)
|
|
68
|
-
return "";
|
|
69
|
-
const startIter = new Gtk.TextIter();
|
|
70
|
-
const endIter = new Gtk.TextIter();
|
|
71
|
-
batch(() => {
|
|
72
|
-
buffer.getStartIter(startIter);
|
|
73
|
-
buffer.getEndIter(endIter);
|
|
74
|
-
});
|
|
75
|
-
return buffer.getText(startIter, endIter, true);
|
|
76
|
-
}
|
|
77
|
-
updateSignalHandlers() {
|
|
78
|
-
if (!this.buffer)
|
|
79
|
-
return;
|
|
80
|
-
const buffer = this.buffer;
|
|
81
|
-
const { onTextChanged, onCanUndoChanged, onCanRedoChanged, onCursorMoved, onHighlightUpdated } = this.props;
|
|
82
|
-
signalStore.set(this, buffer, "changed", onTextChanged ? () => onTextChanged(this.getBufferText()) : null);
|
|
83
|
-
signalStore.set(this, buffer, "notify::can-undo", onCanUndoChanged ? () => onCanUndoChanged(buffer.getCanUndo()) : null);
|
|
84
|
-
signalStore.set(this, buffer, "notify::can-redo", onCanRedoChanged ? () => onCanRedoChanged(buffer.getCanRedo()) : null);
|
|
85
|
-
signalStore.set(this, buffer, "cursor-moved", onCursorMoved ?? null);
|
|
86
|
-
signalStore.set(this, buffer, "highlight-updated", onHighlightUpdated
|
|
87
|
-
? (_buffer, start, end) => onHighlightUpdated(start, end)
|
|
88
|
-
: null);
|
|
89
|
-
}
|
|
90
|
-
updateProps(oldProps, newProps) {
|
|
91
|
-
super.updateProps(oldProps, newProps);
|
|
92
|
-
if (!this.buffer)
|
|
93
|
-
return;
|
|
94
|
-
if (!oldProps || oldProps.enableUndo !== newProps.enableUndo) {
|
|
95
|
-
if (newProps.enableUndo !== undefined) {
|
|
96
|
-
this.buffer.setEnableUndo(newProps.enableUndo);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (!oldProps || oldProps.text !== newProps.text) {
|
|
100
|
-
if (newProps.text !== undefined) {
|
|
101
|
-
const currentText = this.getBufferText();
|
|
102
|
-
if (currentText !== newProps.text) {
|
|
103
|
-
this.buffer.setText(newProps.text, -1);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (!oldProps || oldProps.language !== newProps.language) {
|
|
108
|
-
if (newProps.language !== undefined) {
|
|
109
|
-
const language = this.resolveLanguage(newProps.language);
|
|
110
|
-
this.buffer.setLanguage(language);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!oldProps || oldProps.styleScheme !== newProps.styleScheme) {
|
|
114
|
-
if (newProps.styleScheme !== undefined) {
|
|
115
|
-
const scheme = this.resolveStyleScheme(newProps.styleScheme);
|
|
116
|
-
this.buffer.setStyleScheme(scheme);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!oldProps ||
|
|
120
|
-
oldProps.highlightSyntax !== newProps.highlightSyntax ||
|
|
121
|
-
oldProps.language !== newProps.language) {
|
|
122
|
-
const highlightSyntax = newProps.highlightSyntax ?? newProps.language !== undefined;
|
|
123
|
-
this.buffer.setHighlightSyntax(highlightSyntax);
|
|
124
|
-
}
|
|
125
|
-
if (!oldProps || oldProps.highlightMatchingBrackets !== newProps.highlightMatchingBrackets) {
|
|
126
|
-
const highlightMatchingBrackets = newProps.highlightMatchingBrackets ?? true;
|
|
127
|
-
this.buffer.setHighlightMatchingBrackets(highlightMatchingBrackets);
|
|
128
|
-
}
|
|
129
|
-
if (!oldProps || oldProps.implicitTrailingNewline !== newProps.implicitTrailingNewline) {
|
|
130
|
-
if (newProps.implicitTrailingNewline !== undefined) {
|
|
131
|
-
this.buffer.setImplicitTrailingNewline(newProps.implicitTrailingNewline);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (!oldProps ||
|
|
135
|
-
oldProps.onTextChanged !== newProps.onTextChanged ||
|
|
136
|
-
oldProps.onCanUndoChanged !== newProps.onCanUndoChanged ||
|
|
137
|
-
oldProps.onCanRedoChanged !== newProps.onCanRedoChanged ||
|
|
138
|
-
oldProps.onCursorMoved !== newProps.onCursorMoved ||
|
|
139
|
-
oldProps.onHighlightUpdated !== newProps.onHighlightUpdated) {
|
|
140
|
-
this.updateSignalHandlers();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
unmount() {
|
|
144
|
-
this.buffer = undefined;
|
|
145
|
-
this.sourceView = undefined;
|
|
146
|
-
super.unmount();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
registerNodeClass(SourceBufferNode);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualNode } from "./virtual.js";
|
|
3
|
-
/**
|
|
4
|
-
* Props for the TextBuffer virtual element.
|
|
5
|
-
*
|
|
6
|
-
* Used to declaratively configure the text buffer for a GtkTextView.
|
|
7
|
-
* For GtkSourceView with syntax highlighting, use {@link SourceBufferProps} instead.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* <GtkTextView>
|
|
12
|
-
* <x.TextBuffer
|
|
13
|
-
* text="Hello, World!"
|
|
14
|
-
* enableUndo
|
|
15
|
-
* onTextChanged={(text) => console.log("Text:", text)}
|
|
16
|
-
* />
|
|
17
|
-
* </GtkTextView>
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export type TextBufferProps = {
|
|
21
|
-
/** Text content */
|
|
22
|
-
text?: string;
|
|
23
|
-
/** Whether to enable undo/redo */
|
|
24
|
-
enableUndo?: boolean;
|
|
25
|
-
/** Callback when the text content changes */
|
|
26
|
-
onTextChanged?: (text: string) => void;
|
|
27
|
-
/** Callback when can-undo state changes */
|
|
28
|
-
onCanUndoChanged?: (canUndo: boolean) => void;
|
|
29
|
-
/** Callback when can-redo state changes */
|
|
30
|
-
onCanRedoChanged?: (canRedo: boolean) => void;
|
|
31
|
-
};
|
|
32
|
-
export declare class TextBufferNode extends VirtualNode<TextBufferProps> {
|
|
33
|
-
static priority: number;
|
|
34
|
-
private textView?;
|
|
35
|
-
private buffer?;
|
|
36
|
-
static matches(type: string): boolean;
|
|
37
|
-
setTextView(textView: Gtk.TextView): void;
|
|
38
|
-
private setupBuffer;
|
|
39
|
-
private getBufferText;
|
|
40
|
-
private updateSignalHandlers;
|
|
41
|
-
updateProps(oldProps: TextBufferProps | null, newProps: TextBufferProps): void;
|
|
42
|
-
unmount(): void;
|
|
43
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { batch } from "@gtkx/ffi";
|
|
2
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import { registerNodeClass } from "../registry.js";
|
|
4
|
-
import { signalStore } from "./internal/signal-store.js";
|
|
5
|
-
import { VirtualNode } from "./virtual.js";
|
|
6
|
-
export class TextBufferNode extends VirtualNode {
|
|
7
|
-
static priority = 1;
|
|
8
|
-
textView;
|
|
9
|
-
buffer;
|
|
10
|
-
static matches(type) {
|
|
11
|
-
return type === "TextBuffer";
|
|
12
|
-
}
|
|
13
|
-
setTextView(textView) {
|
|
14
|
-
this.textView = textView;
|
|
15
|
-
this.setupBuffer();
|
|
16
|
-
}
|
|
17
|
-
setupBuffer() {
|
|
18
|
-
if (!this.textView)
|
|
19
|
-
return;
|
|
20
|
-
this.buffer = new Gtk.TextBuffer();
|
|
21
|
-
this.textView.setBuffer(this.buffer);
|
|
22
|
-
if (this.props.enableUndo !== undefined) {
|
|
23
|
-
this.buffer.setEnableUndo(this.props.enableUndo);
|
|
24
|
-
}
|
|
25
|
-
if (this.props.text !== undefined) {
|
|
26
|
-
this.buffer.setText(this.props.text, -1);
|
|
27
|
-
}
|
|
28
|
-
this.updateSignalHandlers();
|
|
29
|
-
}
|
|
30
|
-
getBufferText() {
|
|
31
|
-
const buffer = this.buffer;
|
|
32
|
-
if (!buffer)
|
|
33
|
-
return "";
|
|
34
|
-
const startIter = new Gtk.TextIter();
|
|
35
|
-
const endIter = new Gtk.TextIter();
|
|
36
|
-
batch(() => {
|
|
37
|
-
buffer.getStartIter(startIter);
|
|
38
|
-
buffer.getEndIter(endIter);
|
|
39
|
-
});
|
|
40
|
-
return buffer.getText(startIter, endIter, true);
|
|
41
|
-
}
|
|
42
|
-
updateSignalHandlers() {
|
|
43
|
-
if (!this.buffer)
|
|
44
|
-
return;
|
|
45
|
-
const buffer = this.buffer;
|
|
46
|
-
const { onTextChanged, onCanUndoChanged, onCanRedoChanged } = this.props;
|
|
47
|
-
signalStore.set(this, buffer, "changed", onTextChanged ? () => onTextChanged(this.getBufferText()) : null);
|
|
48
|
-
signalStore.set(this, buffer, "notify::can-undo", onCanUndoChanged ? () => onCanUndoChanged(buffer.getCanUndo()) : null);
|
|
49
|
-
signalStore.set(this, buffer, "notify::can-redo", onCanRedoChanged ? () => onCanRedoChanged(buffer.getCanRedo()) : null);
|
|
50
|
-
}
|
|
51
|
-
updateProps(oldProps, newProps) {
|
|
52
|
-
super.updateProps(oldProps, newProps);
|
|
53
|
-
if (!this.buffer)
|
|
54
|
-
return;
|
|
55
|
-
if (!oldProps || oldProps.enableUndo !== newProps.enableUndo) {
|
|
56
|
-
if (newProps.enableUndo !== undefined) {
|
|
57
|
-
this.buffer.setEnableUndo(newProps.enableUndo);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (!oldProps || oldProps.text !== newProps.text) {
|
|
61
|
-
if (newProps.text !== undefined) {
|
|
62
|
-
const currentText = this.getBufferText();
|
|
63
|
-
if (currentText !== newProps.text) {
|
|
64
|
-
this.buffer.setText(newProps.text, -1);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (!oldProps ||
|
|
69
|
-
oldProps.onTextChanged !== newProps.onTextChanged ||
|
|
70
|
-
oldProps.onCanUndoChanged !== newProps.onCanUndoChanged ||
|
|
71
|
-
oldProps.onCanRedoChanged !== newProps.onCanRedoChanged) {
|
|
72
|
-
this.updateSignalHandlers();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
unmount() {
|
|
76
|
-
this.buffer = undefined;
|
|
77
|
-
this.textView = undefined;
|
|
78
|
-
super.unmount();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
registerNodeClass(TextBufferNode);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Node } from "../node.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
type ChildParentWidget = Gtk.Widget & {
|
|
5
|
-
remove(child: Gtk.Widget): void;
|
|
6
|
-
};
|
|
7
|
-
export declare abstract class VirtualChildNode<P extends ChildParentWidget = ChildParentWidget> extends VirtualNode {
|
|
8
|
-
protected parent?: P;
|
|
9
|
-
protected children: Gtk.Widget[];
|
|
10
|
-
setParent(newParent?: P): void;
|
|
11
|
-
protected abstract getPositionLabel(): string;
|
|
12
|
-
protected abstract attachChild(parent: P, widget: Gtk.Widget): void;
|
|
13
|
-
unmount(): void;
|
|
14
|
-
appendChild(child: Node): void;
|
|
15
|
-
insertBefore(child: Node): void;
|
|
16
|
-
removeChild(child: Node): void;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
import { WidgetNode } from "./widget.js";
|
|
5
|
-
export class VirtualChildNode extends VirtualNode {
|
|
6
|
-
parent;
|
|
7
|
-
children = [];
|
|
8
|
-
setParent(newParent) {
|
|
9
|
-
this.parent = newParent;
|
|
10
|
-
}
|
|
11
|
-
unmount() {
|
|
12
|
-
const parent = this.parent;
|
|
13
|
-
const childrenToRemove = [...this.children];
|
|
14
|
-
if (parent && childrenToRemove.length > 0) {
|
|
15
|
-
scheduleAfterCommit(() => {
|
|
16
|
-
for (const widget of childrenToRemove) {
|
|
17
|
-
const currentParent = widget.getParent();
|
|
18
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
19
|
-
parent.remove(widget);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}, CommitPriority.HIGH);
|
|
23
|
-
}
|
|
24
|
-
this.children = [];
|
|
25
|
-
this.parent = undefined;
|
|
26
|
-
super.unmount();
|
|
27
|
-
}
|
|
28
|
-
appendChild(child) {
|
|
29
|
-
if (!(child instanceof WidgetNode)) {
|
|
30
|
-
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
31
|
-
}
|
|
32
|
-
const widget = child.container;
|
|
33
|
-
this.children.push(widget);
|
|
34
|
-
scheduleAfterCommit(() => {
|
|
35
|
-
if (this.parent) {
|
|
36
|
-
this.attachChild(this.parent, widget);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
insertBefore(child) {
|
|
41
|
-
this.appendChild(child);
|
|
42
|
-
}
|
|
43
|
-
removeChild(child) {
|
|
44
|
-
if (!(child instanceof WidgetNode)) {
|
|
45
|
-
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
46
|
-
}
|
|
47
|
-
const widget = child.container;
|
|
48
|
-
const parent = this.parent;
|
|
49
|
-
const index = this.children.indexOf(widget);
|
|
50
|
-
if (index !== -1) {
|
|
51
|
-
this.children.splice(index, 1);
|
|
52
|
-
}
|
|
53
|
-
scheduleAfterCommit(() => {
|
|
54
|
-
if (parent) {
|
|
55
|
-
const currentParent = widget.getParent();
|
|
56
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
57
|
-
parent.remove(widget);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, CommitPriority.HIGH);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|