Border feature (#1436)

* Allowing pass the view to the RootMouseEvent.

* Allowing bring the current window to front on dragging.

* Improving the ConsoleDriver to get the Attribute colors based on the value.

* Added a PanelView to deal with borders.

* Added a Border feature to all views.
This commit is contained in:
BDisp
2021-08-26 15:55:19 +01:00
committed by GitHub
parent be0ffc2606
commit 8bfa2f0425
22 changed files with 4187 additions and 159 deletions

View File

@@ -6,6 +6,7 @@
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using NStack;
@@ -111,11 +112,11 @@ namespace Terminal.Gui {
public override void UpdateScreen () => window.redrawwin ();
int currentAttribute;
Attribute currentAttribute;
public override void SetAttribute (Attribute c)
{
currentAttribute = c.Value;
currentAttribute = c;
Curses.attrset (currentAttribute);
}
@@ -1118,6 +1119,28 @@ namespace Terminal.Gui {
}
keyHandler (new KeyEvent (k, MapKeyModifiers (k)));
}
public override bool GetColors (int value, out Color foreground, out Color background)
{
bool hasColor = false;
foreground = default;
background = default;
int back = -1;
IEnumerable<int> values = Enum.GetValues (typeof (ConsoleColor))
.OfType<ConsoleColor> ()
.Select (s => (int)s);
if (values.Contains ((value >> 12) & 0xffff)) {
hasColor = true;
back = (value >> 12) & 0xffff;
background = MapCursesColor (back);
}
if (values.Contains ((value - (back << 12)) >> 8)) {
hasColor = true;
foreground = MapCursesColor ((value - (back << 12)) >> 8);
}
return hasColor;
}
}
internal static class Platform {