|
@@ -36,25 +36,33 @@ namespace Terminal.Gui {
|
|
|
|
|
|
public override void AddRune (Rune rune)
|
|
public override void AddRune (Rune rune)
|
|
{
|
|
{
|
|
|
|
+ if (contents.Length != Rows * Cols * 3) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
rune = MakePrintable (rune);
|
|
rune = MakePrintable (rune);
|
|
- if (Clip.Contains (ccol, crow)) {
|
|
|
|
|
|
+ var runeWidth = Rune.ColumnWidth (rune);
|
|
|
|
+ if (Clip.Contains (ccol, crow) && ccol + Math.Max (runeWidth, 1) <= Cols) {
|
|
contents [crow, ccol, 0] = (int)(uint)rune;
|
|
contents [crow, ccol, 0] = (int)(uint)rune;
|
|
contents [crow, ccol, 1] = currentAttribute;
|
|
contents [crow, ccol, 1] = currentAttribute;
|
|
contents [crow, ccol, 2] = 1;
|
|
contents [crow, ccol, 2] = 1;
|
|
dirtyLine [crow] = true;
|
|
dirtyLine [crow] = true;
|
|
- }
|
|
|
|
- ccol++;
|
|
|
|
- var runeWidth = Rune.ColumnWidth (rune);
|
|
|
|
- if (runeWidth > 1) {
|
|
|
|
- for (int i = 1; i < runeWidth; i++) {
|
|
|
|
- contents [crow, ccol, 2] = 0;
|
|
|
|
- if (ccol + 1 < cols) {
|
|
|
|
|
|
+
|
|
|
|
+ ccol++;
|
|
|
|
+ if (runeWidth > 1) {
|
|
|
|
+ for (int i = 1; i < runeWidth; i++) {
|
|
|
|
+ if (ccol < cols) {
|
|
|
|
+ contents [crow, ccol, 2] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
ccol++;
|
|
ccol++;
|
|
- } else {
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else if (ccol < cols && crow < rows) {
|
|
|
|
+ contents [crow, ccol, 2] = 1;
|
|
|
|
+ dirtyLine [crow] = true;
|
|
}
|
|
}
|
|
|
|
+
|
|
//if (ccol == Cols) {
|
|
//if (ccol == Cols) {
|
|
// ccol = 0;
|
|
// ccol = 0;
|
|
// if (crow + 1 < Rows)
|
|
// if (crow + 1 < Rows)
|
|
@@ -107,7 +115,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
Clear ();
|
|
Clear ();
|
|
ResizeScreen ();
|
|
ResizeScreen ();
|
|
- UpdateOffscreen ();
|
|
|
|
|
|
+ UpdateOffScreen ();
|
|
|
|
|
|
Colors.TopLevel = new ColorScheme ();
|
|
Colors.TopLevel = new ColorScheme ();
|
|
Colors.Base = new ColorScheme ();
|
|
Colors.Base = new ColorScheme ();
|
|
@@ -193,15 +201,10 @@ namespace Terminal.Gui {
|
|
|
|
|
|
contents = new int [Rows, Cols, 3];
|
|
contents = new int [Rows, Cols, 3];
|
|
dirtyLine = new bool [Rows];
|
|
dirtyLine = new bool [Rows];
|
|
-
|
|
|
|
- winChanging = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- void UpdateOffscreen ()
|
|
|
|
|
|
+ void UpdateOffScreen ()
|
|
{
|
|
{
|
|
- if (!winChanging) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
// Can raise an exception while is still resizing.
|
|
// Can raise an exception while is still resizing.
|
|
try {
|
|
try {
|
|
for (int row = 0; row < rows; row++) {
|
|
for (int row = 0; row < rows; row++) {
|
|
@@ -213,6 +216,8 @@ namespace Terminal.Gui {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (IndexOutOfRangeException) { }
|
|
} catch (IndexOutOfRangeException) { }
|
|
|
|
+
|
|
|
|
+ winChanging = false;
|
|
}
|
|
}
|
|
|
|
|
|
public override Attribute MakeAttribute (Color fore, Color back)
|
|
public override Attribute MakeAttribute (Color fore, Color back)
|
|
@@ -237,7 +242,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
public override void UpdateScreen ()
|
|
public override void UpdateScreen ()
|
|
{
|
|
{
|
|
- if (winChanging || Console.WindowHeight == 0
|
|
|
|
|
|
+ if (winChanging || Console.WindowHeight == 0 || contents.Length != Rows * Cols * 3
|
|
|| (!HeightAsBuffer && Rows != Console.WindowHeight)
|
|
|| (!HeightAsBuffer && Rows != Console.WindowHeight)
|
|
|| (HeightAsBuffer && Rows != Console.BufferHeight)) {
|
|
|| (HeightAsBuffer && Rows != Console.BufferHeight)) {
|
|
return;
|
|
return;
|
|
@@ -256,7 +261,6 @@ namespace Terminal.Gui {
|
|
if (contents [row, col, 2] != 1) {
|
|
if (contents [row, col, 2] != 1) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (Console.WindowHeight > 0) {
|
|
if (Console.WindowHeight > 0) {
|
|
// Could happens that the windows is still resizing and the col is bigger than Console.WindowWidth.
|
|
// Could happens that the windows is still resizing and the col is bigger than Console.WindowWidth.
|
|
try {
|
|
try {
|
|
@@ -266,6 +270,10 @@ namespace Terminal.Gui {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (; col < cols && contents [row, col, 2] == 1; col++) {
|
|
for (; col < cols && contents [row, col, 2] == 1; col++) {
|
|
|
|
+ // Needed for the .Net Framework.
|
|
|
|
+ if (row == rows - 1 && col == cols - 1) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
var color = contents [row, col, 1];
|
|
var color = contents [row, col, 1];
|
|
if (color != redrawColor) {
|
|
if (color != redrawColor) {
|
|
SetColor (color);
|
|
SetColor (color);
|
|
@@ -439,8 +447,10 @@ namespace Terminal.Gui {
|
|
bool winChanging;
|
|
bool winChanging;
|
|
public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
|
|
public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
|
|
{
|
|
{
|
|
|
|
+ var mLoop = mainLoop.Driver as NetMainLoop;
|
|
|
|
+
|
|
// Note: Net doesn't support keydown/up events and thus any passed keyDown/UpHandlers will never be called
|
|
// Note: Net doesn't support keydown/up events and thus any passed keyDown/UpHandlers will never be called
|
|
- (mainLoop.Driver as NetMainLoop).KeyPressed = (consoleKey) => {
|
|
|
|
|
|
+ mLoop.KeyPressed = (consoleKey) => {
|
|
var map = MapKey (consoleKey);
|
|
var map = MapKey (consoleKey);
|
|
if (map == (Key)0xffffffff) {
|
|
if (map == (Key)0xffffffff) {
|
|
return;
|
|
return;
|
|
@@ -460,7 +470,7 @@ namespace Terminal.Gui {
|
|
keyModifiers = new KeyModifiers ();
|
|
keyModifiers = new KeyModifiers ();
|
|
};
|
|
};
|
|
|
|
|
|
- (mainLoop.Driver as NetMainLoop).WinChanged = (e) => {
|
|
|
|
|
|
+ mLoop.WinChanged = (e) => {
|
|
winChanging = true;
|
|
winChanging = true;
|
|
const int Min_WindowWidth = 14;
|
|
const int Min_WindowWidth = 14;
|
|
Size size = new Size ();
|
|
Size size = new Size ();
|
|
@@ -475,7 +485,7 @@ namespace Terminal.Gui {
|
|
cols = size.Width;
|
|
cols = size.Width;
|
|
rows = size.Height;
|
|
rows = size.Height;
|
|
ResizeScreen ();
|
|
ResizeScreen ();
|
|
- UpdateOffscreen ();
|
|
|
|
|
|
+ UpdateOffScreen ();
|
|
if (!winChanging) {
|
|
if (!winChanging) {
|
|
TerminalResized.Invoke ();
|
|
TerminalResized.Invoke ();
|
|
}
|
|
}
|
|
@@ -529,6 +539,9 @@ namespace Terminal.Gui {
|
|
/// </summary>
|
|
/// </summary>
|
|
public Action<ConsoleKeyInfo> KeyPressed;
|
|
public Action<ConsoleKeyInfo> KeyPressed;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Invoked when the window is changed.
|
|
|
|
+ /// </summary>
|
|
public Action<int> WinChanged;
|
|
public Action<int> WinChanged;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -581,6 +594,7 @@ namespace Terminal.Gui {
|
|
if (Console.BufferWidth != consoleDriver.Cols || Console.BufferHeight != consoleDriver.Rows
|
|
if (Console.BufferWidth != consoleDriver.Cols || Console.BufferHeight != consoleDriver.Rows
|
|
|| Console.WindowTop != consoleDriver.Top
|
|
|| Console.WindowTop != consoleDriver.Top
|
|
|| Console.WindowHeight != lastWindowHeight) {
|
|
|| Console.WindowHeight != lastWindowHeight) {
|
|
|
|
+ // Top only working on Windows.
|
|
newTop = Console.WindowTop;
|
|
newTop = Console.WindowTop;
|
|
lastWindowHeight = Console.WindowHeight;
|
|
lastWindowHeight = Console.WindowHeight;
|
|
return;
|
|
return;
|
|
@@ -659,7 +673,7 @@ namespace Terminal.Gui {
|
|
}
|
|
}
|
|
if (winChanged) {
|
|
if (winChanged) {
|
|
winChanged = false;
|
|
winChanged = false;
|
|
- WinChanged.Invoke (newTop);
|
|
|
|
|
|
+ WinChanged?.Invoke (newTop);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|