Rename new modules to old module names
This commit is contained in:
parent
bc8c5968d6
commit
21bb87fd45
24 changed files with 46 additions and 46 deletions
12
src/ui.rs
12
src/ui.rs
|
|
@ -1,9 +1,9 @@
|
||||||
mod chat2;
|
mod chat;
|
||||||
mod euph;
|
mod euph;
|
||||||
mod input;
|
mod input;
|
||||||
mod rooms;
|
mod rooms;
|
||||||
mod util2;
|
mod util;
|
||||||
mod widgets2;
|
mod widgets;
|
||||||
|
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
@ -23,11 +23,11 @@ use crate::macros::{logging_unwrap, ok_or_return, some_or_return};
|
||||||
use crate::util::InfallibleExt;
|
use crate::util::InfallibleExt;
|
||||||
use crate::vault::Vault;
|
use crate::vault::Vault;
|
||||||
|
|
||||||
pub use self::chat2::ChatMsg;
|
pub use self::chat::ChatMsg;
|
||||||
use self::chat2::ChatState;
|
use self::chat::ChatState;
|
||||||
use self::input::{key, InputEvent, KeyBindingsList};
|
use self::input::{key, InputEvent, KeyBindingsList};
|
||||||
use self::rooms::Rooms;
|
use self::rooms::Rooms;
|
||||||
use self::widgets2::ListState;
|
use self::widgets::ListState;
|
||||||
|
|
||||||
/// Time to spend batch processing events before redrawing the screen.
|
/// Time to spend batch processing events before redrawing the screen.
|
||||||
const EVENT_PROCESSING_TIME: Duration = Duration::from_millis(1000 / 15); // 15 fps
|
const EVENT_PROCESSING_TIME: Duration = Duration::from_millis(1000 / 15); // 15 fps
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use toss::{AsyncWidget, Frame, Pos, Size, Terminal, WidthDb};
|
||||||
|
|
||||||
use crate::store::{Msg, MsgStore};
|
use crate::store::{Msg, MsgStore};
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::{util2, ChatMsg, UiError};
|
use crate::ui::{util, ChatMsg, UiError};
|
||||||
use crate::util::InfallibleExt;
|
use crate::util::InfallibleExt;
|
||||||
|
|
||||||
use self::renderer::{TreeContext, TreeRenderer};
|
use self::renderer::{TreeContext, TreeRenderer};
|
||||||
|
|
@ -255,7 +255,7 @@ impl<M: Msg, S: MsgStore<M>> TreeViewState<M, S> {
|
||||||
fn list_editor_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
fn list_editor_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
||||||
bindings.binding("esc", "close editor");
|
bindings.binding("esc", "close editor");
|
||||||
bindings.binding("enter", "send message");
|
bindings.binding("enter", "send message");
|
||||||
util2::list_editor_key_bindings_allowing_external_editing(bindings, |_| true);
|
util::list_editor_key_bindings_allowing_external_editing(bindings, |_| true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
@ -289,7 +289,7 @@ impl<M: Msg, S: MsgStore<M>> TreeViewState<M, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let handled = util2::handle_editor_input_event_allowing_external_editing(
|
let handled = util::handle_editor_input_event_allowing_external_editing(
|
||||||
editor,
|
editor,
|
||||||
terminal,
|
terminal,
|
||||||
crossterm_lock,
|
crossterm_lock,
|
||||||
|
|
@ -8,9 +8,9 @@ use toss::widgets::{EditorState, Empty, Predrawn, Resize};
|
||||||
use toss::{AsyncWidget, Size, WidthDb};
|
use toss::{AsyncWidget, Size, WidthDb};
|
||||||
|
|
||||||
use crate::store::{Msg, MsgStore, Tree};
|
use crate::store::{Msg, MsgStore, Tree};
|
||||||
use crate::ui::chat2::blocks::{Block, Blocks, Range};
|
use crate::ui::chat::blocks::{Block, Blocks, Range};
|
||||||
use crate::ui::chat2::cursor::Cursor;
|
use crate::ui::chat::cursor::Cursor;
|
||||||
use crate::ui::chat2::renderer::{self, overlaps, Renderer};
|
use crate::ui::chat::renderer::{self, overlaps, Renderer};
|
||||||
use crate::ui::ChatMsg;
|
use crate::ui::ChatMsg;
|
||||||
use crate::util::InfallibleExt;
|
use crate::util::InfallibleExt;
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@ use toss::widgets::EditorState;
|
||||||
use toss::WidthDb;
|
use toss::WidthDb;
|
||||||
|
|
||||||
use crate::store::{Msg, MsgStore};
|
use crate::store::{Msg, MsgStore};
|
||||||
use crate::ui::chat2::cursor::Cursor;
|
use crate::ui::chat::cursor::Cursor;
|
||||||
use crate::ui::ChatMsg;
|
use crate::ui::ChatMsg;
|
||||||
|
|
||||||
use super::renderer::{TreeContext, TreeRenderer};
|
use super::renderer::{TreeContext, TreeRenderer};
|
||||||
|
|
@ -5,7 +5,7 @@ use toss::widgets::{BoxedAsync, EditorState, Join2, Join4, Join5, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::store::Msg;
|
use crate::store::Msg;
|
||||||
use crate::ui::chat2::widgets::{Indent, Seen, Time};
|
use crate::ui::chat::widgets::{Indent, Seen, Time};
|
||||||
use crate::ui::ChatMsg;
|
use crate::ui::ChatMsg;
|
||||||
|
|
||||||
pub const PLACEHOLDER: &str = "[...]";
|
pub const PLACEHOLDER: &str = "[...]";
|
||||||
|
|
@ -6,8 +6,8 @@ use toss::{Style, Terminal, WidgetExt};
|
||||||
|
|
||||||
use crate::euph::{self, Room};
|
use crate::euph::{self, Room};
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::Popup;
|
use crate::ui::widgets::Popup;
|
||||||
use crate::ui::{util2, UiError};
|
use crate::ui::{util, UiError};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
enum Focus {
|
enum Focus {
|
||||||
|
|
@ -133,7 +133,7 @@ impl AccountUiState {
|
||||||
Focus::Password => bindings.binding("enter", "log in"),
|
Focus::Password => bindings.binding("enter", "log in"),
|
||||||
}
|
}
|
||||||
bindings.binding("tab", "switch focus");
|
bindings.binding("tab", "switch focus");
|
||||||
util2::list_editor_key_bindings(bindings, |c| c != '\n');
|
util::list_editor_key_bindings(bindings, |c| c != '\n');
|
||||||
}
|
}
|
||||||
Self::LoggedIn(_) => bindings.binding("L", "log out"),
|
Self::LoggedIn(_) => bindings.binding("L", "log out"),
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +166,7 @@ impl AccountUiState {
|
||||||
return EventResult::Handled;
|
return EventResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if util2::handle_editor_input_event(
|
if util::handle_editor_input_event(
|
||||||
&mut logged_out.email,
|
&mut logged_out.email,
|
||||||
terminal,
|
terminal,
|
||||||
event,
|
event,
|
||||||
|
|
@ -188,7 +188,7 @@ impl AccountUiState {
|
||||||
return EventResult::Handled;
|
return EventResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if util2::handle_editor_input_event(
|
if util::handle_editor_input_event(
|
||||||
&mut logged_out.password,
|
&mut logged_out.password,
|
||||||
terminal,
|
terminal,
|
||||||
event,
|
event,
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ use toss::{Terminal, WidgetExt};
|
||||||
|
|
||||||
use crate::euph::Room;
|
use crate::euph::Room;
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::Popup;
|
use crate::ui::widgets::Popup;
|
||||||
use crate::ui::{util2, UiError};
|
use crate::ui::{util, UiError};
|
||||||
|
|
||||||
pub fn new() -> EditorState {
|
pub fn new() -> EditorState {
|
||||||
EditorState::new()
|
EditorState::new()
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn widget(editor: &mut EditorState) -> BoxedAsync<'_, UiError> {
|
||||||
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
||||||
bindings.binding("esc", "abort");
|
bindings.binding("esc", "abort");
|
||||||
bindings.binding("enter", "authenticate");
|
bindings.binding("enter", "authenticate");
|
||||||
util2::list_editor_key_bindings(bindings, |_| true);
|
util::list_editor_key_bindings(bindings, |_| true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum EventResult {
|
pub enum EventResult {
|
||||||
|
|
@ -45,7 +45,7 @@ pub fn handle_input_event(
|
||||||
EventResult::ResetState
|
EventResult::ResetState
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if util2::handle_editor_input_event(editor, terminal, event, |_| true) {
|
if util::handle_editor_input_event(editor, terminal, event, |_| true) {
|
||||||
EventResult::Handled
|
EventResult::Handled
|
||||||
} else {
|
} else {
|
||||||
EventResult::NotHandled
|
EventResult::NotHandled
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use toss::widgets::{BoxedAsync, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::Popup;
|
use crate::ui::widgets::Popup;
|
||||||
use crate::ui::UiError;
|
use crate::ui::UiError;
|
||||||
|
|
||||||
macro_rules! line {
|
macro_rules! line {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use toss::widgets::{BoxedAsync, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::{ListState, Popup};
|
use crate::ui::widgets::{ListState, Popup};
|
||||||
use crate::ui::UiError;
|
use crate::ui::UiError;
|
||||||
|
|
||||||
pub struct LinksState {
|
pub struct LinksState {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ use toss::{Style, Terminal, WidgetExt};
|
||||||
|
|
||||||
use crate::euph::{self, Room};
|
use crate::euph::{self, Room};
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::Popup;
|
use crate::ui::widgets::Popup;
|
||||||
use crate::ui::{util2, UiError};
|
use crate::ui::{util, UiError};
|
||||||
|
|
||||||
pub fn new(joined: Joined) -> EditorState {
|
pub fn new(joined: Joined) -> EditorState {
|
||||||
EditorState::with_initial_text(joined.session.name)
|
EditorState::with_initial_text(joined.session.name)
|
||||||
|
|
@ -26,7 +26,7 @@ fn nick_char(c: char) -> bool {
|
||||||
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
||||||
bindings.binding("esc", "abort");
|
bindings.binding("esc", "abort");
|
||||||
bindings.binding("enter", "set nick");
|
bindings.binding("enter", "set nick");
|
||||||
util2::list_editor_key_bindings(bindings, nick_char);
|
util::list_editor_key_bindings(bindings, nick_char);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum EventResult {
|
pub enum EventResult {
|
||||||
|
|
@ -50,7 +50,7 @@ pub fn handle_input_event(
|
||||||
EventResult::ResetState
|
EventResult::ResetState
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if util2::handle_editor_input_event(editor, terminal, event, nick_char) {
|
if util::handle_editor_input_event(editor, terminal, event, nick_char) {
|
||||||
EventResult::Handled
|
EventResult::Handled
|
||||||
} else {
|
} else {
|
||||||
EventResult::NotHandled
|
EventResult::NotHandled
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use toss::widgets::{BoxedAsync, Empty, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::euph;
|
use crate::euph;
|
||||||
use crate::ui::widgets2::{List, ListState};
|
use crate::ui::widgets::{List, ListState};
|
||||||
use crate::ui::UiError;
|
use crate::ui::UiError;
|
||||||
|
|
||||||
pub fn widget<'a>(
|
pub fn widget<'a>(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crossterm::style::Stylize;
|
||||||
use toss::widgets::{BoxedAsync, Text};
|
use toss::widgets::{BoxedAsync, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::ui::widgets2::Popup;
|
use crate::ui::widgets::Popup;
|
||||||
use crate::ui::UiError;
|
use crate::ui::UiError;
|
||||||
|
|
||||||
pub enum RoomPopup {
|
pub enum RoomPopup {
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ use toss::{AsyncWidget, Style, Styled, Terminal, WidgetExt};
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::euph;
|
use crate::euph;
|
||||||
use crate::macros::logging_unwrap;
|
use crate::macros::logging_unwrap;
|
||||||
use crate::ui::chat2::{ChatState, Reaction};
|
use crate::ui::chat::{ChatState, Reaction};
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets2::ListState;
|
use crate::ui::widgets::ListState;
|
||||||
use crate::ui::{util2, UiError, UiEvent};
|
use crate::ui::{util, UiError, UiEvent};
|
||||||
use crate::vault::EuphRoomVault;
|
use crate::vault::EuphRoomVault;
|
||||||
|
|
||||||
use super::account::{self, AccountUiState};
|
use super::account::{self, AccountUiState};
|
||||||
|
|
@ -495,13 +495,13 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_nick_list_focus_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
fn list_nick_list_focus_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
||||||
util2::list_list_key_bindings(bindings);
|
util::list_list_key_bindings(bindings);
|
||||||
|
|
||||||
bindings.binding("i", "inspect session");
|
bindings.binding("i", "inspect session");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_nick_list_focus_input_event(&mut self, event: &InputEvent) -> bool {
|
fn handle_nick_list_focus_input_event(&mut self, event: &InputEvent) -> bool {
|
||||||
if util2::handle_list_input_event(&mut self.nick_list, event) {
|
if util::handle_list_input_event(&mut self.nick_list, event) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crossterm::style::Stylize;
|
||||||
use toss::widgets::{BoxedAsync, Empty, Join2, Text};
|
use toss::widgets::{BoxedAsync, Empty, Join2, Text};
|
||||||
use toss::{Style, Styled, WidgetExt};
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use super::widgets2::ListState;
|
use super::widgets::ListState;
|
||||||
use super::UiError;
|
use super::UiError;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ use crate::vault::Vault;
|
||||||
|
|
||||||
use super::euph::room::EuphRoom;
|
use super::euph::room::EuphRoom;
|
||||||
use super::input::{key, InputEvent, KeyBindingsList};
|
use super::input::{key, InputEvent, KeyBindingsList};
|
||||||
use super::widgets2::{List, ListState, Popup};
|
use super::widgets::{List, ListState, Popup};
|
||||||
use super::{util2, UiError, UiEvent};
|
use super::{util, UiError, UiEvent};
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
ShowList,
|
ShowList,
|
||||||
|
|
@ -405,7 +405,7 @@ impl Rooms {
|
||||||
|
|
||||||
fn list_showlist_key_bindings(bindings: &mut KeyBindingsList) {
|
fn list_showlist_key_bindings(bindings: &mut KeyBindingsList) {
|
||||||
bindings.heading("Rooms");
|
bindings.heading("Rooms");
|
||||||
util2::list_list_key_bindings(bindings);
|
util::list_list_key_bindings(bindings);
|
||||||
bindings.empty();
|
bindings.empty();
|
||||||
bindings.binding("enter", "enter selected room");
|
bindings.binding("enter", "enter selected room");
|
||||||
bindings.binding("c", "connect to selected room");
|
bindings.binding("c", "connect to selected room");
|
||||||
|
|
@ -421,7 +421,7 @@ impl Rooms {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_showlist_input_event(&mut self, event: &InputEvent) -> bool {
|
fn handle_showlist_input_event(&mut self, event: &InputEvent) -> bool {
|
||||||
if util2::handle_list_input_event(&mut self.list, event) {
|
if util::handle_list_input_event(&mut self.list, event) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,13 +519,13 @@ impl Rooms {
|
||||||
bindings.heading("Rooms");
|
bindings.heading("Rooms");
|
||||||
bindings.binding("esc", "abort");
|
bindings.binding("esc", "abort");
|
||||||
bindings.binding("enter", "connect to room");
|
bindings.binding("enter", "connect to room");
|
||||||
util2::list_editor_key_bindings(bindings, Self::room_char);
|
util::list_editor_key_bindings(bindings, Self::room_char);
|
||||||
}
|
}
|
||||||
State::Delete(_, _) => {
|
State::Delete(_, _) => {
|
||||||
bindings.heading("Rooms");
|
bindings.heading("Rooms");
|
||||||
bindings.binding("esc", "abort");
|
bindings.binding("esc", "abort");
|
||||||
bindings.binding("enter", "delete room");
|
bindings.binding("enter", "delete room");
|
||||||
util2::list_editor_key_bindings(bindings, Self::room_char);
|
util::list_editor_key_bindings(bindings, Self::room_char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -573,7 +573,7 @@ impl Rooms {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if util2::handle_editor_input_event(ed, terminal, event, Self::room_char) {
|
if util::handle_editor_input_event(ed, terminal, event, Self::room_char) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -590,7 +590,7 @@ impl Rooms {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if util2::handle_editor_input_event(editor, terminal, event, Self::room_char) {
|
if util::handle_editor_input_event(editor, terminal, event, Self::room_char) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use toss::widgets::EditorState;
|
||||||
use toss::Terminal;
|
use toss::Terminal;
|
||||||
|
|
||||||
use super::input::{key, InputEvent, KeyBindingsList};
|
use super::input::{key, InputEvent, KeyBindingsList};
|
||||||
use super::widgets2::ListState;
|
use super::widgets::ListState;
|
||||||
|
|
||||||
pub fn prompt(
|
pub fn prompt(
|
||||||
terminal: &mut Terminal,
|
terminal: &mut Terminal,
|
||||||
Loading…
Add table
Add a link
Reference in a new issue