Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/rgb+combinations?V=4
QUERY_STRINGV=4
CONTENT_TYPE
DOCUMENT_URI/revision/rgb+combinations
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.71.254.248
REMOTE_PORT52492
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.144.25.74
HTTP_CF_RAY87f387e5deaf2327-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP3.144.25.74
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {rgb combinations} !!!!!!\n\[http://www.serice.net/rgb/rgb.png\]\n!!!!!!\n\nGUI\ for\ quickly\ trying\ different\ background\ and\ foreground\ colors.\ \ The\ list\ box\ on\ the\ right\ has\ keyboard\ bindings\ that\ change\ the\ colors\ in\ the\ frame\ on\ the\ left.\ \ The\ home\ page\ is\ http://www.serice.net/rgb/\ which\ has\ the\ source\ which\ is\ also\ listed\ below.\n----\n======\n\ #!/usr/bin/tclsh\n\ \n\ #\n\ #\ This\ program\ reads\ an\ X11\ rgb.txt\ file\ that\ holds\ a\ small,\ simple\n\ #\ database\ that\ maps\ color\ names\ to\ RGB\ component\ values.\ \ It\ then\n\ #\ displays\ the\ colors\ in\ alphabetical\ order\ allowing\ the\ user\ to\n\ #\ preview\ each\ color.\n\ #\n\ #\ It\ is\ possible\ to\ pipe\ the\ colors\ into\ this\ program.\ \ Just\ make\ sure\n\ #\ you\ specify\ the\ rgb.txt\ file\ on\ the\ command\ line\ as\ \"-\".\ \ For\n\ #\ example,\ the\ following\ command\ line\ will\ display\ the\ \"black\"\ and\n\ #\ \"white\"\ colors:\n\ #\n\ #\ \ \ \ \ printf\ \"0\ 0\ 0\ black\\n255\ 255\ 255\ white\\n\"\ |\ ./rgb.tcl\ -\n\ #\n\ #\ Warning:\ Don't\ change\ the\ shebang\ above\ to\ directly\ start\ \"wish.\"\n\ #\ The\ problem\ is\ that\ \"wish\"\ crashes\ if\ \"-h\"\ is\ passed\ in\ on\ the\n\ #\ command\ line,\ but\ we\ need\ \"-h\"\ to\ allow\ the\ user\ to\ ask\ for\ help.\n\ #\ The\ work\ around\ is\ to\ inspect\ \"argv\"\ before\ loading\ Tk.\ \ (See\n\ #\ below.)\n\ #\n\ \n\ ##\n\ #\ Program\ version\n\ set\ rgb_version\ 1.0.1\n\ \n\ ##\n\ #\ Message\ to\ display\ in\ the\ main\ frame.\n\ set\ rgb_message\ \"It\ was\ the\ best\ of\ times,\ it\ was\ the\ worst\ of\ times,\\\n\ it\ was\ the\ age\ of\ wisdom,\ it\ was\ the\ age\ of\ foolishness,\\\n\ it\ was\ the\ epoch\ of\ belief,\ it\ was\ the\ epoch\ of\ incredulity,\\\n\ it\ was\ the\ season\ of\ Light,\ it\ was\ the\ season\ of\ Darkness,\\\n\ it\ was\ the\ spring\ of\ hope,\ it\ was\ the\ winter\ of\ despair,\\\n\ we\ had\ everything\ before\ us,\ we\ had\ nothing\ before\ us,\\\n\ we\ were\ all\ going\ direct\ to\ Heaven,\ we\ were\ all\ going\ direct\\\n\ the\ other\ way--in\ short,\ the\ period\ was\ so\ far\ like\ the\ present\\\n\ period,\ that\ some\ of\ its\ noisiest\ authorities\ insisted\ on\ its\\\n\ being\ received,\ for\ good\ or\ for\ evil,\ in\ the\ superlative\ degree\\\n\ of\ comparison\ only.\"\n\ \n\ ##\n\ #\ Parse\ the\ command\ line\ options.\ \ If\ an\ rgb.txt\ file\ is\ specified\ on\n\ #\ the\ command\ line,\ <code>fname</code>\ will\ be\ set\ to\ match.\n\ #\n\ #\ @param\[out\]\ fnameName\ name\ of\ variable\ to\ hold\ the\ file\ name\n\ proc\ parse_command_line\ \{fnameName\}\ \{\n\ \ \ \ \ global\ argv\n\ \ \ \ \ global\ progname\n\ \n\ \ \ \ \ upvar\ 1\ \$fnameName\ fname\n\ \n\ \ \ \ \ #\ Iterate\ over\ the\ command-line\ arguments.\n\ \ \ \ \ foreach\ arg\ \$argv\ \{\n\ \n\ \ \ \ \ \ \ \ \ #\ -help\n\ \ \ \ \ \ \ \ \ if\ \{(\$arg\ ==\ \"-h\")\ ||\ (\$arg\ ==\ \"-help\")\ ||\ (\$arg\ ==\ \"--help\")\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"Usage:\ \$progname\ \\\[-h\\\]\ \\\[<rgb.txt>\\\]\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\ \ \ \ Note:\ If\ <rgb.txt>\ is\ specified\ as\ \\\"-\\\",\ stdin\ is\ used.\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 0\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Check\ for\ invalid\ flags.\n\ \ \ \ \ \ \ \ \ if\ \{(\[string\ length\ \$argv\]\ >\ 1)\ &&\ (\[string\ index\ \$arg\ 0\]\ ==\ \"-\")\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Error:\ invalid\ flag:\ \$arg\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Must\ be\ the\ name\ of\ the\ file.\n\ \ \ \ \ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ set\ fname\ \$arg\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Error:\ extra\ rgb\ file\ specified:\ \$arg\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Parse\ the\ \"rgb.txt\"\ file\ specified\ by\ the\ path\ <code>fname</code>.\n\ #\ This\ causes\ each\ color\ listed\ in\ <code>fname</code>\ to\ be\ mapped\ in\n\ #\ <code>cnames</code>\ to\ a\ list\ of\ its\ red,\ green,\ and\ blue\ component\n\ #\ colors.\n\ #\n\ #\ @param\[in\]\ fname\ file\ name\ for\ \"rgb.txt\"\ file\n\ #\ @param\[out\]\ cnamesName\ name\ of\ array\ that\ maps\ color\ names\ to\ RGB\n\ proc\ parse_rgb_file\ \{fname\ cnamesName\}\ \{\n\ \ \ \ \ upvar\ 1\ \$cnamesName\ cnames\n\ \n\ \ \ \ \ #\ Open\ file.\n\ \ \ \ \ if\ \{\$fname\ ==\ \"-\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ f\ stdin\n\ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ set\ f\ \[open\ \$fname\ r\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Iterate\ over\ each\ line\ in\ the\ \"rgb.txt\"\ file.\n\ \ \ \ \ while\ \{\[gets\ \$f\ line\]\ >=\ 0\}\ \{\n\ \n\ \ \ \ \ \ \ \ \ #\ Skip\ comments.\n\ \ \ \ \ \ \ \ \ if\ \{\[string\ index\ \$line\ 0\]\ ==\ \"!\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ continue\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Reset.\n\ \ \ \ \ \ \ \ \ set\ red\ 0\n\ \ \ \ \ \ \ \ \ set\ green\ 0\n\ \ \ \ \ \ \ \ \ set\ blue\ 0\n\ \ \ \ \ \ \ \ \ set\ cname\ \"\"\n\ \n\ \ \ \ \ \ \ \ \ #\ Parse\ the\ line.\n\ \ \ \ \ \ \ \ \ regexp\ --\ \{(\[0-9\]+)\[\ \\t\]+(\[0-9\]+)\[\ \\t\]+(\[0-9\]+)\[\ \\t\]+(.*)\$\}\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$line\ all\ red\ green\ blue\ cname\n\ \n\ \ \ \ \ \ \ \ \ #\ Sanity\ check.\n\ \ \ \ \ \ \ \ \ if\ \{\$cname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ continue\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Insert\ results\ into\ \"cnames\"\ array.\n\ \ \ \ \ \ \ \ \ set\ cnames(\$cname)\ \[list\ \$red\ \$green\ \$blue\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Close\ file.\n\ \ \ \ \ if\ \{\$fname\ !=\ \"-\"\}\ \{\n\ \ \ \ \ \ \ \ \ close\ \$f\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Convert\ the\ <code>rgb</code>\ list\ of\ component\ colors\ into\ the\n\ #\ format\ \"#RRGGBB\"\ and\ return\ the\ result.\n\ #\n\ #\ @param\[in\]\ rgb\ RGB\ component\ colors\ as\ a\ list\n\ #\ @return\ RGB\ component\ colors\ as\ a\ string\n\ proc\ format_color\ \{rgb\}\ \{\n\ \ \ \ \ foreach\ \{red\ green\ blue\}\ \$rgb\ \{\}\n\ \ \ \ \ format\ \"#%02x%02x%02x\"\ \$red\ \$green\ \$blue\n\ \}\n\ \n\ ##\n\ #\ This\ function\ returns\ \"black\"\ unless\ the\ list\ of\ component\ colors\ in\n\ #\ <code>rgb</code>\ indicates\ that\ the\ color\ is\ dark.\ \ Then,\ this\n\ #\ function\ returns\ \"white\".\ \ The\ idea\ is\ that\ the\ color\ returned\ is\n\ #\ suitable\ for\ use\ as\ the\ foreground\ (or\ text)\ color\ if\n\ #\ <code>rgb</code>\ is\ the\ background\ color.\n\ #\n\ #\ @param\[in\]\ rgb\ RGB\ component\ colors\ as\ a\ list\n\ #\ @return\ RGB\ component\ colors\ as\ a\ string\n\ proc\ get_fg_color\ \{rgb\}\ \{\n\ \ \ \ \ set\ rv\ black\n\ \ \ \ \ foreach\ \{red\ green\ blue\}\ \$rgb\ \{\}\n\ \ \ \ \ if\ \{(\$red\ <\ 0xa0)\ &&\ (\$green\ <\ 0xa0)\}\ \{\n\ \ \ \ \ \ \ \ \ set\ rv\ white\n\ \ \ \ \ \}\n\ \ \ \ \ return\ \$rv\n\ \}\n\ \n\ ##\n\ #\ Enable\ the\ menu\ item\ <code>item</code>.\n\ #\n\ #\ @param\[in\]\ item\ menu\ item\n\ proc\ enable_menu_item\ \{item\}\ \{\n\ \ \ \ \ global\ progname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Get\ the\ parent\ menu.\n\ \ \ \ \ set\ parent\ \[file\ rootname\ \$item\]\n\ \ \ \ \ if\ \{!\[winfo\ exists\ \$parent\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ enable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ parent:\ \$parent\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ menu\ item\ exists.\n\ \ \ \ \ if\ \{!\[info\ exists\ menu_indexes(\$item)\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ enable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ menu\ item:\ \$item\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Enable\ the\ menu\ item.\n\ \ \ \ \ \$parent\ entryconfigure\ \$menu_indexes(\$item)\ -state\ normal\n\ \}\n\ \n\ ##\n\ #\ Disable\ the\ menu\ item\ <code>item</code>.\n\ #\n\ #\ @param\[in\]\ item\ menu\ item\n\ proc\ disable_menu_item\ \{item\}\ \{\n\ \ \ \ \ global\ progname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Get\ the\ parent\ menu.\n\ \ \ \ \ set\ parent\ \[file\ rootname\ \$item\]\n\ \ \ \ \ if\ \{!\[winfo\ exists\ \$parent\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ disable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ parent:\ \$parent\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ menu\ item\ exists.\n\ \ \ \ \ if\ \{!\[info\ exists\ menu_indexes(\$item)\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ disable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ menu\ item:\ \$item\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Disable\ the\ menu\ item.\n\ \ \ \ \ \$parent\ entryconfigure\ \$menu_indexes(\$item)\ -state\ disabled\n\ \}\n\ \n\ ##\n\ #\ Center\ the\ dialog\ window\ <code>d</code>\ over\ the\ window\n\ #\ <code>p</code>.\ \ If\ <code>p</code>\ does\ not\ exist,\ the\ dialog\ is\n\ #\ centered\ over\ the\ entire\ screen.\n\ #\n\ #\ @param\[in\]\ d\ dialog\ window\n\ #\ @param\[in\]\ p\ parent\ window\n\ #\ @see\ ::tk::PlaceWindow\ (in\ tk.tcl)\n\ proc\ center_dialog\ \{d\ \{p\ \"\"\}\}\ \{\n\ \n\ \ \ \ \ #\ Force\ the\ geometry\ manager\ to\ update\ the\ layout\ so\ we\ can\ query\n\ \ \ \ \ #\ the\ correct\ size\ of\ the\ window.\n\ \ \ \ \ update\ idletasks\n\ \n\ \ \ \ \ #\ Get\ the\ width\ and\ height\ requested\ by\ the\ geometry\ manager.\n\ \ \ \ \ #\ This\ often\ is\ not\ the\ same\ as\ the\ current\ width\ and\ height\n\ \ \ \ \ #\ because\ the\ Window\ Manager\ may\ not\ have\ resized\ the\ window\ yet.\n\ \ \ \ \ set\ d_width\ \[winfo\ reqwidth\ \$d\]\n\ \ \ \ \ set\ d_height\ \[winfo\ reqheight\ \$d\]\n\ \n\ \ \ \ \ #\ If\ the\ parent\ exists,\ use\ the\ geometry\ of\ the\ parent\ window.\n\ \ \ \ \ if\ \{\[winfo\ exists\ \$p\]\}\ \{\n\ \ \ \ \ \ \ \ \ set\ p_x\ \[winfo\ rootx\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_y\ \[winfo\ rooty\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_width\ \[winfo\ width\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_height\ \[winfo\ height\ \$p\]\n\ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ #\ Otherwise,\ use\ the\ geometry\ of\ the\ screen.\n\ \ \ \ \ \ \ \ \ set\ p_x\ 0\n\ \ \ \ \ \ \ \ \ set\ p_y\ 0\n\ \ \ \ \ \ \ \ \ set\ p_width\ \[winfo\ screenwidth\ \$d\]\n\ \ \ \ \ \ \ \ \ set\ p_height\ \[winfo\ screenheight\ \$d\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Set\ the\ new\ location\ for\ the\ dialog\ window.\ \ We\ subtract\ 25\ to\n\ \ \ \ \ #\ raise\ the\ dialog\ a\ little\ on\ the\ screen.\n\ \ \ \ \ set\ new_x\ \[expr\ \{\$p_x\ +\ (\$p_width\ -\ \$d_width)\ /\ 2\}\]\n\ \ \ \ \ set\ new_y\ \[expr\ \{\$p_y\ +\ (\$p_height\ -\ \$d_height)\ /\ 2\ -\ 25\}\]\n\ \n\ \ \ \ \ #\ Bounds\ check.\n\ \ \ \ \ if\ \{\$new_x\ <\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ set\ new_x\ 0\n\ \ \ \ \ \}\n\ \ \ \ \ if\ \{\$new_y\ <\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ set\ new_y\ 0\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Move\ the\ dialog\ window\ into\ place.\n\ \ \ \ \ wm\ geom\ \$d\ \"+\$new_x+\$new_y\"\n\ \}\n\ \n\ ##\n\ #\ This\ function\ is\ called\ when\ the\ selects\ a\ color\ in\ the\ list\ box.\n\ #\ It\ queries\ the\ list\ box\ for\ the\ color\ and\ uses\ it\ to\ set\ the\n\ #\ background\ color\ of\ the\ <code>.f</code>\ frame.\ \ It\ also\ changes\ the\n\ #\ label\ for\ the\ <code>.f</code>\ frame\ to\ be\ the\ name\ of\ the\ color.\n\ proc\ on_color_selection\ \{\}\ \{\n\ \ \ \ \ global\ apply_to_bg\n\ \ \ \ \ global\ apply_to_fg\n\ \ \ \ \ global\ default_bg_color\n\ \n\ \ \ \ \ #\ Get\ the\ index\ of\ the\ selected\ row.\n\ \ \ \ \ set\ index\ \[.lbox\ curselection\]\n\ \ \ \ \ if\ \{\$index\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ return\;\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Get\ the\ text\ of\ the\ selected\ row.\n\ \ \ \ \ set\ row\ \[.lbox\ get\ \$index\]\n\ \n\ \ \ \ \ #\ Recover\ the\ name\ of\ the\ color\ and\ the\ rgb\ value\ from\ the\ row.\n\ \ \ \ \ regexp\ --\ \{(.*)\ \\((#\[0-9a-fA-F\]+)\\)\}\ \$row\ all\ cname\ rgb\n\ \n\ \ \ \ \ #\ Split\ RGB\ string\ into\ component\ colors.\n\ \ \ \ \ scan\ \$rgb\ \"#%02x%02x%02x\"\ red\ green\ blue\n\ \n\ \ \ \ \ #\ Split\ the\ text\ at\ the\ top\ of\ the\ frame\ so\ we\ can\ update\ each\ part.\n\ \ \ \ \ set\ f_text_parts\ \[split\ \[.f\ cget\ -text\]\ \"/\"\]\n\ \ \ \ \ set\ bg_name\ \[lindex\ \$f_text_parts\ 0\]\n\ \ \ \ \ set\ fg_name\ \[lindex\ \$f_text_parts\ 1\]\n\ \ \ \ \ if\ \{\$bg_name\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ bg_name\ \$default_bg_color\n\ \ \ \ \ \}\n\ \ \ \ \ if\ \{\$fg_name\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ fg_name\ black\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ background\ color.\n\ \ \ \ \ if\ \{\$apply_to_bg\}\ \{\n\ \ \ \ \ \ \ \ \ #\ Update\ the\ background\ of\ the\ frame\ and\ the\ frame's\ message.\n\ \ \ \ \ \ \ \ \ .f\ configure\ -bg\ \$rgb\n\ \ \ \ \ \ \ \ \ .f.msg\ configure\ -bg\ \$rgb\n\ \ \ \ \ \ \ \ \ set\ bg_name\ \$cname\n\ \n\ \ \ \ \ \ \ \ \ #\ Update\ the\ foreground\ color\ for\ the\ frame\ (i.e.,\ text\ color\n\ \ \ \ \ \ \ \ \ #\ of\ the\ frame's\ label).\ \ This\ needs\ to\ be\ done\ so\ that\ the\n\ \ \ \ \ \ \ \ \ #\ label's\ color\ will\ contrast\ with\ the\ new\ background\ color.\n\ \ \ \ \ \ \ \ \ set\ frame_fg\ \[get_fg_color\ \[list\ \$red\ \$green\ \$blue\]\]\n\ \ \ \ \ \ \ \ \ .f\ configure\ -fg\ \$frame_fg\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ foreground\ color.\n\ \ \ \ \ if\ \{\$apply_to_fg\}\ \{\n\ \ \ \ \ \ \ \ \ .f.msg\ configure\ -fg\ \$rgb\n\ \ \ \ \ \ \ \ \ set\ fg_name\ \$cname\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ text\ at\ the\ top\ of\ the\ frame.\n\ \ \ \ \ set\ bg_name\ \[string\ trim\ \$bg_name\]\n\ \ \ \ \ set\ fg_name\ \[string\ trim\ \$fg_name\]\n\ \ \ \ \ .f\ configure\ -text\ \"\$bg_name\ /\ \$fg_name\"\n\ \}\n\ \n\ ##\n\ #\ This\ function\ tries\ to\ open\ the\ rgb.txt\ file\ <code>fname</code>.\ \ If\n\ #\ <code>fname</code>\ is\ an\ empty\ string,\ a\ <code>tk_getOpenFile</code>\n\ #\ dialog\ will\ prompt\ the\ user\ for\ a\ file\ name.\ \ Either\ way,\ the\n\ #\ function\ then\ tries\ to\ parse\ the\ file\ extracting\ the\ names\ of\ the\n\ #\ colors\ and\ their\ RGB\ components.\ \ It\ then\ updates\ the\ GUI\ to\ dislay\n\ #\ the\ new\ list\ of\ colors.\n\ #\n\ #\ @param\[in\]\ fname\ file\ name\n\ proc\ on_file_open\ \{fname\}\ \{\n\ \ \ \ \ global\ rgb_fname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Close\ the\ old\ file\ before\ loading\ the\ new\ file.\n\ \ \ \ \ if\ \{!\[on_file_close\]\}\ \{\n\ \ \ \ \ \ \ \ \ #\ User\ canceled\ the\ close.\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Prompt\ the\ user\ for\ a\ file\ name\ if\ one\ isn't\ supplied.\n\ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ #\ Display\ the\ common\ \"File\ Open\"\ dialog.\n\ \ \ \ \ \ \ \ \ set\ fname\ \[tk_getOpenFile\]\n\ \ \ \ \ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ #\ Operation\ canceled.\n\ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ a\ temporary\ array\ to\ hold\ the\ colors.\ \ Each\ array\ name\n\ \ \ \ \ #\ maps\ to\ a\ list\ that\ holds\ the\ RGB\ components\ of\ the\ color.\n\ \ \ \ \ array\ set\ cnames\ \[list\]\n\ \n\ \ \ \ \ #\ Parse\ the\ rgb.txt\ file.\n\ \ \ \ \ parse_rgb_file\ \$fname\ cnames\n\ \n\ \ \ \ \ #\ Iterate\ over\ the\ array\ in\ alphabetical\ order\ inserting\ colors\n\ \ \ \ \ #\ into\ the\ \".lbox\"\ listbox.\n\ \ \ \ \ foreach\ cname\ \[lsort\ -dictionary\ \[array\ names\ cnames\]\]\ \{\n\ \ \ \ \ \ \ \ \ .lbox\ insert\ end\ \"\$cname\ (\[format_color\ \$cnames(\$cname)\])\"\n\ \ \ \ \ \ \ \ \ .lbox\ itemconfigure\ end\ -bg\ \[format_color\ \$cnames(\$cname)\]\n\ \ \ \ \ \ \ \ \ .lbox\ itemconfigure\ end\ -fg\ \[get_fg_color\ \$cnames(\$cname)\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Select\ the\ first\ row.\n\ \ \ \ \ .lbox\ selection\ set\ 0\n\ \n\ \ \ \ \ #\ Let\ the\ GUI\ know\ we\ have\ programmatically\ made\ a\ selection.\n\ \ \ \ \ on_color_selection\n\ \n\ \ \ \ \ #\ Enable\ the\ File/Close\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.file.close\n\ \n\ \ \ \ \ #\ Enable\ the\ Edit/Copy\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.copy\n\ \ \ \ \ bind\ .\ <Control-c>\ \{on_edit_copy\}\n\ \n\ \ \ \ \ #\ Enable\ the\ \"Edit/Apply\ to\ Foreground\"\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.apply_to_fg\n\ \ \ \ \ bind\ .\ <Control-f>\ \{set\ apply_to_fg\ \[expr\ !\$apply_to_fg\]\}\n\ \n\ \ \ \ \ #\ Enable\ the\ \"Edit/Apply\ to\ Background\"\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.apply_to_bg\n\ \ \ \ \ bind\ .\ <Control-b>\ \{set\ apply_to_bg\ \[expr\ !\$apply_to_bg\]\}\n\ \n\ \ \ \ \ #\ Give\ the\ focus\ to\ the\ list\ box.\n\ \ \ \ \ focus\ .lbox\n\ \n\ \ \ \ \ #\ Remember\ the\ name\ of\ the\ rgb\ file.\n\ \ \ \ \ set\ rgb_fname\ \$fname\n\ \}\n\ \n\ ##\n\ #\ Close\ the\ current\ rgb.txt\ file.\n\ #\n\ #\ @return\ whether\ the\ user\ agreed\ to\ close\ the\ file\n\ proc\ on_file_close\ \{\}\ \{\n\ \ \ \ \ global\ default_bg_color\n\ \ \ \ \ global\ rgb_fname\n\ \n\ \ \ \ \ #\ Only\ prompt\ the\ user\ if\ a\ file\ is\ already\ loaded.\n\ \ \ \ \ if\ \{\$rgb_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ message_rv\ \[tk_messageBox\ -type\ okcancel\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -title\ \"Close\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -message\ \"Ok\ to\ close?\"\ \]\n\ \ \ \ \ \ \ \ \ if\ \{\$message_rv\ !=\ \"ok\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ return\ 0\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Clear\ the\ list\ box.\n\ \ \ \ \ .lbox\ delete\ 0\ end\n\ \n\ \ \ \ \ #\ Clear\ the\ frame.\n\ \ \ \ \ .f\ configure\ -text\ \{\}\ -bg\ \$default_bg_color\n\ \ \ \ \ .f.msg\ configure\ -bg\ \$default_bg_color\ -fg\ black\n\ \n\ \ \ \ \ #\ Disable\ the\ \"File/Close\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.file.close\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Copy\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.copy\n\ \ \ \ \ bind\ .\ <Control-c>\ \{\}\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Apply\ to\ Foreground\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.apply_to_fg\n\ \ \ \ \ bind\ .\ <Control-f>\ \{\}\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Apply\ to\ Background\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.apply_to_bg\n\ \ \ \ \ bind\ .\ <Control-b>\ \{\}\n\ \n\ \ \ \ \ #\ Take\ the\ focus\ away\ from\ the\ list\ box.\n\ \ \ \ \ focus\ .\n\ \n\ \ \ \ \ #\ Clear\ the\ file\ name.\n\ \ \ \ \ set\ rgb_fname\ \"\"\n\ \n\ \ \ \ \ return\ 1\n\ \}\n\ \n\ ##\n\ #\ Prompt\ the\ user\ to\ exit\ the\ program.\n\ proc\ on_exit\ \{\}\ \{\n\ \ \ \ \ global\ rgb_fname\n\ \n\ \ \ \ \ #\ Only\ prompt\ the\ user\ if\ a\ file\ is\ currently\ loaded.\n\ \ \ \ \ if\ \{\$rgb_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ message_rv\ \[tk_messageBox\ -type\ okcancel\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -title\ \"Exit\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -message\ \"Ok\ to\ exit?\"\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Exit\ if\ a\ file\ is\ not\ currently\ loaded\ or\ if\ the\ user\ said\ it\ was\ ok.\n\ \ \ \ \ if\ \{(\$rgb_fname\ ==\ \"\")\ ||\ (\$message_rv\ ==\ \"ok\")\}\ \{\n\ \ \ \ \ \ \ \ \ exit\ 0\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Copy\ the\ text\ for\ the\ currently\ selected\ row\ to\ the\ clipboard.\ \ If\n\ #\ no\ row\ is\ selected,\ nothing\ is\ copied\ to\ the\ clipboard.\n\ proc\ on_edit_copy\ \{\}\ \{\n\ \ \ \ \ #\ Get\ the\ index\ of\ the\ selected\ row.\n\ \ \ \ \ set\ index\ \[.lbox\ curselection\]\n\ \ \ \ \ if\ \{\$index\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ return\;\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Get\ the\ text\ of\ the\ selected\ row.\n\ \ \ \ \ set\ row\ \[.lbox\ get\ \$index\]\n\ \n\ \ \ \ \ #\ Set\ the\ clipboard\ text.\n\ \ \ \ \ clipboard\ clear\n\ \ \ \ \ clipboard\ append\ \$row\n\ \}\n\ \n\ ##\n\ #\ Display\ the\ \"About\"\ dialog.\n\ proc\ on_help_about\ \{\}\ \{\n\ \ \ \ \ global\ rgb_version\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ old\ dialog\ is\ destroyed.\n\ \ \ \ \ if\ \{\[winfo\ exists\ .about\]\}\ \{\n\ \ \ \ \ \ \ \ \ destroy\ .about\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ the\ \"About\"\ dialog.\n\ \ \ \ \ toplevel\ .about\ -class\ Dialog\ -bd\ 4\n\ \ \ \ \ wm\ resizable\ .about\ 0\ 0\n\ \ \ \ \ wm\ title\ .about\ \"About\ RGB\"\n\ \ \ \ \ wm\ withdraw\ .about\n\ \n\ \ \ \ \ set\ cwidth\ 375\n\ \ \ \ \ set\ cheight\ 150\n\ \ \ \ \ canvas\ .about.canvas\ -bg\ white\ -width\ \$cwidth\ -height\ \$cheight\n\ \ \ \ \ pack\ .about.canvas\ -expand\ 1\ -fill\ both\ -pady\ 4\n\ \n\ \ \ \ \ #\ Draw\ the\ colored\ blocks.\n\ \ \ \ \ set\ i\ 0\n\ \ \ \ \ set\ clist\ \[list\ azure1\ azure2\ azure3\ azure4\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cornsilk1\ cornsilk2\ cornsilk3\ cornsilk4\]\n\ \ \ \ \ set\ block_width\ 100\n\ \ \ \ \ set\ block_height\ 12\n\ \ \ \ \ set\ x_offset\ \ 10\n\ \ \ \ \ set\ y_offset\ \ 20\n\ \ \ \ \ foreach\ c\ \$clist\ \{\n\ \ \ \ \ \ \ \ \ set\ x0\ \$x_offset\n\ \ \ \ \ \ \ \ \ set\ y0\ \[expr\ \{\$i\ *\ \$block_height\}\ +\ \$y_offset\]\n\ \ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$x_offset\ +\ \$block_width\}\]\n\ \ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{(\$i\ +\ 1)\ *\ \$block_height\}\ +\ \$y_offset\]\n\ \ \ \ \ \ \ \ \ .about.canvas\ create\ rectangle\ \$x0\ \$y0\ \$x1\ \$y1\ -fill\ \$c\n\ \ \ \ \ \ \ \ \ incr\ i\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ the\ labels.\ \ These\ run\ down\ the\ left\ side.\n\ \ \ \ \ set\ left_side\ \"\"\n\ \ \ \ \ append\ left_side\ \"Program:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"Version:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"License:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"Author:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"E-Mail:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"URL:\ \\n\"\n\ \ \ \ \ .about.canvas\ create\ text\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cwidth\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cheight\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ -font\ \"helvetica\ -12\ bold\"\ \\\n\ \ \ \ \ \ \ \ \ -justify\ right\ \\\n\ \ \ \ \ \ \ \ \ -anchor\ e\ \\\n\ \ \ \ \ \ \ \ \ -text\ \$left_side\n\ \n\ \ \ \ \ #\ Create\ the\ values.\ \ These\ run\ down\ the\ right\ side.\n\ \ \ \ \ set\ right_side\ \"\"\n\ \ \ \ \ append\ right_side\ \"RGB\\n\"\n\ \ \ \ \ append\ right_side\ \"\$rgb_version\\n\"\n\ \ \ \ \ append\ right_side\ \"BSD\\n\"\n\ \ \ \ \ append\ right_side\ \"Paul\ Serice\\n\"\n\ \ \ \ \ append\ right_side\ \"[email protected]\\n\"\n\ \ \ \ \ append\ right_side\ \"http://www.serice.net/rgb/\\n\"\n\ \ \ \ \ .about.canvas\ create\ text\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cwidth\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cheight\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ -font\ \"helvetica\ -12\ bold\"\ \\\n\ \ \ \ \ \ \ \ \ -justify\ left\ \\\n\ \ \ \ \ \ \ \ \ -anchor\ w\ \\\n\ \ \ \ \ \ \ \ \ -text\ \$right_side\n\ \n\ \ \ \ \ button\ .about.ok\ -text\ \"OK\"\ -command\ \{destroy\ .about\}\n\ \ \ \ \ pack\ .about.ok\ -side\ right\ -ipadx\ 16\ -pady\ 4\n\ \n\ \ \ \ \ focus\ .about.ok\n\ \n\ \ \ \ \ #\ Wait\ until\ everything\ has\ been\ added\ to\ the\ dialog\ before\ trying\n\ \ \ \ \ #\ to\ center\ it.\n\ \ \ \ \ center_dialog\ .about\ .\n\ \n\ \ \ \ \ #\ Show\ the\ dialog.\n\ \ \ \ \ wm\ deiconify\ .about\n\ \}\n\ \n\ ##\n\ #\ Create\ the\ main\ menu.\n\ proc\ create_main_menu\ \{\}\ \{\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Create\ the\ main\ menu.\n\ \ \ \ \ menu\ .m\ -tearoff\ 0\n\ \ \ \ \ .\ configure\ -menu\ .m\n\ \n\ \ \ \ \ #\ File\n\ \ \ \ \ menu\ .m.file\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.file\ -label\ \"File\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ File/Open\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Open\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl+O\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_file_open\ \"\"\}\n\ \ \ \ \ bind\ .\ <Control-o>\ \{on_file_open\ \"\"\}\n\ \ \ \ \ set\ menu_indexes(.m.file.open)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ File/Close\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Close\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_file_close\}\n\ \ \ \ \ set\ menu_indexes(.m.file.close)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ Separator\n\ \ \ \ \ .m.file\ add\ separator\n\ \n\ \ \ \ \ #\ File/Exit\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Exit\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 1\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_exit\}\n\ \ \ \ \ set\ menu_indexes(.m.file.exit)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ Edit\n\ \ \ \ \ menu\ .m.edit\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.edit\ -label\ \"Edit\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ Edit/Copy\n\ \ \ \ \ .m.edit\ add\ command\ -label\ \"Copy\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl+C\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_edit_copy\}\n\ \ \ \ \ set\ menu_indexes(.m.edit.copy)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Separator\n\ \ \ \ \ .m.edit\ add\ separator\n\ \n\ \ \ \ \ #\ Edit/Apply\ to\ Background\n\ \ \ \ \ .m.edit\ add\ checkbutton\ -label\ \"Apply\ to\ Background\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 9\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl-B\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -variable\ apply_to_bg\n\ \ \ \ \ set\ menu_indexes(.m.edit.apply_to_bg)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Edit/Apply\ to\ Foreground\n\ \ \ \ \ .m.edit\ add\ checkbutton\ -label\ \"Apply\ to\ Foreground\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 9\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl-F\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -variable\ apply_to_fg\n\ \ \ \ \ set\ menu_indexes(.m.edit.apply_to_fg)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Help\n\ \ \ \ \ menu\ .m.help\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.help\ -label\ \"Help\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ Help/About\n\ \ \ \ \ .m.help\ add\ command\ -label\ \"About\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ on_help_about\n\ \ \ \ \ set\ menu_indexes(.m.help.about)\ \[.m.edit\ index\ end\]\n\ \}\n\ \n\ #\n\ #\ Script\ starts\ here.\n\ #\n\ \n\ #\ Set\ the\ program\ name.\n\ set\ progname\ \[file\ tail\ \$argv0\]\n\ \n\ #\ Set\ the\ rgb\ file\ name.\n\ set\ rgb_fname\ \"\"\n\ \n\ #\ Set\ the\ file\ name\ passed\ in\ on\ the\ command\ line.\n\ set\ cmd_fname\ \"\"\n\ \n\ #\ Global\ array\ that\ maps\ each\ menu\ item\ to\ its\ index.\n\ array\ set\ menu_indexes\ \[list\]\n\ \n\ #\ Whether\ to\ apply\ the\ color\ to\ the\ background.\ \ This\ variable\ is\ tied\n\ #\ to\ the\ \"Edit/Apply\ to\ Background\"\ checkbutton.\n\ set\ apply_to_bg\ 1\n\ \n\ #\ Whether\ to\ apply\ the\ color\ to\ the\ foreground.\ \ This\ variable\ is\ tied\n\ #\ to\ the\ \"Edit/Apply\ to\ Foreground\"\ checkbutton.\n\ set\ apply_to_fg\ 0\n\ \n\ #\ Parse\ the\ command\ line.\n\ parse_command_line\ cmd_fname\n\ \n\ #\ Wait\ until\ after\ checking\ \"argv\"\ to\ load\ Tk\;\ otherwise,\ Tk\ crashes\n\ #\ or\ balks\ when\ it\ sees\ \"-h\"\ on\ the\ command\ line.\n\ package\ require\ Tk\n\ \n\ #\ Hide\ the\ window.\n\ wm\ withdraw\ .\n\ \n\ #\ Set\ the\ title.\n\ wm\ title\ .\ RGB\n\ \n\ #\ Create\ the\ main\ menu.\n\ create_main_menu\n\ \n\ #\ Set\ the\ main\ font.\n\ set\ main_font\ \"helvetica\ -12\ bold\"\n\ \n\ #\ Create\ the\ frame\ to\ display\ the\ color.\n\ labelframe\ .f\ -font\ \$main_font\n\ pack\ .f\ -side\ left\ -expand\ 1\ -fill\ both\n\ \n\ #\ Create\ the\ message\ in\ the\ frame.\n\ message\ .f.msg\ -fg\ black\ -font\ \$main_font\ -text\ \$rgb_message\n\ pack\ .f.msg\ -side\ top\ -expand\ 1\ -fill\ both\n\ \n\ #\ Get\ the\ default\ background\ color\ from\ .f\n\ set\ default_bg_color\ \[.f\ cget\ -bg\]\n\ \n\ #\ Create\ the\ list\ box.\n\ listbox\ .lbox\ -setgrid\ 1\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ flat\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -width\ 32\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -height\ 14\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -font\ \$main_font\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -yscrollcommand\ \{.vsb\ set\}\n\ bind\ .lbox\ <ButtonRelease-1>\ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyPress-Up>\ \ \ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyRelease-Up>\ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyPress-Down>\ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyRelease-Down>\ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <Control-KeyRelease-Home>\ \{+on_color_selection\}\n\ bind\ .lbox\ <Control-KeyRelease-End>\ \ \{+on_color_selection\}\n\ pack\ .lbox\ -side\ left\ -expand\ 0\ -fill\ y\n\ \n\ #\ Create\ the\ scroll\ bar.\n\ scrollbar\ .vsb\ -takefocus\ 0\ -command\ \{.lbox\ yview\}\n\ pack\ .vsb\ -side\ left\ -expand\ 0\ -fill\ y\n\ \n\ #\ Parse\ the\ rgb\ file\ which\ loads\ the\ colors.\n\ if\ \{\$cmd_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ on_file_open\ \$cmd_fname\n\ \}\n\ \n\ #\ Show\ the\ window.\n\ wm\ deiconify\ .\n\n----\n\n\[D.\ McC\]\ 2009\ Jan\ 12:\ \ Hey,\ I\ like\ the\ listbox\ lines\ that\ actually\ show\ the\ colors.\ Maybe\ I'll\ include\ something\ like\ them\ in\ the\ next\ version\ of\ \[WISH\ Color\ Picker\ Plus\].\ Feel\ free\ to\ take\ a\ look\ at\ the\ code\ for\ that\ megawidget\ from\ any\ of\ my\ \"WISH\"\ apps\ and\ see\ if\ there's\ anything\ you'd\ like\ to\ use.\n\n----\n!!!!!!\n%|\ \[Category\ Application\]\ |\ \[Category\ GUI\]\ |%\n!!!!!! regexp2} CALL {my render {rgb combinations} !!!!!!\n\[http://www.serice.net/rgb/rgb.png\]\n!!!!!!\n\nGUI\ for\ quickly\ trying\ different\ background\ and\ foreground\ colors.\ \ The\ list\ box\ on\ the\ right\ has\ keyboard\ bindings\ that\ change\ the\ colors\ in\ the\ frame\ on\ the\ left.\ \ The\ home\ page\ is\ http://www.serice.net/rgb/\ which\ has\ the\ source\ which\ is\ also\ listed\ below.\n----\n======\n\ #!/usr/bin/tclsh\n\ \n\ #\n\ #\ This\ program\ reads\ an\ X11\ rgb.txt\ file\ that\ holds\ a\ small,\ simple\n\ #\ database\ that\ maps\ color\ names\ to\ RGB\ component\ values.\ \ It\ then\n\ #\ displays\ the\ colors\ in\ alphabetical\ order\ allowing\ the\ user\ to\n\ #\ preview\ each\ color.\n\ #\n\ #\ It\ is\ possible\ to\ pipe\ the\ colors\ into\ this\ program.\ \ Just\ make\ sure\n\ #\ you\ specify\ the\ rgb.txt\ file\ on\ the\ command\ line\ as\ \"-\".\ \ For\n\ #\ example,\ the\ following\ command\ line\ will\ display\ the\ \"black\"\ and\n\ #\ \"white\"\ colors:\n\ #\n\ #\ \ \ \ \ printf\ \"0\ 0\ 0\ black\\n255\ 255\ 255\ white\\n\"\ |\ ./rgb.tcl\ -\n\ #\n\ #\ Warning:\ Don't\ change\ the\ shebang\ above\ to\ directly\ start\ \"wish.\"\n\ #\ The\ problem\ is\ that\ \"wish\"\ crashes\ if\ \"-h\"\ is\ passed\ in\ on\ the\n\ #\ command\ line,\ but\ we\ need\ \"-h\"\ to\ allow\ the\ user\ to\ ask\ for\ help.\n\ #\ The\ work\ around\ is\ to\ inspect\ \"argv\"\ before\ loading\ Tk.\ \ (See\n\ #\ below.)\n\ #\n\ \n\ ##\n\ #\ Program\ version\n\ set\ rgb_version\ 1.0.1\n\ \n\ ##\n\ #\ Message\ to\ display\ in\ the\ main\ frame.\n\ set\ rgb_message\ \"It\ was\ the\ best\ of\ times,\ it\ was\ the\ worst\ of\ times,\\\n\ it\ was\ the\ age\ of\ wisdom,\ it\ was\ the\ age\ of\ foolishness,\\\n\ it\ was\ the\ epoch\ of\ belief,\ it\ was\ the\ epoch\ of\ incredulity,\\\n\ it\ was\ the\ season\ of\ Light,\ it\ was\ the\ season\ of\ Darkness,\\\n\ it\ was\ the\ spring\ of\ hope,\ it\ was\ the\ winter\ of\ despair,\\\n\ we\ had\ everything\ before\ us,\ we\ had\ nothing\ before\ us,\\\n\ we\ were\ all\ going\ direct\ to\ Heaven,\ we\ were\ all\ going\ direct\\\n\ the\ other\ way--in\ short,\ the\ period\ was\ so\ far\ like\ the\ present\\\n\ period,\ that\ some\ of\ its\ noisiest\ authorities\ insisted\ on\ its\\\n\ being\ received,\ for\ good\ or\ for\ evil,\ in\ the\ superlative\ degree\\\n\ of\ comparison\ only.\"\n\ \n\ ##\n\ #\ Parse\ the\ command\ line\ options.\ \ If\ an\ rgb.txt\ file\ is\ specified\ on\n\ #\ the\ command\ line,\ <code>fname</code>\ will\ be\ set\ to\ match.\n\ #\n\ #\ @param\[out\]\ fnameName\ name\ of\ variable\ to\ hold\ the\ file\ name\n\ proc\ parse_command_line\ \{fnameName\}\ \{\n\ \ \ \ \ global\ argv\n\ \ \ \ \ global\ progname\n\ \n\ \ \ \ \ upvar\ 1\ \$fnameName\ fname\n\ \n\ \ \ \ \ #\ Iterate\ over\ the\ command-line\ arguments.\n\ \ \ \ \ foreach\ arg\ \$argv\ \{\n\ \n\ \ \ \ \ \ \ \ \ #\ -help\n\ \ \ \ \ \ \ \ \ if\ \{(\$arg\ ==\ \"-h\")\ ||\ (\$arg\ ==\ \"-help\")\ ||\ (\$arg\ ==\ \"--help\")\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"Usage:\ \$progname\ \\\[-h\\\]\ \\\[<rgb.txt>\\\]\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\ \ \ \ Note:\ If\ <rgb.txt>\ is\ specified\ as\ \\\"-\\\",\ stdin\ is\ used.\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 0\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Check\ for\ invalid\ flags.\n\ \ \ \ \ \ \ \ \ if\ \{(\[string\ length\ \$argv\]\ >\ 1)\ &&\ (\[string\ index\ \$arg\ 0\]\ ==\ \"-\")\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Error:\ invalid\ flag:\ \$arg\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Must\ be\ the\ name\ of\ the\ file.\n\ \ \ \ \ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ set\ fname\ \$arg\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Error:\ extra\ rgb\ file\ specified:\ \$arg\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Parse\ the\ \"rgb.txt\"\ file\ specified\ by\ the\ path\ <code>fname</code>.\n\ #\ This\ causes\ each\ color\ listed\ in\ <code>fname</code>\ to\ be\ mapped\ in\n\ #\ <code>cnames</code>\ to\ a\ list\ of\ its\ red,\ green,\ and\ blue\ component\n\ #\ colors.\n\ #\n\ #\ @param\[in\]\ fname\ file\ name\ for\ \"rgb.txt\"\ file\n\ #\ @param\[out\]\ cnamesName\ name\ of\ array\ that\ maps\ color\ names\ to\ RGB\n\ proc\ parse_rgb_file\ \{fname\ cnamesName\}\ \{\n\ \ \ \ \ upvar\ 1\ \$cnamesName\ cnames\n\ \n\ \ \ \ \ #\ Open\ file.\n\ \ \ \ \ if\ \{\$fname\ ==\ \"-\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ f\ stdin\n\ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ set\ f\ \[open\ \$fname\ r\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Iterate\ over\ each\ line\ in\ the\ \"rgb.txt\"\ file.\n\ \ \ \ \ while\ \{\[gets\ \$f\ line\]\ >=\ 0\}\ \{\n\ \n\ \ \ \ \ \ \ \ \ #\ Skip\ comments.\n\ \ \ \ \ \ \ \ \ if\ \{\[string\ index\ \$line\ 0\]\ ==\ \"!\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ continue\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Reset.\n\ \ \ \ \ \ \ \ \ set\ red\ 0\n\ \ \ \ \ \ \ \ \ set\ green\ 0\n\ \ \ \ \ \ \ \ \ set\ blue\ 0\n\ \ \ \ \ \ \ \ \ set\ cname\ \"\"\n\ \n\ \ \ \ \ \ \ \ \ #\ Parse\ the\ line.\n\ \ \ \ \ \ \ \ \ regexp\ --\ \{(\[0-9\]+)\[\ \\t\]+(\[0-9\]+)\[\ \\t\]+(\[0-9\]+)\[\ \\t\]+(.*)\$\}\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$line\ all\ red\ green\ blue\ cname\n\ \n\ \ \ \ \ \ \ \ \ #\ Sanity\ check.\n\ \ \ \ \ \ \ \ \ if\ \{\$cname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ continue\n\ \ \ \ \ \ \ \ \ \}\n\ \n\ \ \ \ \ \ \ \ \ #\ Insert\ results\ into\ \"cnames\"\ array.\n\ \ \ \ \ \ \ \ \ set\ cnames(\$cname)\ \[list\ \$red\ \$green\ \$blue\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Close\ file.\n\ \ \ \ \ if\ \{\$fname\ !=\ \"-\"\}\ \{\n\ \ \ \ \ \ \ \ \ close\ \$f\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Convert\ the\ <code>rgb</code>\ list\ of\ component\ colors\ into\ the\n\ #\ format\ \"#RRGGBB\"\ and\ return\ the\ result.\n\ #\n\ #\ @param\[in\]\ rgb\ RGB\ component\ colors\ as\ a\ list\n\ #\ @return\ RGB\ component\ colors\ as\ a\ string\n\ proc\ format_color\ \{rgb\}\ \{\n\ \ \ \ \ foreach\ \{red\ green\ blue\}\ \$rgb\ \{\}\n\ \ \ \ \ format\ \"#%02x%02x%02x\"\ \$red\ \$green\ \$blue\n\ \}\n\ \n\ ##\n\ #\ This\ function\ returns\ \"black\"\ unless\ the\ list\ of\ component\ colors\ in\n\ #\ <code>rgb</code>\ indicates\ that\ the\ color\ is\ dark.\ \ Then,\ this\n\ #\ function\ returns\ \"white\".\ \ The\ idea\ is\ that\ the\ color\ returned\ is\n\ #\ suitable\ for\ use\ as\ the\ foreground\ (or\ text)\ color\ if\n\ #\ <code>rgb</code>\ is\ the\ background\ color.\n\ #\n\ #\ @param\[in\]\ rgb\ RGB\ component\ colors\ as\ a\ list\n\ #\ @return\ RGB\ component\ colors\ as\ a\ string\n\ proc\ get_fg_color\ \{rgb\}\ \{\n\ \ \ \ \ set\ rv\ black\n\ \ \ \ \ foreach\ \{red\ green\ blue\}\ \$rgb\ \{\}\n\ \ \ \ \ if\ \{(\$red\ <\ 0xa0)\ &&\ (\$green\ <\ 0xa0)\}\ \{\n\ \ \ \ \ \ \ \ \ set\ rv\ white\n\ \ \ \ \ \}\n\ \ \ \ \ return\ \$rv\n\ \}\n\ \n\ ##\n\ #\ Enable\ the\ menu\ item\ <code>item</code>.\n\ #\n\ #\ @param\[in\]\ item\ menu\ item\n\ proc\ enable_menu_item\ \{item\}\ \{\n\ \ \ \ \ global\ progname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Get\ the\ parent\ menu.\n\ \ \ \ \ set\ parent\ \[file\ rootname\ \$item\]\n\ \ \ \ \ if\ \{!\[winfo\ exists\ \$parent\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ enable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ parent:\ \$parent\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ menu\ item\ exists.\n\ \ \ \ \ if\ \{!\[info\ exists\ menu_indexes(\$item)\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ enable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ menu\ item:\ \$item\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Enable\ the\ menu\ item.\n\ \ \ \ \ \$parent\ entryconfigure\ \$menu_indexes(\$item)\ -state\ normal\n\ \}\n\ \n\ ##\n\ #\ Disable\ the\ menu\ item\ <code>item</code>.\n\ #\n\ #\ @param\[in\]\ item\ menu\ item\n\ proc\ disable_menu_item\ \{item\}\ \{\n\ \ \ \ \ global\ progname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Get\ the\ parent\ menu.\n\ \ \ \ \ set\ parent\ \[file\ rootname\ \$item\]\n\ \ \ \ \ if\ \{!\[winfo\ exists\ \$parent\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ disable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ parent:\ \$parent\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ menu\ item\ exists.\n\ \ \ \ \ if\ \{!\[info\ exists\ menu_indexes(\$item)\]\}\ \{\n\ \ \ \ \ \ \ \ \ puts\ stderr\ \"\$progname:\ Warning:\ disable_menu_item:\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ no\ menu\ item:\ \$item\"\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Disable\ the\ menu\ item.\n\ \ \ \ \ \$parent\ entryconfigure\ \$menu_indexes(\$item)\ -state\ disabled\n\ \}\n\ \n\ ##\n\ #\ Center\ the\ dialog\ window\ <code>d</code>\ over\ the\ window\n\ #\ <code>p</code>.\ \ If\ <code>p</code>\ does\ not\ exist,\ the\ dialog\ is\n\ #\ centered\ over\ the\ entire\ screen.\n\ #\n\ #\ @param\[in\]\ d\ dialog\ window\n\ #\ @param\[in\]\ p\ parent\ window\n\ #\ @see\ ::tk::PlaceWindow\ (in\ tk.tcl)\n\ proc\ center_dialog\ \{d\ \{p\ \"\"\}\}\ \{\n\ \n\ \ \ \ \ #\ Force\ the\ geometry\ manager\ to\ update\ the\ layout\ so\ we\ can\ query\n\ \ \ \ \ #\ the\ correct\ size\ of\ the\ window.\n\ \ \ \ \ update\ idletasks\n\ \n\ \ \ \ \ #\ Get\ the\ width\ and\ height\ requested\ by\ the\ geometry\ manager.\n\ \ \ \ \ #\ This\ often\ is\ not\ the\ same\ as\ the\ current\ width\ and\ height\n\ \ \ \ \ #\ because\ the\ Window\ Manager\ may\ not\ have\ resized\ the\ window\ yet.\n\ \ \ \ \ set\ d_width\ \[winfo\ reqwidth\ \$d\]\n\ \ \ \ \ set\ d_height\ \[winfo\ reqheight\ \$d\]\n\ \n\ \ \ \ \ #\ If\ the\ parent\ exists,\ use\ the\ geometry\ of\ the\ parent\ window.\n\ \ \ \ \ if\ \{\[winfo\ exists\ \$p\]\}\ \{\n\ \ \ \ \ \ \ \ \ set\ p_x\ \[winfo\ rootx\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_y\ \[winfo\ rooty\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_width\ \[winfo\ width\ \$p\]\n\ \ \ \ \ \ \ \ \ set\ p_height\ \[winfo\ height\ \$p\]\n\ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ #\ Otherwise,\ use\ the\ geometry\ of\ the\ screen.\n\ \ \ \ \ \ \ \ \ set\ p_x\ 0\n\ \ \ \ \ \ \ \ \ set\ p_y\ 0\n\ \ \ \ \ \ \ \ \ set\ p_width\ \[winfo\ screenwidth\ \$d\]\n\ \ \ \ \ \ \ \ \ set\ p_height\ \[winfo\ screenheight\ \$d\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Set\ the\ new\ location\ for\ the\ dialog\ window.\ \ We\ subtract\ 25\ to\n\ \ \ \ \ #\ raise\ the\ dialog\ a\ little\ on\ the\ screen.\n\ \ \ \ \ set\ new_x\ \[expr\ \{\$p_x\ +\ (\$p_width\ -\ \$d_width)\ /\ 2\}\]\n\ \ \ \ \ set\ new_y\ \[expr\ \{\$p_y\ +\ (\$p_height\ -\ \$d_height)\ /\ 2\ -\ 25\}\]\n\ \n\ \ \ \ \ #\ Bounds\ check.\n\ \ \ \ \ if\ \{\$new_x\ <\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ set\ new_x\ 0\n\ \ \ \ \ \}\n\ \ \ \ \ if\ \{\$new_y\ <\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ set\ new_y\ 0\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Move\ the\ dialog\ window\ into\ place.\n\ \ \ \ \ wm\ geom\ \$d\ \"+\$new_x+\$new_y\"\n\ \}\n\ \n\ ##\n\ #\ This\ function\ is\ called\ when\ the\ selects\ a\ color\ in\ the\ list\ box.\n\ #\ It\ queries\ the\ list\ box\ for\ the\ color\ and\ uses\ it\ to\ set\ the\n\ #\ background\ color\ of\ the\ <code>.f</code>\ frame.\ \ It\ also\ changes\ the\n\ #\ label\ for\ the\ <code>.f</code>\ frame\ to\ be\ the\ name\ of\ the\ color.\n\ proc\ on_color_selection\ \{\}\ \{\n\ \ \ \ \ global\ apply_to_bg\n\ \ \ \ \ global\ apply_to_fg\n\ \ \ \ \ global\ default_bg_color\n\ \n\ \ \ \ \ #\ Get\ the\ index\ of\ the\ selected\ row.\n\ \ \ \ \ set\ index\ \[.lbox\ curselection\]\n\ \ \ \ \ if\ \{\$index\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ return\;\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Get\ the\ text\ of\ the\ selected\ row.\n\ \ \ \ \ set\ row\ \[.lbox\ get\ \$index\]\n\ \n\ \ \ \ \ #\ Recover\ the\ name\ of\ the\ color\ and\ the\ rgb\ value\ from\ the\ row.\n\ \ \ \ \ regexp\ --\ \{(.*)\ \\((#\[0-9a-fA-F\]+)\\)\}\ \$row\ all\ cname\ rgb\n\ \n\ \ \ \ \ #\ Split\ RGB\ string\ into\ component\ colors.\n\ \ \ \ \ scan\ \$rgb\ \"#%02x%02x%02x\"\ red\ green\ blue\n\ \n\ \ \ \ \ #\ Split\ the\ text\ at\ the\ top\ of\ the\ frame\ so\ we\ can\ update\ each\ part.\n\ \ \ \ \ set\ f_text_parts\ \[split\ \[.f\ cget\ -text\]\ \"/\"\]\n\ \ \ \ \ set\ bg_name\ \[lindex\ \$f_text_parts\ 0\]\n\ \ \ \ \ set\ fg_name\ \[lindex\ \$f_text_parts\ 1\]\n\ \ \ \ \ if\ \{\$bg_name\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ bg_name\ \$default_bg_color\n\ \ \ \ \ \}\n\ \ \ \ \ if\ \{\$fg_name\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ fg_name\ black\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ background\ color.\n\ \ \ \ \ if\ \{\$apply_to_bg\}\ \{\n\ \ \ \ \ \ \ \ \ #\ Update\ the\ background\ of\ the\ frame\ and\ the\ frame's\ message.\n\ \ \ \ \ \ \ \ \ .f\ configure\ -bg\ \$rgb\n\ \ \ \ \ \ \ \ \ .f.msg\ configure\ -bg\ \$rgb\n\ \ \ \ \ \ \ \ \ set\ bg_name\ \$cname\n\ \n\ \ \ \ \ \ \ \ \ #\ Update\ the\ foreground\ color\ for\ the\ frame\ (i.e.,\ text\ color\n\ \ \ \ \ \ \ \ \ #\ of\ the\ frame's\ label).\ \ This\ needs\ to\ be\ done\ so\ that\ the\n\ \ \ \ \ \ \ \ \ #\ label's\ color\ will\ contrast\ with\ the\ new\ background\ color.\n\ \ \ \ \ \ \ \ \ set\ frame_fg\ \[get_fg_color\ \[list\ \$red\ \$green\ \$blue\]\]\n\ \ \ \ \ \ \ \ \ .f\ configure\ -fg\ \$frame_fg\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ foreground\ color.\n\ \ \ \ \ if\ \{\$apply_to_fg\}\ \{\n\ \ \ \ \ \ \ \ \ .f.msg\ configure\ -fg\ \$rgb\n\ \ \ \ \ \ \ \ \ set\ fg_name\ \$cname\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Update\ the\ text\ at\ the\ top\ of\ the\ frame.\n\ \ \ \ \ set\ bg_name\ \[string\ trim\ \$bg_name\]\n\ \ \ \ \ set\ fg_name\ \[string\ trim\ \$fg_name\]\n\ \ \ \ \ .f\ configure\ -text\ \"\$bg_name\ /\ \$fg_name\"\n\ \}\n\ \n\ ##\n\ #\ This\ function\ tries\ to\ open\ the\ rgb.txt\ file\ <code>fname</code>.\ \ If\n\ #\ <code>fname</code>\ is\ an\ empty\ string,\ a\ <code>tk_getOpenFile</code>\n\ #\ dialog\ will\ prompt\ the\ user\ for\ a\ file\ name.\ \ Either\ way,\ the\n\ #\ function\ then\ tries\ to\ parse\ the\ file\ extracting\ the\ names\ of\ the\n\ #\ colors\ and\ their\ RGB\ components.\ \ It\ then\ updates\ the\ GUI\ to\ dislay\n\ #\ the\ new\ list\ of\ colors.\n\ #\n\ #\ @param\[in\]\ fname\ file\ name\n\ proc\ on_file_open\ \{fname\}\ \{\n\ \ \ \ \ global\ rgb_fname\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Close\ the\ old\ file\ before\ loading\ the\ new\ file.\n\ \ \ \ \ if\ \{!\[on_file_close\]\}\ \{\n\ \ \ \ \ \ \ \ \ #\ User\ canceled\ the\ close.\n\ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Prompt\ the\ user\ for\ a\ file\ name\ if\ one\ isn't\ supplied.\n\ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ #\ Display\ the\ common\ \"File\ Open\"\ dialog.\n\ \ \ \ \ \ \ \ \ set\ fname\ \[tk_getOpenFile\]\n\ \ \ \ \ \ \ \ \ if\ \{\$fname\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ #\ Operation\ canceled.\n\ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ a\ temporary\ array\ to\ hold\ the\ colors.\ \ Each\ array\ name\n\ \ \ \ \ #\ maps\ to\ a\ list\ that\ holds\ the\ RGB\ components\ of\ the\ color.\n\ \ \ \ \ array\ set\ cnames\ \[list\]\n\ \n\ \ \ \ \ #\ Parse\ the\ rgb.txt\ file.\n\ \ \ \ \ parse_rgb_file\ \$fname\ cnames\n\ \n\ \ \ \ \ #\ Iterate\ over\ the\ array\ in\ alphabetical\ order\ inserting\ colors\n\ \ \ \ \ #\ into\ the\ \".lbox\"\ listbox.\n\ \ \ \ \ foreach\ cname\ \[lsort\ -dictionary\ \[array\ names\ cnames\]\]\ \{\n\ \ \ \ \ \ \ \ \ .lbox\ insert\ end\ \"\$cname\ (\[format_color\ \$cnames(\$cname)\])\"\n\ \ \ \ \ \ \ \ \ .lbox\ itemconfigure\ end\ -bg\ \[format_color\ \$cnames(\$cname)\]\n\ \ \ \ \ \ \ \ \ .lbox\ itemconfigure\ end\ -fg\ \[get_fg_color\ \$cnames(\$cname)\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Select\ the\ first\ row.\n\ \ \ \ \ .lbox\ selection\ set\ 0\n\ \n\ \ \ \ \ #\ Let\ the\ GUI\ know\ we\ have\ programmatically\ made\ a\ selection.\n\ \ \ \ \ on_color_selection\n\ \n\ \ \ \ \ #\ Enable\ the\ File/Close\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.file.close\n\ \n\ \ \ \ \ #\ Enable\ the\ Edit/Copy\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.copy\n\ \ \ \ \ bind\ .\ <Control-c>\ \{on_edit_copy\}\n\ \n\ \ \ \ \ #\ Enable\ the\ \"Edit/Apply\ to\ Foreground\"\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.apply_to_fg\n\ \ \ \ \ bind\ .\ <Control-f>\ \{set\ apply_to_fg\ \[expr\ !\$apply_to_fg\]\}\n\ \n\ \ \ \ \ #\ Enable\ the\ \"Edit/Apply\ to\ Background\"\ menu\ item.\n\ \ \ \ \ enable_menu_item\ .m.edit.apply_to_bg\n\ \ \ \ \ bind\ .\ <Control-b>\ \{set\ apply_to_bg\ \[expr\ !\$apply_to_bg\]\}\n\ \n\ \ \ \ \ #\ Give\ the\ focus\ to\ the\ list\ box.\n\ \ \ \ \ focus\ .lbox\n\ \n\ \ \ \ \ #\ Remember\ the\ name\ of\ the\ rgb\ file.\n\ \ \ \ \ set\ rgb_fname\ \$fname\n\ \}\n\ \n\ ##\n\ #\ Close\ the\ current\ rgb.txt\ file.\n\ #\n\ #\ @return\ whether\ the\ user\ agreed\ to\ close\ the\ file\n\ proc\ on_file_close\ \{\}\ \{\n\ \ \ \ \ global\ default_bg_color\n\ \ \ \ \ global\ rgb_fname\n\ \n\ \ \ \ \ #\ Only\ prompt\ the\ user\ if\ a\ file\ is\ already\ loaded.\n\ \ \ \ \ if\ \{\$rgb_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ message_rv\ \[tk_messageBox\ -type\ okcancel\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -title\ \"Close\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -message\ \"Ok\ to\ close?\"\ \]\n\ \ \ \ \ \ \ \ \ if\ \{\$message_rv\ !=\ \"ok\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ return\ 0\n\ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Clear\ the\ list\ box.\n\ \ \ \ \ .lbox\ delete\ 0\ end\n\ \n\ \ \ \ \ #\ Clear\ the\ frame.\n\ \ \ \ \ .f\ configure\ -text\ \{\}\ -bg\ \$default_bg_color\n\ \ \ \ \ .f.msg\ configure\ -bg\ \$default_bg_color\ -fg\ black\n\ \n\ \ \ \ \ #\ Disable\ the\ \"File/Close\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.file.close\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Copy\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.copy\n\ \ \ \ \ bind\ .\ <Control-c>\ \{\}\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Apply\ to\ Foreground\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.apply_to_fg\n\ \ \ \ \ bind\ .\ <Control-f>\ \{\}\n\ \n\ \ \ \ \ #\ Disable\ the\ \"Edit/Apply\ to\ Background\"\ menu\ item.\n\ \ \ \ \ disable_menu_item\ .m.edit.apply_to_bg\n\ \ \ \ \ bind\ .\ <Control-b>\ \{\}\n\ \n\ \ \ \ \ #\ Take\ the\ focus\ away\ from\ the\ list\ box.\n\ \ \ \ \ focus\ .\n\ \n\ \ \ \ \ #\ Clear\ the\ file\ name.\n\ \ \ \ \ set\ rgb_fname\ \"\"\n\ \n\ \ \ \ \ return\ 1\n\ \}\n\ \n\ ##\n\ #\ Prompt\ the\ user\ to\ exit\ the\ program.\n\ proc\ on_exit\ \{\}\ \{\n\ \ \ \ \ global\ rgb_fname\n\ \n\ \ \ \ \ #\ Only\ prompt\ the\ user\ if\ a\ file\ is\ currently\ loaded.\n\ \ \ \ \ if\ \{\$rgb_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ set\ message_rv\ \[tk_messageBox\ -type\ okcancel\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -title\ \"Exit\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -message\ \"Ok\ to\ exit?\"\]\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Exit\ if\ a\ file\ is\ not\ currently\ loaded\ or\ if\ the\ user\ said\ it\ was\ ok.\n\ \ \ \ \ if\ \{(\$rgb_fname\ ==\ \"\")\ ||\ (\$message_rv\ ==\ \"ok\")\}\ \{\n\ \ \ \ \ \ \ \ \ exit\ 0\n\ \ \ \ \ \}\n\ \}\n\ \n\ ##\n\ #\ Copy\ the\ text\ for\ the\ currently\ selected\ row\ to\ the\ clipboard.\ \ If\n\ #\ no\ row\ is\ selected,\ nothing\ is\ copied\ to\ the\ clipboard.\n\ proc\ on_edit_copy\ \{\}\ \{\n\ \ \ \ \ #\ Get\ the\ index\ of\ the\ selected\ row.\n\ \ \ \ \ set\ index\ \[.lbox\ curselection\]\n\ \ \ \ \ if\ \{\$index\ ==\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ return\;\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Get\ the\ text\ of\ the\ selected\ row.\n\ \ \ \ \ set\ row\ \[.lbox\ get\ \$index\]\n\ \n\ \ \ \ \ #\ Set\ the\ clipboard\ text.\n\ \ \ \ \ clipboard\ clear\n\ \ \ \ \ clipboard\ append\ \$row\n\ \}\n\ \n\ ##\n\ #\ Display\ the\ \"About\"\ dialog.\n\ proc\ on_help_about\ \{\}\ \{\n\ \ \ \ \ global\ rgb_version\n\ \n\ \ \ \ \ #\ Make\ sure\ the\ old\ dialog\ is\ destroyed.\n\ \ \ \ \ if\ \{\[winfo\ exists\ .about\]\}\ \{\n\ \ \ \ \ \ \ \ \ destroy\ .about\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ the\ \"About\"\ dialog.\n\ \ \ \ \ toplevel\ .about\ -class\ Dialog\ -bd\ 4\n\ \ \ \ \ wm\ resizable\ .about\ 0\ 0\n\ \ \ \ \ wm\ title\ .about\ \"About\ RGB\"\n\ \ \ \ \ wm\ withdraw\ .about\n\ \n\ \ \ \ \ set\ cwidth\ 375\n\ \ \ \ \ set\ cheight\ 150\n\ \ \ \ \ canvas\ .about.canvas\ -bg\ white\ -width\ \$cwidth\ -height\ \$cheight\n\ \ \ \ \ pack\ .about.canvas\ -expand\ 1\ -fill\ both\ -pady\ 4\n\ \n\ \ \ \ \ #\ Draw\ the\ colored\ blocks.\n\ \ \ \ \ set\ i\ 0\n\ \ \ \ \ set\ clist\ \[list\ azure1\ azure2\ azure3\ azure4\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cornsilk1\ cornsilk2\ cornsilk3\ cornsilk4\]\n\ \ \ \ \ set\ block_width\ 100\n\ \ \ \ \ set\ block_height\ 12\n\ \ \ \ \ set\ x_offset\ \ 10\n\ \ \ \ \ set\ y_offset\ \ 20\n\ \ \ \ \ foreach\ c\ \$clist\ \{\n\ \ \ \ \ \ \ \ \ set\ x0\ \$x_offset\n\ \ \ \ \ \ \ \ \ set\ y0\ \[expr\ \{\$i\ *\ \$block_height\}\ +\ \$y_offset\]\n\ \ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$x_offset\ +\ \$block_width\}\]\n\ \ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{(\$i\ +\ 1)\ *\ \$block_height\}\ +\ \$y_offset\]\n\ \ \ \ \ \ \ \ \ .about.canvas\ create\ rectangle\ \$x0\ \$y0\ \$x1\ \$y1\ -fill\ \$c\n\ \ \ \ \ \ \ \ \ incr\ i\n\ \ \ \ \ \}\n\ \n\ \ \ \ \ #\ Create\ the\ labels.\ \ These\ run\ down\ the\ left\ side.\n\ \ \ \ \ set\ left_side\ \"\"\n\ \ \ \ \ append\ left_side\ \"Program:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"Version:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"License:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"Author:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"E-Mail:\ \\n\"\n\ \ \ \ \ append\ left_side\ \"URL:\ \\n\"\n\ \ \ \ \ .about.canvas\ create\ text\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cwidth\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cheight\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ -font\ \"helvetica\ -12\ bold\"\ \\\n\ \ \ \ \ \ \ \ \ -justify\ right\ \\\n\ \ \ \ \ \ \ \ \ -anchor\ e\ \\\n\ \ \ \ \ \ \ \ \ -text\ \$left_side\n\ \n\ \ \ \ \ #\ Create\ the\ values.\ \ These\ run\ down\ the\ right\ side.\n\ \ \ \ \ set\ right_side\ \"\"\n\ \ \ \ \ append\ right_side\ \"RGB\\n\"\n\ \ \ \ \ append\ right_side\ \"\$rgb_version\\n\"\n\ \ \ \ \ append\ right_side\ \"BSD\\n\"\n\ \ \ \ \ append\ right_side\ \"Paul\ Serice\\n\"\n\ \ \ \ \ append\ right_side\ \"[email protected]\\n\"\n\ \ \ \ \ append\ right_side\ \"http://www.serice.net/rgb/\\n\"\n\ \ \ \ \ .about.canvas\ create\ text\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cwidth\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ \[expr\ \{\$cheight\ /\ 2\}\]\ \\\n\ \ \ \ \ \ \ \ \ -font\ \"helvetica\ -12\ bold\"\ \\\n\ \ \ \ \ \ \ \ \ -justify\ left\ \\\n\ \ \ \ \ \ \ \ \ -anchor\ w\ \\\n\ \ \ \ \ \ \ \ \ -text\ \$right_side\n\ \n\ \ \ \ \ button\ .about.ok\ -text\ \"OK\"\ -command\ \{destroy\ .about\}\n\ \ \ \ \ pack\ .about.ok\ -side\ right\ -ipadx\ 16\ -pady\ 4\n\ \n\ \ \ \ \ focus\ .about.ok\n\ \n\ \ \ \ \ #\ Wait\ until\ everything\ has\ been\ added\ to\ the\ dialog\ before\ trying\n\ \ \ \ \ #\ to\ center\ it.\n\ \ \ \ \ center_dialog\ .about\ .\n\ \n\ \ \ \ \ #\ Show\ the\ dialog.\n\ \ \ \ \ wm\ deiconify\ .about\n\ \}\n\ \n\ ##\n\ #\ Create\ the\ main\ menu.\n\ proc\ create_main_menu\ \{\}\ \{\n\ \ \ \ \ global\ menu_indexes\n\ \n\ \ \ \ \ #\ Create\ the\ main\ menu.\n\ \ \ \ \ menu\ .m\ -tearoff\ 0\n\ \ \ \ \ .\ configure\ -menu\ .m\n\ \n\ \ \ \ \ #\ File\n\ \ \ \ \ menu\ .m.file\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.file\ -label\ \"File\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ File/Open\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Open\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl+O\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_file_open\ \"\"\}\n\ \ \ \ \ bind\ .\ <Control-o>\ \{on_file_open\ \"\"\}\n\ \ \ \ \ set\ menu_indexes(.m.file.open)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ File/Close\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Close\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_file_close\}\n\ \ \ \ \ set\ menu_indexes(.m.file.close)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ Separator\n\ \ \ \ \ .m.file\ add\ separator\n\ \n\ \ \ \ \ #\ File/Exit\n\ \ \ \ \ .m.file\ add\ command\ -label\ \"Exit\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 1\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_exit\}\n\ \ \ \ \ set\ menu_indexes(.m.file.exit)\ \[.m.file\ index\ end\]\n\ \n\ \ \ \ \ #\ Edit\n\ \ \ \ \ menu\ .m.edit\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.edit\ -label\ \"Edit\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ Edit/Copy\n\ \ \ \ \ .m.edit\ add\ command\ -label\ \"Copy\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl+C\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ \{on_edit_copy\}\n\ \ \ \ \ set\ menu_indexes(.m.edit.copy)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Separator\n\ \ \ \ \ .m.edit\ add\ separator\n\ \n\ \ \ \ \ #\ Edit/Apply\ to\ Background\n\ \ \ \ \ .m.edit\ add\ checkbutton\ -label\ \"Apply\ to\ Background\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 9\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl-B\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -variable\ apply_to_bg\n\ \ \ \ \ set\ menu_indexes(.m.edit.apply_to_bg)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Edit/Apply\ to\ Foreground\n\ \ \ \ \ .m.edit\ add\ checkbutton\ -label\ \"Apply\ to\ Foreground\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 9\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -accelerator\ Ctrl-F\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -state\ disabled\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -variable\ apply_to_fg\n\ \ \ \ \ set\ menu_indexes(.m.edit.apply_to_fg)\ \[.m.edit\ index\ end\]\n\ \n\ \ \ \ \ #\ Help\n\ \ \ \ \ menu\ .m.help\ -tearoff\ 0\n\ \ \ \ \ .m\ add\ cascade\ -menu\ .m.help\ -label\ \"Help\"\ -underline\ 0\n\ \n\ \ \ \ \ #\ Help/About\n\ \ \ \ \ .m.help\ add\ command\ -label\ \"About\"\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -underline\ 0\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -command\ on_help_about\n\ \ \ \ \ set\ menu_indexes(.m.help.about)\ \[.m.edit\ index\ end\]\n\ \}\n\ \n\ #\n\ #\ Script\ starts\ here.\n\ #\n\ \n\ #\ Set\ the\ program\ name.\n\ set\ progname\ \[file\ tail\ \$argv0\]\n\ \n\ #\ Set\ the\ rgb\ file\ name.\n\ set\ rgb_fname\ \"\"\n\ \n\ #\ Set\ the\ file\ name\ passed\ in\ on\ the\ command\ line.\n\ set\ cmd_fname\ \"\"\n\ \n\ #\ Global\ array\ that\ maps\ each\ menu\ item\ to\ its\ index.\n\ array\ set\ menu_indexes\ \[list\]\n\ \n\ #\ Whether\ to\ apply\ the\ color\ to\ the\ background.\ \ This\ variable\ is\ tied\n\ #\ to\ the\ \"Edit/Apply\ to\ Background\"\ checkbutton.\n\ set\ apply_to_bg\ 1\n\ \n\ #\ Whether\ to\ apply\ the\ color\ to\ the\ foreground.\ \ This\ variable\ is\ tied\n\ #\ to\ the\ \"Edit/Apply\ to\ Foreground\"\ checkbutton.\n\ set\ apply_to_fg\ 0\n\ \n\ #\ Parse\ the\ command\ line.\n\ parse_command_line\ cmd_fname\n\ \n\ #\ Wait\ until\ after\ checking\ \"argv\"\ to\ load\ Tk\;\ otherwise,\ Tk\ crashes\n\ #\ or\ balks\ when\ it\ sees\ \"-h\"\ on\ the\ command\ line.\n\ package\ require\ Tk\n\ \n\ #\ Hide\ the\ window.\n\ wm\ withdraw\ .\n\ \n\ #\ Set\ the\ title.\n\ wm\ title\ .\ RGB\n\ \n\ #\ Create\ the\ main\ menu.\n\ create_main_menu\n\ \n\ #\ Set\ the\ main\ font.\n\ set\ main_font\ \"helvetica\ -12\ bold\"\n\ \n\ #\ Create\ the\ frame\ to\ display\ the\ color.\n\ labelframe\ .f\ -font\ \$main_font\n\ pack\ .f\ -side\ left\ -expand\ 1\ -fill\ both\n\ \n\ #\ Create\ the\ message\ in\ the\ frame.\n\ message\ .f.msg\ -fg\ black\ -font\ \$main_font\ -text\ \$rgb_message\n\ pack\ .f.msg\ -side\ top\ -expand\ 1\ -fill\ both\n\ \n\ #\ Get\ the\ default\ background\ color\ from\ .f\n\ set\ default_bg_color\ \[.f\ cget\ -bg\]\n\ \n\ #\ Create\ the\ list\ box.\n\ listbox\ .lbox\ -setgrid\ 1\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ flat\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -width\ 32\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -height\ 14\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -font\ \$main_font\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -yscrollcommand\ \{.vsb\ set\}\n\ bind\ .lbox\ <ButtonRelease-1>\ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyPress-Up>\ \ \ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyRelease-Up>\ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyPress-Down>\ \ \ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <KeyRelease-Down>\ \ \ \ \ \ \ \ \ \{+on_color_selection\}\n\ bind\ .lbox\ <Control-KeyRelease-Home>\ \{+on_color_selection\}\n\ bind\ .lbox\ <Control-KeyRelease-End>\ \ \{+on_color_selection\}\n\ pack\ .lbox\ -side\ left\ -expand\ 0\ -fill\ y\n\ \n\ #\ Create\ the\ scroll\ bar.\n\ scrollbar\ .vsb\ -takefocus\ 0\ -command\ \{.lbox\ yview\}\n\ pack\ .vsb\ -side\ left\ -expand\ 0\ -fill\ y\n\ \n\ #\ Parse\ the\ rgb\ file\ which\ loads\ the\ colors.\n\ if\ \{\$cmd_fname\ !=\ \"\"\}\ \{\n\ \ \ \ \ on_file_open\ \$cmd_fname\n\ \}\n\ \n\ #\ Show\ the\ window.\n\ wm\ deiconify\ .\n\n----\n\n\[D.\ McC\]\ 2009\ Jan\ 12:\ \ Hey,\ I\ like\ the\ listbox\ lines\ that\ actually\ show\ the\ colors.\ Maybe\ I'll\ include\ something\ like\ them\ in\ the\ next\ version\ of\ \[WISH\ Color\ Picker\ Plus\].\ Feel\ free\ to\ take\ a\ look\ at\ the\ code\ for\ that\ megawidget\ from\ any\ of\ my\ \"WISH\"\ apps\ and\ see\ if\ there's\ anything\ you'd\ like\ to\ use.\n\n----\n!!!!!!\n%|\ \[Category\ Application\]\ |\ \[Category\ GUI\]\ |%\n!!!!!!} CALL {my revision {rgb combinations}} CALL {::oo::Obj6474362 process revision/rgb+combinations} CALL {::oo::Obj6474360 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4