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:
parent
1743322c16
commit
38f09f7893
14
src/menu.rs
14
src/menu.rs
@ -1,7 +1,7 @@
|
|||||||
use crate::gopher::{self, Type};
|
use crate::gopher::{self, Type};
|
||||||
use crate::ui::{Action, Key, View, MAX_COLS, SCROLL_LINES};
|
use crate::ui::{Action, Key, View, MAX_COLS, SCROLL_LINES};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use termion::{clear, cursor};
|
use termion::cursor;
|
||||||
|
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
pub url: String, // gopher url
|
pub url: String, // gopher url
|
||||||
@ -529,14 +529,22 @@ impl Menu {
|
|||||||
let old_link = self.link;
|
let old_link = self.link;
|
||||||
self.link = link;
|
self.link = link;
|
||||||
if self.is_visible(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 {
|
} else {
|
||||||
if pos > 5 {
|
if pos > 5 {
|
||||||
self.scroll = pos - 5;
|
self.scroll = pos - 5;
|
||||||
} else {
|
} else {
|
||||||
self.scroll = 0;
|
self.scroll = 0;
|
||||||
}
|
}
|
||||||
Action::Redraw
|
if !self.input.is_empty() {
|
||||||
|
Action::List(vec![self.redraw_input(), Action::Redraw])
|
||||||
|
} else {
|
||||||
|
Action::Redraw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Action::None
|
Action::None
|
||||||
|
@ -401,6 +401,11 @@ impl UI {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match action {
|
match action {
|
||||||
|
Action::List(actions) => {
|
||||||
|
for action in actions {
|
||||||
|
self.process_action(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
Action::Keypress(Key::Ctrl('c')) => {
|
Action::Keypress(Key::Ctrl('c')) => {
|
||||||
if !cleared {
|
if !cleared {
|
||||||
self.running = false
|
self.running = false
|
||||||
|
Loading…
Reference in New Issue
Block a user