doc page, minor changes

This commit is contained in:
stjet
2025-03-16 06:04:20 +00:00
parent a2b0eeb510
commit 60cdf3afc0
9 changed files with 37 additions and 11 deletions

4
Cargo.lock generated
View File

@@ -604,9 +604,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]] [[package]]
name = "ming-wm-lib" name = "ming-wm-lib"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79963d3f8d79e0bd7b4530b52448fbcb3be82dbf6901ffa99e870b1a28f8820e" checksum = "de20ca223c0e37c8c05a69174ec8544f4c6f024a9d90321bf997882232510a42"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"

View File

@@ -8,5 +8,5 @@ name = "mingInternet_Koxinga_Browser"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
ming-wm-lib = "0.1.3" ming-wm-lib = "0.1.4"
reqwest = { version = "0.12", features = [ "blocking" ] } reqwest = { version = "0.12", features = [ "blocking" ] }

View File

@@ -11,3 +11,13 @@ Hacker News frontpage:
Wikipedia article: Wikipedia article:
![en.wikipedia.org/wiki/Ming_dynasty](koxinga_wiki.png) ![en.wikipedia.org/wiki/Ming_dynasty](koxinga_wiki.png)
## Building / Installing
After cloning the repo,
```
cargo build --release
chmod +x ./install #or ./local-install
./install
```

View File

@@ -1,2 +1,3 @@
#!/bin/sh #!/bin/sh
cp ./koxinga.md /usr/local/bin/ming_docs/window-likes/koxinga.md
cp ./target/release/mingInternet_Koxinga_Browser /usr/local/bin/mingInternet_Koxinga_Browser cp ./target/release/mingInternet_Koxinga_Browser /usr/local/bin/mingInternet_Koxinga_Browser

9
koxinga.md Normal file
View File

@@ -0,0 +1,9 @@
Koxinga is a web browser supporting text and links.
## Usage
- `u`: URL mode, where a URL can be inputted. Hit enter/return to go to that page.
- `l`: Link mode. The page will now show numbers in front of any links. Input the number corresponding to the link to navigate to, then hit enter/return.
- `j`, `k` to scroll page.
- `0`: Go to top of page.
- `G`: Go to bottom of page.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -1,2 +1,3 @@
#!/bin/sh #!/bin/sh
cp ./koxinga.md ~/.local/bin/ming_docs/window-likes/koxinga.md
cp ./target/release/mingInternet_Koxinga_Browser ~/.local/bin/mingInternet_Koxinga_Browser cp ./target/release/mingInternet_Koxinga_Browser ~/.local/bin/mingInternet_Koxinga_Browser

View File

@@ -186,7 +186,7 @@ impl WindowLike for KoxingaBrowser {
for p in &self.page { for p in &self.page {
let line_no = (p.1 - 2) / LINE_HEIGHT; let line_no = (p.1 - 2) / LINE_HEIGHT;
if line_no >= self.top_line_no && line_no < self.top_line_no + max_lines_screen { if line_no >= self.top_line_no && line_no < self.top_line_no + max_lines_screen {
instructions.push(DrawInstructions::Text([p.0, p.1 - LINE_HEIGHT * self.top_line_no], vec!["nimbus-roman".to_string()], p.2.clone(), if p.3 { theme_info.top_text } else { theme_info.text }, theme_info.background, Some(1), Some(12))); instructions.push(DrawInstructions::Text([p.0, p.1 - LINE_HEIGHT * self.top_line_no], vec!["nimbus-roman".to_string()], p.2.clone(), if p.3 { theme_info.top_text } else { theme_info.text }, theme_info.background, Some(1), Some(11)));
} }
} }
//mode //mode
@@ -195,8 +195,13 @@ impl WindowLike for KoxingaBrowser {
bottom_text += &self.url_input; bottom_text += &self.url_input;
} else if self.mode == Mode::Link { } else if self.mode == Mode::Link {
bottom_text += &self.link_input; bottom_text += &self.link_input;
} else if self.mode == Mode::Normal && self.dimensions[0] >= 500 {
bottom_text += "u (url)";
if self.url.is_some() {
bottom_text += ", l (link), j (down), k (up)";
}
} }
instructions.push(DrawInstructions::Text([0, self.dimensions[1] - LINE_HEIGHT], vec!["nimbus-roman".to_string()], bottom_text, theme_info.text, theme_info.background, Some(1), Some(12))); instructions.push(DrawInstructions::Text([0, self.dimensions[1] - LINE_HEIGHT], vec!["nimbus-roman".to_string()], bottom_text, theme_info.text, theme_info.background, Some(1), Some(11)));
instructions instructions
} }
@@ -209,7 +214,7 @@ impl WindowLike for KoxingaBrowser {
} }
fn ideal_dimensions(&self, _dimensions: Dimensions) -> Dimensions { fn ideal_dimensions(&self, _dimensions: Dimensions) -> Dimensions {
[410, 410] [500, 410]
} }
fn resizable(&self) -> bool { fn resizable(&self) -> bool {
@@ -275,7 +280,7 @@ impl KoxingaBrowser {
let mut line = String::new(); let mut line = String::new();
let mut start_x = x; let mut start_x = x;
for c in s.chars() { for c in s.chars() {
if x + 14 > self.dimensions[0] { if x + 12 > self.dimensions[0] {
//full line, add draw instruction //full line, add draw instruction
self.page.push((start_x, y, line, colour)); self.page.push((start_x, y, line, colour));
line = String::new(); line = String::new();
@@ -284,7 +289,7 @@ impl KoxingaBrowser {
y += LINE_HEIGHT; y += LINE_HEIGHT;
} }
line += &c.to_string(); line += &c.to_string();
x += 13; x += 12;
} }
if line.len() > 0 { if line.len() > 0 {
self.page.push((start_x, y, line, colour)); self.page.push((start_x, y, line, colour));

View File

@@ -15,7 +15,7 @@ fn is_whitespace(c: char) -> bool {
} }
fn handle_escaped(s: &str) -> String { fn handle_escaped(s: &str) -> String {
s.replace("&nbsp;", " ").replace("&#x27;", "'").to_string() s.replace("&nbsp;", " ").replace("&#x27;", "'").replace("&quot;", "\"").to_string()
} }
#[derive(PartialEq)] #[derive(PartialEq)]