1 module libwasm.bindings.Selection; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.LegacyQueryInterface; 7 import libwasm.bindings.Node; 8 import libwasm.bindings.Range; 9 10 @safe: 11 nothrow: 12 13 struct Selection { 14 nothrow: 15 JsHandle handle; 16 alias handle this; 17 this(Handle h) { 18 this.handle = JsHandle(h); 19 } 20 auto anchorNode()() { 21 return recastOpt!(Node)(Object_Getter__OptionalHandle(this.handle, "anchorNode")); 22 } 23 uint anchorOffset()() { 24 return Object_Getter__uint(this.handle, "anchorOffset"); 25 } 26 auto focusNode()() { 27 return recastOpt!(Node)(Object_Getter__OptionalHandle(this.handle, "focusNode")); 28 } 29 uint focusOffset()() { 30 return Object_Getter__uint(this.handle, "focusOffset"); 31 } 32 bool isCollapsed()() { 33 return Object_Getter__bool(this.handle, "isCollapsed"); 34 } 35 uint rangeCount()() { 36 return Object_Getter__uint(this.handle, "rangeCount"); 37 } 38 string type()() { 39 return Object_Getter__string(this.handle, "type"); 40 } 41 auto getRangeAt()(uint index) { 42 return Range(Object_Call_uint__Handle(this.handle, "getRangeAt", index)); 43 } 44 void addRange()(scope ref Range range) { 45 Object_Call_Handle__void(this.handle, "addRange", range.handle); 46 } 47 void removeRange()(scope ref Range range) { 48 Object_Call_Handle__void(this.handle, "removeRange", range.handle); 49 } 50 void removeAllRanges()() { 51 Object_Call__void(this.handle, "removeAllRanges"); 52 } 53 void empty()() { 54 Object_Call__void(this.handle, "empty"); 55 } 56 void collapse(T0)(scope auto ref Optional!(T0) node, uint offset /* = 0 */) if (isTOrPointer!(T0, Node)) { 57 Serialize_Object_VarArgCall!void(this.handle, "collapse", "Optional!Handle;uint", tuple(!node.empty, cast(Handle)node.front._parent, offset)); 58 } 59 void collapse(T0)(scope auto ref Optional!(T0) node) if (isTOrPointer!(T0, Node)) { 60 Serialize_Object_VarArgCall!void(this.handle, "collapse", "Optional!Handle", tuple(!node.empty, cast(Handle)node.front._parent)); 61 } 62 void setPosition(T0)(scope auto ref Optional!(T0) node, uint offset /* = 0 */) if (isTOrPointer!(T0, Node)) { 63 Serialize_Object_VarArgCall!void(this.handle, "setPosition", "Optional!Handle;uint", tuple(!node.empty, cast(Handle)node.front._parent, offset)); 64 } 65 void setPosition(T0)(scope auto ref Optional!(T0) node) if (isTOrPointer!(T0, Node)) { 66 Serialize_Object_VarArgCall!void(this.handle, "setPosition", "Optional!Handle", tuple(!node.empty, cast(Handle)node.front._parent)); 67 } 68 void collapseToStart()() { 69 Object_Call__void(this.handle, "collapseToStart"); 70 } 71 void collapseToEnd()() { 72 Object_Call__void(this.handle, "collapseToEnd"); 73 } 74 void extend()(scope ref Node node, uint offset /* = 0 */) { 75 Serialize_Object_VarArgCall!void(this.handle, "extend", "Handle;uint", tuple(cast(Handle)node._parent, offset)); 76 } 77 void extend()(scope ref Node node) { 78 Object_Call_Handle__void(this.handle, "extend", node._parent); 79 } 80 void setBaseAndExtent()(scope ref Node anchorNode, uint anchorOffset, scope ref Node focusNode, uint focusOffset) { 81 Serialize_Object_VarArgCall!void(this.handle, "setBaseAndExtent", "Handle;uint;Handle;uint", tuple(cast(Handle)anchorNode._parent, anchorOffset, cast(Handle)focusNode._parent, focusOffset)); 82 } 83 void selectAllChildren()(scope ref Node node) { 84 Object_Call_Handle__void(this.handle, "selectAllChildren", node._parent); 85 } 86 void deleteFromDocument()() { 87 Object_Call__void(this.handle, "deleteFromDocument"); 88 } 89 bool containsNode()(scope ref Node node, bool allowPartialContainment /* = false */) { 90 return Serialize_Object_VarArgCall!bool(this.handle, "containsNode", "Handle;bool", tuple(cast(Handle)node._parent, allowPartialContainment)); 91 } 92 bool containsNode()(scope ref Node node) { 93 return Serialize_Object_VarArgCall!bool(this.handle, "containsNode", "Handle", tuple(cast(Handle)node._parent)); 94 } 95 auto DOMString()() { 96 return stringifier(Object_Getter__Handle(this.handle, "DOMString")); 97 } 98 void modify()(string alter, string direction, string granularity) { 99 Serialize_Object_VarArgCall!void(this.handle, "modify", "string;string;string", tuple(alter, direction, granularity)); 100 } 101 void interlinePosition()(bool interlinePosition) { 102 Object_Call_bool__void(this.handle, "interlinePosition", interlinePosition); 103 } 104 bool interlinePosition()() { 105 return Object_Getter__bool(this.handle, "interlinePosition"); 106 } 107 void caretBidiLevel(T0)(scope auto ref Optional!(T0) caretBidiLevel) if (isTOrPointer!(T0, short)) { 108 Serialize_Object_VarArgCall!void(this.handle, "caretBidiLevel", "Optional!(short)", tuple(!caretBidiLevel.empty, caretBidiLevel.front)); 109 } 110 Optional!(short) caretBidiLevel()() { 111 return Selection_caretBidiLevel_Get(this.handle); 112 } 113 string toStringWithFormat()(string formatType, uint flags, int wrapColumn) { 114 return Serialize_Object_VarArgCall!string(this.handle, "toStringWithFormat", "string;uint;int", tuple(formatType, flags, wrapColumn)); 115 } 116 void addSelectionListener()(scope ref nsISelectionListener newListener) { 117 Object_Call_Handle__void(this.handle, "addSelectionListener", newListener.handle); 118 } 119 void removeSelectionListener()(scope ref nsISelectionListener listenerToRemove) { 120 Object_Call_Handle__void(this.handle, "removeSelectionListener", listenerToRemove.handle); 121 } 122 short selectionType()() { 123 return Serialize_Object_VarArgCall!short(this.handle, "selectionType", "", tuple()); 124 } 125 auto GetRangesForInterval()(scope ref Node beginNode, int beginOffset, scope ref Node endNode, int endOffset, bool allowAdjacent) { 126 return Sequence!(Range)(Serialize_Object_VarArgCall!Handle(this.handle, "GetRangesForInterval", "Handle;int;Handle;int;bool", tuple(cast(Handle)beginNode._parent, beginOffset, cast(Handle)endNode._parent, endOffset, allowAdjacent))); 127 } 128 void scrollIntoView()(short aRegion, bool aIsSynchronous, short aVPercent, short aHPercent) { 129 Serialize_Object_VarArgCall!void(this.handle, "scrollIntoView", "short;bool;short;short", tuple(aRegion, aIsSynchronous, aVPercent, aHPercent)); 130 } 131 void setColors()(string aForegroundColor, string aBackgroundColor, string aAltForegroundColor, string aAltBackgroundColor) { 132 Serialize_Object_VarArgCall!void(this.handle, "setColors", "string;string;string;string", tuple(aForegroundColor, aBackgroundColor, aAltForegroundColor, aAltBackgroundColor)); 133 } 134 void resetColors()() { 135 Object_Call__void(this.handle, "resetColors"); 136 } 137 auto QueryInterface(T0)(scope auto ref T0 iid) { 138 // Any 139 Handle _handle_iid = getOrCreateHandle(iid); 140 auto result = nsISupports(Object_Call_Handle__Handle(this.handle, "QueryInterface", _handle_iid)); 141 dropHandle!(T0)(_handle_iid); 142 return result; 143 } 144 } 145 146 147 extern (C) Optional!(short) Selection_caretBidiLevel_Get(Handle);