Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21404
Modified Files: Tag: desiredata desire.tk Log Message: class_new Console
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.7 retrieving revision 1.1.2.600.2.8 diff -C2 -d -r1.1.2.600.2.7 -r1.1.2.600.2.8 *** desire.tk 3 Dec 2006 05:35:49 -0000 1.1.2.600.2.7 --- desire.tk 3 Dec 2006 15:40:40 -0000 1.1.2.600.2.8 *************** *** 582,585 **** --- 582,617 ---- ################## set up main window #########################
+ class_new Console + + def Console init {c} { + set @c $c + frame $c + text $c.1 -width 72 -height 20 -yscrollcommand "$c.2 set" -font $::look(View:font) + scrollbar $c.2 -command "$c.1 yview" + pack $c.1 -side left -fill both -expand yes + pack $c.2 -side left -fill y -expand no + pack $c -fill both -expand yes + $c.2 set 0.0 1.0 + switch $::OS { osx { + bind $c.1 <MouseWheel> {$c.1 yview scroll [expr -2-abs(%D)/%D] units} + }} + set @lines 0 + } + + def Console widget {} {return $@c} + + def Console post_string {x} { + set oldpos [lindex [$@c.2 get] 1] + $@c.1 insert end $x + regsub -all "\n" $x "" y + set n [expr [string length $x]-[string length $y]] + incr @lines $n + while {$@lines >= $::cmdline(console)} { + $@c.1 delete 1.0 2.0 + incr @lines -1 + } + if {$oldpos > 0.9999} {$@c.1 see end} + } + #class_new Client {Menuable View} class_new Client {Menuable Thing} *************** *** 642,646 **** canvas $f.1.clip -width 5 -height 10 -bg #222222 pack $f.1.mtr $f.1.clip -side left ! pack [label $f.2 -text [say $z]:] $f.1 -side left -padx 4 pack $f -side left -pady 0 -padx 0 } --- 674,678 ---- canvas $f.1.clip -width 5 -height 10 -bg #222222 pack $f.1.mtr $f.1.clip -side left ! pack [label $f.2 -text [say $z]:] $f.1 -side left pack $f -side left -pady 0 -padx 0 } *************** *** 657,665 **** frame .debug # pack [label .debug.1 -anchor w -text ""] -side left ! pack [entry .controls.3 -textvariable ::serial -width 10] -side right pack [label .controls.2 -text "obj.serial: " -justify right] -side right pack .debug -side bottom -fill x . configure -menu .mbar wm title . "DesireData" }
--- 689,706 ---- frame .debug # pack [label .debug.1 -anchor w -text ""] -side left ! pack [entry .controls.3 -textvariable ::serial -width 5] -side right pack [label .controls.2 -text "obj.serial: " -justify right] -side right + # set @book [Notebook new_as book] + # $@book add_section 1 [say posts] + # $@book add_section 2 [say socket_log] + # pack .book -side top -fill both -expand 1 + if {$::cmdline(console)} { + #set ::console [Console new .book.main.1.log] + set ::console [Console new .log] + } pack .debug -side bottom -fill x . configure -menu .mbar wm title . "DesireData" + post "DesireData 0.39.A, Tcl %s, Tk %s" $::tcl_patchLevel $::tk_patchLevel }
*************** *** 678,687 **** set pd_opendir [pwd]
! ############### set up socket & start server socket #################### ! # note: here, it's the client that has the server socket, and the ! # server that has the client socket. Yes, this is messed up. Think of ! # two separate things: client-server at the socket level, and client-server ! # at the getting-stuff-done level. --matju ! set sock {} set sock_lobby {} --- 719,723 ---- set pd_opendir [pwd]
! ############### set up socket ########################################## set sock {} set sock_lobby {} *************** *** 786,791 **** ################ utility functions #########################
- proc pdtk_post {s} {post_to_gui $s} - proc enquote {x} { set foo [string map {"," "" ";" "" """ ""} $x] --- 822,825 ---- *************** *** 885,890 **** }
- #################### the "File" menu for the Pd window ############## - def Client init_menus {} { $self populate_menu file { --- 919,922 ---- *************** *** 911,915 **** Listener new .pd " Pd Server" pd_eval } ! if {$::cmdline(console)} {make_console} }
--- 943,955 ---- Listener new .pd " Pd Server" pd_eval } ! } ! ! proc post {args} { ! set s "[eval [linsert $args 0 format]]\n" ! # set s "[info level -1]: $s" ! if {$::cmdline(console)} {$::console post_string $s} else {puts stderr $s} ! } ! proc pdtk_post {s} { ! if {$::cmdline(console)} {$::console post_string $s} else {puts stderr $s} }
*************** *** 5494,5546 **** }
- ##################################################################################### - # console - - proc make_console {} { - global cmdline look - set errMsg "" - if {$cmdline(console) == 0} {return} - frame .log - text .log.1 -width 72 -height 20 -yscrollcommand ".log.2 set" -font $look(View:font) - scrollbar .log.2 -command ".log.1 yview" - .log.1 insert end "DesireData 0.39.A, Tcl $::tcl_version, Tk $::tk_version\n" - pack .log.1 -side left -fill both -expand yes - pack .log.2 -side left -fill y -expand no - pack .log -fill both -expand yes - .log.2 set 0.0 1.0 - switch $::OS { osx { - bind .log.1 <MouseWheel> { - .log.1 yview scroll [expr -2-abs(%D)/%D] units - } - }} - } - - set ::console_lines 0 - proc post_to_gui {x} { - global ::console_lines - if {!$::cmdline(console)} {puts -nonewline stderr $x; return} - set oldpos [lindex [.log.2 get] 1] - .log.1 insert end $x - regsub -all "\n" $x "" y - set n [expr [string length $x]-[string length $y]] - incr ::console_lines $n - while {$::console_lines >= $::cmdline(console)} { - .log.1 delete 1.0 2.0 - incr console_lines -1 - } - if {$oldpos > 0.9999} {.log.1 see end} - } - - proc post {args} { - global cmdline - set s "[eval [linsert $args 0 format]]\n" - # set s "[info level -1]: $s" - if {$cmdline(console)} { - post_to_gui $s - } else { - puts stderr $s - } - } - ############ evaluator
--- 5534,5537 ----