equal
deleted
inserted
replaced
121 abstract class Snapshot |
121 abstract class Snapshot |
122 { |
122 { |
123 val version: Version |
123 val version: Version |
124 val node: Node |
124 val node: Node |
125 val is_outdated: Boolean |
125 val is_outdated: Boolean |
126 def convert(i: Text.Offset): Text.Offset |
|
127 def revert(i: Text.Offset): Text.Offset |
|
128 def lookup_command(id: Command_ID): Option[Command] |
126 def lookup_command(id: Command_ID): Option[Command] |
129 def state(command: Command): Command.State |
127 def state(command: Command): Command.State |
|
128 def convert(i: Text.Offset): Text.Offset |
|
129 def convert(range: Text.Range): Text.Range = range.map(convert(_)) |
|
130 def revert(i: Text.Offset): Text.Offset |
|
131 def revert(range: Text.Range): Text.Range = range.map(revert(_)) |
130 } |
132 } |
131 |
133 |
132 object History |
134 object History |
133 { |
135 { |
134 val init = new History(List(Change.init)) |
136 val init = new History(List(Change.init)) |
158 new Snapshot |
160 new Snapshot |
159 { |
161 { |
160 val version = stable.current.join |
162 val version = stable.current.join |
161 val node = version.nodes(name) |
163 val node = version.nodes(name) |
162 val is_outdated = !(pending_edits.isEmpty && latest == stable) |
164 val is_outdated = !(pending_edits.isEmpty && latest == stable) |
163 |
|
164 def convert(offset: Text.Offset) = (offset /: edits)((i, edit) => edit.convert(i)) |
|
165 def revert(offset: Text.Offset) = (offset /: reverse_edits)((i, edit) => edit.revert(i)) |
|
166 |
|
167 def lookup_command(id: Command_ID): Option[Command] = state_snapshot.lookup_command(id) |
165 def lookup_command(id: Command_ID): Option[Command] = state_snapshot.lookup_command(id) |
168 def state(command: Command): Command.State = |
166 def state(command: Command): Command.State = |
169 try { state_snapshot.command_state(version, command) } |
167 try { state_snapshot.command_state(version, command) } |
170 catch { case _: State.Fail => command.empty_state } |
168 catch { case _: State.Fail => command.empty_state } |
|
169 |
|
170 def convert(offset: Text.Offset) = (offset /: edits)((i, edit) => edit.convert(i)) |
|
171 def revert(offset: Text.Offset) = (offset /: reverse_edits)((i, edit) => edit.revert(i)) |
171 } |
172 } |
172 } |
173 } |
173 } |
174 } |
174 |
175 |
175 |
176 |