• 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 2
  • Subscribers 12
  • Views 261
  • Members are here 0
More Content

Building a editor , because we all need this

Mhawley1
Mhawley1 15 days 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

  • Sign in to reply
  • Cancel
  • PatEscher
    PatEscher 15 days ago

    Hello, 

    we need an Editor for what? For writing tcl code for OrCAD?

    Why does an editor like notepad++ with syntax highlighting is not sufficient. Or why not even using one of the free IDE's instead which bring syntax highlighting, check and some auto completion?

    +Patrick

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Mhawley1
    Mhawley1 15 days ago in reply to PatEscher

    Because I dont want have to save the notepad file and then load it ( or write some iterator script that scans for it )  . I want it to run now at the click of a button . I want a editor to come up right inside of Cadence and be there real time to test out snippets . And the company I work at is paranoid as heck so I cant just install an IDE. Im going to stick with this and see where it goes . Might be useful to someone . 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
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