~julienxx/asuka

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4

[PATCH 0/3] change line highlighting

Details
Message ID
<20210110140758.8733-1-johann@qwertqwefsday.eu>
DKIM signature
pass
Download raw message
I first updated the cursive dependency which required some slight changes, mostly renaming functions.
Then I simplified the text wrapping portion a bit to make it less verbose.
Finally switched the line highlighting to full width to address part of the issue brought up.
In hindsight probably only the last step would be necessary.

[PATCH 1/3] update cursive

Details
Message ID
<20210110140758.8733-2-johann@qwertqwefsday.eu>
In-Reply-To
<20210110140758.8733-1-johann@qwertqwefsday.eu> (view parent)
DKIM signature
pass
Download raw message
Patch: +198 -106
From: Johann150 <johann.galle@protonmail.com>

---
 Cargo.lock  | 258 +++++++++++++++++++++++++++++++++++-----------------
 Cargo.toml  |   2 +-
 src/main.rs |  44 +++++----
 3 files changed, 198 insertions(+), 106 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 4491151..532db48 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,23 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ahash"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
dependencies = [
 "const-random",
]

[[package]]
name = "ahash"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
dependencies = [
 "const-random",
]

[[package]]
name = "aho-corasick"
version = "0.7.13"
@@ -90,6 +108,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"

