working_dir and envp parameters go into MooTermCommand; made TermCommand and EraseBinding private
parent
af14a40e05
commit
c36828962f
|
@ -78,17 +78,17 @@
|
|||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum EraseBinding
|
||||
(in-module "Moo")
|
||||
(c-name "MooTermEraseBinding")
|
||||
(gtype-id "MOO_TYPE_TERM_ERASE_BINDING")
|
||||
(values
|
||||
'("auto" "MOO_TERM_ERASE_AUTO")
|
||||
'("ascii-backspace" "MOO_TERM_ERASE_ASCII_BACKSPACE")
|
||||
'("ascii-delete" "MOO_TERM_ERASE_ASCII_DELETE")
|
||||
'("delete-sequence" "MOO_TERM_ERASE_DELETE_SEQUENCE")
|
||||
)
|
||||
)
|
||||
;; (define-enum EraseBinding
|
||||
;; (in-module "Moo")
|
||||
;; (c-name "MooTermEraseBinding")
|
||||
;; (gtype-id "MOO_TYPE_TERM_ERASE_BINDING")
|
||||
;; (values
|
||||
;; '("auto" "MOO_TERM_ERASE_AUTO")
|
||||
;; '("ascii-backspace" "MOO_TERM_ERASE_ASCII_BACKSPACE")
|
||||
;; '("ascii-delete" "MOO_TERM_ERASE_ASCII_DELETE")
|
||||
;; '("delete-sequence" "MOO_TERM_ERASE_DELETE_SEQUENCE")
|
||||
;; )
|
||||
;; )
|
||||
|
||||
(define-flags TextAttrMask
|
||||
(in-module "Moo")
|
||||
|
@ -420,8 +420,6 @@
|
|||
(return-type "none")
|
||||
(parameters
|
||||
'("const-MooTermCommand*" "cmd")
|
||||
'("const-char*" "working_dir" (null-ok) (default "NULL"))
|
||||
'("strv" "envp" (null-ok) (default "NULL"))
|
||||
'("GError**" "error")
|
||||
)
|
||||
)
|
||||
|
@ -633,6 +631,8 @@
|
|||
(parameters
|
||||
'("const-char*" "cmd_line" (null-ok) (default "NULL"))
|
||||
'("strv" "argv" (null-ok) (default "NULL"))
|
||||
'("const-char*" "working_dir" (null-ok) (default "NULL"))
|
||||
'("strv" "envp" (null-ok) (default "NULL"))
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -367,3 +367,39 @@ _wrap_moo_term_get_selection_bounds (PyGObject *self)
|
|||
return_None;
|
||||
}
|
||||
}
|
||||
%%
|
||||
override moo_term_command_new kwargs
|
||||
static int
|
||||
_wrap_moo_term_command_new (PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { (char*) "cmd_line", (char*) "argv", (char*) "working_dir", (char*) "envp", NULL };
|
||||
char *cmd_line = NULL, **argv = NULL, *working_dir = NULL, **envp = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs,(char*) "|zO&zO&:MooTermCommand.__init__",
|
||||
kwlist,
|
||||
&cmd_line,
|
||||
moo_pyobject_to_strv, &argv,
|
||||
&working_dir,
|
||||
moo_pyobject_to_strv, &envp))
|
||||
return -1;
|
||||
|
||||
if (!argv || !cmd_line)
|
||||
return_ValueErrInt ("Term.__init__: either argv or cmd_line must be given");
|
||||
|
||||
if (argv && cmd_line)
|
||||
return_ValueErrInt ("Term.__init__: only one of argv or cmd_line may be given");
|
||||
|
||||
self->gtype = MOO_TYPE_TERM_COMMAND;
|
||||
self->free_on_dealloc = FALSE;
|
||||
|
||||
if (argv)
|
||||
self->boxed = moo_term_command_new_argv (argv, working_dir, envp);
|
||||
else
|
||||
self->boxed = moo_term_command_new_command_line (cmd_line, working_dir, envp);
|
||||
|
||||
if (!self->boxed)
|
||||
return_RuntimeErrInt ("could not create MooTermCommand object");
|
||||
|
||||
self->free_on_dealloc = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ G_BEGIN_DECLS
|
|||
|
||||
#define TERM_IMPLEMENT_ME TERM_IMPLEMENT_ME_WARNING ("%s: implement me", G_STRLOC)
|
||||
|
||||
|
||||
#define PT_WRITER_PRIORITY G_PRIORITY_DEFAULT
|
||||
#define PT_READER_PRIORITY G_PRIORITY_DEFAULT
|
||||
|
||||
|
@ -80,6 +79,20 @@ typedef enum {
|
|||
|
||||
typedef struct _MooTermFont MooTermFont;
|
||||
|
||||
typedef enum {
|
||||
MOO_TERM_ERASE_AUTO,
|
||||
MOO_TERM_ERASE_ASCII_BACKSPACE,
|
||||
MOO_TERM_ERASE_ASCII_DELETE,
|
||||
MOO_TERM_ERASE_DELETE_SEQUENCE
|
||||
} MooTermEraseBinding;
|
||||
|
||||
struct _MooTermCommand {
|
||||
char *cmd_line;
|
||||
char **argv;
|
||||
char *working_dir;
|
||||
char **envp;
|
||||
};
|
||||
|
||||
struct _MooTermPrivate {
|
||||
struct _MooTermPt *pt;
|
||||
struct _MooTermParser *parser;
|
||||
|
@ -178,6 +191,9 @@ struct _MooTermPrivate {
|
|||
} mouse_stuff;
|
||||
};
|
||||
|
||||
#define MOO_TYPE_TERM_ERASE_BINDING (_moo_term_erase_binding_get_type ())
|
||||
GType _moo_term_erase_binding_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#define term_top_line(term) \
|
||||
((term)->priv->scrolled ? \
|
||||
(term)->priv->top_line : \
|
||||
|
|
|
@ -926,8 +926,6 @@ moo_term_get_screen_size (MooTerm *term,
|
|||
gboolean
|
||||
moo_term_fork_command (MooTerm *term,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error)
|
||||
{
|
||||
MooTermCommand *copy;
|
||||
|
@ -945,9 +943,8 @@ moo_term_fork_command (MooTerm *term,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
result = _moo_term_pt_fork_command (term->priv->pt, copy,
|
||||
working_dir, envp,
|
||||
error);
|
||||
result = _moo_term_pt_fork_command (term->priv->pt, copy, error);
|
||||
|
||||
moo_term_command_free (copy);
|
||||
return result;
|
||||
}
|
||||
|
@ -966,10 +963,10 @@ moo_term_fork_command_line (MooTerm *term,
|
|||
g_return_val_if_fail (MOO_IS_TERM (term), FALSE);
|
||||
g_return_val_if_fail (cmd_line != NULL, FALSE);
|
||||
|
||||
cmd = moo_term_command_new (cmd_line, NULL);
|
||||
result = moo_term_fork_command (term, cmd, working_dir,
|
||||
envp, error);
|
||||
cmd = moo_term_command_new_command_line (cmd_line, working_dir, envp);
|
||||
result = moo_term_fork_command (term, cmd, error);
|
||||
moo_term_command_free (cmd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -987,10 +984,10 @@ moo_term_fork_argv (MooTerm *term,
|
|||
g_return_val_if_fail (MOO_IS_TERM (term), FALSE);
|
||||
g_return_val_if_fail (argv != NULL, FALSE);
|
||||
|
||||
cmd = moo_term_command_new (NULL, argv);
|
||||
result = moo_term_fork_command (term, cmd, working_dir,
|
||||
envp, error);
|
||||
cmd = moo_term_command_new_argv (argv, working_dir, envp);
|
||||
result = moo_term_fork_command (term, cmd, error);
|
||||
moo_term_command_free (cmd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1978,13 +1975,28 @@ moo_term_command_get_type (void)
|
|||
}
|
||||
|
||||
|
||||
MooTermCommand*
|
||||
moo_term_command_new (const char *cmd_line,
|
||||
char **argv)
|
||||
MooTermCommand *
|
||||
moo_term_command_new_argv (char **argv,
|
||||
const char *working_dir,
|
||||
char **envp)
|
||||
{
|
||||
MooTermCommand *cmd = g_new0 (MooTermCommand, 1);
|
||||
cmd->argv = g_strdupv (argv);
|
||||
cmd->envp = g_strdupv (envp);
|
||||
cmd->working_dir = g_strdup (working_dir);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
MooTermCommand *
|
||||
moo_term_command_new_command_line (const char *cmd_line,
|
||||
const char *working_dir,
|
||||
char **envp)
|
||||
{
|
||||
MooTermCommand *cmd = g_new0 (MooTermCommand, 1);
|
||||
cmd->cmd_line = g_strdup (cmd_line);
|
||||
cmd->argv = g_strdupv (argv);
|
||||
cmd->envp = g_strdupv (envp);
|
||||
cmd->working_dir = g_strdup (working_dir);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
@ -1995,6 +2007,8 @@ moo_term_command_copy (const MooTermCommand *cmd)
|
|||
MooTermCommand *copy = g_new0 (MooTermCommand, 1);
|
||||
copy->cmd_line = g_strdup (cmd->cmd_line);
|
||||
copy->argv = g_strdupv (cmd->argv);
|
||||
copy->working_dir = g_strdup (cmd->working_dir);
|
||||
copy->envp = g_strdupv (cmd->envp);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -2005,7 +2019,9 @@ moo_term_command_free (MooTermCommand *cmd)
|
|||
if (cmd)
|
||||
{
|
||||
g_free (cmd->cmd_line);
|
||||
g_free (cmd->working_dir);
|
||||
g_strfreev (cmd->argv);
|
||||
g_strfreev (cmd->envp);
|
||||
g_free (cmd);
|
||||
}
|
||||
}
|
||||
|
@ -2021,7 +2037,7 @@ moo_term_start_default_shell (MooTerm *term,
|
|||
cmd = _moo_term_get_default_shell ();
|
||||
g_return_val_if_fail (cmd != NULL, FALSE);
|
||||
|
||||
result = moo_term_fork_command (term, cmd, NULL, NULL, error);
|
||||
result = moo_term_fork_command (term, cmd, error);
|
||||
|
||||
moo_term_command_free (cmd);
|
||||
return result;
|
||||
|
@ -2045,7 +2061,7 @@ emit_new_line (MooTerm *term)
|
|||
|
||||
|
||||
GType
|
||||
moo_term_erase_binding_get_type (void)
|
||||
_moo_term_erase_binding_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define MOO_TYPE_TERM_COMMAND (moo_term_command_get_type ())
|
||||
#define MOO_TYPE_TERM_ERASE_BINDING (moo_term_erase_binding_get_type ())
|
||||
|
||||
#define MOO_TYPE_TERM (moo_term_get_type ())
|
||||
#define MOO_TERM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_TERM, MooTerm))
|
||||
|
@ -65,18 +64,6 @@ struct _MooTermClass
|
|||
void (*new_line) (MooTerm *term);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MOO_TERM_ERASE_AUTO,
|
||||
MOO_TERM_ERASE_ASCII_BACKSPACE,
|
||||
MOO_TERM_ERASE_ASCII_DELETE,
|
||||
MOO_TERM_ERASE_DELETE_SEQUENCE
|
||||
} MooTermEraseBinding;
|
||||
|
||||
struct _MooTermCommand {
|
||||
char *cmd_line;
|
||||
char **argv;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MOO_TERM_ERROR_FAILED,
|
||||
MOO_TERM_ERROR_INVAL
|
||||
|
@ -87,15 +74,12 @@ GQuark moo_term_error_quark (void) G_GNUC_CONST;
|
|||
|
||||
GType moo_term_get_type (void) G_GNUC_CONST;
|
||||
GType moo_term_command_get_type (void) G_GNUC_CONST;
|
||||
GType moo_term_erase_binding_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void moo_term_set_adjustment (MooTerm *term,
|
||||
GtkAdjustment *vadj);
|
||||
|
||||
gboolean moo_term_fork_command (MooTerm *term,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error);
|
||||
gboolean moo_term_fork_command_line (MooTerm *term,
|
||||
const char *cmd_line,
|
||||
|
@ -157,8 +141,12 @@ guint moo_term_char_width (MooTerm *term);
|
|||
gboolean moo_term_start_default_shell (MooTerm *term,
|
||||
GError **error);
|
||||
|
||||
MooTermCommand *moo_term_command_new (const char *cmd_line,
|
||||
char **argv);
|
||||
MooTermCommand *moo_term_command_new_argv (char **argv,
|
||||
const char *working_dir,
|
||||
char **envp);
|
||||
MooTermCommand *moo_term_command_new_command_line (const char *cmd_line,
|
||||
const char *working_dir,
|
||||
char **envp);
|
||||
MooTermCommand *moo_term_command_copy (const MooTermCommand *cmd);
|
||||
void moo_term_command_free (MooTermCommand *cmd);
|
||||
|
||||
|
|
|
@ -87,8 +87,6 @@ static void set_size (MooTermPt *pt,
|
|||
guint height);
|
||||
static gboolean fork_command (MooTermPt *pt,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error);
|
||||
static void pt_write (MooTermPt *pt,
|
||||
const char *string,
|
||||
|
@ -162,8 +160,6 @@ _moo_term_get_default_shell (void)
|
|||
static gboolean
|
||||
fork_command (MooTermPt *pt_gen,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error)
|
||||
{
|
||||
MooTermPtCyg *pt;
|
||||
|
@ -174,7 +170,8 @@ fork_command (MooTermPt *pt_gen,
|
|||
|
||||
pt = MOO_TERM_PT_CYG (pt_gen);
|
||||
|
||||
result = run_in_helper (cmd->cmd_line, working_dir, envp,
|
||||
result = run_in_helper (cmd->cmd_line,
|
||||
cmd->working_dir, cmd->envp,
|
||||
TERM_WIDTH (pt), TERM_HEIGHT (pt),
|
||||
&pt->in, &pt->out, &pt->pid,
|
||||
&pt->process_id, error);
|
||||
|
|
|
@ -79,8 +79,6 @@ static void set_size (MooTermPt *pt,
|
|||
guint height);
|
||||
static gboolean fork_command (MooTermPt *pt,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error);
|
||||
static gboolean fork_argv (MooTermPt *pt,
|
||||
char **argv,
|
||||
|
@ -276,21 +274,21 @@ fork_argv (MooTermPt *pt_gen,
|
|||
}
|
||||
|
||||
|
||||
static gboolean fork_command (MooTermPt *pt_gen,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error)
|
||||
static gboolean
|
||||
fork_command (MooTermPt *pt_gen,
|
||||
const MooTermCommand *cmd,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (cmd != NULL, FALSE);
|
||||
g_return_val_if_fail (cmd->argv != NULL, FALSE);
|
||||
g_return_val_if_fail (MOO_IS_TERM_PT_UNIX (pt_gen), FALSE);
|
||||
|
||||
return fork_argv (pt_gen, cmd->argv, working_dir, envp, error);
|
||||
return fork_argv (pt_gen, cmd->argv, cmd->working_dir, cmd->envp, error);
|
||||
}
|
||||
|
||||
|
||||
static void kill_child (MooTermPt *pt_gen)
|
||||
static void
|
||||
kill_child (MooTermPt *pt_gen)
|
||||
{
|
||||
MooTermPtUnix *pt = MOO_TERM_PT_UNIX (pt_gen);
|
||||
|
||||
|
@ -697,7 +695,7 @@ send_intr (MooTermPt *pt)
|
|||
|
||||
|
||||
/* TODO: it should be in glib */
|
||||
MooTermCommand*
|
||||
MooTermCommand *
|
||||
_moo_term_get_default_shell (void)
|
||||
{
|
||||
static char *argv[2] = {NULL, NULL};
|
||||
|
@ -708,7 +706,7 @@ _moo_term_get_default_shell (void)
|
|||
if (!argv[0]) argv[0] = g_strdup ("/bin/sh");
|
||||
}
|
||||
|
||||
return moo_term_command_new (NULL, argv);
|
||||
return moo_term_command_new_argv (argv, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,12 +100,10 @@ _moo_term_pt_set_size (MooTermPt *pt,
|
|||
gboolean
|
||||
_moo_term_pt_fork_command (MooTermPt *pt,
|
||||
const MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_TERM_PT (pt), FALSE);
|
||||
return MOO_TERM_PT_GET_CLASS(pt)->fork_command (pt, cmd, working_dir, envp, error);
|
||||
return MOO_TERM_PT_GET_CLASS(pt)->fork_command (pt, cmd, error);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ struct _MooTermPtClass {
|
|||
guint height);
|
||||
gboolean (*fork_command) (MooTermPt *pt,
|
||||
const struct _MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error);
|
||||
void (*write) (MooTermPt *pt,
|
||||
const char *data,
|
||||
|
@ -87,8 +85,6 @@ void _moo_term_pt_send_intr (MooTermPt *pt);
|
|||
|
||||
gboolean _moo_term_pt_fork_command (MooTermPt *pt,
|
||||
const struct _MooTermCommand *cmd,
|
||||
const char *working_dir,
|
||||
char **envp,
|
||||
GError **error);
|
||||
void _moo_term_pt_kill_child (MooTermPt *pt);
|
||||
|
||||
|
|
Loading…
Reference in New Issue