helix-mirror/helix-core/src/state.rs

43 lines
886 B
Rust
Raw Normal View History

use crate::{Rope, Selection};
/// A state represents the current editor state of a single buffer.
#[cfg_attr(feature = "debug", derive(Debug))]
2020-10-23 06:36:46 +04:00
#[derive(Clone)]
pub struct State {
pub doc: Rope,
pub selection: Selection,
}
impl State {
2020-05-28 09:45:44 +04:00
#[must_use]
pub fn new(doc: Rope) -> Self {
Self {
2020-06-01 12:42:28 +04:00
doc,
selection: Selection::point(0),
}
}
// update/transact:
// update(desc) => transaction ? transaction.doc() for applied doc
// transaction.apply(doc)
// doc.transact(fn -> ... end)
// replaceSelection (transaction that replaces selection)
// changeByRange
// changes
// slice
//
// getters:
// tabSize
// indentUnit
// languageDataAt()
//
// config:
// indentation
// tabSize
// lineUnit
// syntax
// foldable
// changeFilter/transactionFilter
}