mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 16:58:01 +01:00
Updated TextAutocomplete
This commit is contained in:
@@ -27,51 +27,51 @@ public class TabViewExample : Scenario
|
||||
{
|
||||
Menus =
|
||||
[
|
||||
new MenuBarItem (
|
||||
"_File",
|
||||
new MenuItem []
|
||||
{
|
||||
new ("_Add Blank Tab", "", AddBlankTab),
|
||||
new (
|
||||
"_Clear SelectedTab",
|
||||
"",
|
||||
() => _tabView.SelectedTab = null
|
||||
),
|
||||
new ("_Quit", "", Quit)
|
||||
}
|
||||
),
|
||||
new MenuBarItem (
|
||||
"_View",
|
||||
new []
|
||||
{
|
||||
_miShowTopLine =
|
||||
new MenuItem ("_Show Top Line", "", ShowTopLine)
|
||||
{
|
||||
Checked = true, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miShowBorder =
|
||||
new MenuItem ("_Show Border", "", ShowBorder)
|
||||
{
|
||||
Checked = true, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miTabsOnBottom =
|
||||
new MenuItem ("_Tabs On Bottom", "", SetTabsOnBottom)
|
||||
{
|
||||
Checked = false, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miShowTabViewBorder =
|
||||
new MenuItem (
|
||||
"_Show TabView Border",
|
||||
"",
|
||||
ShowTabViewBorder
|
||||
) { Checked = true, CheckType = MenuItemCheckStyle.Checked }
|
||||
}
|
||||
)
|
||||
new (
|
||||
"_File",
|
||||
new MenuItem []
|
||||
{
|
||||
new ("_Add Blank Tab", "", AddBlankTab),
|
||||
new (
|
||||
"_Clear SelectedTab",
|
||||
"",
|
||||
() => _tabView.SelectedTab = null
|
||||
),
|
||||
new ("_Quit", "", Quit)
|
||||
}
|
||||
),
|
||||
new (
|
||||
"_View",
|
||||
new []
|
||||
{
|
||||
_miShowTopLine =
|
||||
new ("_Show Top Line", "", ShowTopLine)
|
||||
{
|
||||
Checked = true, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miShowBorder =
|
||||
new ("_Show Border", "", ShowBorder)
|
||||
{
|
||||
Checked = true, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miTabsOnBottom =
|
||||
new ("_Tabs On Bottom", "", SetTabsOnBottom)
|
||||
{
|
||||
Checked = false, CheckType = MenuItemCheckStyle.Checked
|
||||
},
|
||||
_miShowTabViewBorder =
|
||||
new (
|
||||
"_Show TabView Border",
|
||||
"",
|
||||
ShowTabViewBorder
|
||||
) { Checked = true, CheckType = MenuItemCheckStyle.Checked }
|
||||
}
|
||||
)
|
||||
]
|
||||
};
|
||||
appWindow.Add (menu);
|
||||
|
||||
_tabView = new TabView
|
||||
_tabView = new()
|
||||
{
|
||||
X = 0,
|
||||
Y = 1,
|
||||
@@ -80,13 +80,13 @@ public class TabViewExample : Scenario
|
||||
BorderStyle = LineStyle.Single
|
||||
};
|
||||
|
||||
_tabView.AddTab (new Tab { DisplayText = "Tab1", View = new Label { Text = "hodor!" } }, false);
|
||||
_tabView.AddTab (new Tab { DisplayText = "Tab2", View = new TextField { Text = "durdur" } }, false);
|
||||
_tabView.AddTab (new Tab { DisplayText = "Interactive Tab", View = GetInteractiveTab () }, false);
|
||||
_tabView.AddTab (new Tab { DisplayText = "Big Text", View = GetBigTextFileTab () }, false);
|
||||
_tabView.AddTab (new() { DisplayText = "Tab1", View = new Label { Text = "hodor!" } }, false);
|
||||
_tabView.AddTab (new() { DisplayText = "Tab2", View = new TextField { Text = "durdur" } }, false);
|
||||
_tabView.AddTab (new() { DisplayText = "Interactive Tab", View = GetInteractiveTab () }, false);
|
||||
_tabView.AddTab (new() { DisplayText = "Big Text", View = GetBigTextFileTab () }, false);
|
||||
|
||||
_tabView.AddTab (
|
||||
new Tab
|
||||
new()
|
||||
{
|
||||
DisplayText =
|
||||
"Long name Tab, I mean seriously long. Like you would not believe how long this tab's name is its just too much really woooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooowwww thats long",
|
||||
@@ -100,7 +100,7 @@ public class TabViewExample : Scenario
|
||||
);
|
||||
|
||||
_tabView.AddTab (
|
||||
new Tab
|
||||
new()
|
||||
{
|
||||
DisplayText = "Les Mise" + '\u0301' + "rables", View = new Label { Text = "This tab name is unicode" }
|
||||
},
|
||||
@@ -108,7 +108,7 @@ public class TabViewExample : Scenario
|
||||
);
|
||||
|
||||
_tabView.AddTab (
|
||||
new Tab
|
||||
new()
|
||||
{
|
||||
DisplayText = "Les Mise" + '\u0328' + '\u0301' + "rables",
|
||||
View = new Label
|
||||
@@ -123,7 +123,7 @@ public class TabViewExample : Scenario
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
_tabView.AddTab (
|
||||
new Tab { DisplayText = $"Tab{i}", View = new Label { Text = $"Welcome to tab {i}" } },
|
||||
new() { DisplayText = $"Tab{i}", View = new Label { Text = $"Welcome to tab {i}" } },
|
||||
false
|
||||
);
|
||||
}
|
||||
@@ -178,13 +178,14 @@ public class TabViewExample : Scenario
|
||||
|
||||
// Run - Start the application.
|
||||
Application.Run (appWindow);
|
||||
|
||||
appWindow.Dispose ();
|
||||
|
||||
// Shutdown - Calling Application.Shutdown is required.
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
private void AddBlankTab () { _tabView.AddTab (new Tab (), false); }
|
||||
private void AddBlankTab () { _tabView.AddTab (new (), false); }
|
||||
|
||||
private View GetBigTextFileTab ()
|
||||
{
|
||||
|
||||
@@ -13,19 +13,22 @@ public class TextViewAutocompletePopup : Scenario
|
||||
private int _height = 10;
|
||||
private MenuItem _miMultiline;
|
||||
private MenuItem _miWrap;
|
||||
#if V2_STATUSBAR
|
||||
private StatusItem _siMultiline;
|
||||
private StatusItem _siWrap;
|
||||
#endif
|
||||
private Shortcut _siMultiline;
|
||||
private Shortcut _siWrap;
|
||||
private TextView _textViewBottomLeft;
|
||||
private TextView _textViewBottomRight;
|
||||
private TextView _textViewCentered;
|
||||
private TextView _textViewTopLeft;
|
||||
private TextView _textViewTopRight;
|
||||
|
||||
public override void Setup ()
|
||||
public override void Main ()
|
||||
{
|
||||
Win.Title = GetName ();
|
||||
// Init
|
||||
Application.Init ();
|
||||
|
||||
// Setup - Create a top-level application window and configure it.
|
||||
Toplevel appWindow = new ();
|
||||
|
||||
var width = 20;
|
||||
var text = " jamp jemp jimp jomp jump";
|
||||
|
||||
@@ -53,22 +56,30 @@ public class TextViewAutocompletePopup : Scenario
|
||||
)
|
||||
]
|
||||
};
|
||||
Top.Add (menu);
|
||||
appWindow.Add (menu);
|
||||
|
||||
_textViewTopLeft = new TextView { Width = width, Height = _height, Text = text };
|
||||
_textViewTopLeft = new TextView
|
||||
{
|
||||
Y = 1,
|
||||
Width = width, Height = _height, Text = text
|
||||
};
|
||||
_textViewTopLeft.DrawContent += TextViewTopLeft_DrawContent;
|
||||
Win.Add (_textViewTopLeft);
|
||||
appWindow.Add (_textViewTopLeft);
|
||||
|
||||
_textViewTopRight = new TextView { X = Pos.AnchorEnd (width), Width = width, Height = _height, Text = text };
|
||||
_textViewTopRight = new TextView
|
||||
{
|
||||
X = Pos.AnchorEnd (width), Y = 1,
|
||||
Width = width, Height = _height, Text = text
|
||||
};
|
||||
_textViewTopRight.DrawContent += TextViewTopRight_DrawContent;
|
||||
Win.Add (_textViewTopRight);
|
||||
appWindow.Add (_textViewTopRight);
|
||||
|
||||
_textViewBottomLeft = new TextView
|
||||
{
|
||||
Y = Pos.AnchorEnd (_height), Width = width, Height = _height, Text = text
|
||||
};
|
||||
_textViewBottomLeft.DrawContent += TextViewBottomLeft_DrawContent;
|
||||
Win.Add (_textViewBottomLeft);
|
||||
appWindow.Add (_textViewBottomLeft);
|
||||
|
||||
_textViewBottomRight = new TextView
|
||||
{
|
||||
@@ -79,7 +90,7 @@ public class TextViewAutocompletePopup : Scenario
|
||||
Text = text
|
||||
};
|
||||
_textViewBottomRight.DrawContent += TextViewBottomRight_DrawContent;
|
||||
Win.Add (_textViewBottomRight);
|
||||
appWindow.Add (_textViewBottomRight);
|
||||
|
||||
_textViewCentered = new TextView
|
||||
{
|
||||
@@ -90,28 +101,35 @@ public class TextViewAutocompletePopup : Scenario
|
||||
Text = text
|
||||
};
|
||||
_textViewCentered.DrawContent += TextViewCentered_DrawContent;
|
||||
Win.Add (_textViewCentered);
|
||||
appWindow.Add (_textViewCentered);
|
||||
|
||||
_miMultiline.Checked = _textViewTopLeft.Multiline;
|
||||
_miWrap.Checked = _textViewTopLeft.WordWrap;
|
||||
|
||||
var statusBar = new StatusBar (
|
||||
#if V2_STATUSBAR
|
||||
new []
|
||||
{
|
||||
new (
|
||||
Application.QuitKey,
|
||||
$"{Application.QuitKey} to Quit",
|
||||
$"Quit",
|
||||
() => Quit ()
|
||||
),
|
||||
_siMultiline = new StatusItem (KeyCode.Null, "", null),
|
||||
_siWrap = new StatusItem (KeyCode.Null, "", null)
|
||||
_siMultiline = new Shortcut (Key.Empty, "", null),
|
||||
_siWrap = new Shortcut (Key.Empty, "", null)
|
||||
}
|
||||
#endif
|
||||
);
|
||||
Top.Add (statusBar);
|
||||
|
||||
Win.LayoutStarted += Win_LayoutStarted;
|
||||
);
|
||||
appWindow.Add (statusBar);
|
||||
|
||||
appWindow.LayoutStarted += Win_LayoutStarted;
|
||||
|
||||
// Run - Start the application.
|
||||
Application.Run (appWindow);
|
||||
|
||||
appWindow.Dispose ();
|
||||
|
||||
// Shutdown - Calling Application.Shutdown is required.
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
private void Multiline ()
|
||||
@@ -138,16 +156,12 @@ public class TextViewAutocompletePopup : Scenario
|
||||
|
||||
private void SetMultilineStatusText ()
|
||||
{
|
||||
#if V2_STATUSBAR
|
||||
_siMultiline.Title = $"Multiline: {_miMultiline.Checked}";
|
||||
#endif
|
||||
}
|
||||
|
||||
private void SetWrapStatusText ()
|
||||
{
|
||||
#if V2_STATUSBAR
|
||||
_siWrap.Title = $"WordWrap: {_miWrap.Checked}";
|
||||
#endif
|
||||
}
|
||||
private void TextViewBottomLeft_DrawContent (object sender, DrawEventArgs e) { SetAllSuggestions (_textViewBottomLeft); }
|
||||
private void TextViewBottomRight_DrawContent (object sender, DrawEventArgs e) { SetAllSuggestions (_textViewBottomRight); }
|
||||
|
||||
Reference in New Issue
Block a user