aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termcmd.c
blob: 97c795279f00516730fe1036c7c7aaee82d25931 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "private.h"

#include <Elementary.h>
#include "main.h"
#include "win.h"
#include "termio.h"
#include "config.h"
#include "controls.h"
#include "media.h"
#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)
{
   if (!cmd) return EINA_FALSE;
   if ((cmd[0] == '/') || (cmd[0] == 's')) // search
     {
        if (cmd[1] == 0) // clear search
          {
             printf("search clear\n");
             return EINA_TRUE;
          }
        printf("search '%s'\n", cmd + 1);
        return EINA_TRUE;
     }
   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')) // search
     {
        if (cmd[1] == 0) // clear search
          {
             printf("search clear\n");
             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)
          {
             if (cmd[1] == 0) // back to default
               {
                  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;
               }
             else if (cmd[1] == 'b') // big font size
               {
                  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);
               }
          }
        return EINA_TRUE;
     }
   if ((cmd[0] == 'g') || (cmd[0] == 'G')) // grid size
     {
        int w = -1, h = -1;
        int r = sscanf(cmd, "g%ix%i", &w, &h);

        if (r == 1)
          {
             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;
               }
          }
        if ((w > 0) && (h > 0))
          termio_grid_size_set(obj, w, h);
        return EINA_TRUE;
     }
   return EINA_FALSE;
   obj = win = bg = NULL;
}