OXYGENHUB
◆ main openmsx / share / scripts / monitor.tcl
2.0 KiB · Tcl · last changed chore(): initial commit 1 month ago source blame history raw
1
namespace eval monitor {
2
3
variable monitors
4
5
set_help_text monitor_type \
6
{Select a monitor color profile.
7
8
Usage:
9
  monitor_type          Shows the current profile
10
  monitor_type -list    Show all possible types
11
  monitor_type <type>   Select new type
12
}
13
14
set_tabcompletion_proc monitor_type [namespace code tab_monitor_type]
15
proc tab_monitor_type {args} {
16
	variable monitors
17
	set result [dict keys $monitors]
18
	lappend result "-list"
19
}
20
21
dict set monitors normal {{ 1 0 0 } { 0 1 0 } { 0 0 1 }}
22
dict set monitors red    {{ 1 0 0 } { 0 0 0 } { 0 0 0 }}
23
dict set monitors green  {{ 0 0 0 } { 0 1 0 } { 0 0 0 }}
24
dict set monitors blue   {{ 0 0 0 } { 0 0 0 } { 0 0 1 }}
25
dict set monitors monochrome_amber        {{ .257 .504 .098 } { .193 .378 .073 } { 0 0 0 }}
26
dict set monitors monochrome_amber_bright {{ .333 .333 .333 } { .249 .249 .249 } { 0 0 0 }}
27
dict set monitors monochrome_green        {{ .129 .252 .049 } { .257 .504 .098 } { .129 .252 .049 }}
28
dict set monitors monochrome_green_bright {{ .167 .167 .167 } { .333 .333 .333 } { .167 .167 .167 }}
29
dict set monitors monochrome_white        {{ .257 .504 .098 } { .257 .504 .098 } { .257 .504 .098 }}
30
dict set monitors monochrome_white_bright {{ .333 .333 .333 } { .333 .333 .333 } { .333 .333 .333 }}
31
32
proc monitor_type {{monitor ""}} {
33
	variable monitors
34
35
	if {$monitor eq ""} {
36
		dict for {type matrix} $monitors {
37
			if {$matrix eq $::color_matrix} {
38
				return $type
39
			}
40
		}
41
		return "Custom monitor type: $::color_matrix"
42
	} elseif {$monitor eq "-list"} {
43
		return [dict keys $monitors]
44
	} else {
45
		if {[dict exists $monitors $monitor]} {
46
			set ::color_matrix [dict get $monitors $monitor]
47
		} else {
48
			error "No such monitor type: $monitor"
49
		}
50
	}
51
}
52
53
namespace export monitor_type
54
55
user_setting create enum monitor_type "Selects the monitor color profile" normal [dict keys $monitors]
56
proc monitor_type_changed {name1 name2 op} { monitor_type $::monitor_type }
57
trace add variable ::monitor_type write [namespace code monitor_type_changed]
58
59
} ;# namespace monitor
60
61
namespace import monitor::*