Skip to content

Commit

Permalink
Support CSI SGR 9
Browse files Browse the repository at this point in the history
add support for strikethrough

Closes #43
  • Loading branch information
seeeturtle committed Dec 24, 2018
1 parent edda82c commit 20d19df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/asciinema/player/view.cljs
Expand Up @@ -42,16 +42,17 @@
color)]
(str prefix color))))

(defn part-class-name [{:keys [fg bg bold blink underline inverse italic cursor]}]
(defn part-class-name [{:keys [fg bg bold blink underline inverse italic strikethrough cursor]}]
(let [fg-final (if inverse (or bg "bg") fg)
bg-final (if inverse (or fg "fg") bg)
fg-class (color-class-name fg-final bold "fg-")
bg-class (color-class-name bg-final blink "bg-")
bold-class (when bold "bright")
italic-class (when italic "italic")
underline-class (when underline "underline")
strikethrough-class (when strikethrough "strikethrough")
cursor-class (when cursor "cursor")
classes (remove nil? [fg-class bg-class bold-class italic-class underline-class cursor-class])]
classes (remove nil? [fg-class bg-class bold-class italic-class underline-class strikethrough-class cursor-class])]
(when (seq classes)
(string/join " " classes))))

Expand Down
4 changes: 4 additions & 0 deletions src/less/partials/_terminal.less
Expand Up @@ -34,6 +34,10 @@
font-style: italic;
}

.strikethrough {
text-decoration: line-through;
}

&.font-small {
font-size: 12px;
}
Expand Down
1 change: 1 addition & 0 deletions test/asciinema/player/view_test.cljs
Expand Up @@ -24,6 +24,7 @@
{:fg 1 :bold true} {:class-name "fg-9 bright"}
{:fg 9 :bold true} {:class-name "fg-9 bright"}
{:fg 1 :bg 2 :underline true} {:class-name "fg-1 bg-2 underline"}
{:fg 1 :bg 2 :strikethrough true} {:class-name "fg-1 bg-2 strikethrough"}
{:fg [1 2 3] :bg [4 5 6] :bold true :underline true} {:class-name "bright underline" :style {:color "rgb(1,2,3)" :background-color "rgb(4,5,6)"}}
;; inversed colors
{:inverse true} {:class-name "fg-bg bg-fg"}
Expand Down

0 comments on commit 20d19df

Please sign in to comment.