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
devs/discomfitor/cc
godfath3r 8 years ago committed by Boris Faure
parent 4f3ee44e6b
commit ca8f4ce2d3
  1. 39
      man/terminology.1
  2. 4
      src/bin/controls.c
  3. 1
      src/bin/ipc.h
  4. 63
      src/bin/main.c
  5. 4
      src/bin/main.h

@ -1,5 +1,5 @@
.\" 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
Terminology \- Terminal Emulator written with EFL (Enlightenment Foundation Libraries).
.SH SYNOPSIS
@ -13,7 +13,12 @@ icons for files and so on...
.TP
.B \-e, \-\-exec <cmnd>
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
.B \-d=CURRENT-DIRECTORY, \-\-current\-directory=CURRENT-DIRECTORY
@ -46,6 +51,36 @@ Set window role.
Type: STR.
.
.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
Set window title.
Type: STR.

@ -76,13 +76,13 @@ _cb_ct_new(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EIN
static void
_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
_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

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

@ -276,7 +276,7 @@ _term_resize_track_stop(Split *sp)
}
static void
_split_split(Split *sp, Eina_Bool horizontal)
_split_split(Split *sp, Eina_Bool horizontal, char *cmd)
{
Split *sp2, *sp1;
Evas_Object *o;
@ -312,7 +312,7 @@ _split_split(Split *sp, Eina_Bool horizontal)
config = config_fork(sp->term->config);
if (termio_cwd_get(sp->term->term, buf, sizeof(buf))) wdir = buf;
sp2->term = main_term_new(sp->wn, config,
NULL, config->login_shell, wdir,
cmd, config->login_shell, wdir,
80, 24, EINA_FALSE);
sp2->terms = eina_list_append(sp2->terms, sp2->term);
_term_resize_track_start(sp2);
@ -408,21 +408,21 @@ main_new(Evas_Object *win, Evas_Object *term)
}
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);
if (!sp) return;
_split_split(sp, EINA_TRUE);
_split_split(sp, EINA_TRUE, cmd);
}
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);
if (!sp) return;
_split_split(sp, EINA_FALSE);
_split_split(sp, EINA_FALSE, cmd);
}
static void
@ -1565,7 +1565,7 @@ _cb_split_h(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
Term *term = data;
main_split_h(term->wn->win, term->term);
main_split_h(term->wn->win, term->term, NULL);
}
static void
@ -1573,7 +1573,7 @@ _cb_split_v(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
Term *term = data;
main_split_v(term->wn->win, term->term);
main_split_v(term->wn->win, term->term, NULL);
}
static void
@ -2439,6 +2439,7 @@ main_ipc_new(Ipc_Instance *inst)
if (inst->role) nargc += 2;
if (inst->title) 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->login_shell) nargc += 1;
if (inst->fullscreen) nargc += 1;
@ -2487,6 +2488,11 @@ main_ipc_new(Ipc_Instance *inst)
nargv[i++] = "-f";
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)
@ -2731,6 +2737,11 @@ static Ecore_Getopt options = {
gettext_noop("Set icon name.")),
ECORE_GETOPT_STORE_STR ('f', "font",
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",
gettext_noop("Set emotion module to use."), emotion_choices),
@ -2823,6 +2834,7 @@ elm_main(int argc, char **argv)
char *title = NULL;
char *icon_name = NULL;
char *font = NULL;
char *startup_split = NULL;
char *video_module = NULL;
Eina_Bool login_shell = 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(icon_name),
ECORE_GETOPT_VALUE_STR(font),
ECORE_GETOPT_VALUE_STR(startup_split),
ECORE_GETOPT_VALUE_STR(video_module),
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_x = 0, pos_y = 0;
int size_w = 1, size_h = 1;
Eina_List *cmds_list = NULL;
elm_language_set("");
#if HAVE_GETTEXT && ENABLE_NLS
@ -2949,6 +2963,8 @@ elm_main(int argc, char **argv)
{
eina_strbuf_append(strb, argv[i]);
eina_strbuf_append_char(strb, ' ');
if (startup_split)
cmds_list = eina_list_append(cmds_list, argv[i]);
}
cmd = eina_strbuf_string_steal(strb);
eina_strbuf_free(strb);
@ -3176,6 +3192,7 @@ remote:
inst.maximized = maximized;
inst.hold = hold;
inst.nowm = nowm;
inst.startup_split = startup_split;
if (ipc_instance_add(&inst))
goto end;
}
@ -3233,6 +3250,36 @@ remote:
main_media_update(wn->config);
main_win_sizing_handle(wn);
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)
{
int screen_w, screen_h;

@ -9,8 +9,8 @@ typedef struct _Split Split;
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_split_h(Evas_Object *win, Evas_Object *term);
void main_split_v(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, char *cmd);
void main_close(Evas_Object *win, Evas_Object *term);
void main_trans_update(const Config *config);

Loading…
Cancel
Save