# Welcome to GPUI!
GPUI is a hybrid immediate and retained mode, GPU accelerated, UI framework
for Rust, designed to support a wide variety of applications.
## Getting Started
GPUI is still in active development as we work on the Zed code editor and isn't yet on crates.io. You'll also need to use the latest version of stable rust and be on macOS. Add the following to your Cargo.toml:
```
gpui = { git = "https://github.com/zed-industries/zed" }
```
Everything in GPUI starts with an `App`. You can create one with `App::new()`, and kick off your application by passing a callback to `App::run()`. Inside this callback, you can create a new window with `AppContext::open_window()`, and register your first root view. See [gpui.rs](https://www.gpui.rs/) for a complete example.
## The Big Picture
GPUI offers three different [registers](https://en.wikipedia.org/wiki/Register_(sociolinguistics)) depending on your needs:
- State management and communication with Models. Whenever you need to store application state that communicates between different parts of your application, you'll want to use GPUI's models. Models are owned by GPUI and are only accessible through an owned smart pointer similar to an `Rc`. See the `app::model_context` module for more information.
- High level, declarative UI with Views. All UI in GPUI starts with a View. A view is simply a model that can be rendered, via the `Render` trait. At the start of each frame, GPUI will call this render method on the root view of a given window. Views build a tree of `elements`, lay them out and style them with a tailwind-style API, and then give them to GPUI to turn into pixels. See the `div` element for an all purpose swiss-army knife of rendering.
- Low level, imperative UI with Elements. Elements are the building blocks of UI in GPUI, and they provide a nice wrapper around an imperative API that provides as much flexibility and control as you need. Elements have total control over how they and their child elements are rendered and and can be used for making efficient views into large lists, implement custom layouting for a code editor, and anything else you can think of. See the `element` module for more information.
Each of these registers has one or more corresponding contexts that can be accessed from all GPUI services. This context is your main interface to GPUI, and is used extensively throughout the framework.
## Other Resources
In addition to the systems above, GPUI provides a range of smaller services that are useful for building complex applications:
- Actions are user-defined structs that are used for converting keystrokes into logical operations in your UI. Use this for implementing keyboard shortcuts, such as cmd-q. See the `action` module for more information.
- Platform services, such as `quit the app` or `open a URL` are available as methods on the `app::AppContext`.
- An async executor that is integrated with the platform's event loop. See the `executor` module for more information.,
- The `[gpui::test]` macro provides a convenient way to write tests for your GPUI applications. Tests also have their own kind of context, a `TestAppContext` which provides ways of simulating common platform input. See `app::test_context` and `test` modules for more details.
Currently, the best way to learn about these APIs is to read the Zed source code, ask us about it at a fireside hack, or drop a question in the [Zed Discord](https://discord.gg/U4qhCEhMXP). We're working on improving the documentation, creating more examples, and will be publishing more guides to GPUI on our [blog](https://zed.dev/blog).
没有合适的资源?快使用搜索试试~ 我知道了~
基于Rust的一款支持多人协作的代码编辑器项目源码,默认支持 Rust,还自带了 rust-analyzer,主打高性能
共1725个文件
rs:691个
scm:206个
toml:158个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 39 浏览量
2024-03-03
15:53:34
上传
评论
收藏 13.58MB ZIP 举报
温馨提示
基于Rust的一款支持多人协作的代码编辑器项目源码,默认支持 Rust,还自带了 rust-analyzer,主打高性能
资源推荐
资源详情
资源评论
收起资源包目录
基于Rust的一款支持多人协作的代码编辑器项目源码,默认支持 Rust,还自带了 rust-analyzer,主打高性能 (1725个子文件)
bootstrap 261B
bump-nightly 234B
bump-zed-minor-versions 3KB
bump-zed-patch-version 360B
bundle 12KB
clear-target-dir-if-larger-than 487B
clippy 418B
basic.conf 291B
admin_api.conf 141B
crate-dep-graph 313B
deploy-collab 398B
deploy-postgrest 490B
Dockerfile 976B
.dockerignore 146B
drop-test-dbs 243B
zed.entitlements 863B
evaluate_semantic_index 93B
generate-eula-rtf 310B
generate-licenses 926B
get-changes-since 2KB
get-crate-version 269B
get-preview-channel-changes 3KB
.gitattributes 115B
.gitignore 391B
.gitignore 15B
.gitignore 14B
.gitignore 13B
.gitkeep 0B
.gitmodules 129B
bindings.h 203B
dispatch.h 60B
histogram 3KB
import-themes 41B
prettier_server.js 9KB
atelier.json 242KB
test_change_surrounding_character_objects.json 95KB
test_delete_surrounding_character_objects.json 95KB
gruvbox.json 71KB
rose_pine.json 36KB
ayu.json 35KB
test_change_word_object.json 30KB
test_delete_word_object.json 30KB
one.json 24KB
solarized.json 23KB
default.json 22KB
test_capital_f_and_capital_t.json 21KB
default-macos.json 19KB
test_f_and_t.json 19KB
default-linux.json 19KB
test_visual_word_object.json 16KB
vim.json 15KB
sandcastle.json 12KB
summercamp.json 12KB
andromeda.json 12KB
test_repeated_cl.json 10KB
test_repeated_cb.json 10KB
test_repeated_ce.json 10KB
test_change_sentence_object.json 10KB
test_delete_sentence_object.json 10KB
test_repeated_word.json 9KB
test_repeated_cj.json 9KB
file_types.json 7KB
jetbrains.json 3KB
test_b.json 3KB
textmate.json 3KB
gpt-engineer.json 3KB
tree-sitter.json 3KB
test_percent.json 2KB
test_wrapped_lines.json 2KB
atom.json 2KB
test_w.json 2KB
test_visual_block_mode.json 2KB
sublime_text.json 2KB
test_repeat_visual.json 2KB
test_end_of_word.json 2KB
test_visual_delete.json 1KB
test_visual_change.json 1KB
test_paste_visual.json 1KB
test_paste.json 1KB
test_visual_line_change.json 1KB
test_visual_yank.json 1KB
test_ctrl_d_u.json 1KB
test_comma_semicolon.json 1018B
test_previous_word_end.json 1017B
test_jump_to_line_boundaries.json 982B
test_substitute_line.json 978B
test_visual_line_delete.json 899B
test_multiline_surrounding_character_objects.json 888B
test_gg.json 874B
test_paste_visual_block.json 872B
initial_tasks.json 817B
test_insert_with_counts.json 811B
test_window_bottom.json 800B
test_dot_repeat.json 794B
test_delete_w.json 784B
test_end_of_document.json 774B
test_change_w.json 769B
test_singleline_surrounding_character_objects.json 765B
test_matching.json 761B
test_insert_line_above.json 746B
共 1725 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
程序员柳
- 粉丝: 6910
- 资源: 1465
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功