[App Sharing] deptty: deepin-terminal 但用 rust 编写
Tofloor
poster avatar
st0nie
deepin
10 hours ago
Author

https://github.com/st0nie/deptty

之前突发奇想,在AI辅助下写了个 dtk 的 rust binding (https://github.com/st0nie/dtk-rs)

用这个库就能够用 rust 编写相对简单 dtk 程序了,理论上你不用写一行c++代码,但是发现遇到稍微复杂一点的需求,就会发现dtk-rs中缺少部分功能。

因此打算用这个 binding 做一个相对完整的应用程序,在开发应用的过程中完善 dtk-rs,所以就有了本项目。

deptty_0.1.0-1_amd64.tar.gz

用 rust 写 terminal 有几个好处:

  1. 可以非常方便的使用第三方库
  2. 可以避免一些比较低级的内存安全错误
  3. 可以用 cargo-deb 产出 deb 包
  4. 性能不太可能会太差

deptty 目前的完成度是基本可用,除了ssh管理器与quake模式缺失以外,其他功能基本与 deepin-terminal 一致。

deptty 的配置全部使用toml文件,详细请看 https://github.com/st0nie/deptty/blob/main/CONFIG.md

所有快捷键均可自定义,并拥有比较合理的默认快捷键(konsole 风格),deepin-terminal 默认的快捷键会和 pi agent 等应用冲突。

image.png

以下是本项目的截图:

image.png

项目使用了比较多的第三方库,因此本体代码比较少,只有 ~4000 loc,技术选型包括:

  1. 用 alacritty_terminal 作为终端库
  2. 用 portable-pty 作为 PTY wrapper
  3. 用 dtk::Paintwidget 渲染文本
    ……

具体可以看 https://github.com/st0nie/deptty/blob/main/ARCHITECTURE.md

性能方面:

image.png

本终端在 vtebench 基准测试的所有项目均明显领先于 deepin-terminal,

使用 time seq 10000000 模拟终端输出大量文本的场景,deepin-terminal 耗时 14.534s,deptty 耗时 3.363s,deptty 比 deepin-terminal 快了三倍

image.png

使用 typometer 分析输入延迟,deptty 几乎是 deepin-terminal 的一半,并且更加稳定

image.png

image.png

Reply Favorite View the author
All Replies
avatar
𰻞𰻝面
deepin
10 hours ago
#1

已安装,感觉不错

Reply View the author
avatar
181******22
deepin
9 hours ago
#2
Reply View the author
avatar
Ligocut光剪视频剪辑软件
deepin
Backbone of ecological co-construction group
9 hours ago
#3

好东西啊,那么是不是可以用rust写出所有dtk界面的软件?

Reply View the author
avatar
𰻞𰻝面
deepin
8 hours ago
#4
Ligocut光剪视频剪辑软件

好东西啊,那么是不是可以用rust写出所有dtk界面的软件?

应该不是问题

Reply View the author
avatar
st0nie
deepin
7 hours ago
#5
Ligocut光剪视频剪辑软件

好东西啊,那么是不是可以用rust写出所有dtk界面的软件?

既然终端可以写出来的话,其他应用当然也可以,我认为终端的复杂度还是比较高的

Reply View the author
avatar
st0nie
deepin
5 hours ago
#6
𰻞𰻝面

应该不是问题

我认为用 rust 写 dtk 应用最大的问题,就是系统的 rust 工具链版本比较旧。开发者通常使用 rustup 安装开发工具链来开发 rust 应用,dh_cargo 打包起来也比较麻烦,分发的话只好用 cargo deb 来分发……

Reply View the author
avatar
cuisirwork
deepin
4 hours ago
#7

厉害了我的哥。

Reply View the author
avatar
mozixun
Moderator
3 hours ago
#8
st0nie

我认为用 rust 写 dtk 应用最大的问题,就是系统的 rust 工具链版本比较旧。开发者通常使用 rustup 安装开发工具链来开发 rust 应用,dh_cargo 打包起来也比较麻烦,分发的话只好用 cargo deb 来分发……

这个问题需要去致电工信部, 或者在Better Deepin Repo上维护(Better Deepin Repo的Rust编译器版本是1.95)

Reply View the author