|
@@ -114,7 +114,7 @@ namespace Terminal.Gui {
|
|
|
int lastWindowHeight;
|
|
|
int largestWindowHeight;
|
|
|
#if PROCESS_REQUEST
|
|
|
- bool neededProcessRequest;
|
|
|
+ bool neededProcessRequest;
|
|
|
#endif
|
|
|
public int NumberOfCSI { get; }
|
|
|
|
|
@@ -140,7 +140,7 @@ namespace Terminal.Gui {
|
|
|
inputReady.Reset ();
|
|
|
}
|
|
|
#if PROCESS_REQUEST
|
|
|
- neededProcessRequest = false;
|
|
|
+ neededProcessRequest = false;
|
|
|
#endif
|
|
|
if (inputResultQueue.Count > 0) {
|
|
|
return inputResultQueue.Dequeue ();
|
|
@@ -196,7 +196,8 @@ namespace Terminal.Gui {
|
|
|
if (Console.WindowTop != consoleDriver.Top) {
|
|
|
// Top only working on Windows.
|
|
|
var winPositionEv = new WindowPositionEvent () {
|
|
|
- Top = Console.WindowTop
|
|
|
+ Top = Console.WindowTop,
|
|
|
+ Left = Console.WindowLeft
|
|
|
};
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.WindowPosition,
|
|
@@ -205,10 +206,10 @@ namespace Terminal.Gui {
|
|
|
return;
|
|
|
}
|
|
|
#if PROCESS_REQUEST
|
|
|
- if (!neededProcessRequest) {
|
|
|
- Console.Out.Write ("\x1b[6n");
|
|
|
- neededProcessRequest = true;
|
|
|
- }
|
|
|
+ if (!neededProcessRequest) {
|
|
|
+ Console.Out.Write ("\x1b[6n");
|
|
|
+ neededProcessRequest = true;
|
|
|
+ }
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
@@ -469,7 +470,7 @@ namespace Terminal.Gui {
|
|
|
string value = "";
|
|
|
for (int i = 0; i < kChar.Length; i++) {
|
|
|
var c = kChar [i];
|
|
|
- if (c == '[') {
|
|
|
+ if (c == '\u001b' || c == '[') {
|
|
|
foundPoint++;
|
|
|
} else if (foundPoint == 1 && c != ';' && c != '?') {
|
|
|
value += c.ToString ();
|
|
@@ -1144,6 +1145,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
public struct WindowPositionEvent {
|
|
|
public int Top;
|
|
|
+ public int Left;
|
|
|
public Point CursorPosition;
|
|
|
}
|
|
|
|
|
@@ -1174,17 +1176,16 @@ namespace Terminal.Gui {
|
|
|
const int COLOR_BRIGHT_CYAN = 96;
|
|
|
const int COLOR_BRIGHT_WHITE = 97;
|
|
|
|
|
|
- int cols, rows, top;
|
|
|
+ int cols, rows, left, top;
|
|
|
|
|
|
public override int Cols => cols;
|
|
|
public override int Rows => rows;
|
|
|
- public override int Left => 0;
|
|
|
+ public override int Left => left;
|
|
|
public override int Top => top;
|
|
|
public override bool HeightAsBuffer { get; set; }
|
|
|
|
|
|
public NetWinVTConsole NetWinConsole { get; }
|
|
|
public bool IsWinPlatform { get; }
|
|
|
- public bool AlwaysSetPosition { get; set; }
|
|
|
public override IClipboard Clipboard { get; }
|
|
|
internal override int [,,] Contents => contents;
|
|
|
|
|
@@ -1242,12 +1243,18 @@ namespace Terminal.Gui {
|
|
|
|
|
|
contents [crow, ccol - 1, 0] = (int)(uint)' ';
|
|
|
|
|
|
- } else if (runeWidth < 2 && ccol < Cols - 1
|
|
|
+ } else if (runeWidth < 2 && ccol <= Clip.Right - 1
|
|
|
&& Rune.ColumnWidth ((char)contents [crow, ccol, 0]) > 1) {
|
|
|
|
|
|
contents [crow, ccol + 1, 0] = (int)(uint)' ';
|
|
|
+ contents [crow, ccol + 1, 2] = 1;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (runeWidth > 1 && ccol == Clip.Right - 1) {
|
|
|
+ contents [crow, ccol, 0] = (int)(uint)' ';
|
|
|
+ } else {
|
|
|
+ contents [crow, ccol, 0] = (int)(uint)rune;
|
|
|
}
|
|
|
- contents [crow, ccol, 0] = (int)(uint)rune;
|
|
|
contents [crow, ccol, 1] = currentAttribute;
|
|
|
contents [crow, ccol, 2] = 1;
|
|
|
|
|
@@ -1256,7 +1263,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
ccol++;
|
|
|
if (runeWidth > 1) {
|
|
|
- if (validClip) {
|
|
|
+ if (validClip && ccol < Clip.Right) {
|
|
|
contents [crow, ccol, 1] = currentAttribute;
|
|
|
contents [crow, ccol, 2] = 0;
|
|
|
}
|
|
@@ -1288,6 +1295,9 @@ namespace Terminal.Gui {
|
|
|
StopReportingMouseMoves ();
|
|
|
Console.ResetColor ();
|
|
|
Clear ();
|
|
|
+ //Set cursor key to cursor.
|
|
|
+ Console.Out.Write ("\x1b[?25h");
|
|
|
+ Console.Out.Flush ();
|
|
|
}
|
|
|
|
|
|
void Clear ()
|
|
@@ -1313,6 +1323,10 @@ namespace Terminal.Gui {
|
|
|
{
|
|
|
TerminalResized = terminalResized;
|
|
|
|
|
|
+ //Set cursor key to application.
|
|
|
+ Console.Out.Write ("\x1b[?25l");
|
|
|
+ Console.Out.Flush ();
|
|
|
+
|
|
|
Console.TreatControlCAsInput = true;
|
|
|
|
|
|
cols = Console.WindowWidth;
|
|
@@ -1455,56 +1469,68 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
|
|
|
int top = Top;
|
|
|
+ int left = Left;
|
|
|
int rows = Math.Min (Console.WindowHeight + top, Rows);
|
|
|
int cols = Cols;
|
|
|
+ System.Text.StringBuilder output = new System.Text.StringBuilder ();
|
|
|
+ var lastCol = -1;
|
|
|
|
|
|
- var savedCursorVisible = Console.CursorVisible = false;
|
|
|
+ Console.CursorVisible = false;
|
|
|
for (int row = top; row < rows; row++) {
|
|
|
if (!dirtyLine [row]) {
|
|
|
continue;
|
|
|
}
|
|
|
dirtyLine [row] = false;
|
|
|
- System.Text.StringBuilder output = new System.Text.StringBuilder ();
|
|
|
- for (int col = 0; col < cols; col++) {
|
|
|
+ output.Clear ();
|
|
|
+ for (int col = left; col < cols; col++) {
|
|
|
if (Console.WindowHeight > 0 && !SetCursorPosition (col, row)) {
|
|
|
return;
|
|
|
}
|
|
|
- var lastCol = -1;
|
|
|
+ lastCol = -1;
|
|
|
+ var outputWidth = 0;
|
|
|
for (; col < cols; col++) {
|
|
|
- if (col > 0 && contents [row, col, 2] == 0
|
|
|
- && Rune.ColumnWidth ((char)contents [row, col - 1, 0]) > 1) {
|
|
|
-
|
|
|
- if (col == cols - 1 && output.Length > 0) {
|
|
|
- Console.CursorLeft = lastCol;
|
|
|
+ if (contents [row, col, 2] == 0) {
|
|
|
+ if (output.Length > 0) {
|
|
|
+ //Console.CursorLeft = lastCol;
|
|
|
+ //Console.CursorTop = row;
|
|
|
+ SetVirtualCursorPosition (lastCol, row);
|
|
|
Console.Write (output);
|
|
|
+ output.Clear ();
|
|
|
+ lastCol += outputWidth;
|
|
|
+ outputWidth = 0;
|
|
|
+ } else if (lastCol == -1) {
|
|
|
+ lastCol = col;
|
|
|
}
|
|
|
+ if (lastCol + 1 < cols)
|
|
|
+ lastCol++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ if (lastCol == -1)
|
|
|
+ lastCol = col;
|
|
|
+
|
|
|
var attr = contents [row, col, 1];
|
|
|
if (attr != redrawAttr) {
|
|
|
output.Append (WriteAttributes (attr));
|
|
|
- if (lastCol == -1)
|
|
|
- lastCol = col;
|
|
|
- }
|
|
|
- if (AlwaysSetPosition && !SetCursorPosition (col, row)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (AlwaysSetPosition) {
|
|
|
- Console.Write ($"{output}{(char)contents [row, col, 0]}");
|
|
|
- } else {
|
|
|
- output.Append ((char)contents [row, col, 0]);
|
|
|
- if (lastCol == -1)
|
|
|
- lastCol = col;
|
|
|
}
|
|
|
+ outputWidth++;
|
|
|
+ output.Append ((char)contents [row, col, 0]);
|
|
|
contents [row, col, 2] = 0;
|
|
|
- if (!AlwaysSetPosition && col == cols - 1) {
|
|
|
- Console.Write (output);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+ if (output.Length > 0) {
|
|
|
+ //Console.CursorLeft = lastCol;
|
|
|
+ //Console.CursorTop = row;
|
|
|
+ SetVirtualCursorPosition (lastCol, row);
|
|
|
+ Console.Write (output);
|
|
|
+ }
|
|
|
}
|
|
|
- Console.CursorVisible = savedCursorVisible;
|
|
|
+ }
|
|
|
+
|
|
|
+ void SetVirtualCursorPosition (int lastCol, int row)
|
|
|
+ {
|
|
|
+ Console.Out.Write ($"\x1b[{row + 1};{lastCol + 1}H");
|
|
|
+ Console.Out.Flush ();
|
|
|
}
|
|
|
|
|
|
System.Text.StringBuilder WriteAttributes (int attr)
|
|
@@ -1779,8 +1805,10 @@ namespace Terminal.Gui {
|
|
|
break;
|
|
|
case NetEvents.EventType.WindowPosition:
|
|
|
var newTop = inputEvent.WindowPositionEvent.Top;
|
|
|
- if (HeightAsBuffer && top != newTop) {
|
|
|
+ var newLeft = inputEvent.WindowPositionEvent.Left;
|
|
|
+ if (HeightAsBuffer && (top != newTop || left != newLeft)) {
|
|
|
top = newTop;
|
|
|
+ left = newLeft;
|
|
|
Refresh ();
|
|
|
}
|
|
|
break;
|
|
@@ -1798,6 +1826,7 @@ namespace Terminal.Gui {
|
|
|
size = new Size (Math.Max (Min_WindowWidth, Console.WindowWidth),
|
|
|
Console.WindowHeight);
|
|
|
top = 0;
|
|
|
+ left = 0;
|
|
|
} else {
|
|
|
//largestWindowHeight = Math.Max (Console.BufferHeight, largestWindowHeight);
|
|
|
largestWindowHeight = Console.BufferHeight;
|