Skip to content

Commit

Permalink
Merge 'rewrite-mwp'
Browse files Browse the repository at this point in the history
This wil re-implement all of the existing features of the old 
application into the new one. The user experience is as close
as possible to the old one
  • Loading branch information
Builditluc authored Jul 31, 2024
2 parents 1ffc3ee + 0bc02bb commit fad87a2
Show file tree
Hide file tree
Showing 29 changed files with 1,700 additions and 625 deletions.
126 changes: 103 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ futures = "0.3.28"
human-panic = "1.2.2"
libc = "0.2.147"
log = "0.4.20"
ratatui = "0.24.0"
ratatui = "0.26.3"
signal-hook = "0.3.17"
textwrap = { version = "0.16.0", features = ["smawk"] }
tokio = { version = "1.32.0", features = ["full"] }
Expand All @@ -33,13 +33,8 @@ tokio-util = "0.7.8"
tracing = "0.1.37"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tui-input = "0.8.0"

#tui-logger = { version = "0.9.6", default-features = false, features = ["ratatui-support", "tracing-support"] }
# Until tui-logger releases a new version with ratatui v0.24, we have to use the git repository
tui-logger = { git = "https://github.com/gin66/tui-logger/", rev = "b9460de320b25a9862d54d151519487f414579d3", default-features = false, features = [ "tracing-support" ]}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
tui-input = "0.9"
tui-logger = { version = "0.11.1", default-features = false, features = ["crossterm", "tracing-support"] }

[dependencies.wiki-api]
path = "wiki-api"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.71.1
1.77.2
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pkgs.mkShell {
nativeBuildInputs = with pkgs; [ libiconv rustup ];

buildInputs = with pkgs; [ openssl ncurses pkg-config ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];

packages = [ pkgs.mdbook ];
packages = [ pkgs.gdb ];

RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
28 changes: 24 additions & 4 deletions src/action.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::fmt::Debug;

use tokio::sync::mpsc;
use wiki_api::{page::Page, search::Search};
use wiki_api::{
languages::Language,
page::{LanguageLink, Link, Page},
search::{Search, SearchResult},
};

use crate::components::page::Renderer;

Expand All @@ -15,7 +19,15 @@ pub enum Action {

// View Focus
ToggleShowLogger,
ToggleShowHelp,
ShowPageLanguageSelection,

/// PopupMessage(Title, Content)
PopupMessage(String, String),
/// PopupError(Error)
PopupError(String),
/// PopupError(Title, Content, Callback)
PopupDialog(String, String, Box<ActionPacket>),
PopPopup,

SwitchContextSearch,
SwitchContextPage,
Expand Down Expand Up @@ -45,7 +57,9 @@ pub enum Action {
ExitSearchBar,

// Page loading
LoadPage(String),
LoadSearchResult(SearchResult),
LoadLink(Link),
LoadLangaugeLink(LanguageLink),

Search(SearchAction),
Page(PageAction),
Expand All @@ -56,13 +70,17 @@ pub enum Action {
pub enum SearchAction {
StartSearch(String),
FinshSearch(Search),
ContinueSearch,
ClearSearchResults,
OpenSearchResult,
ChangeMode(crate::components::search::Mode),
ChangeLanguage(Language),
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PageAction {
SwitchRenderer(Renderer),
ToggleContents,

SelectFirstLink,
SelectLastLink,
Expand All @@ -72,6 +90,8 @@ pub enum PageAction {

SelectPrevLink,
SelectNextLink,

GoToHeader(String),
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -107,7 +127,7 @@ impl From<ActionPacket> for ActionResult {
}
}

#[derive(Default)]
#[derive(Default, Clone, PartialEq, Eq)]
pub struct ActionPacket {
actions: Vec<Action>,
}
Expand Down
Loading

0 comments on commit fad87a2

Please sign in to comment.