@gtkx/react 0.1.44 → 0.1.45
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.
|
@@ -331,6 +331,8 @@ ${widgetPropsContent}
|
|
|
331
331
|
}
|
|
332
332
|
if (isTextViewWidget(widget.name)) {
|
|
333
333
|
lines.push("");
|
|
334
|
+
lines.push(`\t/** The contents of the text buffer. */`);
|
|
335
|
+
lines.push(`\ttext?: string;`);
|
|
334
336
|
lines.push(`\t/** Called when the text buffer content changes */`);
|
|
335
337
|
lines.push(`\tonChanged?: (text: string) => void;`);
|
|
336
338
|
}
|
package/dist/generated/jsx.d.ts
CHANGED
|
@@ -1177,6 +1177,7 @@ export interface TextViewProps extends WidgetProps {
|
|
|
1177
1177
|
onSetAnchor?: (self: Gtk.TextView) => void;
|
|
1178
1178
|
onToggleCursorVisible?: (self: Gtk.TextView) => void;
|
|
1179
1179
|
onToggleOverwrite?: (self: Gtk.TextView) => void;
|
|
1180
|
+
text?: string;
|
|
1180
1181
|
onChanged?: (text: string) => void;
|
|
1181
1182
|
ref?: Ref<Gtk.TextView>;
|
|
1182
1183
|
}
|
package/dist/nodes/text-view.js
CHANGED
|
@@ -9,6 +9,9 @@ const getBufferText = (buffer) => {
|
|
|
9
9
|
buffer.getEndIter(endRef);
|
|
10
10
|
return buffer.getText(startRef.value, endRef.value, true);
|
|
11
11
|
};
|
|
12
|
+
const setBufferText = (buffer, text) => {
|
|
13
|
+
buffer.setText(text, -1);
|
|
14
|
+
};
|
|
12
15
|
export class TextViewNode extends Node {
|
|
13
16
|
static matches(type) {
|
|
14
17
|
return type === "TextView";
|
|
@@ -20,6 +23,9 @@ export class TextViewNode extends Node {
|
|
|
20
23
|
super(type, props, app);
|
|
21
24
|
this.buffer = this.widget.getBuffer();
|
|
22
25
|
this.onChanged = props.onChanged;
|
|
26
|
+
if (typeof props.text === "string") {
|
|
27
|
+
setBufferText(this.buffer, props.text);
|
|
28
|
+
}
|
|
23
29
|
queueMicrotask(() => this.connectBufferSignal());
|
|
24
30
|
}
|
|
25
31
|
connectBufferSignal() {
|
|
@@ -38,6 +44,7 @@ export class TextViewNode extends Node {
|
|
|
38
44
|
}
|
|
39
45
|
consumedProps() {
|
|
40
46
|
const consumed = super.consumedProps();
|
|
47
|
+
consumed.add("text");
|
|
41
48
|
consumed.add("onChanged");
|
|
42
49
|
return consumed;
|
|
43
50
|
}
|
|
@@ -47,6 +54,12 @@ export class TextViewNode extends Node {
|
|
|
47
54
|
this.onChanged = newProps.onChanged;
|
|
48
55
|
this.connectBufferSignal();
|
|
49
56
|
}
|
|
57
|
+
if (this.buffer && oldProps.text !== newProps.text && typeof newProps.text === "string") {
|
|
58
|
+
const currentText = getBufferText(this.buffer);
|
|
59
|
+
if (currentText !== newProps.text) {
|
|
60
|
+
setBufferText(this.buffer, newProps.text);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
50
63
|
super.updateProps(oldProps, newProps);
|
|
51
64
|
}
|
|
52
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"react-reconciler": "0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.1.
|
|
39
|
+
"@gtkx/ffi": "0.1.45"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/gir": "0.1.
|
|
42
|
+
"@gtkx/gir": "0.1.45"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^19"
|