Colors may now be overridden using the "colorfile" option.
This commit is contained in:
parent
4da9ae7c25
commit
dc459535a7
8 changed files with 238 additions and 34 deletions
|
|
@ -60,6 +60,10 @@ $Id$
|
||||||
* Stamps may now include a second sound effect, used as a spoken
|
* Stamps may now include a second sound effect, used as a spoken
|
||||||
description.
|
description.
|
||||||
(stampname_desc.ogg or .wav and localized stampname_desc_ll.ogg or .wav)
|
(stampname_desc.ogg or .wav and localized stampname_desc_ll.ogg or .wav)
|
||||||
|
|
||||||
|
* The color palette may now be overridden by creating a text file
|
||||||
|
containing color descriptions, and using the "colorfile" option.
|
||||||
|
|
||||||
|
|
||||||
* Tool improvements:
|
* Tool improvements:
|
||||||
------------------------
|
------------------------
|
||||||
|
|
@ -95,7 +99,6 @@ $Id$
|
||||||
* Kuro Neko ("Black Cat") (animated, directional)
|
* Kuro Neko ("Black Cat") (animated, directional)
|
||||||
(Based on the cat from 'xneko' by Masayuki Koba)
|
(Based on the cat from 'xneko' by Masayuki Koba)
|
||||||
|
|
||||||
|
|
||||||
* New Starter Images:
|
* New Starter Images:
|
||||||
-------------------
|
-------------------
|
||||||
* Shipwreck
|
* Shipwreck
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,27 @@ Windows Users
|
||||||
starts up, rather than loading the last image that was being
|
starts up, rather than loading the last image that was being
|
||||||
edited.
|
edited.
|
||||||
|
|
||||||
|
colorfile=FILENAME
|
||||||
|
|
||||||
|
You may override Tux Paint's default color palette by creating a
|
||||||
|
plain ASCII text file that describes the colors you want, and
|
||||||
|
pointing to that file using the colorfile option.
|
||||||
|
|
||||||
|
The file should list one color per line. Colors are defined in
|
||||||
|
terms of their Red, Green and Blue values, each from 0 (off) to
|
||||||
|
255 (brightest). (For more information, try Wikipedia's "RGB
|
||||||
|
color model" article.)
|
||||||
|
|
||||||
|
Colors may be listed using three decimal numbers (e.g.,
|
||||||
|
"255 64 128") or a 6- or 3-digit-long hexadecimal 'triplet'
|
||||||
|
(e.g., "#ff4080" or "#F48"). Note: You must separate decimal
|
||||||
|
values with spaces, and begin hexadecimal values with a
|
||||||
|
pound/number-sign character ("#").
|
||||||
|
|
||||||
|
After the color definition (on the same line) you may enter text
|
||||||
|
to describe the color. Tux will display this text when the color
|
||||||
|
is clicked. (For example, "#FFF White as snow.")
|
||||||
|
|
||||||
lang=LANGUAGE
|
lang=LANGUAGE
|
||||||
|
|
||||||
Run Tux Paint in one of the supported languages. Possible choice
|
Run Tux Paint in one of the supported languages. Possible choice
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.newbreedsoftware.com/tuxpaint/
|
||||||
|
|
||||||
June 14, 2002 - August 27, 2006
|
June 14, 2002 - September 9, 2006
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -165,6 +165,9 @@ Main Screen
|
||||||
[Colors - Black, White, Red, Pink, Orange, Yellow, Green, Cyan, Blue, Purple,
|
[Colors - Black, White, Red, Pink, Orange, Yellow, Green, Cyan, Blue, Purple,
|
||||||
Brown, Grey]
|
Brown, Grey]
|
||||||
|
|
||||||
|
(NOTE: You can define your own colors for Tux Paint. See the
|
||||||
|
"Options" documentation.)
|
||||||
|
|
||||||
Bottom: Help Area
|
Bottom: Help Area
|
||||||
|
|
||||||
At the very bottom of the screen, Tux, the Linux Penguin,
|
At the very bottom of the screen, Tux, the Linux Penguin,
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,31 @@ New Breed Software</p>
|
||||||
This causes Tux Paint to display a blank canvas when it first
|
This causes Tux Paint to display a blank canvas when it first
|
||||||
starts up, rather than loading the last image that was being edited.
|
starts up, rather than loading the last image that was being edited.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><code><b>colorfile=<i>FILENAME</i></b></code></dt>
|
||||||
|
<dd>
|
||||||
|
<p>You may override Tux Paint's default color palette by creating
|
||||||
|
a plain ASCII text file that describes the colors you want, and
|
||||||
|
pointing to that file using the <code>colorfile</code> option.</p>
|
||||||
|
|
||||||
|
<p>The file should list one color per line. Colors are defined in
|
||||||
|
terms of their Red, Green and Blue values, each from 0 (off) to 255
|
||||||
|
(brightest). (For more information, try Wikipedia's
|
||||||
|
"<a href="http://en.wikipedia.org/wiki/Rgb">RGB color model</a>"
|
||||||
|
article.)</p>
|
||||||
|
|
||||||
|
<p>Colors may be listed using three decimal numbers (e.g.,
|
||||||
|
"<code>255 64 128</code>") or a 6- or 3-digit-long hexadecimal
|
||||||
|
'triplet' (e.g., "<code>#ff4080</code>" or "<code>#F48</code>").
|
||||||
|
Note: You must separate decimal values with spaces, and begin
|
||||||
|
hexadecimal values with a pound/number-sign character
|
||||||
|
("<code>#</code>").</p>
|
||||||
|
|
||||||
|
<p>After the color definition (on the same line) you may enter text to
|
||||||
|
describe the color. Tux will display this text when the color is
|
||||||
|
clicked. (For example,
|
||||||
|
"<code>#FFF White as snow.</code>")</p>
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt><code><b>lang=<i>LANGUAGE</i></b></code></dt>
|
<dt><code><b>lang=<i>LANGUAGE</i></b></code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ New Breed Software</p>
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
||||||
|
|
||||||
<p>June 14, 2002 - August 27, 2006</p>
|
<p>June 14, 2002 - September 9, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<hr size=2 noshade>
|
<hr size=2 noshade>
|
||||||
|
|
@ -169,8 +169,8 @@ New Breed Software</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>When Tux Paint first loads, a title/credits screen will appear.</p>
|
<p>When Tux Paint first loads, a title/credits screen will appear.</p>
|
||||||
|
|
||||||
<center><img src="images/tuxpaint-title.jpg" width=324 height=254
|
<p align=center><img src="images/tuxpaint-title.jpg" width=324 height=254
|
||||||
alt="[Title Screenshot]"></center>
|
alt="[Title Screenshot]"></p>
|
||||||
|
|
||||||
<p>Once loading is complete, press a key or click on the mouse to continue.
|
<p>Once loading is complete, press a key or click on the mouse to continue.
|
||||||
(Or, after about 30 seconds, the title screen will go away
|
(Or, after about 30 seconds, the title screen will go away
|
||||||
|
|
@ -189,9 +189,9 @@ New Breed Software</p>
|
||||||
<dd>
|
<dd>
|
||||||
<p>The toolbar contains the drawing and editing controls.</p>
|
<p>The toolbar contains the drawing and editing controls.</p>
|
||||||
|
|
||||||
<center><img src="images/tools.jpg" width=324 height=254
|
<p align=center><img src="images/tools.jpg" width=324 height=254
|
||||||
alt="[Tools: Paint, Stamp, Lines, Shapes, Text, Magic, Undo, Redo,
|
alt="[Tools: Paint, Stamp, Lines, Shapes, Text, Magic, Undo, Redo,
|
||||||
Eraser, New, Open, Save, Print, Quit]"></center>
|
Eraser, New, Open, Save, Print, Quit]"></p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>Middle: Drawing Canvas</dt>
|
<dt>Middle: Drawing Canvas</dt>
|
||||||
|
|
@ -199,8 +199,8 @@ New Breed Software</p>
|
||||||
<p>The largest part of the screen, in the center, is the drawing
|
<p>The largest part of the screen, in the center, is the drawing
|
||||||
canvas. This is, obviously, where you draw!</p>
|
canvas. This is, obviously, where you draw!</p>
|
||||||
|
|
||||||
<center><img src="images/canvas.jpg" width=324 height=254
|
<p align=center><img src="images/canvas.jpg" width=324 height=254
|
||||||
alt="[(Canvas)]"></center>
|
alt="[(Canvas)]"></p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -211,8 +211,8 @@ New Breed Software</p>
|
||||||
the various brushes available. When the Rubber Stamp tool
|
the various brushes available. When the Rubber Stamp tool
|
||||||
is selected, it shows the different shapes you can use.</p>
|
is selected, it shows the different shapes you can use.</p>
|
||||||
|
|
||||||
<center><img src="images/selector.jpg" width=324 height=254
|
<p align=center><img src="images/selector.jpg" width=324 height=254
|
||||||
alt="[Selectors - Brushes, Letters, Shapes, Stamps]"></center>
|
alt="[Selectors - Brushes, Letters, Shapes, Stamps]"></p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -221,9 +221,13 @@ New Breed Software</p>
|
||||||
<p>A palette of available colors are shown near the bottom of the
|
<p>A palette of available colors are shown near the bottom of the
|
||||||
screen.</p>
|
screen.</p>
|
||||||
|
|
||||||
<center><img src="images/colors.jpg" width=324 height=254
|
<p align=center><img src="images/colors.jpg" width=324 height=254
|
||||||
alt="[Colors - Black, White, Red, Pink, Orange, Yellow, Green, Cyan,
|
alt="[Colors - Black, White, Red, Pink, Orange, Yellow, Green, Cyan,
|
||||||
Blue, Purple, Brown, Grey]"></center>
|
Blue, Purple, Brown, Grey]"></p>
|
||||||
|
|
||||||
|
<p>(NOTE: You can define your own colors for Tux Paint.
|
||||||
|
See the "<a href="OPTIONS.html"><i>Options</i></a>"
|
||||||
|
documentation.)</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -232,10 +236,10 @@ New Breed Software</p>
|
||||||
<p>At the very bottom of the screen, Tux, the Linux Penguin,
|
<p>At the very bottom of the screen, Tux, the Linux Penguin,
|
||||||
provides tips and other information while you draw.</p>
|
provides tips and other information while you draw.</p>
|
||||||
|
|
||||||
<center><img src="images/tips.jpg" width=324 height=254
|
<p align=center><img src="images/tips.jpg" width=324 height=254
|
||||||
alt="(For example: 'Pick a shape. Click to pick the center, drag, then
|
alt="(For example: 'Pick a shape. Click to pick the center, drag, then
|
||||||
let go when it is the size you want. Move around to rotate it, and
|
let go when it is the size you want. Move around to rotate it, and
|
||||||
click to draw it.)"></center>
|
click to draw it.)"></p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
@ -264,8 +268,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/ex_paint.png" width=120 height=95
|
<p align=center><img src="images/ex_paint.png" width=120 height=95
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<hr size=1>
|
<hr size=1>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
@ -297,8 +301,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/ex_stamps.png" width=182 height=156
|
<p align=center><img src="images/ex_stamps.png" width=182 height=156
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<hr size=1>
|
<hr size=1>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
@ -320,8 +324,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/ex_lines.png" width=76 height=103
|
<p align=center><img src="images/ex_lines.png" width=76 height=103
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<hr size=1>
|
<hr size=1>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
@ -364,8 +368,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/ex_shapes.png" width=177 height=104
|
<p align=center><img src="images/ex_shapes.png" width=177 height=104
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<hr size=1>
|
<hr size=1>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
@ -387,8 +391,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/ex_text.png" width=139 height=69
|
<p aling=center><img src="images/ex_text.png" width=139 height=69
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<hr size=1>
|
<hr size=1>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
@ -590,8 +594,8 @@ New Breed Software</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
|
|
||||||
<center><img src="images/open_dialog.jpg" width=194 height=152
|
<p align=center><img src="images/open_dialog.jpg" width=194 height=152
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<p>Click a picture to select it, then...</p>
|
<p>Click a picture to select it, then...</p>
|
||||||
|
|
||||||
|
|
@ -688,8 +692,8 @@ New Breed Software</p>
|
||||||
whether you want to save over the old version, or create a new
|
whether you want to save over the old version, or create a new
|
||||||
entry (a new file).</p>
|
entry (a new file).</p>
|
||||||
|
|
||||||
<center><img src="images/saveover.png" width=177 height=110
|
<p align=center><img src="images/saveover.png" width=177 height=110
|
||||||
alt=""></center>
|
alt=""></p>
|
||||||
|
|
||||||
<p>(NOTE: If either the "<code>saveover</code>" or
|
<p>(NOTE: If either the "<code>saveover</code>" or
|
||||||
"<code>saveovernew</code>" options are set, it won't ask before saving
|
"<code>saveovernew</code>" options are set, it won't ask before saving
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef COLORS_H
|
||||||
|
#define COLORS_H
|
||||||
|
|
||||||
/* What colors are available: */
|
/* What colors are available: */
|
||||||
|
|
||||||
|
|
@ -98,3 +100,8 @@ const char *const default_color_names[NUM_DEFAULT_COLORS] = {
|
||||||
gettext_noop("Tan!"),
|
gettext_noop("Tan!"),
|
||||||
gettext_noop("Beige!")
|
gettext_noop("Beige!")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char colorfile[256];
|
||||||
|
|
||||||
|
#endif /* COLORS_H */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ tuxpaint -- A drawing program for young children.
|
||||||
[\-\-saveover]
|
[\-\-saveover]
|
||||||
[\-\-saveovernew]
|
[\-\-saveovernew]
|
||||||
[\-\-nosave]
|
[\-\-nosave]
|
||||||
|
[\-\-colorfile \fIFILE\fP]
|
||||||
|
|
||||||
.TP 9
|
.TP 9
|
||||||
.B tuxpaint
|
.B tuxpaint
|
||||||
|
|
@ -252,6 +253,14 @@ When you start \fITux Paint\fP, it loads the last image that was being worked
|
||||||
on. The \fI\-\-startblank\fP option disables this, so it always starts with
|
on. The \fI\-\-startblank\fP option disables this, so it always starts with
|
||||||
a blank canvas. The default behavior is \fI\-\-startlast\fP.
|
a blank canvas. The default behavior is \fI\-\-startlast\fP.
|
||||||
|
|
||||||
|
.TP 8
|
||||||
|
.B \-\-colorfile \fIFILE\fP
|
||||||
|
This option allows you to override the default color palette in \fITux Paint\fP
|
||||||
|
and replace it with your own. The file should be a plain ASCII text file
|
||||||
|
containing one color description per line. Colors may be in decimal or
|
||||||
|
6- or 3-digit hexadecimal, and followed by a description. (For example,
|
||||||
|
"\fI#000 Black\fP" and "\fI255 192 64 Orange\fP".)
|
||||||
|
|
||||||
.SH OPTIONS - LANGUAGE
|
.SH OPTIONS - LANGUAGE
|
||||||
.l
|
.l
|
||||||
Various parts of \fITux Paint\fP have been translated into numerous languages.
|
Various parts of \fITux Paint\fP have been translated into numerous languages.
|
||||||
|
|
@ -469,7 +478,7 @@ welsh | cymraeg
|
||||||
.PD
|
.PD
|
||||||
|
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-\- lang help
|
.B \-\-lang help
|
||||||
Display a lists of all supported languages.
|
Display a lists of all supported languages.
|
||||||
|
|
||||||
.SH OPTIONS - MISCELLANEOUS
|
.SH OPTIONS - MISCELLANEOUS
|
||||||
|
|
|
||||||
140
src/tuxpaint.c
140
src/tuxpaint.c
|
|
@ -5194,6 +5194,7 @@ static void show_usage(FILE * f, char *prg)
|
||||||
" %s [--altprintmod | --altprintalways | --altprintnever]\n"
|
" %s [--altprintmod | --altprintalways | --altprintnever]\n"
|
||||||
" %s [--lang LANGUAGE | --locale LOCALE | --lang help]\n"
|
" %s [--lang LANGUAGE | --locale LOCALE | --lang help]\n"
|
||||||
" %s [--nosysconfig] [--nolockfile]\n"
|
" %s [--nosysconfig] [--nolockfile]\n"
|
||||||
|
" %s [--colorfile FILE]\n"
|
||||||
/* " %s [--record FILE | --playback FILE]\n" */
|
/* " %s [--record FILE | --playback FILE]\n" */
|
||||||
"\n",
|
"\n",
|
||||||
prg, prg,
|
prg, prg,
|
||||||
|
|
@ -5203,7 +5204,7 @@ static void show_usage(FILE * f, char *prg)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
blank,
|
blank,
|
||||||
#endif
|
#endif
|
||||||
blank, blank, blank, blank, blank);
|
blank, blank, blank, blank, blank, blank);
|
||||||
|
|
||||||
free(blank);
|
free(blank);
|
||||||
}
|
}
|
||||||
|
|
@ -5711,6 +5712,10 @@ static int load_user_fonts_stub(void *vp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define hex2dec(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
|
||||||
|
((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) : \
|
||||||
|
((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) : 0)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/* Setup: */
|
/* Setup: */
|
||||||
|
|
||||||
|
|
@ -5819,6 +5824,7 @@ static void setup(int argc, char *argv[])
|
||||||
playing = 0;
|
playing = 0;
|
||||||
ok_to_use_lockfile = 1;
|
ok_to_use_lockfile = 1;
|
||||||
start_blank = 0;
|
start_blank = 0;
|
||||||
|
colorfile[0] = '\0';
|
||||||
|
|
||||||
|
|
||||||
#ifdef __BEOS__
|
#ifdef __BEOS__
|
||||||
|
|
@ -5964,6 +5970,22 @@ static void setup(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
noshortcuts = 0;
|
noshortcuts = 0;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[i], "--colorfile") == 0)
|
||||||
|
{
|
||||||
|
if (i < argc - 1)
|
||||||
|
{
|
||||||
|
strcpy(colorfile, argv[i + 1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Forgot to specify the file name! */
|
||||||
|
|
||||||
|
fprintf(stderr, "%s takes an argument\n", argv[i]);
|
||||||
|
show_usage(stderr, (char *) getfilename(argv[0]));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (argv[i][0] == '-' && argv[i][1] == '-' && argv[i][2] >= '1'
|
else if (argv[i][0] == '-' && argv[i][1] == '-' && argv[i][2] >= '1'
|
||||||
&& argv[i][2] <= '9')
|
&& argv[i][2] <= '9')
|
||||||
{
|
{
|
||||||
|
|
@ -6443,11 +6465,117 @@ static void setup(int argc, char *argv[])
|
||||||
|
|
||||||
/* Load colors, or use default ones: */
|
/* Load colors, or use default ones: */
|
||||||
|
|
||||||
if (0 == 1)
|
if (colorfile[0] != '\0')
|
||||||
{
|
{
|
||||||
/* FIXME: Allow loading colors from file: */
|
fi = fopen(colorfile, "r");
|
||||||
|
if (fi == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"\nWarning, could not open color file. Using defaults.\n");
|
||||||
|
perror(colorfile);
|
||||||
|
colorfile[0] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int max = 0, per = 5;
|
||||||
|
char str[80], tmp_str[80];
|
||||||
|
int count;
|
||||||
|
|
||||||
|
NUM_COLORS = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
fgets(str, sizeof(str), fi);
|
||||||
|
|
||||||
|
if (!feof(fi))
|
||||||
|
{
|
||||||
|
if (NUM_COLORS + 1 > max)
|
||||||
|
{
|
||||||
|
color_hexes = realloc(color_hexes, sizeof(Uint8 *) * (max + per));
|
||||||
|
color_names = realloc(color_names, sizeof(char *) * (max + per));
|
||||||
|
|
||||||
|
for (i = max; i < max + per; i++)
|
||||||
|
color_hexes[i] = malloc(sizeof(Uint8) * 3);
|
||||||
|
|
||||||
|
max = max + per;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (str[strlen(str) - 1] == '\n' ||
|
||||||
|
str[strlen(str) - 1] == '\r')
|
||||||
|
str[strlen(str) - 1] = '\0';
|
||||||
|
|
||||||
|
if (str[0] == '#')
|
||||||
|
{
|
||||||
|
/* Hex form */
|
||||||
|
|
||||||
|
sscanf(str + 1, "%s %n", tmp_str, &count);
|
||||||
|
|
||||||
|
if (strlen(tmp_str) == 6)
|
||||||
|
{
|
||||||
|
/* Byte (#rrggbb) form */
|
||||||
|
|
||||||
|
color_hexes[NUM_COLORS][0] =
|
||||||
|
(hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[1]);
|
||||||
|
color_hexes[NUM_COLORS][1] =
|
||||||
|
(hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[3]);
|
||||||
|
color_hexes[NUM_COLORS][2] =
|
||||||
|
(hex2dec(tmp_str[4]) << 4) + hex2dec(tmp_str[5]);
|
||||||
|
|
||||||
|
color_names[NUM_COLORS] = strdup(str + count);
|
||||||
|
NUM_COLORS++;
|
||||||
|
}
|
||||||
|
else if (strlen(tmp_str) == 3)
|
||||||
|
{
|
||||||
|
/* Nybble (#rgb) form */
|
||||||
|
|
||||||
|
color_hexes[NUM_COLORS][0] = (hex2dec(tmp_str[0]) << 4);;
|
||||||
|
color_hexes[NUM_COLORS][1] = (hex2dec(tmp_str[1]) << 4);;
|
||||||
|
color_hexes[NUM_COLORS][2] = (hex2dec(tmp_str[2]) << 4);;
|
||||||
|
|
||||||
|
color_names[NUM_COLORS] = strdup(str + count);
|
||||||
|
NUM_COLORS++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Assume int form */
|
||||||
|
|
||||||
|
if (sscanf(str, "%hu %hu %hu %n",
|
||||||
|
(short unsigned int *) &(color_hexes[NUM_COLORS][0]),
|
||||||
|
(short unsigned int *) &(color_hexes[NUM_COLORS][1]),
|
||||||
|
(short unsigned int *) &(color_hexes[NUM_COLORS][2]),
|
||||||
|
&count) >= 3)
|
||||||
|
{
|
||||||
|
color_names[NUM_COLORS] = strdup(str + count);
|
||||||
|
NUM_COLORS++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!feof(fi));
|
||||||
|
|
||||||
|
if (NUM_COLORS < 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"\nWarning, not enough colors in color file. Using defaults.\n");
|
||||||
|
fprintf(stderr, "%s\n", colorfile);
|
||||||
|
colorfile[0] = '\0';
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_COLORS; i++)
|
||||||
|
{
|
||||||
|
free(color_names[i]);
|
||||||
|
free(color_hexes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(color_names);
|
||||||
|
free(color_hexes);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/* Use default, if no file specified (or trouble opening it) */
|
||||||
|
|
||||||
|
if (colorfile[0] == '\0')
|
||||||
{
|
{
|
||||||
NUM_COLORS = NUM_DEFAULT_COLORS;
|
NUM_COLORS = NUM_DEFAULT_COLORS;
|
||||||
|
|
||||||
|
|
@ -14786,6 +14914,10 @@ static void parse_options(FILE * fi)
|
||||||
{
|
{
|
||||||
set_langstr(str + 5);
|
set_langstr(str + 5);
|
||||||
}
|
}
|
||||||
|
else if (strstr(str, "colorfile=") == str)
|
||||||
|
{
|
||||||
|
strcpy(colorfile, str + 10);
|
||||||
|
}
|
||||||
else if (strstr(str, "printdelay=") == str)
|
else if (strstr(str, "printdelay=") == str)
|
||||||
{
|
{
|
||||||
sscanf(str + 11, "%d", &print_delay);
|
sscanf(str + 11, "%d", &print_delay);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue