diff options
-rwxr-xr-x | twerk | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/twerk b/twerk index 2cafd18..4df2ef6 100755 --- a/twerk +++ b/twerk | |||
@@ -91,6 +91,7 @@ main() { | |||
91 | format_posts > "$TWERK_FILE" | 91 | format_posts > "$TWERK_FILE" |
92 | 92 | ||
93 | read_posts "$TWERK_FILE" | 93 | read_posts "$TWERK_FILE" |
94 | # cat "$TWERK_FILE" | ||
94 | } | 95 | } |
95 | 96 | ||
96 | remain() { | 97 | remain() { |
@@ -185,18 +186,21 @@ format_posts() { | |||
185 | tr ' ' '\n' | | 186 | tr ' ' '\n' | |
186 | while IFS= read -r word | 187 | while IFS= read -r word |
187 | do | 188 | do |
189 | pword= | ||
188 | case "$word" in | 190 | case "$word" in |
189 | \@\<*\>) | 191 | \@\<*\>) |
190 | word="${word#@<}" | 192 | word="${word#@<}" |
191 | word="${word%>}" | 193 | word="${word%>}" |
192 | word="[35m@${word}[0m" | 194 | pword="[35m@${word}[0m" |
195 | word="@${word}" | ||
193 | ;; | 196 | ;; |
194 | \@\<*) | 197 | \@\<*) |
195 | read nextword | 198 | read nextword |
196 | case "$nextword" in | 199 | case "$nextword" in |
197 | *\>) | 200 | *\>) |
198 | word="${word#@<}" | 201 | word="${word#@<}" |
199 | word="[35m@${word}[0m" | 202 | pword="[35m@${word}[0m" |
203 | word="@${word}" | ||
200 | ;; | 204 | ;; |
201 | *) | 205 | *) |
202 | word="$word $nextword" | 206 | word="$word $nextword" |
@@ -205,7 +209,6 @@ format_posts() { | |||
205 | ;; | 209 | ;; |
206 | esac | 210 | esac |
207 | 211 | ||
208 | |||
209 | if test $(( linewidth + ${#word} )) -ge "$TWERK_WIDTH" | 212 | if test $(( linewidth + ${#word} )) -ge "$TWERK_WIDTH" |
210 | then | 213 | then |
211 | echo | 214 | echo |
@@ -213,7 +216,8 @@ format_posts() { | |||
213 | printf "%${TWERK_HANG}s \` " "" | 216 | printf "%${TWERK_HANG}s \` " "" |
214 | linewidth=$((linewidth+TWERK_HANG+2)) | 217 | linewidth=$((linewidth+TWERK_HANG+2)) |
215 | fi | 218 | fi |
216 | printf '%s ' "$word" | 219 | |
220 | printf '%s ' "${pword:-$word}" | ||
217 | linewidth=$((linewidth + ${#word})) | 221 | linewidth=$((linewidth + ${#word})) |
218 | done | 222 | done |
219 | echo | 223 | echo |