public static void WriteInput(this OffscreenBuffer offscreenBuffer, TextInputBuffer textInputBuffer) { offscreenBuffer.Write(textInputBuffer.ToBackwardString()); offscreenBuffer.PushCursor(); offscreenBuffer.Write(textInputBuffer.ToForwardString()); }
public void Insert(string value, int length) { var textInputBuffer = new TextInputBuffer(); foreach (var c in value) { textInputBuffer.Insert(c); } Assert.Equal(length, textInputBuffer.Length); Assert.Equal(value, textInputBuffer.ToString()); }
public AsyncTextInputBufferResult(Func <string> initializationFunc, CancellationToken cancellationToken, TextInputBuffer defaultBuffer = null) { if (defaultBuffer == null) { defaultBuffer = new TextInputBuffer("Loading..."); } Buffer = defaultBuffer; Task.Run(() => { string result = initializationFunc(); Buffer.Dispose(); Buffer = new TextInputBuffer(result); }, cancellationToken); }
public void MoveBackward(string value, string backward, string forward) { var textInputBuffer = new TextInputBuffer(); foreach (var c in value) { textInputBuffer.Insert(c); } textInputBuffer.MoveBackward(); Assert.Equal(backward, textInputBuffer.ToBackwardString()); Assert.Equal(forward, textInputBuffer.ToForwardString()); }
public void Backspace(string value, string substring) { var textInputBuffer = new TextInputBuffer(); foreach (var c in value) { textInputBuffer.Insert(c); } textInputBuffer.Backspace(); Assert.Equal(substring, textInputBuffer.ToString()); Assert.Equal(substring, textInputBuffer.ToBackwardString()); Assert.Equal(string.Empty, textInputBuffer.ToForwardString()); }
public void Delete(string value, string substring) { var textInputBuffer = new TextInputBuffer(); foreach (var c in value) { textInputBuffer.Insert(c); } while (!textInputBuffer.IsStart) { textInputBuffer.MoveBackward(); } textInputBuffer.Delete(); Assert.Equal(substring, textInputBuffer.ToString()); Assert.Equal(string.Empty, textInputBuffer.ToBackwardString()); Assert.Equal(substring, textInputBuffer.ToForwardString()); }
// Dispose any possibly unmanaged resources (textures, buffers) here. protected override void Dispose(bool disposing) { TextInputBuffer.DisposeBuffers(_TextInputBuffers); base.Dispose(disposing); }
// Create any possibly unmanaged resources (textures, buffers) here. protected override void Create() { base.Create(); _TextInputBuffers = TextInputBuffer.CreateBuffers(2); }
private void DrawRightFrame(Vector2 frameSize) { var rightFrameNode = ListView.GetSelectedNode(ListViewID); if (_currentRightFrameNode != rightFrameNode) { _currentRightFrameNode = rightFrameNode; Task.Run(() => { string newText = rightFrameNode.GetNodeSpecialText(); TextInputBuffer newBuffer = new TextInputBuffer(newText); InvokeOnMainThread(() => { if (_currentRightFrameNode == rightFrameNode) { _rightFrameTextBuffer.Dispose(); _rightFrameTextBuffer = newBuffer; _rightFrameRawText = newText; } else { newBuffer.Dispose(); } }); }); } if (_selectableText) { ImGui.PushStyleColor(ColorTarget.FrameBg, new Vector4(1, 1, 1, 1)); ImGui.PushStyleColor(ColorTarget.Text, new Vector4(0, 0, 0, 1)); ImGui.InputTextMultiline( "", _rightFrameTextBuffer.Buffer, _rightFrameTextBuffer.Length, frameSize * new Vector2(2.5f, 1f) - Vector2.UnitY * 35f, InputTextFlags.ReadOnly, null, IntPtr.Zero); ImGui.PopStyleColor(2); } else { unsafe { byte *start = (byte *)_rightFrameTextBuffer.Buffer.ToPointer(); byte *end = start + _rightFrameTextBuffer.Length; if (_wrapRightFrame) { ImGuiNative.igPushTextWrapPos(ImGuiNative.igGetColumnWidth(ImGuiNative.igGetColumnIndex())); } ImGuiNative.igTextUnformatted(start, end); if (_wrapRightFrame) { ImGuiNative.igPopTextWrapPos(); } } } }