网站首页 > 开源技术 正文
Terminal.Gui:用于为 .NET、.NET Core 和 Mono 构建丰富的控制台应用程序的工具包,可在 Windows、Mac 和 Linux/Unix 上运行。
快速开始
将这些命令粘贴到您最喜欢的 Windows、Mac 或 Linux 终端中。这将安装Terminal.Gui.Templates,创建一个新的“Hello World”TUI 应用程序并运行它。
(按CTRL-Q退出应用程序)
dotnet new --install Terminal.Gui.templates
dotnet new tui -n myproj
cd myproj
dotnet run
特征
- 跨平台- Windows、Mac 和 Linux。Curses、Windows Console和 .NET Console 的终端驱动程序意味着应用程序可以在彩色和单色终端上正常运行。
- 键盘和鼠标输入- 支持键盘和鼠标输入,包括对拖放的支持。
- 灵活的布局- 支持绝对布局和创新的计算布局系统。计算布局可以轻松地相对于彼此布局控件并启用动态终端 UI。
- 剪贴板支持- 通过课程提供的文本剪切、复制和粘贴Clipboard。
- 任意视图- 所有可见的 UI 元素都是该类的子类View,并且这些元素又可以包含任意数量的子视图。
- 高级应用程序功能- Mainloop支持处理事件、空闲处理程序、计时器和监视文件描述符。大多数类对于线程来说都是安全的。
- 反应式扩展- 使用反应式扩展并受益于提高的代码可读性以及应用 MVVM 模式和ReactiveUI数据绑定的能力。
C# 中的示例用法
以下示例显示了 C# 中的基本 Terminal.Gui 应用程序:
// A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements
using Terminal.Gui;
Application.Run<ExampleWindow> ();
System.Console.WriteLine (#34;Username: {((ExampleWindow)Application.Top).usernameText.Text}");
// Before the application exits, reset Terminal.Gui for clean shutdown
Application.Shutdown ();
// Defines a top-level window with border and title
public class ExampleWindow : Window {
public TextField usernameText;
public ExampleWindow ()
{
Title = "Example App (Ctrl+Q to quit)";
// Create input components and labels
var usernameLabel = new Label () {
Text = "Username:"
};
usernameText = new TextField ("") {
// Position text field adjacent to the label
X = Pos.Right (usernameLabel) + 1,
// Fill remaining horizontal space
Width = Dim.Fill (),
};
var passwordLabel = new Label () {
Text = "Password:",
X = Pos.Left (usernameLabel),
Y = Pos.Bottom (usernameLabel) + 1
};
var passwordText = new TextField ("") {
Secret = true,
// align with the text box above
X = Pos.Left (usernameText),
Y = Pos.Top (passwordLabel),
Width = Dim.Fill (),
};
// Create login button
var btnLogin = new Button () {
Text = "Login",
Y = Pos.Bottom(passwordLabel) + 1,
// center the login button horizontally
X = Pos.Center (),
IsDefault = true,
};
// When login button is clicked display a message popup
btnLogin.Clicked += () => {
if (usernameText.Text == "admin" && passwordText.Text == "password") {
MessageBox.Query ("Logging In", "Login Successful", "Ok");
Application.RequestStop ();
} else {
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
};
// Add the views to the Window
Add (usernameLabel, usernameText, passwordLabel, passwordText, btnLogin);
}
}
运行时应用程序如下所示:
示例应用程序运行
安装中
使用NuGet安装Terminal.GuiNuGet包:https://www.nuget.org/packages/Terminal.Gui
.NET Core 项目中的安装
要将 Terminal.Gui 安装到 .NET Core 项目中,请使用dotnetCLI 工具和此命令。
dotnet add package Terminal.Gui
展示柜
- UI Catalog - UI Catalog 项目提供了一个易于使用和扩展的示例,说明了Terminal.Gui的功能。运行dotnet run --project UICatalog以运行 UI 目录。
?
- PowerShell 的Out-ConsoleGridView-OCGV将命令的输出发送到交互式表。 ?
- F7History - PowerShell 的图形命令历史记录(基于 PowerShell 构建Out-ConsoleGridView)。
?
- PoshRedisViewer - 用 F# 编写的 PowerShell 紧凑型 Redis 查看器模块。
- PoshDotnetDumpAnalyzeViewer - PowerShell 的 dotnet-dump UI 模块. ?
- TerminalGuiDesigner - 用于构建 Terminal.Gui 应用程序的跨平台视图设计器。
项目地址:
https://github.com/gui-cs/Terminal.Gui
猜你喜欢
- 2024-09-30 微软 Win11 四月更新增强 Terminal 终端应用:支持输入表情符号
- 2024-09-30 Windows 11 22H2 和 23H2 将很快允许用户创建 TAR 和 7Z 压缩档
- 2024-09-30 在Windows系统和Linux系统中,如何打造一个好终端?
- 2024-09-30 让“咖喱”味的Windows 11变回清爽!
- 2024-09-30 微软新版 Windows Terminal:老款处理器的困境与解决之道
- 2024-09-30 Windows Terminal迎来0.9预览版 新增功能和Bug修复
- 2024-09-30 Windows Terminal 1.7预览版发布:改进窗口管理 优化设置UI
- 2024-09-30 Windows Terminal新版发布:终于支持鼠标输入
- 2024-09-30 告别黑底白字,微软发布新版命令行界面Windows Terminal
- 2024-09-30 微软 Windows Terminal 1.7 正式版发布
你 发表评论:
欢迎- 03-19基于layui+springcloud的企业级微服务框架
- 03-19开箱即用的前端开发模板,扩展Layui原生UI样式,集成第三方组件
- 03-19SpringMVC +Spring +Mybatis + Layui通用后台管理系统OneManageV2.1
- 03-19SpringBoot+LayUI后台管理系统开发脚手架
- 03-19layui下拉菜单form.render局部刷新方法亲测有效
- 03-19Layui 遇到的坑(记录贴)(layui chm)
- 03-19基于ASP.NET MVC + Layui的通用后台开发框架
- 03-19LayUi自定义模块的定义与使用(layui自定义表格)
- 最近发表
-
- 基于layui+springcloud的企业级微服务框架
- 开箱即用的前端开发模板,扩展Layui原生UI样式,集成第三方组件
- SpringMVC +Spring +Mybatis + Layui通用后台管理系统OneManageV2.1
- SpringBoot+LayUI后台管理系统开发脚手架
- layui下拉菜单form.render局部刷新方法亲测有效
- Layui 遇到的坑(记录贴)(layui chm)
- 基于ASP.NET MVC + Layui的通用后台开发框架
- LayUi自定义模块的定义与使用(layui自定义表格)
- Layui 2.9.11正式发布(layui2.6)
- Layui 2.9.13正式发布(layui2.6)
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)