Implemented torsocks link opening

This commit is contained in:
Luxferre
2024-10-16 13:11:49 +03:00
parent a43cec33b3
commit b44a60f485
2 changed files with 31 additions and 9 deletions
+6
View File
@@ -36,6 +36,7 @@ The following features are already (fully or partially) supported in BFG.
* In-page text search
* Ini-based customization of the current Ttk theme, content fonts and colors
* Non-TLS mode for systems without TclTLS support
* Opening links in Torified windows (for the systems with torsocks installed)
## Non-supported features
@@ -86,6 +87,7 @@ The following keybindings are currently supported:
* Shift+d: download the file or page contents under the selected link and open it with your default application
* Space / Return (Enter): click on the selected link
* Shift + Space / Shift + Return (Enter): open the selected link in a new window
* Control + Shift + Space / Control + Shift + Return (Enter): open the selected link in a new window in Tor
* h / Arrow Left / PgUp: scroll the content up 10 lines
* j / Arrow Down: scroll the content down 1 line
* k / Arrow Up: scroll the content up 1 line
@@ -99,12 +101,16 @@ The following mouse bindings are currently supported:
* Left click: open the link
* Shift + Left click or Middle click: open the link in a new window
* Shift + Middle click or Control + Shift + Left click: open the link in a new window in Tor
* Right click: download the link contents
* Shift + Right click: download the link contents and open it with your default application
* Scroll wheel: scroll the page content
* Mouse button 8 ("Back") if present: go back in history
* Mouse button 9 ("Forward") if present: go forward in history
Note: opening a link in Tor requires Tor to be running and torsocks command to be installed in the system.
You don't need to do any special combinations to open links in Tor once the parent window is already opened via torsocks. You also cannot open new windows in clearnet from the Tor-enabled windows.
## Customization
+25 -9
View File
@@ -272,7 +272,7 @@ proc clicklink {linknum} {
}
# open link in a new window
proc windowlink {linknum} {
proc windowlink {linknum istor} {
global bfg_prompt sentry_status linklist ilinklist
global tclpath scriptpath
set url [lindex $linklist $linknum]
@@ -289,7 +289,8 @@ proc windowlink {linknum} {
unset -nocomplain bfg_prompt
}
# forward the URL to a new window
exec -ignorestderr -- $tclpath $scriptpath $url &
if {$istor eq 1} {set epath "torsocks $tclpath"} else {set epath $tclpath}
exec -ignorestderr -- {*}$epath $scriptpath $url &
}
# link downloading logic
@@ -362,9 +363,10 @@ proc linkinsert {textw prevurl rooturl url name iprefix tag} {
}
# handle possible interactive part
set bindcmd "clicklink $linkcount"
set bindcmd2 "windowlink $linkcount"
set bindcmd3 "downloadlink $linkcount 0"
set bindcmd4 "downloadlink $linkcount 1"
set bindcmd2 "windowlink $linkcount 0"
set bindcmd3 "windowlink $linkcount 1"
set bindcmd4 "downloadlink $linkcount 0"
set bindcmd5 "downloadlink $linkcount 1"
lappend ilinklist $iprefix
# perform the insertion
$textw insert end $linktext "$tagname $tag"
@@ -372,8 +374,10 @@ proc linkinsert {textw prevurl rooturl url name iprefix tag} {
$textw tag bind $tagname <Button-1> $bindcmd
$textw tag bind $tagname <Shift-Button-1> $bindcmd2
$textw tag bind $tagname <Button-2> $bindcmd2
$textw tag bind $tagname <Button-3> $bindcmd3
$textw tag bind $tagname <Shift-Button-3> $bindcmd4
$textw tag bind $tagname <Control-Shift-Button-1> $bindcmd3
$textw tag bind $tagname <Shift-Button-2> $bindcmd3
$textw tag bind $tagname <Button-3> $bindcmd4
$textw tag bind $tagname <Shift-Button-3> $bindcmd5
$textw tag bind $tagname <Enter> "set prev_status \"\$bfg_status\";set bfg_status [trunc \"$url\"];%W configure -cursor hand2"
$textw tag bind $tagname <Leave> {
set bfg_status $prev_status
@@ -1113,13 +1117,25 @@ bind . <Key> {
bind . <Shift-space> {
if {$linkcount > 0} { # we have some links
windowlink $curlink
windowlink $curlink 0
}
}
bind . <Shift-Return> {
if {$linkcount > 0} { # we have some links
windowlink $curlink
windowlink $curlink 0
}
}
bind . <Control-Shift-space> {
if {$linkcount > 0} { # we have some links
windowlink $curlink 1
}
}
bind . <Control-Shift-Return> {
if {$linkcount > 0} { # we have some links
windowlink $curlink 1
}
}