1

I'm using the terminal.gui library for c#. The text currently runs off the edge of the frame, but I want it to start a new line when it reaches the edge. Here is my code (frame 1 code not inlcuded since its not relevant):

            Application.Init();
            var top = Application.Top;
            var mainWindow = new Window("The")
            {
                X = 0,
                Y = 1,
                Width = Dim.Fill(),
                Height = Dim.Fill(),
            };
            var frame1 = new FrameView();
            frame1.Width = Dim.Percent(30, false);
            frame1.Height = Dim.Fill();
            frame1.Title = "Archives";
            mainWindow.Add(frame1);

            var frame2 = new FrameView();
            frame2.Width = Dim.Percent(70, false);
            frame2.Height = Dim.Fill();
            frame2.X = Pos.Right(frame1);
            frame2.Title = "Viewer";
            mainWindow.Add(frame2);

            top.Add(mainWindow);
            Label lbl = new Label("helllllllo world helllllllo world helllllllo world ");
                        lbl.Width = 10;
                        frame2.Add(lbl);

here is the result enter image description here

j. doe
  • 21
  • 3

1 Answers1

0

Your label has a vertical height of 1 (the default height). If you change its Height and Width to Dim.Fill() then it will automatically wrap:

lbl.Width = Dim.Fill();
lbl.Height = Dim.Fill();

If you do that then it will look something like this:

enter image description here

Note: If you want scrolling and other features then you might want to change from Label to TextView:

TextView lbl = new TextView();
lbl.Text = "helllllllo world helllllllo world helllllllo world ";
lbl.WordWrap = true;
lbl.Width = Dim.Fill();
lbl.Height = Dim.Fill();
lbl.ReadOnly = true;
Thomas N
  • 623
  • 1
  • 4
  • 14