Add splits as startup arguments

Summary:
You can have use one of the following options:

______
|  |  |   -s or --split v
|__|__|

______
|_____|   -s or --split h
|_____|

______
|  |__|   -s or --split v-h
|__|__|

______
|__|  |   -s or --split vh
|__|__|

______
|__ __|   -s or --split h-v
|__|__|

______
|__|__|   -s or --split hv
|_____|

______
|__|__|   -s or --split vh--h
|__|__|

Reviewers: billiob

Differential Revision: https://phab.enlightenment.org/D1244
This commit is contained in:
godfath3r 2014-08-09 11:46:47 +02:00 committed by Boris Faure
parent 4f3ee44e6b
commit ca8f4ce2d3
5 changed files with 97 additions and 14 deletions

View File

@ -1,5 +1,5 @@
.\" Manpage for Terminology .\" Manpage for Terminology
.TH man 1 "13 May 2014" "0.6" "Terminology man page" .TH man 1 "09 August 2014" "0.7" "Terminology man page"
.SH NAME .SH NAME
Terminology \- Terminal Emulator written with EFL (Enlightenment Foundation Libraries). Terminology \- Terminal Emulator written with EFL (Enlightenment Foundation Libraries).
.SH SYNOPSIS .SH SYNOPSIS
@ -13,7 +13,12 @@ icons for files and so on...
.TP .TP
.B \-e, \-\-exec <cmnd> .B \-e, \-\-exec <cmnd>
Specify command to execute. Specify command to execute.
Defaults to $SHELL (or passwd shell or /bin/sh) Defaults to \fB$SHELL\fP (or passwd shell or \fB/bin/sh\fP)
When used along with \fB\-S\fP/\fB\-\-split\fP, each argument is used as a command for a
split, leaving away the extra arguments.
With 3 splits, one vertical, a command on the right, an horizontal split on
the left with only a command on the bottom, the following arguments should be used:
\fB\-\-split v\-h\-\- \-e command1 $SHELL command2\fP
. .
.TP .TP
.B \-d=CURRENT-DIRECTORY, \-\-current\-directory=CURRENT-DIRECTORY .B \-d=CURRENT-DIRECTORY, \-\-current\-directory=CURRENT-DIRECTORY
@ -46,6 +51,36 @@ Set window role.
Type: STR. Type: STR.
. .
.TP .TP
.B \-s=vh\-, \-\-split=vh\-
Terminology can start with splits opened as described below.
The arguments are a string with the following characters:
\fB\-s v\fP splits terminal vertically
\fB\-s h\fP splits horizontally
\fB\-\fP defines a placeholder for a shell or a command when used with
\fB\-\-exec\fP/\fB\-e\fP
Examples:
______
| | |
$ \fBterminology -s v\fP |__|__|
______
|_____|
$ \fBterminology -s h\fP |_____|
______
|__| |
$ \fBterminology -s vh\fP |__|__|
______
| |__|
$ \fBterminology -s v-h\fP |__|__|
______
$ \fBterminology -s vh--h\fP |__|__|
\fBhv--v\fP |__|__|
Type: STR.
.
.TP
.B \-T=TITLE, \-\-title=TITLE .B \-T=TITLE, \-\-title=TITLE
Set window title. Set window title.
Type: STR. Type: STR.

View File

