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