Plan 9 from Bell Labs’s /usr/web/sources/contrib/rog/sh-examples/sliders.sh

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/dis/sh

load tk echo
nl='
'

#run slider.sh
fn slider {
	(chan w) := $*
	x scale $w -orient horizontal -from 0 -to 255 -command '{send '^$chan^'}'
}
# run colour.sh
fn colour {
	(nil w) := $*
	x frame $w
	x pack propagate $w 0
	x $w configure -width 100 -height 100
}
fn colourcmd {
	(w col) := $*
	x $w configure -bg $col
}

# run label.sh
fn label {
	(nil w) := $*
	x label $w
}
fn labelcmd {
	(w label) := $*
	x $w configure -text ${tkquote $label}
}

wid=${tk window 'sliders'}
fn x { a := $*; or {tk $wid $a} {echo error on tk cmd $"a':' $status }}
pctl newpgrp
while {} {tk winctl $wid ${recv $wid}} &
x update
for (i in slider1 slider2 slider3) {
	chan $i
	tk namechan $wid $i
}

slider slider1 .s1
slider slider2 .s2
slider slider3 .s3
label '' .label
colour '' .col
x pack .s1 .s2 .s3 .label .col -side top -fill x
slider1 := slider2 := slider3 := 0
colourcmd .col '#000000'
tk onscreen $wid
x update

while {} {
	(chan val) := ${alt slider1 slider2 slider3}
	$chan = $val
	echo $slider1 $slider2 $slider3
} | rgb2tkcol | {
	getlines {
		colourcmd .col $line
		labelcmd .label $line
		x update
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.