**Widget wrapper on Linux Systems for the surf webbrowser** An easy wrapper for the lightweight surf webbrowser on Linux systems to embed an htmlviewer into Tcl/Tk applications . Requires surf and xprop tools. *** Links *** * Surf: https://surf.suckless.org * Surf manpage: http://manpages.ubuntu.com/manpages/wily/man1/surf.1.html * Xprop manpage: https://www.x.org/releases/X11R7.5/doc/man/man1/xprop.1.html * Background for surf: http://troubleshooters.com/linux/surf.htm * Install on Linux / fedora: sudo dnf install surf xprop dmenu # (dmenu optional for Ctrl-g new url entering) * TkXext wrapped as Starkit or Zip file can be downloaded here: https://bitbucket.org/mittelmark/tcl-code/downloads/ [WikiDBImage SnitXsurf.png] Source Code: ====== ############################################################################## # # Created By : Dr. Detlef Groth # Created : Mon Jan 29 05:11:44 2018 # Last Modified : <180129.0605> # # Description : A web browser widget for Tcl/Tk using the # minimimal web browser surf see: # https://surf.suckless.org/ # # # Notes : surve can be driven by setting it's x-properties for instance # using the commandline tool xprop # as surf supports the Xembed protocol it should run without TkXext, but it did not show up without # Requirements : surf and xprop # on fedora: dnf install surf xprop # # History : 0.1 initial release 2018-01-29 # ############################################################################## # # Copyright (c) 2018 Dr. Detlef Groth. # # License BSD # package require Tk package require TkXext package require snit package provide SnitXSurf 0.1 snit::widget SnitXSurf { option -home http://www.duckduckgo.com option -search http://duckduckgo.com/?q= variable surf constructor {args} { $self configurelist $args frame $win.f -width 200 -height 200 -container 1 set sin [open "|surf -e [expr [winfo id $win.f]] dummy &" r] #exec surf -e [expr [winfo id $win.f]] dummy & # in principle we could get the xiud directly # but this does not work (yet) # -e embeds but surf is invisible still so we need TkXext fconfigure $sin -blocking false -buffering none fileevent $sin readable [list embedSurf $sin] set surf [TkXext.find.window *dummy*]; while {$surf eq ""} { after 500 set surf [TkXext.find.window *dummy*]; if {[incr x] > 20} { break } } if {$surf eq ""} { destroy $win.f return -code error "unable to find the Firefox window" } # as -e did not work for surf on Tk TkXext.reparent.window $surf [winfo id $win.f] bind $win.f [list TkXext.resize.window $surf %w %h] pack $win.f -fill both -expand 1 exec xprop -id [expr 0x$surf] -f _SURF_GO 8s -set _SURF_GO $options(-home) & bind $win.f [mymethod killSurf %W] } method browse {url} { exec xprop -id [expr 0x$surf] -f _SURF_GO 8s -set _SURF_GO $url & } method search {keyword} { exec xprop -id [expr 0x$surf] -f _SURF_GO 8s -set _SURF_GO $options(-search)$keyword & } method KillSurf {w} { TkXext.delete.or.kill $surf } method embedSurf {chan} { if {[gets $chan line] < 0} { if {[eof $chan]} { close $chan return } # Could not read a complete line this time; Tcl's # internal buffering will hold the partial line for us # until some more data is available over the socket. } else { puts stdout $line } } } if {$argv0 eq [info script]} { if {[llength $argv] <= 1 } { SnitXSurf .surf -home http://www.duckduckgo.com pack .surf -side top -fill both -expand true if {[llength $argv] == 1} { .surf browse [lindex $argv 0] } } } ====== ** Discussion ** <> Application | Internet | Snit Widgets | Snit