mirror of https://github.com/helix-editor/helix
working file tree
parent
a0153fb50b
commit
e063c58d30
|
@ -1,6 +1,6 @@
|
||||||
use fuzzy_matcher::FuzzyMatcher;
|
use fuzzy_matcher::FuzzyMatcher;
|
||||||
use helix_core::{graphemes, Tendril, Selection};
|
use helix_core::{graphemes, Tendril, Selection};
|
||||||
use helix_view::{document::Mode, Document, DocumentId, Editor, editor::Action};
|
use helix_view::{document::Mode, Document, DocumentId, Editor, editor::Action, extension::document_id_to_usize};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use steel::{
|
use steel::{
|
||||||
gc::unsafe_erased_pointers::CustomReference,
|
gc::unsafe_erased_pointers::CustomReference,
|
||||||
|
@ -556,6 +556,7 @@ fn configure_engine() -> std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine:
|
||||||
|
|
||||||
engine.register_fn("editor-focus", current_focus);
|
engine.register_fn("editor-focus", current_focus);
|
||||||
engine.register_fn("editor->doc-id", get_document_id);
|
engine.register_fn("editor->doc-id", get_document_id);
|
||||||
|
engine.register_fn("doc-id->usize", document_id_to_usize);
|
||||||
engine.register_fn("editor-switch!", switch);
|
engine.register_fn("editor-switch!", switch);
|
||||||
engine.register_fn("editor-set-focus!", Editor::focus);
|
engine.register_fn("editor-set-focus!", Editor::focus);
|
||||||
engine.register_fn("editor-mode", editor_get_mode);
|
engine.register_fn("editor-mode", editor_get_mode);
|
||||||
|
@ -969,6 +970,8 @@ fn get_document_id(editor: &mut Editor, view_id: helix_view::ViewId) -> Document
|
||||||
editor.tree.get(view_id).doc
|
editor.tree.get(view_id).doc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get the document from the document id - TODO: Add result type here
|
// Get the document from the document id - TODO: Add result type here
|
||||||
fn get_document(editor: &mut Editor, doc_id: DocumentId) -> &Document {
|
fn get_document(editor: &mut Editor, doc_id: DocumentId) -> &Document {
|
||||||
editor.documents.get(&doc_id).unwrap()
|
editor.documents.get(&doc_id).unwrap()
|
||||||
|
|
|
@ -9,3 +9,7 @@ impl Custom for crate::graphics::CursorKind {}
|
||||||
impl Custom for DocumentId {}
|
impl Custom for DocumentId {}
|
||||||
impl Custom for ViewId {}
|
impl Custom for ViewId {}
|
||||||
impl CustomReference for Document {}
|
impl CustomReference for Document {}
|
||||||
|
|
||||||
|
pub fn document_id_to_usize(doc_id: &DocumentId) -> usize {
|
||||||
|
doc_id.0.into()
|
||||||
|
}
|
Loading…
Reference in New Issue