[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chrono"
version = "0.4.13"
@@ -101,6 +125,28 @@ dependencies = [
 "time",
]

[[package]]
name = "const-random"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4"
dependencies = [
 "const-random-macro",
 "proc-macro-hack",
]

[[package]]
name = "const-random-macro"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40"
dependencies = [
 "getrandom 0.2.1",
 "lazy_static",
 "proc-macro-hack",
 "tiny-keccak",
]

[[package]]
name = "constant_time_eq"
version = "0.1.5"
@@ -109,9 +155,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"

[[package]]
name = "core-foundation"
version = "0.7.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62"
dependencies = [
 "core-foundation-sys",
 "libc",
@@ -119,62 +165,76 @@ dependencies = [

[[package]]
name = "core-foundation-sys"
version = "0.7.0"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"

[[package]]
name = "crossbeam-channel"
version = "0.3.9"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa"
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
dependencies = [
 "crossbeam-utils 0.6.6",
 "crossbeam-utils",
 "maybe-uninit",
]

[[package]]
name = "crossbeam-utils"
version = "0.6.6"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
 "cfg-if",
 "autocfg",
 "cfg-if 0.1.10",
 "lazy_static",
]

[[package]]
name = "crossbeam-utils"
version = "0.7.2"
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"

[[package]]
name = "cursive"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a9f12332ab2bca26979ef00cfef9a1c2e287db03b787a83d892ad9961f81374"
dependencies = [
 "autocfg",
 "cfg-if",
 "ahash 0.3.8",
 "cfg-if 0.1.10",
 "crossbeam-channel",
 "cursive_core",
 "enumset",
 "lazy_static",
 "libc",
 "log",
 "maplit",
 "ncurses",
 "signal-hook",
 "term_size",
 "unicode-segmentation",
 "unicode-width",
]

[[package]]
name = "cursive"
version = "0.13.0"
name = "cursive_core"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6261747aa936aab19fc4ac3a2c1a8eee8fb5862ba96fb1e524ee56cb520d9caf"
checksum = "85fc5b6a8ba2f1bc743892068bde466438f78d6247197e2dc094bfd53fdea4b7"
dependencies = [
 "cfg-if",
 "ahash 0.4.7",
 "chrono",
 "crossbeam-channel",
 "enum-map",
 "enumset",
 "hashbrown",
 "lazy_static",
 "libc",
 "log",
 "maplit",
 "ncurses",
 "num",
 "owning_ref",
 "signal-hook",
 "term_size",
 "toml",
 "unicode-segmentation",
 "unicode-width",
 "xi-unicode",
@@ -258,9 +318,9 @@ dependencies = [

[[package]]
name = "enumset"
version = "0.4.5"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93182dcb6530c757e5879b22ebc5cfbd034861585b442819389614e223ac1c47"
checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1"
dependencies = [
 "enumset_derive",
 "num-traits",
@@ -268,9 +328,9 @@ dependencies = [

[[package]]
name = "enumset_derive"
version = "0.4.4"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "751a786cfcc7d5ceb9e0fe06f0e911da6ce3a3044633e029df4c370193c86a62"
checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac"
dependencies = [
 "darling",
 "proc-macro2",
@@ -299,22 +359,37 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"

[[package]]
name = "form_urlencoded"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
dependencies = [
 "matches",
 "percent-encoding",
]

[[package]]
name = "getrandom"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
dependencies = [
 "cfg-if",
 "cfg-if 0.1.10",
 "libc",
 "wasi",
 "wasi 0.9.0+wasi-snapshot-preview1",
]

[[package]]
name = "hashbrown"
version = "0.5.0"
name = "getrandom"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353"
checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6"
dependencies = [
 "cfg-if 1.0.0",
 "libc",
 "wasi 0.10.1+wasi-snapshot-preview1",
]

[[package]]
name = "ident_case"
@@ -357,7 +432,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
 "cfg-if",
 "cfg-if 0.1.10",
]

[[package]]
@@ -372,6 +447,12 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"

[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"

[[package]]
name = "memchr"
version = "2.3.3"
@@ -380,9 +461,9 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"

[[package]]
name = "native-tls"
version = "0.2.4"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d"
checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4"
dependencies = [
 "lazy_static",
 "libc",
@@ -409,9 +490,9 @@ dependencies = [

[[package]]
name = "num"
version = "0.2.1"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36"
checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f"
dependencies = [
 "num-complex",
 "num-integer",
@@ -422,19 +503,18 @@ dependencies = [

[[package]]
name = "num-complex"
version = "0.2.4"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5"
dependencies = [
 "autocfg",
 "num-traits",
]

[[package]]
name = "num-integer"
version = "0.1.43"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
 "autocfg",
 "num-traits",
@@ -442,9 +522,9 @@ dependencies = [

[[package]]
name = "num-iter"
version = "0.1.41"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
dependencies = [
 "autocfg",
 "num-integer",
@@ -453,9 +533,9 @@ dependencies = [

[[package]]
name = "num-rational"
version = "0.2.4"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
dependencies = [
 "autocfg",
 "num-integer",
@@ -464,9 +544,9 @@ dependencies = [

[[package]]
name = "num-traits"
version = "0.2.12"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
 "autocfg",
]
@@ -487,7 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
dependencies = [
 "bitflags",
 "cfg-if",
 "cfg-if 0.1.10",
 "foreign-types",
 "lazy_static",
 "libc",
@@ -540,6 +620,12 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"

[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"

[[package]]
name = "proc-macro2"
version = "1.0.18"
@@ -564,7 +650,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
 "getrandom",
 "getrandom 0.1.14",
 "libc",
 "rand_chacha",
 "rand_core",
@@ -587,7 +673,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
 "getrandom",
 "getrandom 0.1.14",
]

[[package]]
@@ -611,16 +697,16 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431"
dependencies = [
 "getrandom",
 "getrandom 0.1.14",
 "redox_syscall",
 "rust-argon2",
]

[[package]]
name = "regex"
version = "1.3.9"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
 "aho-corasick",
 "memchr",
@@ -630,9 +716,9 @@ dependencies = [

[[package]]
name = "regex-syntax"
version = "0.6.18"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"

[[package]]
name = "remove_dir_all"
@@ -652,7 +738,7 @@ dependencies = [
 "base64",
 "blake2b_simd",
 "constant_time_eq",
 "crossbeam-utils 0.7.2",
 "crossbeam-utils",
]

[[package]]
@@ -667,9 +753,9 @@ dependencies = [

[[package]]
name = "security-framework"
version = "0.4.4"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535"
checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69"
dependencies = [
 "bitflags",
 "core-foundation",
@@ -680,20 +766,14 @@ dependencies = [

[[package]]
name = "security-framework-sys"
version = "0.4.3"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405"
checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b"
dependencies = [
 "core-foundation-sys",
 "libc",
]

[[package]]
name = "serde"
version = "1.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"

[[package]]
name = "signal-hook"
version = "0.1.16"
@@ -714,6 +794,12 @@ dependencies = [
 "libc",
]

[[package]]
name = "smawk"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1bc737c97d093feb72e67f4926d9b22d717ce8580cd25f0ce86d74e859c466d"

[[package]]
name = "stable_deref_trait"
version = "1.1.1"
@@ -743,7 +829,7 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [
 "cfg-if",
 "cfg-if 0.1.10",
 "libc",
 "rand",
 "redox_syscall",
@@ -763,10 +849,11 @@ dependencies = [

[[package]]
name = "textwrap"
version = "0.12.1"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
checksum = "3cdcf6b66102d38821c33eea2bf1e8b7bd738072171cbf8a0683fbb46fcb8b0b"
dependencies = [
 "smawk",
 "unicode-width",
]

@@ -790,19 +877,19 @@ dependencies = [
]

[[package]]
name = "tinyvec"
version = "0.3.3"
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
 "crunchy",
]

[[package]]
name = "toml"
version = "0.5.6"
name = "tinyvec"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
 "serde",
]
checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"

[[package]]
name = "unicode-bidi"
@@ -842,10 +929,11 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"

[[package]]
name = "url"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
dependencies = [
 "form_urlencoded",
 "idna",
 "matches",
 "percent-encoding",
@@ -863,6 +951,12 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"

[[package]]
name = "wasi"
version = "0.10.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9"

[[package]]
name = "winapi"
version = "0.3.9"
diff --git a/Cargo.toml b/Cargo.toml
index 8f678e8..80d46d2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ authors = ["Julien Blanchard <julien@typed-hole.org>"]
edition = "2018"

[dependencies]
cursive = "0.13"
cursive = "0.15"
native-tls = "*"
url = "*"
regex = "*"
diff --git a/src/main.rs b/src/main.rs
index d1e3d63..4a05250 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,9 +8,9 @@ use cursive::align::HAlign;
use cursive::theme::{BaseColor, Color, Effect, PaletteColor, Style, Theme};
use cursive::traits::*;
use cursive::utils::markup::StyledString;
use cursive::view::Scrollable;
use cursive::view::{Margins, Scrollable};
use cursive::views::{Dialog, EditView, Panel, SelectView};
use cursive::Cursive;
use cursive::{Cursive, CursiveExt};

use json::object;
use regex::Regex;
@@ -56,7 +56,7 @@ fn main() {

    siv.add_fullscreen_layer(
        Dialog::around(Panel::new(
            select.with_id("main").scrollable().full_screen(),
            select.with_name("main").scrollable().full_screen(),
        ))
        .title("Asuka Browser")
        .h_align(HAlign::Center)
@@ -65,7 +65,7 @@ fn main() {
        .button("Bookmarks (B)", |s| show_bookmarks(s))
        .button("Reload (r)", |s| reload_page(s))
        .button("Quit (q)", |s| s.quit())
        .with_id("container"),
        .with_name("container"),
    );

    if args.len() > 1 {
@@ -99,10 +99,9 @@ fn prompt_for_url(s: &mut Cursive) {
    s.add_layer(
        Dialog::new()
            .title("Enter URL")
            // Padding is (left, right, top, bottom)
            .padding((1, 1, 1, 0))
            .padding(Margins::lrtb(1, 1, 1, 0))
            .content(EditView::new().on_submit(goto_url).fixed_width(20))
            .with_id("url_popup"),
            .with_name("url_popup"),
    );
}

@@ -110,8 +109,7 @@ fn prompt_for_answer(s: &mut Cursive, url: Url, message: String) {
    s.add_layer(
        Dialog::new()
            .title(message)
            // Padding is (left, right, top, bottom)
            .padding((1, 1, 1, 0))
            .padding(Margins::lrtb(1, 1, 1, 0))
            .content(
                EditView::new()
                    .on_submit(move |s, response| {
@@ -121,7 +119,7 @@ fn prompt_for_answer(s: &mut Cursive, url: Url, message: String) {
                    })
                    .fixed_width(60),
            )
            .with_id("url_query"),
            .with_name("url_query"),
    );
}

@@ -129,8 +127,7 @@ fn prompt_for_secret_answer(s: &mut Cursive, url: Url, message: String) {
    s.add_layer(
        Dialog::new()
            .title(message)
            // Padding is (left, right, top, bottom)
            .padding((1, 1, 1, 0))
            .padding(Margins::lrtb(1, 1, 1, 0))
            .content(
                EditView::new()
                    .secret()
@@ -141,7 +138,7 @@ fn prompt_for_secret_answer(s: &mut Cursive, url: Url, message: String) {
                    })
                    .fixed_width(60),
            )
            .with_id("url_query"),
            .with_name("url_query"),
    );
}

@@ -172,7 +169,7 @@ fn add_bookmark(s: &mut Cursive) {

fn show_bookmarks(s: &mut Cursive) {
    // Hide popup when pressing B on an opened popup
    if s.find_id::<Dialog>("bookmarks_popup").is_some() {
    if s.find_name::<Dialog>("bookmarks_popup").is_some() {
        s.pop_layer();
        return;
    }
@@ -192,7 +189,7 @@ fn show_bookmarks(s: &mut Cursive) {
    s.add_layer(
        Dialog::around(select.scrollable().fixed_size((50, 10)))
            .title("Bookmarks")
            .with_id("bookmarks_popup"),
            .with_name("bookmarks_popup"),
    );
}

@@ -214,7 +211,7 @@ fn reload_page(s: &mut Cursive) {

fn visit_url(s: &mut Cursive, url: &Url) {
    // Close URL popup if any
    if s.find_id::<Dialog>("url_popup").is_some() {
    if s.find_name::<Dialog>("url_popup").is_some() {
        s.pop_layer();
    }

@@ -287,10 +284,9 @@ fn handle_response_status(

fn draw_content(s: &mut Cursive, url: &Url, content: Option<Vec<u8>>) {
    if let Some(data) = content {
        let mut main_view = match s.find_id::<SelectView>("main") {
            Some(view) => view,
            None => panic!("Can't find main view."),
        };
        let mut main_view = s
            .find_name::<SelectView>("main")
            .expect("Can't find main view.");

        // set title and clear old content
        set_title(s, url.as_str());
@@ -382,7 +378,7 @@ fn draw_content(s: &mut Cursive, url: &Url, content: Option<Vec<u8>>) {
                    let l = caps.get(1).map_or("", |m| m.as_str());
                    (l.to_string(), true)
                }
                None => (line, false)
                None => (line, false),
            };

            let max_size = screen_size.x - 10 - if quoted { 2 } else { 0 };
@@ -410,7 +406,7 @@ fn draw_content(s: &mut Cursive, url: &Url, content: Option<Vec<u8>>) {
}

fn set_title(s: &mut Cursive, text: &str) {
    let mut container = match s.find_id::<Dialog>("container") {
    let mut container = match s.find_name::<Dialog>("container") {
        Some(view) => view,
        None => panic!("Can't find container view."),
    };
@@ -423,7 +419,9 @@ fn follow_line(s: &mut Cursive, line: &str) {
    if let Ok(data) = parsed {
        if link::is_gemini(&data) {
            let current_url = history::get_current_url().unwrap();
            let next_url = current_url.join(&data["url"].to_string()).expect("Not a URL");
            let next_url = current_url
                .join(&data["url"].to_string())
                .expect("Not a URL");
            visit_url(s, &next_url)
        } else {
            open::that(data["url"].to_string()).unwrap();
-- 
2.20.1

[PATCH 2/3] clean up text wrapping

Details
Message ID
<20210110140758.8733-3-johann@qwertqwefsday.eu>
In-Reply-To
<20210110140758.8733-1-johann@qwertqwefsday.eu> (view parent)
DKIM signature
pass
Download raw message
Patch: +6 -11
From: Johann150 <johann.galle@protonmail.com>

---
 src/main.rs | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 4a05250..441df85 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -381,18 +381,13 @@ fn draw_content(s: &mut Cursive, url: &Url, content: Option<Vec<u8>>) {
                None => (line, false),
            };

            let max_size = screen_size.x - 10 - if quoted { 2 } else { 0 };
            let lines = if line.len() > max_size {
                textwrap::fill(&line, max_size)
            } else {
                line
            };
            let max_size = screen_size.x - 6;
            let mut options = textwrap::Options::new(max_size);
            if quoted {
                options = options.initial_indent("> ").subsequent_indent("> ");
            }

            let lines = if quoted {
                textwrap::indent(&lines.as_str(), "> ")
            } else {
                lines
            };
            let lines = textwrap::fill(&line, options);

            if lines.is_empty() {
                main_view.add_item("", String::from("0"));
-- 
2.20.1

[PATCH 3/3] highlight full width

Details
Message ID
<20210110140758.8733-4-johann@qwertqwefsday.eu>
In-Reply-To
<20210110140758.8733-1-johann@qwertqwefsday.eu> (view parent)
DKIM signature
pass
Download raw message
Patch: +1 -1
From: Johann150 <johann.galle@protonmail.com>

---
 src/main.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.rs b/src/main.rs
index 441df85..3447184 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -56,7 +56,7 @@ fn main() {

    siv.add_fullscreen_layer(
        Dialog::around(Panel::new(
            select.with_name("main").scrollable().full_screen(),
            select.with_name("main").full_width().scrollable().full_screen(),
        ))
        .title("Asuka Browser")
        .h_align(HAlign::Center)
-- 
2.20.1

[PATCH 2/3 v2] clean up text wrapping

Details
Message ID
<674738c0-8abf-0359-af2e-0d0df1b459ce@qwertqwefsday.eu>
In-Reply-To
<20210110140758.8733-3-johann@qwertqwefsday.eu> (view parent)
DKIM signature
pass
Download raw message
Patch: +6 -11
From: Johann150 <johann.galle@protonmail.com>

fixed the width calculation, forgot to account for the scroll bar
---
  src/main.rs | 17 ++++++-----------
  1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 4a05250..2481e85 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -381,18 +381,13 @@ fn draw_content(s: &mut Cursive, url: &Url, content: Option<Vec<u8>>) {
                 None => (line, false),
             };

            let max_size = screen_size.x - 10 - if quoted { 2 } else { 0 };
            let lines = if line.len() > max_size {
                textwrap::fill(&line, max_size)
            } else {
                line
            };
            let max_size = screen_size.x - 8;
            let mut options = textwrap::Options::new(max_size);
            if quoted {
                options = options.initial_indent("> ").subsequent_indent("> ");
            }

            let lines = if quoted {
                textwrap::indent(&lines.as_str(), "> ")
            } else {
                lines
            };
            let lines = textwrap::fill(&line, options);

             if lines.is_empty() {
                 main_view.add_item("", String::from("0"));
-- 
2.20.1
Reply to thread Export thread (mbox)