gui-cs / terminal.gui Goto Github PK
View Code? Open in Web Editor NEWCross Platform Terminal UI toolkit for .NET
License: MIT License
Cross Platform Terminal UI toolkit for .NET
License: MIT License
Should be similar in spirit to the UIScrollView in that it can move the contents of the subviews
Work in Progress in ScrollView
We are currently reporting the mouse movement events, but it looks like the terminal via curses
is not sending us the events we need when the mouse is clicked and then moved.
It is currently sitting in an instance of the TextField and should instead be accessible to all fields and future entries.
Should unprocessed cursor key events trigger focus? -> Yes, we should. More discoverable than tab/shifttab
Currently does conversions from string to ustring and should use ustring methods, when those are implemented (and ustringbuilder)
And allow for yank operetions
Rows and columns, multi-row/column spanning for specific cells, etc.
Merely a control that draws a frame with a label
It should render more detail depending on the height. 1 line, current design; 2 progress plus percentage; 3 framed; 4 frame with progress; 6 frame wothnprogress padded
We should have a system to define keyboard chords as well as a Command system, to not rely nor be limieted by the function keys.
This would allow things like "C-x C-s" to be defined easily.
Can use the work-in-progress XtermSharp and mono/pty-sharp
as it currently prevents the library from working there.
Currently the only backend in use for gui.cs is the ncurses backend. There is a partial implementation of a System.Console
based driver but it is not complete.
Currently we use mainloop.cs
to monitor input on standard input and wake up the mainloop to read the input. We need a variant that works for Windows, likely using Console.ReadKey
and using some AutoResetEvent
to wake up the thread.
Generally, we can either make mainloop.cs
fully cross platform, or we could surface Windows/Unix codepaths, and let the consumer (in this case, gui.cs) deal with it.
In addition to that, the backend itself needs to be completed.
Would be good to have a way of toggling a way to draw a box around boundaries on views.
Control-L does not redraw everything when there are many toplevels running
Redraw (Control-L) handler needs to do a painter's paint job, currently
only Application.Top gets the SetNeedsDisplay(), but this needs to apply
on Control-L to the entire stack.
Repro: activate dialog box, press esc, and this clears the dialog contents.
To make it simpler to add a splash of color to the UI.
Some thoughts:
Tags:
<b>
- bold<u>
- underline<r>
- reverseColors:
<red>
, <green>
, <yellow>
etc+-------------------------------------------------------+
| Directory: [/usr/local/bin/ ] [-] |
| |
| File: [_________________________________] |
| |
| +-------------------------------------------------+ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| +-------------------------------------------------+ |
| |
| [Cancel] [Open] |
| |
+-------------------------------------------------------+
I can type anywhere, characters are just printed on top of the views.
Typing a non-alpha character makes the next character overwrite the previous etc.
Trying to compile this on Windows it wants "Unix" something?
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Unix' does not exist in the namespace 'Mono' (are you missing an assembly reference?) Terminal.Gui V:\Downloads\gui.cs-master\gui.cs-master\Terminal.Gui\MonoCurses\mainloop.cs 28 Active
Error CS0246 The type or namespace name 'Pollfd' could not be found (are you missing a using directive or an assembly reference?) Terminal.Gui V:\Downloads\gui.cs-master\gui.cs-master\Terminal.Gui\MonoCurses\mainloop.cs 86 Active
Error CS0246 The type or namespace name 'PollEvents' could not be found (are you missing a using directive or an assembly reference?) Terminal.Gui V:\Downloads\gui.cs-master\gui.cs-master\Terminal.Gui\MonoCurses\mainloop.cs 217 Active
Error CS0006 Metadata file 'V:\Downloads\gui.cs-master\gui.cs-master\Terminal.Gui\bin\Debug\Terminal.Gui.dll' could not be found Terminal V:\Downloads\gui.cs-master\gui.cs-master\CSC 1 Active
Pondering: should it support attributed text?
This is the function bar at the bottom of the screen that provides a visual cue for the available commands.
There is a partial implementation in the old gui.cs:
A hotlabel, is just a label but it has the following properties:
Should this just be folded into the regular Label?
Many characters that take up two slots are not properly rendered as we render those two, but do not fully fill the requested region. Need to use Rune.ColumnWidth
to compute the current position.
[x] Setup documentation extracting process
[x] Publish API docs
[ ] Public guideline docs
The issue is that we are not finding a valid view, due to our offset code.
Repro: run the sample, and try clicking on the radio at the end of the word "Personal", it only works if you click on the first few characters.
Need to make a .NET Standard 2 library out of a this, and a NuGet package.
Desired:
[x] Link the mono-curses files directly, to reduce dependencies
[x] Link Mainloop directly, same reason
Challenges:
Moving to .NET Standard means the main application will end up pulling some 99 assemblies, unless we switch it to .NET Core. Either option is slower.
There is a bug in P/Invoke against poll that renders the results of poll unusable.
It would be great to support .NET Core.
Should include other color themes, currently we have the Norton-esque theme, we could include a TurboVision-esque theme. The support is already in place, it is a matter of allocating new colors in each driver.
We could likely have a simple listview that relies on text being returned, and a more complicated one, that allows users to provide a full view to be rendered in place - to allow colors and other features.
Implemented as ListView, some features missing:
Scrollviews should take the focus for any focusable controls and show allow for the key navigation keystrokes to control where the focus goes.
Additionally, we probably should make "PositionCursor" return the Point where the cursor would be in a View, instead of manually positioning it. The caller would place the cursor in the right place.
This would allow us to figure out where the cursor should go in a scrollview and scroll to the right location on those scenarios.
This needs to exist:
Currently at best, we have LayoutSubviews, but there is no support for anchoring, springs or any other layout system.
Should consider what options we have.
Perhaps Views
could have a LayoutManager
in charge of laying things out. Would be desirable to have a layout manager that can work by default with Add
, and the question is whether attributes of how a view should be laid out should live in the view itself, or should be an attached property when they are added to the parent.
It seems that with layout managers, we could have general purpose pones like Grid, or Flex, and convenience View subclasses like HBox/VBox to finetune the layout.
There exists common confusion about terminal colors. This is what we have right now:
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
The 256-color palette is configured at start and is a 666-cube of colors,
each of them defined as a 24-bit (888 rgb) color.
This means that current support can only display 256 different colors in the
terminal while "true color" means that you can display 16 million different
colors at the same time.
Truecolor escape codes do not use a color palette. They just specify the
color itself.
This is a good test case:
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
awk 'BEGIN{
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum+1,1);
}
printf "\n";
}'
Keep in mind that it is possible to use both ';' and ':' as Control Sequence
Introducer delimiters.
According to Wikipedia[1], this behavior is only supported by xterm and konsole.
[1] https://en.wikipedia.org/wiki/ANSI_color
Since
ncurses-6.0-20180121,
terminfo began to support the 24-bit True Color capability under the name of
"RGB". You need to use the "setaf" and "setab" commands to set the foreground
and background respectively.
There will be no reliable way to detect the "RGB" flag until the new release of
terminfo/ncurses. S-Lang author added a check for $COLORTERM containing either
"truecolor" or "24bit" (case sensitive). In addition,
VTE,
Konsole and
iTerm2 set this variable to
"truecolor". It has been in VTE for a while and but is relatively new, being
still git-only in Konsole and iTerm2).
This is obviously not a reliable method, and is not forwarded via sudo, SSH etc.
However, whenever it errs, it errs on the safe side. It does not advertise
support when it is actually unsupported. App developers can freely choose to
check for this same variable, or introduce their own method (e.g. an option in
their config file). They should use whichever method best matches the overall
design of their app. Checking $COLORTERM is recommended though since it will
lead to a more seamless desktop experience where only one variable needs to be
set. This would be system-wide so that the user would not need to set it
separately for each app.
A more reliable method in an interactive program which can read terminal
responses, and one that is transparent to things like sudo, SSH, etc.. is to
simply try setting a truecolor value and then query the terminal to ask what
color it currently has. If the response replies the same color that was set
then it indicates truecolor is supported.
$ (echo -e '\e[48:2:1:2:3m\eP$qm\e\\' ; xxd)
^[P1$r48:2:1:2:3m^[\
00000000: 1b50 3124 7234 383a 323a 313a 323a 336d .P1$r48:2:1:2:3m
Here we ask to set the background color to RGB(1,2,3)
- an unlikely default
choice - and request the value that we just set. The response comes back that
the request was understood (1
), and that the color is indeed 48:2:1:2:3
.
This tells us also that the terminal supports the colon delimiter. If instead,
the terminal did not support truecolor we might see a response like
^[P1$r40m^[\
00000000: 1b50 3124 7234 306d 1b5c 0a .P1$r40m.\.
This terminal replied the color is 40
- it has not accepted our request to
set 48:2:1:2:3
.
^[P0$r^[\
00000000: 1b50 3024 721b 5c0a .P0$r.\.
This terminal did not even understand the DECRQSS request - its response was
0$r
. We do not learn if it managed to set the color, but since it doesn't
understand how to reply to our request it is unlikely to support truecolor
either.
lscolors
to see a truecolor test)There are a bunch of libvte-based terminals for GTK2, so they are listed in the
another section.
Also, while this one is not a terminal, but a terminal replayer, it is
still worth mentioning:
Note about color differences:
a) RGB axes are not orthogonal, so you cannot use
sqrt(R^2+G^2+B^2) formula
b) for color differences there is more correct (but
much more complex)
CIEDE2000 formula
(which may easily blow up performance if used blindly) [2].
[2] neovim/neovim#793 (comment)
--truecolor
option)ls
program that supports iconsSee the repository https://github.com/termstandard/colors
Or the gist and discussion here: https://gist.github.com/XVilka/8346728
Reusable scrollbars.
Work-in progress in ScrollBarView
Perhaps dialog containers need to set a general style for the child widgets,so that when we set a dialog, or error box, all the children added get the right set of default colors.
Widgets should not use Colors.Base or Colors.Dialog, they should likely use the colors defined in the toplevel container, so that the Dialog vs Toplevel colors are set there only.
Resizing of the toplevel windows, and message boxes should be relatively easy, but there is no support to relayout the views. As we do not currently have a layout system, beyond the absolute positioning system.
Update The https://github.com/migueldeicaza/gui.cs/tree/layout branch now contains a C# port of the Xamarin Flex engine that Stephane Delcroix did, while the port is complete, it is completely untested, that needs to be done.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.