• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - TCL
  3. Building a editor , because we all need this

Stats

  • Replies 3
  • Subscribers 12
  • Views 963
  • Members are here 0
More Content

Building a editor , because we all need this

Mhawley1
Mhawley1 1 month ago

Hey Everybody , I feel like we need and or Deserve a build in editor inside of Cadence . 

So here is my code so far and it collapses the procedures . Feel free to use this as a starting point . My goal is to execute the code . Highlighting would be nice . Autocompletion would be probably not be possible . But try it out everyone and see what you think . 

package require Tk

proc LaunchWindow {} {
set w .myWin
catch {destroy $w}
toplevel $w
wm withdraw .
wm title $w "Text Box with Scrollbar"

label $w.label -text "Enter your text below:"

frame $w.textFrame

text $w.textbox -width 50 -height 10 -wrap word -yscrollcommand "$w.scroll set"

scrollbar $w.scroll -orient vertical -command "$w.textbox yview"

pack $w.textbox -side left -fill both -expand 1
pack $w.scroll -side right -fill y
pack $w.label -padx 10 -pady 5
pack $w.textFrame -padx 10 -pady 5 -fill both -expand 1

# Button to print text
button $w.button -text "Execute" -command {
puts [.myWin.textbox get 1.0 end]
}
pack $w.button -padx 10 -pady 5

# Define a tag that hides text
$w.textbox tag configure hidden -elide true




# Button to hide all blocks enclosed in { ... }
button $w.hideBlocksButton -text "Hide Code Blocks" -command {
set text [.myWin.textbox get 1.0 end]
set startIdx 0
set braceLevel 0
set blockStart ""

# Scan character by character
for {set i 0} {$i < [string length $text]} {incr i} {
set char [string index $text $i]
set idx [.myWin.textbox index "1.0 + $i chars"]

if {$char eq "\{"} {
if {$braceLevel == 0} {
set blockStart $idx
}
incr braceLevel
} elseif {$char eq "\}"} {
if {$braceLevel > 0} {
incr braceLevel -1
if {$braceLevel == 0} {

set nextCharIndex [expr {$i + 1}]
set blockEnd [.myWin.textbox index "1.0 + $nextCharIndex chars"]

.myWin.textbox tag add hidden $blockStart $blockEnd
}
}
}
}
}
pack $w.hideBlocksButton -padx 10 -pady 5


# Button to restore all blocks enclosed in { ... }
button $w.restoreBlocksButton -text "Restore Code Blocks" -command {
set text [.myWin.textbox get 1.0 end]
set startIdx 0
set braceLevel 0
set blockStart ""

# Scan character by character
for {set i 0} {$i < [string length $text]} {incr i} {
set char [string index $text $i]
set idx [.myWin.textbox index "1.0 + $i chars"]

if {$char eq "\{"} {
if {$braceLevel == 0} {
set blockStart $idx
}
incr braceLevel
} elseif {$char eq "\}"} {
if {$braceLevel > 0} {
incr braceLevel -1
if {$braceLevel == 0} {

set nextCharIndex [expr {$i + 1}]
set blockEnd [.myWin.textbox index "1.0 + $nextCharIndex chars"]

.myWin.textbox tag remove hidden $blockStart $blockEnd
}
}
}
}
}
pack $w.restoreBlocksButton -padx 10 -pady 5


}

LaunchWindow

  • Cancel
  • Sign in to reply
Parents
  • Mhawley1
    Mhawley1 28 days ago

    Here is a update on the editor in TCL . It now supports basic folding of procedures and there is a find search . Its not a very pretty but it suits my needs . 

    Commenting # has some problems where it only assesses every other line and when you run the find it retains the highlight . 

    anyways below is the link the the GitHub repo . Feel free to clone or add or commit to . 

    github.com/.../Cadence_tcl_editor.git

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Mhawley1
    Mhawley1 28 days ago

    Here is a update on the editor in TCL . It now supports basic folding of procedures and there is a find search . Its not a very pretty but it suits my needs . 

    Commenting # has some problems where it only assesses every other line and when you run the find it retains the highlight . 

    anyways below is the link the the GitHub repo . Feel free to clone or add or commit to . 

    github.com/.../Cadence_tcl_editor.git

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information