summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-07-02 21:57:49 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-07-02 21:57:49 -0700
commitc081af5121f648d32826c914a83ab2119f7885c9 (patch)
treeeb4299d0d130192d97358f39a1aa3a9836a6b176
parent26a32afeae757c24d829e4fbe3f9c289f8156eca (diff)
Fix fragmented highlight styles
-rw-r--r--TODO.md2
-rw-r--r--roadmap.md1
-rw-r--r--src/tui/markdown.rs19
-rw-r--r--themes/default.toml2
4 files changed, 18 insertions, 6 deletions
diff --git a/TODO.md b/TODO.md
index 53db6d6..024018a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,10 +4,10 @@
1. Move to github actions ASAP, travis & appveyor are a PITA. See resources below.
2. Refactor layout handling (see TODO on `tui::views::LayoutView::relayout`)
3. Release on AUR & Homebrew
+4. Clean up term.rs ; only keep what's actually ergonomic
### bugs
1. Shift+TAB should move focus backwards
-3. Make highlight take precedence over md styling in answer preview
### feature ideas
- Add sort option, e.g. relevance|votes|date
diff --git a/roadmap.md b/roadmap.md
index ef75cf6..759c465 100644
--- a/roadmap.md
+++ b/roadmap.md
@@ -34,6 +34,5 @@
also bring up an advanced search form that allows mutliselect of sites, select
search engine, etc.
- [ ] or `/` searches current q/a
- - [ ] clean up dingleberries in error.rs and term.rs ; only keep what's actually ergonomic
- [ ] per platform package mgmt
- [ ] more testing
diff --git a/src/tui/markdown.rs b/src/tui/markdown.rs
index 369380e..c913e9d 100644
--- a/src/tui/markdown.rs
+++ b/src/tui/markdown.rs
@@ -35,7 +35,8 @@ pub fn preprocess(input: String) -> String {
}
/// Preview markdown of the given length
-/// **Note**: Assumes preprocessing has taken place
+/// Currently removes any color (i.e. code highlighting) to avoid
+/// the jarring issue of a fragmented highlight style on focused items.
pub fn preview(width: usize, input: &StyledString) -> StyledString {
let mut w = 0;
let mut new_spans = Vec::new();
@@ -43,14 +44,14 @@ pub fn preview(width: usize, input: &StyledString) -> StyledString {
// Filter newlines
if span.width == 0 {
w += 1;
- new_spans.push(IndexedSpan {
+ new_spans.push(drop_color(IndexedSpan {
content: IndexedCow::Owned(" ".to_owned()),
width: 1,
..*span
- });
+ }));
} else {
w += span.width;
- new_spans.push(span.clone());
+ new_spans.push(drop_color(span.clone()));
}
if w > width {
break;
@@ -61,6 +62,16 @@ pub fn preview(width: usize, input: &StyledString) -> StyledString {
prev
}
+fn drop_color(span: StyledIndexedSpan) -> StyledIndexedSpan {
+ IndexedSpan {
+ attr: Style {
+ color: None,
+ ..span.attr
+ },
+ ..span
+ }
+}
+
/// Parse the given markdown text into a list of spans.
/// This is a shortcut for `Parser::new(preprocessed_input).collect()`.
fn parse_spans(input: &str) -> Vec<StyledIndexedSpan> {
diff --git a/themes/default.toml b/themes/default.toml
index 1650fa7..9cfaeaa 100644
--- a/themes/default.toml
+++ b/themes/default.toml
@@ -36,3 +36,5 @@ title_secondary = "yellow"
# Lower precision values can use only 3 digits.
highlight = "yellow"
highlight_inactive = "light yellow"
+# Note: you may want to change hightlight_text for darker terminal themes.
+highlight_text = "default" # or "black"