yaic

yet another ii client
git clone git://git.ckyln.com/~cem/yaic.git
Log | Files | Refs | README | LICENSE

commit 9025ffe41a54831fbc6134108cf77b3225623531
parent f4a54fd4abee402429ffb35595addbcd6414e1cd
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 16 Apr 2020 19:26:32 +0300

yaic: add nickname highlighting support for the user.

Diffstat:
Myaic | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/yaic b/yaic @@ -169,20 +169,29 @@ main() { # Server messages are printed grey to be not distracting. case "$auth" in "$n") printf '%s \033[1;33m%-10.*s \033[m' "$cleardate" "$l" "$auth" ;; - "-!-") printf '\033[37m%s %-10.*s ' "$cleardate" "$l" "$auth" ;; + "-!-") printf '\033[37m%s %-10.*s ' "$cleardate" "$l" "$auth"; ;; "$ss") printf '%s %-10.*s ' "$cleardate" "$l" "$auth" ;; - *) printf '%s \033[1;36m%-10.*s \033[m' "$cleardate" "$l" "$auth" ;; + *) printf '%s \033[1;36m%-10.*s \033[m' "$cleardate" "$l" "$auth" + highlight=1 + ;; esac - # This prints the message and fold it. It doesn't add any + # This prints the message and folds it. It doesn't add any # space if it is the first line. But adds space equal to - # the space given for the time, nick, and two spaces. + # the space given for the time, nick, and two spaces. If the + # user's nick is inside the message string, highlight it, but + # only once. We get the highlight value only for messages from + # other users (i.e. not server messages or your own messages). firstline=1 - printf '%s\n' "$msg" | fold -sw "$f" | while read -r line; do + printf '%s\n' "$msg" | sed "s/$n/${highlight:+}$n${highlight:+}/" | fold -sw "$f" | while read -r line; do [ "$firstline" ] || printf '%*s' "$(( ${#cleardate} + l + 2 ))" '' - printf '%s\n' "$line"; unset firstline + printf '%s\n' "$line" ; unset firstline done + # Unset the highlight variable so that we don't highlight + # server messages. + unset highlight + # Refresh the statusbar line. statusbar