Extract unseen parse code to a new function
patch f60229b708e75d0875fccec0e71aa2867c3872c7
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun May 29 11:22:47 CEST 2016
* Extract unseen parse code to a new function
diff -rN -u old-idlebiff/idlebiff new-idlebiff/idlebiff
--- old-idlebiff/idlebiff 2024-11-22 16:20:53.660845891 +0100
+++ new-idlebiff/idlebiff 2024-11-22 16:20:53.660845891 +0100
@@ -343,7 +343,7 @@
variable ::shared::conf
variable ::shared::ka
- fileevent $con readable { parse_idle $con }
+ fileevent $con readable { parse_idle_check $con }
ask_unseen $con
enter_mailbox $con
enter_idle $con
@@ -400,30 +400,32 @@
}
}
-proc parse_idle { con } \
+proc parse_idle_check { con } \
{
variable ::shared::idle
- variable ::shared::msgs
- variable ::shared::conf
- variable ::shared::img_up
- variable ::shared::img_down
- variable ::shared::new_messages
set linea [ read_line $con ]
set prim [ string range $linea 0 0 ]
if { $prim eq "+" } { set idle 1 } \
elseif { $idle==1 } { idle_cycle $con 1 } \
- else \
+ else { parse_unseen $linea }
+}
+
+proc parse_unseen { linea } \
+{
+ variable ::shared::conf
+ variable ::shared::img_up
+ variable ::shared::img_down
+ variable ::shared::new_messages
+
+ append statusexp {^\*\s+status\s+} {"*} $conf(mailbox) {"*} {\s+\(unseen\s+(\d+)\).*$}
+ if [ regexp -lineanchor -nocase $statusexp $linea -> new_messages ] \
{
- append statusexp {^\*\s+status\s+} {"*} $conf(mailbox) {"*} {\s+\(unseen\s+(\d+)\).*$}
- if [ regexp -lineanchor -nocase $statusexp $linea -> new_messages ] \
- {
- if { $new_messages > 0 } \
- { set current $img_up } \
- else { set current $img_down }
- update_img $current
- }
- }
+ if { $new_messages > 0 } \
+ { set current $img_up } \
+ else { set current $img_down }
+ update_img $current
+ }
}
proc read_line { con } \