From 778ada705f593c7fa51fb1d8c53eabaefbf88968 Mon Sep 17 00:00:00 2001 From: Hans Unzner Date: Sat, 18 Apr 2026 22:55:30 +0200 Subject: [PATCH 1/2] halshow: add function "Add from clipboard" to watch context menu --- tcl/bin/halshow.tcl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tcl/bin/halshow.tcl b/tcl/bin/halshow.tcl index 71c7eb76bda..619f3aa8cd6 100755 --- a/tcl/bin/halshow.tcl +++ b/tcl/bin/halshow.tcl @@ -704,6 +704,7 @@ proc makeWatch {} { bind $::cisp { if {$::watchlist_len <= 20} reloadWatch } + bind $::cisp {popupmenu_watch_general %W %X %Y} } proc makeSettings {} { @@ -957,6 +958,7 @@ proc watchHAL {which} { refreshItem $i $vartype $label } +# Popup menu for selected items proc popupmenu_watch {vartype label index writable which x y} { # create menu set m [menu .popupMenu$index -tearoff false] @@ -975,6 +977,49 @@ proc popupmenu_watch {vartype label index writable which x y} { bind $m [list destroy $m] } +# Popup menu for background (no item selected) +proc popupmenu_watch_general {w x y} { + # check if no other element is under cursor + if {![llength [$w find withtag current]]} { + # create menu + set m [menu .popupMenuText -tearoff false] + # add entries + $m add command -label [msgcat::mc "Add from clipboard"] -command { + catch {parse_hal_text [clipboard get]} + } + $m add command -label [msgcat::mc "Erase Watch"] -command { + watchReset all + setStatusbar [msgcat::mc "Watchlist cleared"] + } + # show menu + tk_popup $m $x $y + bind $m [list destroy $m] + } +} + +# Parse as a HAL file to filter out pins, signals and parameters and add +# the result to the watchlist +proc parse_hal_text {text} { + foreach line [split $text "\n"] { + set line [string trim $line] + # skip empty lines + if {$line eq ""} continue + # if line begins with 'net', take next as signal and rest as pins + if {[regexp {^\s*net\s+(\S+)\s*(.*)$} $line -> sig pin]} { + addToWatchFromSel sig $sig + if {$pin ne ""} { + addToWatchFromSel pin $pin + } + # first argument after setp is a parameter + } elseif {[regexp {^\s*setp\s+(\S+)} $line -> param]} { + addToWatchFromSel param $param + # try adding everything else as pin + } else { + addToWatchFromSel pin $line + } + } +} + proc popupmenu_text {x y} { # create menu set m [menu .popupMenuText -tearoff false] From f91eac3ab4883485edac6d0f763233897a926f9e Mon Sep 17 00:00:00 2001 From: Hans Unzner Date: Mon, 20 Apr 2026 00:36:29 +0200 Subject: [PATCH 2/2] halshow: add window to enter hal syntax from clipboard This adds an entry to the backgorund context menu. This opens a text box to enter HAL-file like text to quickly add items to the watch list. --- tcl/bin/halshow.tcl | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tcl/bin/halshow.tcl b/tcl/bin/halshow.tcl index 619f3aa8cd6..5615126b1ac 100755 --- a/tcl/bin/halshow.tcl +++ b/tcl/bin/halshow.tcl @@ -266,6 +266,8 @@ set watchmenu [menu $menubar.watch -tearoff 1] -command {addToWatch sig [msgcat::mc "Signal"]} $watchmenu add command -label [msgcat::mc "Add parameter"] \ -command {addToWatch param [msgcat::mc "Parameter"]} + $watchmenu add command -label [msgcat::mc "Add from HAL text"] \ + -command addToWatchFromText $watchmenu add separator $watchmenu add command -label [msgcat::mc "Reload Watch"] \ -command {reloadWatch} @@ -987,6 +989,7 @@ proc popupmenu_watch_general {w x y} { $m add command -label [msgcat::mc "Add from clipboard"] -command { catch {parse_hal_text [clipboard get]} } + $m add command -label [msgcat::mc "Add from HAL text"] -command addToWatchFromText $m add command -label [msgcat::mc "Erase Watch"] -command { watchReset all setStatusbar [msgcat::mc "Watchlist cleared"] @@ -1020,6 +1023,30 @@ proc parse_hal_text {text} { } } +# Creates a window with a text box to add items to the watchlist +proc addToWatchFromText {} { + # create toplevel dialog + set w .clipDialog + catch {destroy $w} + toplevel $w + wm title $w [msgcat::mc "Add to watch"] + # text widget + text $w.t -width 80 -height 20 + pack $w.t -fill both -expand 1 + # insert clipboard content + catch {$w.t insert 1.0 [clipboard get]} + # frame for buttons and buttons + frame $w.f + pack $w.f -fill x + button $w.f.ok -text "Add" -command " + set txt \[$w.t get 1.0 end\] + destroy $w + parse_hal_text \$txt + " + button $w.f.cancel -text "Cancel" -command "destroy $w" + pack $w.f.ok $w.f.cancel -side left -expand 1 -fill x +} + proc popupmenu_text {x y} { # create menu set m [menu .popupMenuText -tearoff false] @@ -1113,7 +1140,7 @@ proc entrybox {defVal buttonText label} { return "cancel" } else { set wn [toplevel .top] - wm title $wn [msgcat::mc "User input"] + wm title $wn [msgcat::mc "Input"] set xpos "[ expr {[winfo rootx [winfo parent $wn]]+ \ ([winfo width [winfo parent $wn]]-[winfo reqwidth $wn])/2}]" set ypos "[ expr {[winfo rooty [winfo parent $wn]]+ \