1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2006-01-06 23:20:58 -08:00
|
|
|
* Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2006 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2004-12-28 15:46:49 -08:00
|
|
|
#include "conf.h"
|
2006-02-18 00:30:09 -08:00
|
|
|
#include "e16-ecore_list.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "iclass.h"
|
|
|
|
#include "tclass.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static Ecore_List *tclass_list = NULL;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static char *
|
|
|
|
TextstateFontLookup(const char *name)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
const char *font;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (*name == '*')
|
|
|
|
{
|
|
|
|
font = FontLookup(name + 1);
|
|
|
|
if (font)
|
|
|
|
name = font;
|
|
|
|
}
|
|
|
|
return Estrdup(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TextState *
|
|
|
|
TextstateCreate(void)
|
|
|
|
{
|
|
|
|
TextState *ts;
|
2004-05-23 09:11:36 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ts = Ecalloc(1, sizeof(TextState));
|
|
|
|
if (!ts)
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
2004-05-23 09:11:36 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ts->fontname = NULL;
|
|
|
|
ts->style.mode = MODE_WRAP_CHAR;
|
|
|
|
ts->style.orientation = FONT_TO_RIGHT;
|
|
|
|
ts->efont = NULL;
|
|
|
|
ts->xfont = NULL;
|
|
|
|
ts->xfontset = 0;
|
2004-05-23 09:11:36 -07:00
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return ts;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
TextStateDestroy(TextState * ts)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
if (ts->fontname)
|
|
|
|
Efree(ts->fontname);
|
|
|
|
if (ts->xfont)
|
|
|
|
XFreeFont(disp, ts->xfont);
|
|
|
|
if (ts->efont)
|
2003-12-12 10:42:15 -08:00
|
|
|
Efont_free(ts->efont);
|
1999-08-17 15:56:46 -07:00
|
|
|
Efree(ts);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static TextClass *
|
|
|
|
TextclassCreate(const char *name)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
TextClass *tc;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
tc = Ecalloc(1, sizeof(TextClass));
|
|
|
|
if (!tc)
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!tclass_list)
|
|
|
|
tclass_list = ecore_list_new();
|
|
|
|
ecore_list_prepend(tclass_list, tc);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
tc->name = Estrdup(name);
|
|
|
|
tc->justification = 512;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return tc;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
TextclassDestroy(TextClass * tc)
|
|
|
|
{
|
|
|
|
if (tc->ref_count > 0)
|
|
|
|
{
|
|
|
|
DialogOK(_("Textclass Error!"), _("%u references remain\n"),
|
|
|
|
tc->ref_count);
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
if (tc->name)
|
|
|
|
Efree(tc->name);
|
|
|
|
if (tc->norm.normal)
|
|
|
|
TextStateDestroy(tc->norm.normal);
|
|
|
|
if (tc->norm.hilited)
|
|
|
|
TextStateDestroy(tc->norm.hilited);
|
|
|
|
if (tc->norm.clicked)
|
|
|
|
TextStateDestroy(tc->norm.clicked);
|
|
|
|
if (tc->norm.disabled)
|
|
|
|
TextStateDestroy(tc->norm.disabled);
|
|
|
|
if (tc->active.normal)
|
|
|
|
TextStateDestroy(tc->active.normal);
|
|
|
|
if (tc->active.hilited)
|
|
|
|
TextStateDestroy(tc->active.hilited);
|
|
|
|
if (tc->active.clicked)
|
|
|
|
TextStateDestroy(tc->active.clicked);
|
|
|
|
if (tc->active.disabled)
|
|
|
|
TextStateDestroy(tc->active.disabled);
|
|
|
|
if (tc->sticky.normal)
|
|
|
|
TextStateDestroy(tc->sticky.normal);
|
|
|
|
if (tc->sticky.hilited)
|
|
|
|
TextStateDestroy(tc->sticky.hilited);
|
|
|
|
if (tc->sticky.clicked)
|
|
|
|
TextStateDestroy(tc->sticky.clicked);
|
|
|
|
if (tc->sticky.disabled)
|
|
|
|
TextStateDestroy(tc->sticky.disabled);
|
|
|
|
if (tc->sticky_active.normal)
|
|
|
|
TextStateDestroy(tc->sticky_active.normal);
|
|
|
|
if (tc->sticky_active.hilited)
|
|
|
|
TextStateDestroy(tc->sticky_active.hilited);
|
|
|
|
if (tc->sticky_active.clicked)
|
|
|
|
TextStateDestroy(tc->sticky_active.clicked);
|
|
|
|
if (tc->sticky_active.disabled)
|
|
|
|
TextStateDestroy(tc->sticky_active.disabled);
|
|
|
|
Efree(tc);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-09-26 10:32:10 -07:00
|
|
|
void
|
|
|
|
TextclassIncRefcount(TextClass * tc)
|
|
|
|
{
|
|
|
|
tc->ref_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextclassDecRefcount(TextClass * tc)
|
|
|
|
{
|
|
|
|
tc->ref_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TextclassGetJustification(TextClass * tc)
|
|
|
|
{
|
|
|
|
return tc->justification;
|
|
|
|
}
|
|
|
|
|
2005-10-15 05:14:00 -07:00
|
|
|
void
|
|
|
|
TextclassSetJustification(TextClass * tc, int just)
|
|
|
|
{
|
|
|
|
tc->justification = just;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
TextclassPopulate(TextClass * tclass)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!tclass)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
if (!tclass->norm.normal)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
if (!tclass->norm.hilited)
|
|
|
|
tclass->norm.hilited = tclass->norm.normal;
|
|
|
|
if (!tclass->norm.clicked)
|
|
|
|
tclass->norm.clicked = tclass->norm.normal;
|
|
|
|
if (!tclass->norm.disabled)
|
|
|
|
tclass->norm.disabled = tclass->norm.normal;
|
|
|
|
|
|
|
|
if (!tclass->active.normal)
|
|
|
|
tclass->active.normal = tclass->norm.normal;
|
|
|
|
if (!tclass->active.hilited)
|
|
|
|
tclass->active.hilited = tclass->active.normal;
|
|
|
|
if (!tclass->active.clicked)
|
|
|
|
tclass->active.clicked = tclass->active.normal;
|
|
|
|
if (!tclass->active.disabled)
|
|
|
|
tclass->active.disabled = tclass->active.normal;
|
|
|
|
|
|
|
|
if (!tclass->sticky.normal)
|
|
|
|
tclass->sticky.normal = tclass->norm.normal;
|
|
|
|
if (!tclass->sticky.hilited)
|
|
|
|
tclass->sticky.hilited = tclass->sticky.normal;
|
|
|
|
if (!tclass->sticky.clicked)
|
|
|
|
tclass->sticky.clicked = tclass->sticky.normal;
|
|
|
|
if (!tclass->sticky.disabled)
|
|
|
|
tclass->sticky.disabled = tclass->sticky.normal;
|
|
|
|
|
|
|
|
if (!tclass->sticky_active.normal)
|
|
|
|
tclass->sticky_active.normal = tclass->norm.normal;
|
|
|
|
if (!tclass->sticky_active.hilited)
|
|
|
|
tclass->sticky_active.hilited = tclass->sticky_active.normal;
|
|
|
|
if (!tclass->sticky_active.clicked)
|
|
|
|
tclass->sticky_active.clicked = tclass->sticky_active.normal;
|
|
|
|
if (!tclass->sticky_active.disabled)
|
|
|
|
tclass->sticky_active.disabled = tclass->sticky_active.normal;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static int
|
|
|
|
_TextclassMatchName(const void *data, const void *match)
|
|
|
|
{
|
|
|
|
return strcmp(((const TextClass *)data)->name, match);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
TextClass *
|
|
|
|
TextclassFind(const char *name, int fallback)
|
|
|
|
{
|
|
|
|
TextClass *tc;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
tc = ecore_list_find(tclass_list, _TextclassMatchName, name);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (tc || !fallback)
|
|
|
|
return tc;
|
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
tc = ecore_list_find(tclass_list, _TextclassMatchName, "__FALLBACK_TCLASS");
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
return tc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TextclassConfigLoad(FILE * fs)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
char s2[FILEPATH_LEN_MAX];
|
|
|
|
int i1, r, g, b;
|
|
|
|
TextClass *tc = NULL;
|
|
|
|
TextState *ts = NULL;
|
|
|
|
int fields;
|
|
|
|
|
|
|
|
while (GetLine(s, sizeof(s), fs))
|
|
|
|
{
|
|
|
|
s2[0] = 0;
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
fields = sscanf(s, "%i %4000[^=]", &i1, s2);
|
|
|
|
|
|
|
|
if (fields < 1)
|
|
|
|
{
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
}
|
|
|
|
else if (i1 == CONFIG_CLOSE)
|
|
|
|
{
|
|
|
|
if (fields != 1)
|
|
|
|
Alert(_("CONFIG: ignoring extra data in \"%s\"\n"), s);
|
|
|
|
}
|
|
|
|
else if (i1 != CONFIG_INVALID)
|
|
|
|
{
|
|
|
|
if (fields != 2)
|
|
|
|
{
|
|
|
|
Alert(_("CONFIG: missing required data in \"%s\"\n"), s);
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (i1)
|
|
|
|
{
|
|
|
|
case CONFIG_CLOSE:
|
2006-02-18 00:30:09 -08:00
|
|
|
TextclassPopulate(tc);
|
2004-12-28 15:46:49 -08:00
|
|
|
goto done;
|
|
|
|
case CONFIG_CLASSNAME:
|
2006-02-18 00:30:09 -08:00
|
|
|
if (TextclassFind(s2, 0))
|
|
|
|
{
|
|
|
|
SkipTillEnd(fs);
|
|
|
|
goto done;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
tc = TextclassCreate(s2);
|
|
|
|
break;
|
|
|
|
case TEXT_ORIENTATION:
|
|
|
|
if (ts)
|
|
|
|
ts->style.orientation = atoi(s2);
|
|
|
|
break;
|
|
|
|
case TEXT_JUSTIFICATION:
|
|
|
|
if (tc)
|
|
|
|
tc->justification = atoi(s2);
|
|
|
|
break;
|
|
|
|
case CONFIG_DESKTOP:
|
|
|
|
case ICLASS_NORMAL:
|
|
|
|
if (tc)
|
|
|
|
tc->norm.normal = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_CLICKED:
|
|
|
|
if (tc)
|
|
|
|
tc->norm.clicked = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_HILITED:
|
|
|
|
if (tc)
|
|
|
|
tc->norm.hilited = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_DISABLED:
|
|
|
|
if (tc)
|
|
|
|
tc->norm.disabled = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_NORMAL:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky.normal = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_CLICKED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky.clicked = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_HILITED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky.hilited = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_DISABLED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky.disabled = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_ACTIVE_NORMAL:
|
|
|
|
if (tc)
|
|
|
|
tc->active.normal = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_ACTIVE_CLICKED:
|
|
|
|
if (tc)
|
|
|
|
tc->active.clicked = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_ACTIVE_HILITED:
|
|
|
|
if (tc)
|
|
|
|
tc->active.hilited = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_ACTIVE_DISABLED:
|
|
|
|
if (tc)
|
|
|
|
tc->active.disabled = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_ACTIVE_NORMAL:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky_active.normal = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_ACTIVE_CLICKED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky_active.clicked = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_ACTIVE_HILITED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky_active.hilited = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICLASS_STICKY_ACTIVE_DISABLED:
|
|
|
|
if (tc)
|
|
|
|
tc->sticky_active.disabled = ts = TextstateCreate();
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
ts->fontname = TextstateFontLookup(s2);
|
|
|
|
ts->style.mode = MODE_VERBATIM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TEXT_MODE:
|
|
|
|
if (ts)
|
|
|
|
ts->style.mode = atoi(s2);
|
|
|
|
break;
|
|
|
|
case TEXT_EFFECT:
|
|
|
|
if (ts)
|
|
|
|
ts->effect = atoi(s2);
|
|
|
|
break;
|
|
|
|
case TEXT_FG_COL:
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
r = g = b = 0;
|
|
|
|
sscanf(s, "%*s %i %i %i", &r, &g, &b);
|
|
|
|
ESetColor(&ts->fg_col, r, g, b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TEXT_BG_COL:
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
r = g = b = 0;
|
|
|
|
sscanf(s, "%*s %i %i %i", &r, &g, &b);
|
|
|
|
ESetColor(&ts->bg_col, r, g, b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Alert(_("Warning: unable to determine what to do with\n"
|
|
|
|
"the following text in the middle of current Text"
|
|
|
|
" definition:\n" "%s\nWill ignore and continue...\n"), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
err = -1;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return err;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Textclass Module
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
TextclassSighan(int sig, void *prm __UNUSED__)
|
|
|
|
{
|
|
|
|
TextClass *tc;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
case ESIGNAL_INIT:
|
|
|
|
/* create a fallback textclass in case no textclass is found */
|
|
|
|
tc = TextclassCreate("__FALLBACK_TCLASS");
|
|
|
|
tc->norm.normal = TextstateCreate();
|
|
|
|
tc->norm.normal->fontname =
|
|
|
|
Estrdup("-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
|
|
|
|
ESetColor(&(tc->norm.normal->fg_col), 0, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
TextclassIpc(const char *params, Client * c __UNUSED__)
|
|
|
|
{
|
|
|
|
char param1[FILEPATH_LEN_MAX];
|
|
|
|
char param2[FILEPATH_LEN_MAX];
|
|
|
|
char param3[FILEPATH_LEN_MAX];
|
|
|
|
TextClass *tc;
|
|
|
|
|
|
|
|
if (!params)
|
|
|
|
{
|
|
|
|
IpcPrintf("Please specify...\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
param1[0] = 0;
|
|
|
|
param2[0] = 0;
|
|
|
|
param3[0] = 0;
|
|
|
|
|
|
|
|
word(params, 1, param1);
|
|
|
|
word(params, 2, param2);
|
|
|
|
|
2005-02-13 05:58:50 -08:00
|
|
|
if (!strncmp(param1, "list", 2))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(tclass_list, tc) IpcPrintf("%s\n", tc->name);
|
2005-02-13 05:58:50 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!param1[0])
|
|
|
|
{
|
|
|
|
IpcPrintf("TextClass not specified\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tc = TextclassFind(param1, 0);
|
|
|
|
if (!tc)
|
|
|
|
{
|
|
|
|
IpcPrintf("TextClass not found: %s\n", param1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(param2, "create"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "delete"))
|
|
|
|
{
|
|
|
|
if (tc)
|
|
|
|
TextclassDestroy(tc);
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "modify"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "apply"))
|
|
|
|
{
|
|
|
|
if (tc)
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
int x, y;
|
|
|
|
const char *txt;
|
|
|
|
Window win;
|
|
|
|
|
|
|
|
word(params, 3, param3);
|
2005-11-20 14:47:41 -08:00
|
|
|
win = (Window) strtoul(param3, NULL, 0);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
word(params, 4, param3);
|
|
|
|
x = atoi(param3);
|
|
|
|
word(params, 5, param3);
|
|
|
|
y = atoi(param3);
|
2005-11-20 14:47:41 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
word(params, 6, param3);
|
|
|
|
state = STATE_NORMAL;
|
|
|
|
if (!strcmp(param3, "normal"))
|
|
|
|
state = STATE_NORMAL;
|
|
|
|
else if (!strcmp(param3, "hilited"))
|
|
|
|
state = STATE_HILITED;
|
|
|
|
else if (!strcmp(param3, "clicked"))
|
|
|
|
state = STATE_CLICKED;
|
|
|
|
else if (!strcmp(param3, "disabled"))
|
|
|
|
state = STATE_DISABLED;
|
2005-11-20 14:47:41 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
txt = atword(params, 7);
|
2005-11-20 14:47:41 -08:00
|
|
|
if (!txt)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!EDrawableCheck(win, 0)) /* Grab server? */
|
|
|
|
return;
|
|
|
|
TextDraw(tc, win, 0, 0, state, txt, x, y, 99999, 99999, 17, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "query_size"))
|
|
|
|
{
|
|
|
|
if (tc)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
const char *txt;
|
|
|
|
|
|
|
|
w = h = 0;
|
|
|
|
txt = atword(params, 3);
|
|
|
|
if (txt)
|
|
|
|
TextSize(tc, 0, 0, STATE_NORMAL, txt, &w, &h, 17);
|
|
|
|
IpcPrintf("%i %i\n", w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "query"))
|
|
|
|
{
|
|
|
|
if (tc)
|
|
|
|
IpcPrintf("TextClass %s found\n", tc->name);
|
|
|
|
}
|
|
|
|
else if (!strcmp(param2, "ref_count"))
|
|
|
|
{
|
|
|
|
if (tc)
|
|
|
|
IpcPrintf("%u references remain.\n", tc->ref_count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IpcPrintf("Error: Unknown operation specified\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static const IpcItem TextclassIpcArray[] = {
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
TextclassIpc,
|
|
|
|
"textclass", NULL,
|
2005-02-13 05:58:50 -08:00
|
|
|
"List textclasses, create/delete/modify/apply a textclass",
|
|
|
|
NULL}
|
2004-12-28 15:46:49 -08:00
|
|
|
,
|
|
|
|
};
|
|
|
|
#define N_IPC_FUNCS (sizeof(TextclassIpcArray)/sizeof(IpcItem))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Module descriptor
|
|
|
|
*/
|
2006-04-21 15:52:59 -07:00
|
|
|
const EModule ModTextclass = {
|
2004-12-28 15:46:49 -08:00
|
|
|
"textclass", "tc",
|
|
|
|
TextclassSighan,
|
|
|
|
{N_IPC_FUNCS, TextclassIpcArray}
|
|
|
|
,
|
|
|
|
{0, NULL}
|
|
|
|
};
|