Advertisement
talvo

Potato nowrap

May 12th, 2018
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 5.16 KB | None | 0 0
  1. proc ::skin::potato::show {c} {
  2.     variable widgets;
  3.     variable opts;
  4.  
  5.     ::skin::potato::worldBar $c
  6.     ::skin::potato::spawnBar $c
  7.  
  8.     set input1 [::potato::connInfo $c input1]
  9.     set input2 [::potato::connInfo $c input2]
  10.  
  11.     pack $input1 -in $widgets(pane,btm,pane,top) -side left -expand 1 -fill both -anchor nw
  12.     pack $input2 -in $widgets(pane,btm,pane,btm) -side left -expand 1 -fill both -anchor nw
  13.  
  14.     $input1 configure -yscrollcommand [list $widgets(pane,btm,pane,top,sb) set]
  15.     $widgets(pane,btm,pane,top,sb) configure -command [list $input1 yview]
  16.     $input2 configure -yscrollcommand [list $widgets(pane,btm,pane,btm,sb) set]
  17.     $widgets(pane,btm,pane,btm,sb) configure -command [list $input2 yview]
  18.  
  19.     $widgets(pane,top) configure -background [::potato::connInfo $c top,bg]
  20.     $widgets(conn,$c,txtframe) configure -background [::potato::connInfo $c top,bg]
  21.  
  22.     $widgets(pane,btm,idle) configure -background [::potato::connInfo $c bottom,bg] \
  23.         -foreground [::potato::connInfo $c bottom,fg] -font [::potato::connInfo $c bottom,font]
  24.  
  25.     set btm(font) [::potato::connInfo $c bottom,font]
  26.     set btm(fg) [::potato::connInfo $c bottom,fg]
  27.     set btm(bg) [::potato::connInfo $c bottom,bg]
  28.     set btm(insert) [::potato::reverseColour $btm(bg)]
  29.  
  30.     if { $c == 0 && !$::potato::misc(connZeroInputWindows) } {
  31.         $widgets(pane) paneconfigure $widgets(pane,btm) -hide 1
  32.     } else {
  33.         $widgets(pane) paneconfigure $widgets(pane,btm) -hide 0
  34.     }
  35.  
  36.     if { [info exists widgets(conn,$c,withInput)] } {
  37.         focus $widgets(conn,$c,withInput)
  38.     } else {
  39.         focus [set input[::potato::connInfo $c inputFocus]]
  40.     }
  41.  
  42.     update idletasks
  43.     pack $widgets(conn,$c,txtframe) -in $widgets(pane,top) -side top -expand 1 -fill both -anchor nw -pady 0 -padx [list 3 0]
  44.     pack $widgets(conn,$c,txtframe,sbX) -in $widgets(pane,top) -side bottom -expand 0 -fill x -anchor sw
  45.     fixWindowOrder $c
  46.  
  47.     if { $c == 0 } {
  48.         $widgets(statusbar,worldname,label) configure -text $::potato::potato(name)
  49.         $widgets(statusbar,hostinfo,label) configure -text [::potato::T "Not Connected"]
  50.         $widgets(statusbar,connstatus,sub,msg) configure -text [::potato::T "Not Connected"] -image {}
  51.         $widgets(statusbar,worldname,label,prompt) configure -textvariable ""
  52.     } else {
  53.         $widgets(statusbar,worldname,label) configure -text "$c. [potato::connInfo $c connname]"
  54.         $widgets(statusbar,hostinfo,label) configure -text "[potato::connInfo $c host]:[potato::connInfo $c port]"
  55.         $widgets(statusbar,worldname,label,prompt) configure -textvariable ::potato::conn($c,prompt)
  56.     }
  57.  
  58.     $widgets(statusbar,connstatus,sub,time) configure -textvariable ::potato::conn($c,stats,formatted)
  59.     updateTaskButtons
  60.  
  61.     return;
  62.  
  63. };# ::skin::potato::show
  64.  
  65. proc ::skin::potato::import {c} {
  66.     variable widgets;
  67.  
  68.     set t [::potato::connInfo $c text]
  69.  
  70.     set widgets(conn,$c,txtframe) [frame $widgets(pane,top).txtframe-$c]
  71.     set widgets(conn,$c,txtframe,cmd) ::skin::potato::conn_${c}_txtframe_cmd
  72.     rename $widgets(conn,$c,txtframe) $widgets(conn,$c,txtframe,cmd)
  73.     proc ::$widgets(conn,$c,txtframe) {first args} [string map [list CONNID $c] {
  74.         if { $first == "yview" } {
  75.             [::skin::potato::activeTextWidget CONNID] yview {*}$args
  76.         } else {
  77.             ::skin::potato::conn_CONNID_txtframe_cmd $first {*}$args
  78.         }
  79.     }]
  80.  
  81.     set widgets(conn,$c,txtframe,sb) [::ttk::scrollbar $widgets(conn,$c,txtframe).sb -orient vertical]
  82.  
  83.     pack $widgets(conn,$c,txtframe,sb) -side right -fill y -anchor ne
  84.     set widgets(conn,$c,txtframe,sbX) [::ttk::scrollbar $widgets(pane,top).sbX-$c -orient horizontal -command [list $t xview]]
  85.     $t config -xscrollcommand [list $widgets(conn,$c,txtframe,sbX) set]
  86.  
  87.     bind $widgets(conn,$c,txtframe) <MouseWheel> [list ::skin::potato::scrollActiveTextWidget $c %D]
  88.     bind $widgets(conn,$c,txtframe) <Button-4> [list ::skin::potato::scrollActiveTextWidget $c 120]
  89.     bind $widgets(conn,$c,txtframe) <Button-5> [list ::skin::potato::scrollActiveTextWidget $c -120]
  90.  
  91.     bind $widgets(conn,$c,txtframe) <Button-3> [list ::skin::potato::rightclickOutput $c "" %x %y %X %Y]
  92.     bind $t <Button-3> [list ::skin::potato::rightclickOutput $c $t %x %y %X %Y]
  93.  
  94.     foreach x [::potato::connInfo $c spawns] {
  95.         addSpawn $c $x
  96.     }
  97.  
  98.     showSpawn $c ""
  99.  
  100.     return;
  101.  
  102. };# ::skin::potato::import
  103.  
  104. proc ::skin::potato::unshow {c} {
  105.     variable widgets;
  106.     variable spawns;
  107.  
  108.     set input1 [::potato::connInfo $c input1]
  109.     set input2 [::potato::connInfo $c input2]
  110.  
  111.     set widgets(conn,$c,withInput) [set input[::potato::connInfo $c inputFocus]]
  112.  
  113.     $input1 configure -yscrollcommand ""
  114.     $widgets(pane,btm,pane,top,sb) configure -command ""
  115.     $input2 configure -yscrollcommand ""
  116.     $widgets(pane,btm,pane,btm,sb) configure -command ""
  117.     pack forget $widgets(conn,$c,txtframe) $input1 $input2 $widgets(conn,$c,txtframe,sbX)
  118.     catch {wm withdraw $widgets(conn,$c,find)}
  119.     catch {destroy {*}[winfo children $widgets(spawnbar)]}
  120.  
  121.     worldBarButtonNames
  122.  
  123.     array unset spawns $c,*
  124.  
  125.     return;
  126.  
  127. };# ::skin::potato::unshow
  128.  
  129. ::potato::define_slash_cmd wrap {
  130.     variable conn;
  131.    
  132.     set t [::potato::connInfo $c text]
  133.     set wrap [$t cget -wrap]
  134.     if { $wrap eq "word" } {
  135.         $t configure -wrap none
  136.         pack $t -expand 1 -fill both
  137.     } else {
  138.         $t configure -wrap word
  139.         pack $t -expand 0 -fill y
  140.     }
  141.  
  142.  
  143.     return [list 1];
  144.  
  145. };# /wrap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement