File: monitor.tcl

package info (click to toggle)
openmsx 20.0%2Bdfsg-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,544 kB
  • sloc: cpp: 236,922; xml: 49,948; tcl: 15,056; python: 5,385; perl: 281; sh: 77; makefile: 53
file content (61 lines) | stat: -rw-r--r-- 2,053 bytes parent folder | download | duplicates (2)
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
namespace eval monitor {

variable monitors

set_help_text monitor_type \
{Select a monitor color profile.

Usage:
  monitor_type          Shows the current profile
  monitor_type -list    Show all possible types
  monitor_type <type>   Select new type
}

set_tabcompletion_proc monitor_type [namespace code tab_monitor_type]
proc tab_monitor_type {args} {
	variable monitors
	set result [dict keys $monitors]
	lappend result "-list"
}

dict set monitors normal {{ 1 0 0 } { 0 1 0 } { 0 0 1 }}
dict set monitors red    {{ 1 0 0 } { 0 0 0 } { 0 0 0 }}
dict set monitors green  {{ 0 0 0 } { 0 1 0 } { 0 0 0 }}
dict set monitors blue   {{ 0 0 0 } { 0 0 0 } { 0 0 1 }}
dict set monitors monochrome_amber        {{ .257 .504 .098 } { .193 .378 .073 } { 0 0 0 }}
dict set monitors monochrome_amber_bright {{ .333 .333 .333 } { .249 .249 .249 } { 0 0 0 }}
dict set monitors monochrome_green        {{ .129 .252 .049 } { .257 .504 .098 } { .129 .252 .049 }}
dict set monitors monochrome_green_bright {{ .167 .167 .167 } { .333 .333 .333 } { .167 .167 .167 }}
dict set monitors monochrome_white        {{ .257 .504 .098 } { .257 .504 .098 } { .257 .504 .098 }}
dict set monitors monochrome_white_bright {{ .333 .333 .333 } { .333 .333 .333 } { .333 .333 .333 }}

proc monitor_type {{monitor ""}} {
	variable monitors

	if {$monitor eq ""} {
		dict for {type matrix} $monitors {
			if {$matrix eq $::color_matrix} {
				return $type
			}
		}
		return "Custom monitor type: $::color_matrix"
	} elseif {$monitor eq "-list"} {
		return [dict keys $monitors]
	} else {
		if {[dict exists $monitors $monitor]} {
			set ::color_matrix [dict get $monitors $monitor]
		} else {
			error "No such monitor type: $monitor"
		}
	}
}

namespace export monitor_type

user_setting create enum monitor_type "Selects the monitor color profile" normal [dict keys $monitors]
proc monitor_type_changed {name1 name2 op} { monitor_type $::monitor_type }
trace add variable ::monitor_type write [namespace code monitor_type_changed]

} ;# namespace monitor

namespace import monitor::*