Support unicode chars in ListViews and TextFields
See original GitHub issueI am not sure if I just repeat issue #93 here. Sorry if I do.
Issue
I am currently using some unicode signs like: ≡ ⌂ ↑ ↓ …
While rendering them in a ListView or TextField, I got a IndexOutOfRangeException
. In Labels, everything is okay.
at System.Rune.bisearch(UInt32 rune, UInt32[,] table, Int32 max)
at System.Rune.ColumnWidth(Rune rune)
at Terminal.Gui.ListView.ListWrapper.RenderUstr(ustring ustr, Int32 col, Int32 line, Int32 width)
at Terminal.Gui.ListView.ListWrapper.Render(Boolean marked, Int32 item, Int32 col, Int32 line, Int32 width)
at Terminal.Gui.ListView.Redraw(Rect region)
at Terminal.Gui.View.Redraw(Rect region)
at Terminal.Gui.Window.Redraw(Rect bounds)
at Terminal.Gui.View.Redraw(Rect region)
at Terminal.Gui.Application.Redraw(View view)
at Terminal.Gui.Application.Begin(Toplevel toplevel)
at Terminal.Gui.Application.Run(Toplevel view)
at grrui.Program.Main(String[] args) in D:\Develop\GitHub\RepoZ\grrui\Program.cs:line 43
It turns out that "\u2261"
for example, returns Rune 8801
. Rune.ColumnWidth(8801)
throws.
How to reproduce
Simply replace the Example\demo.cs in your solution and hit <kbd>F5</kbd>.
using Terminal.Gui;
static class Demo {
static void Main()
{
Application.Init();
var top = Application.Top;
var tframe = top.Frame;
var win = new Window("Unicode chars") {
X = 0,
Y = 0,
Width = Dim.Fill(),
Height = Dim.Fill()
};
var unicodeChars = "\u2261 \u2302 \u2191 \u2193 \u2026";
var lbl = new Label("They work in Labels: " + unicodeChars)
{
X = 1,
Y = 2
};
// ** COMMENT THIS OUT TO SEE THE CRASH **
unicodeChars = "--CENSORED--";
var txt = new TextField("But they won't work in TextFields: " + unicodeChars)
{
X = Pos.Left(lbl),
Y = Pos.Bottom(lbl) + 1,
Width = 50
};
var lst = new ListView(new string[] {
"They won't work in ListViews as well.",
"Here they come: " + unicodeChars,
"If you want to try this out by yourself,",
"simply remove that line saying \"CENSORED\" in code."
}
) {
X = Pos.Left(lbl),
Y = 6,
Width = Dim.Fill(),
Height = Dim.Fill()
};
lst.SelectedItem = 0;
win.Add(lbl);
win.Add(txt);
win.Add(lst);
top.Add(win);
Application.Run();
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Support unicode chars in ListViews and TextFields #146
I am currently using some unicode signs like: ≡ ⌂ ↑ ↓ … While rendering them in a ListView or TextField, I got...
Read more >Unicode characters in Listview c# - Stack Overflow
Here is the thing: I need to display japanese character in listview in a SQL operated database manager I am currently building for...
Read more >Using Unicode in Visual FoxPro Web and Desktop ...
This article describes how to work with Unicode in Visual FoxPro. VFP doesn't support Unicode natively, but with some know how you can...
Read more >iOS 15 - Assigning unicode charact…
My problem is, It works fine till iOS 14, but not in iOS 15, the unicode character in secure text field takes it...
Read more >TextView | Android Developers
Hint text to display when the text is empty. May be a string value, using '\\;' to escape characters such as '\\n' or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fixed this issue in NStack, so I opened a further issue over there to be able to fix it with PR44.
Let’s keep this one open until the fix made it into NStack and gui.cs updates to a new version.
@awaescher Is there any way you could help us build unit tests for Unicode support? I can barely spell Unicode and I certainly don’t have many personal use cases beyond Powerline console symbols.
It seems you have an app with real requirements. Anything you could contribute would be appreciated. Even if it were just great text examples.