$ tar xvzf notebook.tar.gz $ cd notebookkit $ patch -p1 < patchfile patching file Makefile ...The patch utility is available on any Unix system. Windows users can get a native port at <http://www.weihenstephan.de/~syring/win32/UnxUtils.html> or get a current Cygwin Environment at <http://www.cygwin.com> which allows the use of a lot of other great Unix tools as well.In general, every line prefixed by a plus sign has been added, every line with a minus sign has been removed. Lines with an exclamation mark are exchanged against something different usually mentioned below a line of some minus signs. The patch also indicates the changed file names, a rough line position in the file and some context around the patched lines.For a description of what a patch does, please have a look at the header lines.Patch 0:
*********************************************************************** Patch file for notebook Version 1.1 Turns original Makefile into Unix Makefile, thereby assuming that TCL installation is under /usr/local/tcl, with the library directory at TCLLIB=/usr/local/tcl/lib and the packages are located under $(TCLLIB)/bwidget1.6 $(TCLLIB)/tcllib1.4 $(TCLLIB)/snit $(TCLLIB)/trycatch *********************************************************************** diff -Nawur notebookkit-1.1.orig/Makefile notebookkit-1.1/Makefile --- notebookkit-1.1.orig/Makefile Sun Jul 20 23:26:21 2003 +++ notebookkit-1.1/Makefile Mon Jul 21 19:42:13 2003 @@ -1,41 +1,34 @@ -WINKIT = /Users/will/tclkit/tclkit-win32.upx.exe -OSXKIT = /Users/will/tclkit/tclkit-darwin-ppc +WKIT = /Users/will/tclkit/tclkit-win32.upx.exe +TCLLIB=/usr/local/tcl/lib all: @echo "Use 'make build' to build the executable." @echo "Use 'make install' to install it." install: - cp -r * /Users/will/bin/notebookkit - -dist: build - cp notebook.exe notebook notebook.kit README.txt \ - /Users/will/work/wjduquette/notebook - make clean - cd .. ; tar cvf notebook1.1.tar notebookkit ; gzip notebook1.1.tar - cp ../notebook1.1.tar.gz /Users/will/work/wjduquette/notebook - -build: update buildvfs buildexe + cp notebook.exe /local/bin update: update.tcl cp -f help.nbk lib/app-notebook +build: update buildvfs buildexe + buildvfs: mkdir -p ./notebook.vfs cp main.tcl ./notebook.vfs cp -r lib ./notebook.vfs rm -rf ./notebook.vfs/lib/CVS rm -rf ./notebook.vfs/lib/*/CVS - cp -r /Library/Tcl/bwidget1.6 ./notebook.vfs/lib - cp -r /Library/Tcl/tcllib1.3 ./notebook.vfs/lib - cp -r /Users/will/Library/Tcl/snit ./notebook.vfs/lib - cp -r /Users/will/Library/Tcl/trycatch ./notebook.vfs/lib + cp -r $(TCLLIB)/bwidget1.6 ./notebook.vfs/lib + cp -r $(TCLLIB)/tcllib1.4 ./notebook.vfs/lib + cp -r $(TCLLIB)/snit ./notebook.vfs/lib + cp -r $(TCLLIB)/trycatch ./notebook.vfs/lib buildexe: - sdx.kit wrap notebook.exe -runtime $(WINKIT) - sdx.kit wrap notebook -runtime $(OSXKIT) sdx.kit wrap notebook.kit + #sdx.kit wrap notebook.kit -writable + # sdx.kit wrap notebook.exe -runtime $(WKIT) clean: - -rm -rf notebook.vfs notebook.exe notebook.kit notebook.bat notebook + -rm -rf notebook.vfs notebook.exe notebook.kit notebook.batPatch 1:
*********************************************************************** Patch file for notebook Version 1.1 Add functionality to use <TAB> for jumping forward to next link, and underlining the link; and <RETURN> or <SPACE> to follow the link. By Ramon Ribó Rodríguez, Barcelona, Spain *********************************************************************** diff -Nawur notebookkit-1.1.orig/lib/app-notebook/renderpane.tcl notebookkit-1.1/lib/app-notebook/renderpane.tcl --- notebookkit-1.1.orig/lib/app-notebook/renderpane.tcl Sun Jun 29 23:21:31 2003 +++ notebookkit-1.1/lib/app-notebook/renderpane.tcl Mon Jul 21 22:35:49 2003 @@ -121,6 +121,74 @@ # Prepare to receive preferences events; unregister on # destroy. prefs register $selfns [mymethod UsePreferences] + + + # ramsan + bind $win.pane <Tab> { + set range [%W tag ranges act] + if { $range == "" } { + set iniidx 1.0 + } else { set iniidx [lindex $range 1] } + + set newrange "" + foreach tag "link button img" { + set r [%W tag nextrange $tag $iniidx] + if { $r == "" } { continue } + if { $newrange == "" || \ + [%W compare [lindex $newrange 0] > [lindex $r 0]] } { + set newrange $r + set tagname $tag + } + } + if { $newrange == "" && [%W compare $iniidx != 1.0] } { + foreach tag "link button img" { + set r [%W tag nextrange $tag 1.0 $iniidx] + if { $r == "" } { continue } + if { $newrange == "" || \ + [%W compare [lindex $newrange 0] > [lindex $r 0]] } { + set newrange $r + set tagname $tag + } + } + } + if { $newrange == "" } { + bell + } else { + %W tag delete act + if { $tagname != "img" } { + %W tag conf act -underline 1 + } else { + %W tag conf act -background red + %W image configure [lindex $newrange 0] -padx 1 -pady 1 + } + eval %W tag add act $newrange + %W see [lindex $newrange 0] + } + break + } + # ramsan + bind $win.pane <Return> { + set range [%W tag ranges act] + if { $range == "" } { break } + set idx [lindex $range 0] + if { [lsearch [%W tag names $idx] link] != -1 } { + set comm [%W tag bind link <1>] + if { $comm == "" } { set comm [%W tag bind link <ButtonRelease-1>] } + } elseif { [lsearch [%W tag names $idx] button] != -1 } { + set comm [%W tag bind button <1>] + if { $comm == "" } { set comm [%W tag bind button <ButtonRelease-1>] } + } elseif { [lsearch [%W tag names $idx] img] != -1 } { + set ipos [lsearch -glob [%W tag names $idx] img,*] + set tag [lindex [%W tag names $idx] $ipos] + set comm [%W tag bind $tag <1>] + if { $comm == "" } { set comm [%W tag bind $tag <ButtonRelease-1>] } + } else { break } + foreach "x y wi he" [%W bbox $idx] break + set comm [string map [list %%x $x %%y $y] $comm] + eval $comm + } + # ramsan + bind $win.pane <space> [bind $win.pane <Return>] } destructor {Patch 2:
*********************************************************************** Patch file for notebook Version 1.1 Add's support for tag '#unpre' to switch back from preformatted to normal mode. Good for inserting code examples. Patch supplied by Guido Ostkamp *********************************************************************** diff -Nawur notebookkit-1.1.orig/lib/app-notebook/renderpane.tcl notebookkit-1.1/lib/app-notebook/renderpane.tcl --- notebookkit-1.1.orig/lib/app-notebook/renderpane.tcl Sun Jun 29 23:21:31 2003 +++ notebookkit-1.1/lib/app-notebook/renderpane.tcl Mon Jul 21 22:35:49 2003 @@ -288,6 +356,8 @@ if {[string match "#---*" $value]} { $self InsertHLine } elseif {[string match "#pre*" $value]} { + # Skip it. + } elseif {[string match "#unpre*" $value]} { # Skip it. } else { $self insert end $value pre diff -Nawur notebookkit-1.1.orig/lib/markupparser/markupparser.tcl notebookkit-1.1/lib/markupparser/markupparser.tcl --- notebookkit-1.1.orig/lib/markupparser/markupparser.tcl Sun Jun 29 23:12:42 2003 +++ notebookkit-1.1/lib/markupparser/markupparser.tcl Mon Jul 21 23:21:41 2003 @@ -71,6 +71,14 @@ return -1 } +proc ::markupparser::FindEndOfLine {text} { + if {[regexp -indices {(\n)} $text match]} { + return [lindex $match 0] + } + return -1 +} + + # debugHandler tag value # # tag: A parsed markup tag @@ -314,6 +322,7 @@ # Parses text, generating a list directly proc ::markupparser::parse {text} { set result {} + set premode 0 # Q: Would scanning the string without modification be quicker? while {[string length $text] > 0} { @@ -329,9 +338,24 @@ lappend result HASH $para if {[string match "#pre*" $para] || [string match "#Tcl*" $para]} { - lappend result PRE $text + set premode 1 + } elseif {[string match "#unpre*" $para]} { + set premode 0 + } + continue + } + + if { $premode == 1 } { + set eop [FindEndOfLine $text] + + if {$eop == -1} { + set para $text set text "" + } else { + set para [string range $text 0 $eop] + set text [string range $text [expr {$eop + 1}] end] } + lappend result PRE $para continue }
Patch 3:WHD: Notebook 1.2 includes this patch (or, really, a more thorough version; the Win-style Cut, Copy and Paste keys will work anywhere you can edit or copy text).
*********************************************************************** Patch file for notebook Version 1.1 Add proper mapping to Ctrl-c, Ctrl-x and Ctrl-v for Copy, Cut, and Paste functionality under Unix (otherwise this actions are only available through Meta-w, Control-w, Control-y). Patch supplied by Guido Ostkamp *********************************************************************** diff -Nawur notebookkit-1.1.orig/lib/app-notebook/pageeditor.tcl notebookkit-1.1/lib/app-notebook/pageeditor.tcl --- notebookkit-1.1.orig/lib/app-notebook/pageeditor.tcl Sun Jul 20 23:14:42 2003 +++ notebookkit-1.1/lib/app-notebook/pageeditor.tcl Tue Jul 22 22:54:47 2003 @@ -118,6 +118,12 @@ [list $win.pane.text insert insert "&lb;"] bind $win.pane.text <Control-bracketright> \ [list $win.pane.text insert insert "&rb;"] + bind $win.pane.text <Control-c> \ + [tk_textCopy $win.pane.text] + bind $win.pane.text <Control-v> \ + [tk_textPaste $win.pane.text] + bind $win.pane.text <Control-x> \ + [tk_textCut $win.pane.text] #TBD bind $win.pane.text <Tab> \
Patch 4:WHD: Notebook 1.2 includes an equivalent fix.
*********************************************************************** Patch file for notebook Version 1.1 Use confirmation for <ESC> key after editing only, if something was changed. For copy only actions, this is not necessary. Patch supplied by Guido Ostkamp *********************************************************************** diff -Nawur notebookkit-1.1.orig/lib/app-notebook/pageeditor.tcl notebookkit-1.1/lib/app-notebook/pageeditor.tcl --- notebookkit-1.1.orig/lib/app-notebook/pageeditor.tcl Sun Jul 20 23:14:42 2003 +++ notebookkit-1.1/lib/app-notebook/pageeditor.tcl Tue Jul 22 22:54:47 2003 @@ -148,6 +154,7 @@ $self Revert + $win.pane.text edit modified 0 focus $win.pane.text } @@ -372,6 +379,7 @@ # Cancel editing. method Cancel {} { + if { [$win.pane.text edit modified] == 1 } { set result [tk_messageBox -icon question -parent $win \ -title "Are you sure?" \ -message "Return to browser without saving?" \ @@ -380,6 +388,7 @@ if {$result ne "yes"} { return + } } uplevel \#0 $options(-endcmd) [list $current 0] +# End of Notebook Database FilePatch 5:
*********************************************************************** Patch file for notebook Version 1.1 Move text 'User Menu' to the bottom of the user menu, so that the 'back' button is the first one to appear. This shortens the way for the mouse. Patch supplied by Guido Ostkamp *********************************************************************** diff -Naur notebookkit-1.1.orig/lib/app-notebook/pagebrowser.tcl notebookkit/lib/app-notebook/pagebrowser.tcl --- notebookkit-1.1.orig/lib/app-notebook/pagebrowser.tcl Sun Jul 20 16:51:35 2003 +++ notebookkit/lib/app-notebook/pagebrowser.tcl Wed Jul 23 18:52:16 2003 @@ -1311,12 +1311,6 @@ # FIRST, delete any existing items. $pv.rp.user delete 0 end - # NEXT, add the standard boilerplate. - $pv.rp.user add command \ - -label "User Menu" \ - -state disabled - $pv.rp.user add separator - # NEXT, retrieve the user's choices set items [$w eval usermenu] @@ -1326,6 +1320,12 @@ -label $label \ -command [list $w eval $command] } + $pv.rp.user add separator + + # NEXT, add the standard boilerplate. + $pv.rp.user add command \ + -label "User Menu" \ + -state disabled }Patch 6:bttr 2017-11-01: Notebook 2.2.0 includes an equivalent fix. Probably also earlier versions.
*********************************************************************** Patch file for notebook Version 1.1 If viewing (not editing) a page, make key up and down immediately scroll the page by one line - and not just an invisible cursor. Attention: Patch1 must be applied before using this one. Patch supplied by Guido Ostkamp *********************************************************************** diff -Naur notebookkit-patch1/lib/app-notebook/renderpane.tcl notebookkit/lib/app-notebook/renderpane.tcl --- notebookkit-patch1/lib/app-notebook/renderpane.tcl Sat Jul 26 13:00:28 2003 +++ notebookkit/lib/app-notebook/renderpane.tcl Sat Jul 26 13:01:29 2003 @@ -189,6 +189,9 @@ } # ramsan bind $win.pane <space> [bind $win.pane <Return>] + + bind $win.pane <Key-Down> { %W yview scroll 1 units } + bind $win.pane <Key-Up> { %W yview scroll -1 units } } destructor {
Patch 7:WHD: Please note, this patch won't work on Windows or Mac OS X. But then, Windows does this kind of file locking automatically.
*********************************************************************** Patch file for notebook Version 1.1 Use lockfile for currently open notebook file, so the file cannot get destroyed by erroneously running several instances on the same file. The code for AcquireLock and ReleaseLock was borrowed from the wikit-starkit and slightly modified. Patch supplied by Guido Ostkamp *********************************************************************** diff -Naur notebookkit/lib/app-notebook/notebookbrowser.tcl notebookkit.new/lib/app-notebook/notebookbrowser.tcl --- notebookkit/lib/app-notebook/notebookbrowser.tcl Wed May 7 01:36:37 2003 +++ notebookkit.new/lib/app-notebook/notebookbrowser.tcl Mon Jul 28 23:38:22 2003 @@ -145,7 +145,7 @@ $p.menubar.file add command \ -label "Exit" \ -underline 1 \ - -command {exit 0} + -command [list $w exit] # Next, create the Page menu menu $p.menubar.page -tearoff no @@ -328,6 +328,7 @@ } open - new - + exit - message { return [eval Op$cmd $w $args] } @@ -471,5 +472,16 @@ } +# Opexit w +# +# Exits from notebook file in the page browser +proc ::Notebook::Browser::Opexit {w {filename ""}} { + variable "" + # detach from the old database + if {"" != $($w-db)} { + db.$w detach $w + } + exit 0 +} diff -Naur notebookkit/lib/notebookdb/notebookdb.tcl notebookkit.new/lib/notebookdb/notebookdb.tcl --- notebookkit/lib/notebookdb/notebookdb.tcl Sun Jul 20 23:03:56 2003 +++ notebookkit.new/lib/notebookdb/notebookdb.tcl Mon Jul 28 23:41:00 2003 @@ -39,6 +39,33 @@ snit::type ::notebookdb::notebookdb { + proc AcquireLock {lockFile} { + catch { + set fd [open $lockFile] + set opid [gets $fd] + close $fd + if {$opid != "" && ![file exists [file join / proc $opid]]} { + file delete $lockFile + set fd [open savelog.txt a] + set now [clock format [clock seconds]] + puts $fd "# $now drop lock $opid -> [pid]" + close $fd + } + } + catch {close $fd} + + if {![catch {open $lockFile {CREAT EXCL WRONLY}} fd]} { + puts $fd [pid] + close $fd + return 0 + } + return 1 + } + + proc ReleaseLock {lockFile} { + file delete $lockFile + } + # # OPTIONS # @@ -89,6 +116,11 @@ # Next, try to load the file from disk, if it exists; otherwise, # save the default contents + if { [AcquireLock $filename.lck] != 0 } { + error "Could not load notebook file:\n\n'$filename'\n\nlock failed - file already in use" + exit 1 + } + if {[file exists $filename]} { interp create $self.loader $self.loader alias page $self Loader.Page @@ -145,6 +177,8 @@ # Destroys the interpreter; all other cleanup is done by snit. destructor { if {[info commands $self.interp] != ""} { + set filename $options(-dbfile) + ReleaseLock $filename.lck interp delete $self.interp } }
NOTE: Notebook patches should now be saved at the Notebook Wiki, http://notebook.wjduquette.com.
See also Notebook App, Snit.