diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-02 17:38:27 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-07 16:02:14 -0500 |
| commit | 035344054768562bee7db12e02e3bec1c8409210 (patch) | |
| tree | 8e1c116daa1f3db6ff242b532c9ad87439f57fed /client/navigation.go | |
| parent | 5a9d7f9db6212260dd18a45d6279d1377daa5857 (diff) | |
window history
Diffstat (limited to 'client/navigation.go')
| -rw-r--r-- | client/navigation.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/client/navigation.go b/client/navigation.go new file mode 100644 index 0000000..e418445 --- /dev/null +++ b/client/navigation.go @@ -0,0 +1,38 @@ +package main + +import ( + "citrons.xyz/talk/client/window" +) + +func (a *application) removeFromHistory(location window.Location) { + for i := len(a.windowHist) - 1; i >= 0; i-- { + if a.windowHist[i] != location { + continue + } + if i < len(a.windowHist) - 1 { + a.windowHist = append(a.windowHist[:i], a.windowHist[i + 1:]...) + } else { + a.windowHist = a.windowHist[:i] + } + break + } +} + +func (a *application) traverseHistory(direction int) { + var i int + for i = 0; i < len(a.windowHist); i++ { + if a.windowHist[i] == a.currentWindow { + break + } + } + i += direction + if i >= 0 && i < len(a.windowHist) { + a.currentWindow = a.windowHist[i] + } +} + +func (a *application) goTo(location window.Location) { + a.removeFromHistory(location) + a.windowHist = append(a.windowHist, location) + a.currentWindow = location +} |
