aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termcmd.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-08-23 02:27:54 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-08-23 02:27:54 +0000
commit3aa2288a07d0922c5c7f3c1a0b53c6f097d670ef (patch)
tree806daa5de1c5b41cff358f9d05ca40c760299f37 /src/bin/termcmd.c
parentmedia: turn off media on video playblack del. (diff)
downloadterminology-3aa2288a07d0922c5c7f3c1a0b53c6f097d670ef.tar.gz
refactor cmd in separate functions, it's growing too big.
SVN revision: 75583
Diffstat (limited to 'src/bin/termcmd.c')
-rw-r--r--src/bin/termcmd.c214
1 files changed, 109 insertions, 105 deletions
diff --git a/src/bin/termcmd.c b/src/bin/termcmd.c
index 97c7952..fb64014 100644
--- a/src/bin/termcmd.c
+++ b/src/bin/termcmd.c
@@ -10,134 +10,138 @@
#include "utils.h"
#include "termcmd.h"
-// called as u type
-Eina_Bool
-termcmd_watch(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd)
+static Eina_Bool
+_termcmd_search(Evas_Object *obj __UNUSED__, Evas_Object *win __UNUSED__, Evas_Object *bg __UNUSED__, const char *cmd)
{
- if (!cmd) return EINA_FALSE;
- if ((cmd[0] == '/') || (cmd[0] == 's')) // search
+ if (cmd[0] == 0) // clear search
{
- if (cmd[1] == 0) // clear search
- {
- printf("search clear\n");
- return EINA_TRUE;
- }
- printf("search '%s'\n", cmd + 1);
+ printf("search clear\n");
return EINA_TRUE;
}
- return EINA_FALSE;
- obj = win = bg = NULL;
+ printf("search '%s'\n", cmd);
+ return EINA_TRUE;
}
-// called when you hit enter
-Eina_Bool
-termcmd_do(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd)
+static Eina_Bool
+_termcmd_font_size(Evas_Object *obj, Evas_Object *win __UNUSED__, Evas_Object *bg __UNUSED__, const char *cmd)
{
- if (!cmd) return EINA_FALSE;
- if ((cmd[0] == '/') || (cmd[0] == 's')) // search
+ Config *config = termio_config_get(obj);
+
+ if (config)
{
- if (cmd[1] == 0) // clear search
+ if (cmd[0] == 0) // back to default
{
- printf("search clear\n");
+ config->font.bitmap = config->font.orig_bitmap;
+ if (config->font.orig_name)
+ {
+ eina_stringshare_del(config->font.name);
+ config->font.name = eina_stringshare_add(config->font.orig_name);
+ }
+ termio_font_size_set(obj, config->font.orig_size);
return EINA_TRUE;
}
- printf("search '%s'\n", cmd + 1);
- return EINA_TRUE;
- }
- if ((cmd[0] == 'f') || (cmd[0] == 'F')) // font size
- {
- Config *config = termio_config_get(obj);
-
- if (config)
+ else if (cmd[0] == 'b') // big font size
{
- if (cmd[1] == 0) // back to default
+ if (config->font.orig_bitmap)
{
- config->font.bitmap = config->font.orig_bitmap;
- if (config->font.orig_name)
- {
- eina_stringshare_del(config->font.name);
- config->font.name = eina_stringshare_add(config->font.orig_name);
- }
- termio_font_size_set(obj, config->font.orig_size);
- return EINA_TRUE;
+ config->font.bitmap = 1;
+ eina_stringshare_del(config->font.name);
+ config->font.name = eina_stringshare_add("10x20.pcf");
+ termio_font_size_set(obj, 20);
}
- else if (cmd[1] == 'b') // big font size
+ else
{
- if (config->font.orig_bitmap)
- {
- config->font.bitmap = 1;
- eina_stringshare_del(config->font.name);
- config->font.name = eina_stringshare_add("10x20.pcf");
- termio_font_size_set(obj, 20);
- }
- else
- {
- termio_font_size_set(obj, 20);
- }
- }
- else if (cmd[1] == '+') // size up
- {
- termio_font_size_set(obj, config->font.size + 1);
- }
- else if (cmd[1] == '-') // size down
- {
- termio_font_size_set(obj, config->font.size - 1);
+ termio_font_size_set(obj, 20);
}
}
- return EINA_TRUE;
+ else if (cmd[0] == '+') // size up
+ {
+ termio_font_size_set(obj, config->font.size + 1);
+ }
+ else if (cmd[0] == '-') // size down
+ {
+ termio_font_size_set(obj, config->font.size - 1);
+ }
}
- if ((cmd[0] == 'g') || (cmd[0] == 'G')) // grid size
- {
- int w = -1, h = -1;
- int r = sscanf(cmd, "g%ix%i", &w, &h);
+ return EINA_TRUE;
+}
- if (r == 1)
+static Eina_Bool
+_termcmd_grid_size(Evas_Object *obj, Evas_Object *win __UNUSED__, Evas_Object *bg __UNUSED__, const char *cmd)
+{
+ int w = -1, h = -1;
+ int r = sscanf(cmd, "%ix%i", &w, &h);
+
+ if (r == 1)
+ {
+ switch (w)
{
- switch (w)
- {
- case 0:
- w = 80;
- h = 24;
- break;
- case 1:
- w = 80;
- h = 40;
- break;
- case 2:
- w = 80;
- h = 60;
- break;
- case 3:
- w = 80;
- h = 80;
- break;
- case 4:
- w = 120;
- h = 24;
- break;
- case 5:
- w = 120;
- h = 40;
- break;
- case 6:
- w = 120;
- h = 60;
- break;
- case 7:
- w = 120;
- h = 80;
- break;
- case 8:
- w = 120;
- h = 120;
- break;
- }
+ case 0:
+ w = 80;
+ h = 24;
+ break;
+ case 1:
+ w = 80;
+ h = 40;
+ break;
+ case 2:
+ w = 80;
+ h = 60;
+ break;
+ case 3:
+ w = 80;
+ h = 80;
+ break;
+ case 4:
+ w = 120;
+ h = 24;
+ break;
+ case 5:
+ w = 120;
+ h = 40;
+ break;
+ case 6:
+ w = 120;
+ h = 60;
+ break;
+ case 7:
+ w = 120;
+ h = 80;
+ break;
+ case 8:
+ w = 120;
+ h = 120;
+ break;
}
- if ((w > 0) && (h > 0))
- termio_grid_size_set(obj, w, h);
- return EINA_TRUE;
}
+ if ((w > 0) && (h > 0))
+ termio_grid_size_set(obj, w, h);
+ return EINA_TRUE;
+}
+
+// called as u type
+Eina_Bool
+termcmd_watch(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd)
+{
+ if (!cmd) return EINA_FALSE;
+ if ((cmd[0] == '/') || (cmd[0] == 's'))
+ return _termcmd_search(obj, win, bg, cmd + 1);
return EINA_FALSE;
obj = win = bg = NULL;
}
+// called when you hit enter
+Eina_Bool
+termcmd_do(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd)
+{
+ if (!cmd) return EINA_FALSE;
+ if ((cmd[0] == '/') || (cmd[0] == 's'))
+ return _termcmd_search(obj, win, bg, cmd + 1);
+ if ((cmd[0] == 'f') || (cmd[0] == 'F'))
+ return _termcmd_font_size(obj, win, bg, cmd + 1);
+ if ((cmd[0] == 'g') || (cmd[0] == 'G'))
+ return _termcmd_grid_size(obj, win, bg, cmd + 1);
+
+ return EINA_FALSE;
+ obj = win = bg = NULL;
+}