goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
718 stars 62 forks source link

Does window support chinese character text auto wrap? #82

Closed winplusx closed 3 years ago

winplusx commented 3 years ago

I use a_window.WriteLine(ChineseCharacterText); and it will cross the border.

goblinfactory commented 3 years ago

Please provide a small code example, that shows what you want to happen, and then ...what does happen.

for example;

          var w = new Window(20, 5);
            (var left, var right) = w.SplitLeftRight("left", "right");
            left.WriteLine("one\r\ntwo\rthree\nfour");

            /*
             I am expecting to see the words get wrapped, and the last word "four" to also cause a carriage return
                ┌─ left ─┬─ right ─┐
                │three   │         │
                │four    │         │
                │        │         │
                └────────┴─────────┘

           but instead I see the following; it appears as if there there are 2 carriage returns instead 
          of one after the last line.
                ┌─ left ─┬─ right ─┐
                │four    │         │
                │        │         │
                │        │         │
                └────────┴─────────┘
            */

This will help explain exactly what you mean, and what behaviour you are expecting from Konsole.

Thank you

Alan

p.s. the test above is fictitious (made up) - to demonstrate how to ask for help using an example to clarify what you are expecting.

winplusx commented 3 years ago

This is the Code: var test = Window.OpenBox("Test Chinese", 20, 12, new BoxStyle() { ThickNess = LineThickNess.Single }); test.WriteLine("这是一个中文句子测试,是否可以自动换行不越界");

/* I am expecting to see the words get wrapped

┌── Test Chinese ──┐ │这是一个中文句子 │测试,是否可以自 │ │ 动换行不越界 │ │ │ └─────── ─────┘

but instead I see the following ┌── Test Chinese ──┐ │这是一个中文句子测试,是否可以自动换 │行不越界 │ │ │ │ │ └─────── ─────┘ Thank you for any help.

goblinfactory commented 3 years ago

Thank you, ... I'll take a look at this tomorrow.

goblinfactory commented 3 years ago

Hi @winplusx I get similar results, so possibly the answer is no. I dont have an chinese operating system to test on, in case that impacts the Operating system console in some way or other.

It's possible there might be work arounds, but the few experiments I've done in the past to support additional character sets (fonts) have involved configuring the windows command console itself to use a specific font.

Which means that even if there were some tricks, they would not help you create a C# application you can give to someone else, without requiring them to jump through the same tricks/hoops.

We also cannot force the console to use a specific font programmatically, not easily and not worth the hassle. So ... this is a no from me unfortunately.

Alan