@ -76,13 +76,13 @@ _cb_ct_new(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EIN
static void static void
_cb_ct_split_v(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) _cb_ct_split_v(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{ {
main_split_v(ct_win, ct_term); main_split_v(ct_win, ct_term, NULL);
} }
static void static void
_cb_ct_split_h(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) _cb_ct_split_h(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{ {
main_split_h(ct_win, ct_term); main_split_h(ct_win, ct_term, NULL);
} }
static void static void

View File

@ -16,6 +16,7 @@ struct _Ipc_Instance
const char *icon_name; const char *icon_name;
const char *font; const char *font;
const char *startup_id; const char *startup_id;
const char *startup_split;
int x, y, w, h; int x, y, w, h;
int pos; int pos;
int login_shell; int login_shell;

View File

@ -276,7 +276,7 @@ _term_resize_track_stop(Split *sp)
} }
static void static void
_split_split(Split *sp, Eina_Bool horizontal) _split_split(Split *sp, Eina_Bool horizontal, char *cmd)
{ {
Split *sp2, *sp1; Split *sp2, *sp1;
Evas_Object *o; Evas_Object *o;
@ -312,7 +312,7 @@ _split_split(Split *sp, Eina_Bool horizontal)
config = config_fork(sp->term->config); config = config_fork(sp->term->config);
if (termio_cwd_get(sp->term->term, buf, sizeof(buf))) wdir = buf; if (termio_cwd_get(sp->term->term, buf, sizeof(buf))) wdir = buf;
sp2->term = main_term_new(sp->wn, config, sp2->term = main_term_new(sp->wn, config,
NULL, config->login_shell, wdir, cmd, config->login_shell, wdir,
80, 24, EINA_FALSE); 80, 24, EINA_FALSE);
sp2->terms = eina_list_append(sp2->terms, sp2->term); sp2->terms = eina_list_append(sp2->terms, sp2->term);
_term_resize_track_start(sp2); _term_resize_track_start(sp2);
@ -408,21 +408,21 @@ main_new(Evas_Object *win, Evas_Object *term)
} }
void void
main_split_h(Evas_Object *win, Evas_Object *term) main_split_h(Evas_Object *win, Evas_Object *term, char *cmd)
{ {
Split *sp = _split_find(win, term, NULL); Split *sp = _split_find(win, term, NULL);
if (!sp) return; if (!sp) return;
_split_split(sp, EINA_TRUE); _split_split(sp, EINA_TRUE, cmd);
} }
void void
main_split_v(Evas_Object *win, Evas_Object *term) main_split_v(Evas_Object *win, Evas_Object *term, char *cmd)
{ {
Split *sp = _split_find(win, term, NULL); Split *sp = _split_find(win, term, NULL);
if (!sp) return; if (!sp) return;
_split_split(sp, EINA_FALSE); _split_split(sp, EINA_FALSE, cmd);
} }
static void static void
@ -1565,7 +1565,7 @@ _cb_split_h(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{ {
Term *term = data; Term *term = data;
main_split_h(term->wn->win, term->term); main_split_h(term->wn->win, term->term, NULL);
} }
static void static void
@ -1573,7 +1573,7 @@ _cb_split_v(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{ {
Term *term = data; Term *term = data;
main_split_v(term->wn->win, term->term); main_split_v(term->wn->win, term->term, NULL);
} }
static void static void
@ -2439,6 +2439,7 @@ main_ipc_new(Ipc_Instance *inst)
if (inst->role) nargc += 2; if (inst->role) nargc += 2;
if (inst->title) nargc += 2; if (inst->title) nargc += 2;
if (inst->font) nargc += 2; if (inst->font) nargc += 2;
if (inst->startup_split) nargc += 2;
if ((inst->pos) || (inst->w > 0) || (inst->h > 0)) nargc += 2; if ((inst->pos) || (inst->w > 0) || (inst->h > 0)) nargc += 2;
if (inst->login_shell) nargc += 1; if (inst->login_shell) nargc += 1;
if (inst->fullscreen) nargc += 1; if (inst->fullscreen) nargc += 1;
@ -2487,6 +2488,11 @@ main_ipc_new(Ipc_Instance *inst)
nargv[i++] = "-f"; nargv[i++] = "-f";
nargv[i++] = (char *)inst->font; nargv[i++] = (char *)inst->font;
} }
if (inst->startup_split)
{
nargv[i++] = "-S";
nargv[i++] = (char *)inst->startup_split;
}
if ((inst->pos) || (inst->w > 0) || (inst->h > 0)) if ((inst->pos) || (inst->w > 0) || (inst->h > 0))
{ {
if (!inst->pos) if (!inst->pos)
@ -2731,6 +2737,11 @@ static Ecore_Getopt options = {
gettext_noop("Set icon name.")), gettext_noop("Set icon name.")),
ECORE_GETOPT_STORE_STR ('f', "font", ECORE_GETOPT_STORE_STR ('f', "font",
gettext_noop("Set font (NAME/SIZE for scalable, NAME for bitmap.")), gettext_noop("Set font (NAME/SIZE for scalable, NAME for bitmap.")),
ECORE_GETOPT_STORE_STR ('S', "split",
gettext_noop("Split the terminal window."
" 'v' for vertical and 'h' for horizontal."
" Can be used multiple times. eg -S vhvv or --split hv"
" More description available on the man page.")),
ECORE_GETOPT_CHOICE ('v', "video-module", ECORE_GETOPT_CHOICE ('v', "video-module",
gettext_noop("Set emotion module to use."), emotion_choices), gettext_noop("Set emotion module to use."), emotion_choices),
@ -2823,6 +2834,7 @@ elm_main(int argc, char **argv)
char *title = NULL; char *title = NULL;
char *icon_name = NULL; char *icon_name = NULL;
char *font = NULL; char *font = NULL;
char *startup_split = NULL;
char *video_module = NULL; char *video_module = NULL;
Eina_Bool login_shell = 0xff; /* unset */ Eina_Bool login_shell = 0xff; /* unset */
Eina_Bool video_mute = 0xff; /* unset */ Eina_Bool video_mute = 0xff; /* unset */
@ -2857,6 +2869,7 @@ elm_main(int argc, char **argv)
ECORE_GETOPT_VALUE_STR(title), ECORE_GETOPT_VALUE_STR(title),
ECORE_GETOPT_VALUE_STR(icon_name), ECORE_GETOPT_VALUE_STR(icon_name),
ECORE_GETOPT_VALUE_STR(font), ECORE_GETOPT_VALUE_STR(font),
ECORE_GETOPT_VALUE_STR(startup_split),
ECORE_GETOPT_VALUE_STR(video_module), ECORE_GETOPT_VALUE_STR(video_module),
ECORE_GETOPT_VALUE_BOOL(login_shell), ECORE_GETOPT_VALUE_BOOL(login_shell),
@ -2890,6 +2903,7 @@ elm_main(int argc, char **argv)
int pos_set = 0, size_set = 0; int pos_set = 0, size_set = 0;
int pos_x = 0, pos_y = 0; int pos_x = 0, pos_y = 0;
int size_w = 1, size_h = 1; int size_w = 1, size_h = 1;
Eina_List *cmds_list = NULL;
elm_language_set(""); elm_language_set("");
#if HAVE_GETTEXT && ENABLE_NLS #if HAVE_GETTEXT && ENABLE_NLS
@ -2949,6 +2963,8 @@ elm_main(int argc, char **argv)
{ {
eina_strbuf_append(strb, argv[i]); eina_strbuf_append(strb, argv[i]);
eina_strbuf_append_char(strb, ' '); eina_strbuf_append_char(strb, ' ');
if (startup_split)
cmds_list = eina_list_append(cmds_list, argv[i]);
} }
cmd = eina_strbuf_string_steal(strb); cmd = eina_strbuf_string_steal(strb);
eina_strbuf_free(strb); eina_strbuf_free(strb);
@ -3176,6 +3192,7 @@ remote:
inst.maximized = maximized; inst.maximized = maximized;
inst.hold = hold; inst.hold = hold;
inst.nowm = nowm; inst.nowm = nowm;
inst.startup_split = startup_split;
if (ipc_instance_add(&inst)) if (ipc_instance_add(&inst))
goto end; goto end;
} }
@ -3233,6 +3250,36 @@ remote:
main_media_update(wn->config); main_media_update(wn->config);
main_win_sizing_handle(wn); main_win_sizing_handle(wn);
evas_object_show(wn->win); evas_object_show(wn->win);
if (startup_split)
{
unsigned int i = 0;
void *pch = NULL;
Term *next = term;
for (i=0; i<strlen(startup_split); i++)
{
if (startup_split[i] == 'v')
{
pch = eina_list_nth(cmds_list, 1);
main_split_v(next->wn->win, next->term, pch);
cmds_list = eina_list_remove(cmds_list, pch);
}
else if (startup_split[i] == 'h')
{
pch = eina_list_nth(cmds_list, 1);
main_split_h(next->wn->win, next->term, pch);
cmds_list = eina_list_remove(cmds_list, pch);
}
else if (startup_split[i] == '-')
next = _term_next_get(next);
else
{
ERR(_("invalid argument found for option -S/--split. See --help."));
goto end;
}
}
if (cmds_list) eina_list_free(cmds_list);
}
if (pos_set) if (pos_set)
{ {
int screen_w, screen_h; int screen_w, screen_h;

View File

@ -9,8 +9,8 @@ typedef struct _Split Split;
void main_new(Evas_Object *win, Evas_Object *term); void main_new(Evas_Object *win, Evas_Object *term);
void main_new_with_dir(Evas_Object *win, Evas_Object *term, const char *wdir); void main_new_with_dir(Evas_Object *win, Evas_Object *term, const char *wdir);
void main_split_h(Evas_Object *win, Evas_Object *term); void main_split_h(Evas_Object *win, Evas_Object *term, char *cmd);
void main_split_v(Evas_Object *win, Evas_Object *term); void main_split_v(Evas_Object *win, Evas_Object *term, char *cmd);
void main_close(Evas_Object *win, Evas_Object *term); void main_close(Evas_Object *win, Evas_Object *term);
void main_trans_update(const Config *config); void main_trans_update(const Config *config);