Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- In the source tree the version will always be 1.0 for all projects. -->
<!-- In the source tree the version will always be 2.0 for all projects. -->
<!-- Do not modify these. -->
<AssemblyVersion>1.0</AssemblyVersion>
<FileVersion>1.0</FileVersion>
<Version>1.0</Version>
<InformationalVersion>1.0</InformationalVersion>
<AssemblyVersion>2.0</AssemblyVersion>
<FileVersion>2.0</FileVersion>
<Version>2.0</Version>
<InformationalVersion>2.0</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
[![License](https://img.shields.io/github/license/gui-cs/gui.cs.svg)](LICENSE)
![Bugs](https://img.shields.io/github/issues/gui-cs/gui.cs/bug)

# This is the v2.0 Branch - Under Development

See the v2 Discussion here: https://github.com/gui-cs/Terminal.Gui/discussions/1940

# Terminal.Gui - Cross Platform Terminal UI toolkit for .NET

A toolkit for building rich console apps for .NET, .NET Core, and Mono that works on Windows, the Mac, and Linux/Unix.
Expand Down
10 changes: 5 additions & 5 deletions ReactiveExample/ReactiveExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- In the source tree the version will always be 1.0 for all projects. -->
<!-- In the source tree the version will always be 2.0 for all projects. -->
<!-- Do not modify these. -->
<AssemblyVersion>1.0</AssemblyVersion>
<FileVersion>1.0</FileVersion>
<Version>1.0</Version>
<InformationalVersion>1.0</InformationalVersion>
<AssemblyVersion>2.0</AssemblyVersion>
<FileVersion>2.0</FileVersion>
<Version>2.0</Version>
<InformationalVersion>2.0</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ReactiveUI.Fody" Version="18.4.1" />
Expand Down
185 changes: 44 additions & 141 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,62 +62,43 @@ public override void AddRune (Rune rune)
Curses.move (crow, ccol);
needMove = false;
}
if (runeWidth == 0 && ccol > 0) {
var r = contents [crow, ccol - 1, 0];
var s = new string (new char [] { (char)r, (char)rune });
string sn;
if (!s.IsNormalized ()) {
sn = s.Normalize ();
} else {
sn = s;
}
var c = sn [0];
Curses.mvaddch (crow, ccol - 1, (int)(uint)c);
contents [crow, ccol - 1, 0] = c;
contents [crow, ccol - 1, 1] = currentAttribute;
contents [crow, ccol - 1, 2] = 1;
if (runeWidth < 2 && ccol > 0
&& Rune.ColumnWidth ((char)contents [crow, ccol - 1, 0]) > 1) {

} else {
if (runeWidth < 2 && ccol > 0
&& Rune.ColumnWidth ((char)contents [crow, ccol - 1, 0]) > 1) {

var curAtttib = currentAttribute;
Curses.attrset (contents [crow, ccol - 1, 1]);
Curses.mvaddch (crow, ccol - 1, (int)(uint)' ');
contents [crow, ccol - 1, 0] = (int)(uint)' ';
Curses.move (crow, ccol);
Curses.attrset (curAtttib);

} else if (runeWidth < 2 && ccol <= Clip.Right - 1
&& Rune.ColumnWidth ((char)contents [crow, ccol, 0]) > 1) {

var curAtttib = currentAttribute;
Curses.attrset (contents [crow, ccol + 1, 1]);
Curses.mvaddch (crow, ccol + 1, (int)(uint)' ');
contents [crow, ccol + 1, 0] = (int)(uint)' ';
Curses.move (crow, ccol);
Curses.attrset (curAtttib);
var curAtttib = CurrentAttribute;
Curses.attrset (contents [crow, ccol - 1, 1]);
Curses.mvaddch (crow, ccol - 1, (int)(uint)' ');
contents [crow, ccol - 1, 0] = (int)(uint)' ';
Curses.move (crow, ccol);
Curses.attrset (curAtttib);

}
if (runeWidth > 1 && ccol == Clip.Right - 1) {
Curses.addch ((int)(uint)' ');
contents [crow, ccol, 0] = (int)(uint)' ';
} else {
Curses.addch ((int)(uint)rune);
contents [crow, ccol, 0] = (int)(uint)rune;
}
contents [crow, ccol, 1] = currentAttribute;
contents [crow, ccol, 2] = 1;
} else if (runeWidth < 2 && ccol <= Clip.Right - 1
&& Rune.ColumnWidth ((char)contents [crow, ccol, 0]) > 1) {

var curAtttib = CurrentAttribute;
Curses.attrset (contents [crow, ccol + 1, 1]);
Curses.mvaddch (crow, ccol + 1, (int)(uint)' ');
contents [crow, ccol + 1, 0] = (int)(uint)' ';
Curses.move (crow, ccol);
Curses.attrset (curAtttib);

}
if (runeWidth > 1 && ccol == Clip.Right - 1) {
Curses.addch ((int)(uint)' ');
contents [crow, ccol, 0] = (int)(uint)' ';
} else {
Curses.addch ((int)(uint)rune);
contents [crow, ccol, 0] = (int)(uint)rune;
}
contents [crow, ccol, 1] = CurrentAttribute;
contents [crow, ccol, 2] = 1;
} else
needMove = true;

if (runeWidth < 0 || runeWidth > 0) {
ccol++;
}
ccol++;
if (runeWidth > 1) {
if (validClip && ccol < Clip.Right) {
contents [crow, ccol, 1] = currentAttribute;
contents [crow, ccol, 1] = CurrentAttribute;
contents [crow, ccol, 2] = 0;
}
ccol++;
Expand Down Expand Up @@ -162,35 +143,18 @@ public override void End ()
SetCursorVisibility (CursorVisibility.Default);

Curses.endwin ();

// I'm commenting this because was used in a trying to fix the Linux hanging and forgot to exclude it.
// Clear and reset entire screen.
//Console.Out.Write ("\x1b[2J");
//Console.Out.Flush ();

// Set top and bottom lines of a window.
//Console.Out.Write ("\x1b[1;25r");
//Console.Out.Flush ();

//Set cursor key to cursor.
//Console.Out.Write ("\x1b[?1l");
//Console.Out.Flush ();
}

public override void UpdateScreen () => window.redrawwin ();

Attribute currentAttribute;

public override void SetAttribute (Attribute c)
{
currentAttribute = c;
Curses.attrset (currentAttribute);
base.SetAttribute (c);
Curses.attrset (CurrentAttribute);
}

public Curses.Window window;

//static short last_color_pair = 16;

/// <summary>
/// Creates a curses color from the provided foreground and background colors
/// </summary>
Expand All @@ -216,35 +180,6 @@ public override Attribute MakeColor (Color fore, Color back)
return MakeColor ((short)MapColor (fore), (short)MapColor (back));
}

int [,] colorPairs = new int [16, 16];

public override void SetColors (ConsoleColor foreground, ConsoleColor background)
{
int f = (short)foreground;
int b = (short)background;
var v = colorPairs [f, b];
if ((v & 0x10000) == 0) {
b &= 0x7;
bool bold = (f & 0x8) != 0;
f &= 0x7;

v = MakeColor ((short)f, (short)b) | (bold ? Curses.A_BOLD : 0);
colorPairs [(int)foreground, (int)background] = v | 0x1000;
}
SetAttribute (v & 0xffff);
}

Dictionary<int, int> rawPairs = new Dictionary<int, int> ();
public override void SetColors (short foreColorId, short backgroundColorId)
{
int key = ((ushort)foreColorId << 16) | (ushort)backgroundColorId;
if (!rawPairs.TryGetValue (key, out var v)) {
v = MakeColor (foreColorId, backgroundColorId);
rawPairs [key] = v;
}
SetAttribute (v);
}

static Key MapCursesKey (int cursesKey)
{
switch (cursesKey) {
Expand Down Expand Up @@ -832,7 +767,7 @@ public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandle
};
}

Curses.Event oldMouseEvents, reportableMouseEvents;
Curses.Event reportableMouseEvents;
public override void Init (Action terminalResized)
{
if (window != null)
Expand Down Expand Up @@ -889,39 +824,23 @@ public override void Init (Action terminalResized)
Curses.noecho ();

Curses.Window.Standard.keypad (true);
reportableMouseEvents = Curses.mousemask (Curses.Event.AllEvents | Curses.Event.ReportMousePosition, out oldMouseEvents);
reportableMouseEvents = Curses.mousemask (Curses.Event.AllEvents | Curses.Event.ReportMousePosition, out _);
TerminalResized = terminalResized;
if (reportableMouseEvents.HasFlag (Curses.Event.ReportMousePosition))
StartReportingMouseMoves ();

ResizeScreen ();
UpdateOffScreen ();

//HLine = Curses.ACS_HLINE;
//VLine = Curses.ACS_VLINE;
//Stipple = Curses.ACS_CKBOARD;
//Diamond = Curses.ACS_DIAMOND;
//ULCorner = Curses.ACS_ULCORNER;
//LLCorner = Curses.ACS_LLCORNER;
//URCorner = Curses.ACS_URCORNER;
//LRCorner = Curses.ACS_LRCORNER;
//LeftTee = Curses.ACS_LTEE;
//RightTee = Curses.ACS_RTEE;
//TopTee = Curses.ACS_TTEE;
//BottomTee = Curses.ACS_BTEE;
//RightArrow = Curses.ACS_RARROW;
//LeftArrow = Curses.ACS_LARROW;
//UpArrow = Curses.ACS_UARROW;
//DownArrow = Curses.ACS_DARROW;
CurrentAttribute = MakeColor (Color.White, Color.Black);

if (Curses.HasColors) {
Curses.StartColor ();
Curses.UseDefaultColors ();

CreateColors ();
InitalizeColorSchemes ();
} else {
CreateColors (false);
InitalizeColorSchemes (false);

// BUGBUG: This is a hack to make the colors work on the Mac?
// The new Theme support overwrites these colors, so this is not needed?
Colors.TopLevel.Normal = Curses.COLOR_GREEN;
Colors.TopLevel.Focus = Curses.COLOR_WHITE;
Colors.TopLevel.HotNormal = Curses.COLOR_YELLOW;
Expand All @@ -948,6 +867,10 @@ public override void Init (Action terminalResized)
Colors.Error.HotFocus = Curses.A_REVERSE;
Colors.Error.Disabled = Curses.A_BOLD | Curses.COLOR_GRAY;
}

ResizeScreen ();
UpdateOffScreen ();

}

public override void ResizeScreen ()
Expand Down Expand Up @@ -1022,6 +945,8 @@ static int MapColor (Color color)
return Curses.COLOR_YELLOW | Curses.A_BOLD | Curses.COLOR_GRAY;
case Color.White:
return Curses.COLOR_WHITE | Curses.A_BOLD | Curses.COLOR_GRAY;
case Color.Invalid:
return Curses.COLOR_BLACK;
}
throw new ArgumentException ("Invalid color code");
}
Expand Down Expand Up @@ -1095,28 +1020,6 @@ public override void StopReportingMouseMoves ()
Console.Out.Flush ();
}

//int lastMouseInterval;
//bool mouseGrabbed;

public override void UncookMouse ()
{
//if (mouseGrabbed)
// return;
//lastMouseInterval = Curses.mouseinterval (0);
//mouseGrabbed = true;
}

public override void CookMouse ()
{
//mouseGrabbed = false;
//Curses.mouseinterval (lastMouseInterval);
}

public override Attribute GetAttribute ()
{
return currentAttribute;
}

/// <inheritdoc/>
public override bool GetCursorVisibility (out CursorVisibility visibility)
{
Expand Down
Loading