Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fconfigure $pd_socket -blocking 0 -buffering line -buffersize 1000000 -encoding utf-8;
- fileevent $pd_socket readable {::pd_connect::pd_readsocket ""}
- proc ::pd_connect::pd_readsocket {cmd_from_pd} {
- variable pd_socket
- if {[eof $pd_socket]} {
- # if we lose the socket connection, that means pd quit, so we quit
- close $pd_socket
- exit
- }
- while {[gets $pd_socket line] > -1} {
- puts -nonewline stderr "A"
- append cmd_from_pd $line\n
- }
- if {[string index $cmd_from_pd end] eq "\\"} {
- puts -nonewline stderr "\\"
- pd_readsocket $cmd_from_pd
- } else {
- puts -nonewline stderr "e"
- if {[catch {uplevel #0 $cmd_from_pd} errorname]} {
- global errorInfo
- switch -regexp -- $errorname {
- "missing close-brace" {
- pd_readsocket $cmd_from_pd
- } "^invalid command name" {
- ::pdwindow::fatal [concat [_ "(Tcl) INVALID COMMAND NAME: "] $errorInfo "\n"]
- } default {
- ::pdwindow::fatal [concat [_ "(Tcl) UNHANDLED ERROR: "] $errorInfo "\n"]
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement