Fixed posting and replying issues
This commit is contained in:
@@ -29,6 +29,13 @@ proc readfile {fname} {
|
||||
|
||||
# main data posting function
|
||||
proc postiidata {rooturl authstr echoname msgto subj repto text} {
|
||||
set rooturl [string trim $rooturl]
|
||||
set authstr [string trim $authstr]
|
||||
set echoname [string trim $echoname]
|
||||
set repto [string trim $repto]
|
||||
set msgto [string trim $msgto]
|
||||
set subj [string trim $subj]
|
||||
set text [string trimright $text]
|
||||
if {$repto ne ""} {set text "@repto:$repto\r\n$text"}
|
||||
set rawdata "$echoname\n$msgto\n$subj\n\n$text"
|
||||
set rawdata [encoding convertto utf-8 $rawdata]
|
||||
|
||||
@@ -107,18 +107,20 @@ proc clicklink {textw msgid} {
|
||||
}
|
||||
|
||||
proc linkinsert {textw uri is_orig} {
|
||||
global linkcount linklist tiix_bgcolor tiix_linkcolor
|
||||
global linkcount linklist tiix_bgcolor tiix_linkcolor tiix_post_repto
|
||||
if {$is_orig eq 1} {
|
||||
set tagname "orig_tiixlink_$uri"
|
||||
} else {
|
||||
set tagname "tiixlink_$uri"
|
||||
}
|
||||
$textw insert end $uri $tagname
|
||||
if {$is_orig eq 0} {
|
||||
$textw tag configure $tagname -underline on -foreground $tiix_linkcolor -background $tiix_bgcolor
|
||||
$textw tag bind $tagname <Button-1> "clicklink $textw $uri"
|
||||
$textw tag bind $tagname <Enter> {%W configure -cursor hand2}
|
||||
$textw tag bind $tagname <Leave> {%W configure -cursor $contentcursor}
|
||||
if {$is_orig eq 0} { # scroll on click
|
||||
$textw tag bind $tagname <Button-1> "clicklink $textw $uri"
|
||||
} else { # insert to repto field on click
|
||||
$textw tag bind $tagname <Button-1> "set tiix_post_repto $uri; updatefromreps; .tabbar select .tabbar.p"
|
||||
}
|
||||
incr linkcount
|
||||
lappend linklist $uri
|
||||
@@ -152,15 +154,21 @@ proc tiix_viewecho {} {
|
||||
set tz ""
|
||||
set renderedts ""
|
||||
catch { # because some servers don't provide timestamps
|
||||
set renderedts [clock format $msg(timestamp) -format {%Y-%m-%d %H:%M:%S} -timezone $tz]
|
||||
set renderedts [clock format [string trim $msg(timestamp)] -format {%Y-%m-%d %H:%M:%S} -timezone $tz]
|
||||
}
|
||||
set textw .tabbar.r.content.text
|
||||
$textw insert end "\[$renderedts\] "
|
||||
linkinsert $textw $msg(msgid) 1
|
||||
set msg(echoname) [string trim $msg(echoname)]
|
||||
set msg(msgfrom) [string trim $msg(msgfrom)]
|
||||
set msg(msgfromaddr) [string trim $msg(msgfromaddr)]
|
||||
set msg(msgto) [string trim $msg(msgto)]
|
||||
set msg(repto) [string trim $msg(repto)]
|
||||
set msg(subj) [string trim $msg(subj)]
|
||||
$textw insert end "\n$msg(echoname) - $msg(msgfrom) ($msg(msgfromaddr)) to $msg(msgto)\n"
|
||||
if {$msg(repto) ne ""} {
|
||||
$textw insert end "Replied to: "
|
||||
linkinsert $textw "$msg(repto)" 0
|
||||
linkinsert $textw $msg(repto) 0
|
||||
$textw insert end "\n"
|
||||
}
|
||||
set msg(body) [lmap s $msg(body) {string trimright $s}]
|
||||
@@ -197,6 +205,7 @@ set contentcursor "left_ptr"
|
||||
wm title . "tiix"
|
||||
wm minsize . 800 600
|
||||
ttk::notebook .tabbar
|
||||
ttk::notebook::enableTraversal .tabbar
|
||||
grid .tabbar -row 0 -column 0 -sticky nswe
|
||||
grid columnconfigure . 0 -weight 1
|
||||
grid rowconfigure . 0 -weight 1
|
||||
@@ -374,7 +383,28 @@ ttk::button .tabbar.c.cfgsave -text "Save configuration" -command {
|
||||
grid .tabbar.c.cfgsave -row $rownum -column 0 -sticky nsw -padx 5
|
||||
grid columnconfigure .tabbar.c 1 -weight 1
|
||||
|
||||
# Custom keybindings
|
||||
# Custom bindings
|
||||
|
||||
proc updatefromreps {} {
|
||||
global tiix_post_repto localdb tiix_post_to tiix_post_subj tiix_post_echoname
|
||||
set tiix_post_repto [string trim $tiix_post_repto]
|
||||
if {$tiix_post_repto ne ""} {
|
||||
sqlite3 msgdb $localdb -readonly true
|
||||
msgdb eval {SELECT * FROM `msg` WHERE `msgid`=$tiix_post_repto;} msg {
|
||||
set tiix_post_to [string trim $msg(msgfrom)]
|
||||
set tiix_post_subj [string trim $msg(subj)]
|
||||
set tiix_post_echoname [string trim $msg(echoname)]
|
||||
if {![string match "Re: *" $tiix_post_subj]} {
|
||||
set tiix_post_subj "Re: $tiix_post_subj"
|
||||
}
|
||||
}
|
||||
msgdb close
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bind .tabbar.p.addrframe.repto <Return> updatefromreps
|
||||
bind .tabbar.p.addrframe.repto <Leave> updatefromreps
|
||||
|
||||
# general keybinding switch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user