2
0
mirror of https://github.com/xvxx/phetch synced 2024-11-10 13:10:54 +00:00

scroll to link

This commit is contained in:
dvkt 2019-12-18 21:56:37 -08:00
parent cd05894dd6
commit e7fe42d73d
2 changed files with 19 additions and 7 deletions

View File

@ -29,6 +29,7 @@
A `<gopher-url>` should be something like: A `<gopher-url>` should be something like:
- gopher.floodgap.com/1/gopher
- gopherproject.org - gopherproject.org
- gopher://txtn.ws/ - gopher://txtn.ws/
- forthworks.com/1/atua - forthworks.com/1/atua
@ -56,16 +57,18 @@ Just unzip/untar the `phetch` program into your $PATH and get going!
- http://ascii-table.com/ansi-escape-sequences.php - http://ascii-table.com/ansi-escape-sequences.php
- http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html - http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html
## TODO ## todo
### Basics ### basics
- [ ] download to ~/Downloads - [ ] download to ~/Downloads
- [ ] prompt
- [ ] go to URL
- [ ] `?` to show all keyboard shortcuts - [ ] `?` to show all keyboard shortcuts
- [ ] save history to file - [ ] save history to file
- [ ] load history from file - [ ] load history from file
- [ ] load most recent URL when opening without args - [ ] load most recent URL when opening without args
- [ ] ipv6 - [ ] ipv6
### Bonus ### bonus
- [ ] show loading spinner during gopher request - [ ] show loading spinner during gopher request
- [ ] TLS - [ ] TLS
- [ ] fuzzy find search links - [ ] fuzzy find search links
@ -74,7 +77,7 @@ Just unzip/untar the `phetch` program into your $PATH and get going!
- [ ] detect SIGWINCH - [ ] detect SIGWINCH
- https://github.com/BurntSushi/chan-signal - https://github.com/BurntSushi/chan-signal
## Screenies ## screenies
![Links](./img/links.png) ![Links](./img/links.png)

View File

@ -330,9 +330,18 @@ impl MenuView {
} }
} }
fn action_select_link(&mut self, line: usize) -> Action { fn action_select_link(&mut self, link: usize) -> Action {
if line < self.links().len() { if link < self.links().len() {
self.link = line; if let Some(&line) = self.links().get(link) {
if self.link_visibility(link) != Some(LinkDir::Visible) {
if line > SCROLL_LINES {
self.scroll = line - SCROLL_LINES;
} else {
self.scroll = 0;
}
}
}
self.link = link;
Action::Redraw Action::Redraw
} else { } else {
Action::None Action::None