feat: add selection, active line, and incremental highlighting to code

view
This commit is contained in:
2026-11-05 16:42:15 +07:00
parent 503b105bad
commit f272f80d09
6 changed files with 640 additions and 92 deletions
+3 -1
View File
@@ -2845,7 +2845,8 @@ struct CodeViewDemo {
impl CodeViewDemo {
fn new(cx: &mut Context<Self>) -> Self {
let code = cx.new(|_| CodeViewState::new("code-view-demo", RUST_SAMPLE, Language::Rust));
let code =
cx.new(|cx| CodeViewState::new("code-view-demo", RUST_SAMPLE, Language::Rust, cx));
// The panel is a cached view in the dock: it re-renders only when
// the code state it renders is notified.
let subscription = cx.observe(&code, |_, _, cx| cx.notify());
@@ -3214,6 +3215,7 @@ fn main() {
.with_http_client(std::sync::Arc::new(reqwest_client::ReqwestClient::new()))
.run(|cx: &mut App| {
gpui_native_core::init(cx);
gpui_native_editor::code_view::bind_code_view_keys(cx);
cx.bind_keys([
KeyBinding::new("cmd-k", OpenCommandPalette, None),
KeyBinding::new("ctrl-k", OpenCommandPalette, None),