tyalpha: support opacity level option

Summary:
support opacity level option for tyalpha.

usage: tyalpha [-p] on|off|<opacity level>

Test Plan: terminology -> tyalpha 60

Reviewers: billiob, raster

Subscribers: seoz

Differential Revision: https://phab.enlightenment.org/D1197
This commit is contained in:
wonguk.jeong 2014-07-17 12:50:04 +02:00 committed by Boris Faure
parent 2833ad913c
commit a83bd06905
2 changed files with 39 additions and 36 deletions

View File

@ -1183,6 +1183,40 @@ _cb_popup_queue(void *data, Evas_Object *obj EINA_UNUSED, void *event)
_popmedia_queue_add(term, src);
}
static void
_set_alpha(Config *config, const char *val, Eina_Bool save)
{
int opacity;
if (!config || !val) return;
config->temporary = !save;
if (isdigit(*val))
{
opacity = atoi(val);
if (opacity >= 100)
{
config->translucent = EINA_FALSE;
config->opacity = 100;
}
else if (opacity >= 0)
{
config->translucent = EINA_TRUE;
config->opacity = opacity;
}
}
else if ((!strcasecmp(val, "on")) ||
(!strcasecmp(val, "true")) ||
(!strcasecmp(val, "yes")))
config->translucent = EINA_TRUE;
else
config->translucent = EINA_FALSE;
main_trans_update(config);
if (save) config_save(config, NULL);
}
static void
_cb_command(void *data, Evas_Object *obj EINA_UNUSED, void *event)
{
@ -1235,40 +1269,9 @@ _cb_command(void *data, Evas_Object *obj EINA_UNUSED, void *event)
else if (cmd[0] == 'a') // set alpha
{
if (cmd[1] == 't') // temporary
{
Config *config = termio_config_get(term->term);
if (config)
{
config->temporary = EINA_TRUE;
if ((cmd[2] == '1') ||
(!strcasecmp(cmd + 2, "on")) ||
(!strcasecmp(cmd + 2, "true")) ||
(!strcasecmp(cmd + 2, "yes")))
config->translucent = EINA_TRUE;
else
config->translucent = EINA_FALSE;
main_trans_update(config);
}
}
_set_alpha(termio_config_get(term->term), cmd + 2, EINA_FALSE);
else if (cmd[1] == 'p') // permanent
{
Config *config = termio_config_get(term->term);
if (config)
{
config->temporary = EINA_FALSE;
if ((cmd[2] == '1') ||
(!strcasecmp(cmd + 2, "on")) ||
(!strcasecmp(cmd + 2, "true")) ||
(!strcasecmp(cmd + 2, "yes")))
config->translucent = EINA_TRUE;
else
config->translucent = EINA_FALSE;
main_trans_update(config);
config_save(config, NULL);
}
}
_set_alpha(termio_config_get(term->term), cmd + 2, EINA_TRUE);
}
}

View File

@ -12,7 +12,7 @@ main(int argc, char **argv)
if (!getenv("TERMINOLOGY")) return 0;
if (argc <= 1)
{
printf("Usage: %s [-p] on|off\n"
printf("Usage: %s [-p] on|off|<opacity level>\n"
" Change the terminal transparency on or off\n"
" -p Make change permanent (stored in config)\n"
"\n",