Skip to content

Commit 6a376a5

Browse files
committed
hook up selection and copy/paste
1 parent eeaca67 commit 6a376a5

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/XTerm.NET/InputHandler.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public void Print(string data)
114114
}
115115
}
116116

117+
var line = _buffer.Lines[_buffer.Y + _buffer.YBase];
118+
117119
// Handle autowrap
118120
if (_buffer.X >= _terminal.Cols)
119121
{
@@ -128,23 +130,18 @@ public void Print(string data)
128130
{
129131
_buffer.SetCursor(0, _buffer.Y + 1);
130132
}
133+
if (line != null)
134+
line.IsWrapped = true;
131135
}
132136
else
133137
{
134138
return; // Don't print beyond line edge
135139
}
136140
}
137141

138-
var line = _buffer.Lines[_buffer.Y + _buffer.YBase];
139142
if (line == null)
140143
return;
141144

142-
// Mark line as wrapped if we just wrapped
143-
if (_buffer.X == 0 && line != null)
144-
{
145-
line.IsWrapped = true;
146-
}
147-
148145
// Translate character through active charset
149146
var translatedData = data;
150147
if (data.Length == 1)

src/XTerm.NET/Terminal.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using XTerm.Input;
66
using XTerm.Events.Parser;
77
using XTerm.Events;
8+
using XTerm.Selection;
89

910
namespace XTerm;
1011

@@ -18,6 +19,7 @@ public class Terminal
1819
private readonly InputHandler _inputHandler;
1920
private readonly KeyboardInputGenerator _keyboardInput;
2021
private readonly MouseTracker _mouseTracker;
22+
private readonly SelectionManager _selectionManager;
2123
private Buffer.TerminalBuffer _buffer;
2224
private Buffer.TerminalBuffer? _normalBuffer;
2325
private Buffer.TerminalBuffer? _altBuffer;
@@ -184,7 +186,8 @@ public Terminal(TerminalOptions? options = null)
184186
_parser = new EscapeSequenceParser();
185187
_inputHandler = new InputHandler(this);
186188
_keyboardInput = new KeyboardInputGenerator(this);
187-
_mouseTracker = new MouseTracker(this); // Initialize mouse tracker
189+
_mouseTracker = new MouseTracker(this);
190+
_selectionManager = new SelectionManager(this);
188191

189192
// Subscribe to parser events using C# event pattern
190193
_parser.Print += OnParserPrint;
@@ -447,6 +450,11 @@ public string GenerateFocusEvent(bool focused)
447450
/// </summary>
448451
public MouseEncoding MouseEncoding => _mouseTracker.Encoding;
449452

453+
/// <summary>
454+
/// Gets the selection manager for text selection.
455+
/// </summary>
456+
public SelectionManager Selection => _selectionManager;
457+
450458
/// <summary>
451459
/// Gets the mouse tracker (internal use for mode setting).
452460
/// </summary>

0 commit comments

Comments
 (0)