/usr/share/openmsx/scripts/_cycle.tcl is in openmsx-data 0.10.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | namespace eval cycle {
set help_cycle \
{Cycle through the possible values of an enum setting.
'cycle_back' does the same as 'cycle', but it goes in the opposite direction.
Usage:
cycle <enum_setting> [<cycle_list>]
cycle_back <enum_setting> [<cycle_list>]
Example:
cycle scale_algorithm
cycle scale_algorithm "hq2x hq2xlite"
}
set_help_text cycle $help_cycle
set_help_text cycle_back $help_cycle
set_tabcompletion_proc cycle [namespace code tab_cycle]
set_tabcompletion_proc cycle_back [namespace code tab_cycle]
proc tab_cycle {args} {
set result [list]
foreach setting [openmsx_info setting] {
set type [lindex [openmsx_info setting $setting] 0]
if {($type eq "enumeration") || ($type eq "boolean")} {
lappend result $setting
}
}
return $result
}
proc cycle {setting {cycle_list {}} {step 1}} {
set setting_info [openmsx_info setting $setting]
set type [lindex $setting_info 0]
if {$type eq "enumeration"} {
if {[llength $cycle_list] == 0} {
set cycle_list [lindex $setting_info 2]
}
} elseif {$type eq "boolean"} {
set cycle_list [list "true" "false"]
} else {
error "Not an enumeration setting: $setting"
}
set cur [lsearch -exact -nocase $cycle_list [set ::$setting]]
set new [expr {($cur + $step) % [llength $cycle_list]}]
set ::$setting [lindex $cycle_list $new]
}
proc cycle_back {setting} {
cycle $setting {} -1
}
set_help_text toggle \
{Toggles a boolean setting
Usage:
toggle <boolean_setting>
Example:
toggle fullscreen
}
set_tabcompletion_proc toggle [namespace code tab_cycle]
proc toggle {setting} {
cycle $setting "on off"
}
namespace export cycle
namespace export cycle_back
namespace export toggle
} ;# namespace cycle
namespace import cycle::*
|