1 from pysize
.core
.pysize_fs_tree
import pysize_tree
2 from pysize
.core
.observable
import observable
6 next_insertion_index
= 0
7 history_observable
= observable()
10 global next_insertion_index
12 same
= next_insertion_index
and fp
== history
[next_insertion_index
- 1][0]
14 if next_insertion_index
== len(history
):
15 # History is being written
18 (paths
, name
) = history
[next_insertion_index
]
20 # History took another path, clear the remaining forward history
21 del history
[next_insertion_index
+ 1:]
22 history
[next_insertion_index
] = (fp
, tree
.root
.get_name())
23 next_insertion_index
+= 1
24 history_observable
.fire_observers(next_insertion_index
, history
)
27 if 0 <= index
and index
< len(history
):
28 return history
[index
][0]
30 def move_history(delta
):
31 global next_insertion_index
32 entry
= get_entry(next_insertion_index
- 1 + delta
)
33 next_insertion_index
+= delta
34 history_observable
.fire_observers(next_insertion_index
, history
)
38 if len(history
) > next_insertion_index
:
39 return move_history(1)
42 if next_insertion_index
> 1:
43 return move_history(-1)