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

use Action::List when selecting a link

This commit is contained in:
dvkt 2020-01-02 13:08:54 -08:00
parent 1743322c16
commit 38f09f7893
2 changed files with 16 additions and 3 deletions

View File

@ -1,7 +1,7 @@
use crate::gopher::{self, Type};
use crate::ui::{Action, Key, View, MAX_COLS, SCROLL_LINES};
use std::fmt;
use termion::{clear, cursor};
use termion::cursor;
pub struct Menu {
pub url: String, // gopher url
@ -529,14 +529,22 @@ impl Menu {
let old_link = self.link;
self.link = link;
if self.is_visible(link) {
self.reset_cursor(old_link)
if !self.input.is_empty() {
Action::List(vec![self.redraw_input(), self.reset_cursor(old_link)])
} else {
self.reset_cursor(old_link)
}
} else {
if pos > 5 {
self.scroll = pos - 5;
} else {
self.scroll = 0;
}
Action::Redraw
if !self.input.is_empty() {
Action::List(vec![self.redraw_input(), Action::Redraw])
} else {
Action::Redraw
}
}
} else {
Action::None

View File

@ -401,6 +401,11 @@ impl UI {
};
match action {
Action::List(actions) => {
for action in actions {
self.process_action(action);
}
}
Action::Keypress(Key::Ctrl('c')) => {
if !cleared {
self.running = false