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