|
1 | 1 | import { ImGuiKey } from "./enum.ts";
|
2 | 2 | import { ImGuiInputTextFlags, ImWchar } from "./type.ts";
|
3 |
| -import { ffi as imgui } from "./ffi.ts"; |
| 3 | +import { cString, ffi as imgui, StringSource } from "./ffi.ts"; |
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * Shared state of InputText() when using
|
@@ -116,4 +116,28 @@ export class ImGuiInputTextCallbackData {
|
116 | 116 | set SelectionEnd(value: number) {
|
117 | 117 | imgui.DImGuiInputTextCallbackDataSetSelectionEnd(this.#self, value);
|
118 | 118 | }
|
| 119 | + |
| 120 | + // IMGUI_API void DeleteChars(int pos, int bytes_count); |
| 121 | + // IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL); |
| 122 | + // void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; } |
| 123 | + // void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; } |
| 124 | + // bool HasSelection() const { return SelectionStart != SelectionEnd; } |
| 125 | + |
| 126 | + deleteChars(pos: number, bytes_count: number) { |
| 127 | + imgui.ImGuiInputTextCallbackData_DeleteChars(this.#self, pos, bytes_count); |
| 128 | + } |
| 129 | + insertChars(pos: number, text: StringSource) { |
| 130 | + imgui.ImGuiInputTextCallbackData_InsertChars(this.#self, pos, cString(text), null); |
| 131 | + } |
| 132 | + selectAll() { |
| 133 | + this.SelectionStart = 0; |
| 134 | + this.SelectionEnd = this.BufTextLen; |
| 135 | + } |
| 136 | + clearSelction() { |
| 137 | + this.SelectionStart = this.BufTextLen; |
| 138 | + this.SelectionEnd = this.BufTextLen; |
| 139 | + } |
| 140 | + hasSelection() { |
| 141 | + return this.SelectionStart != this.SelectionEnd; |
| 142 | + } |
119 | 143 | }
|
0 commit comments