[vte/wip/rishi/precmd-preexec: 3/4] Support precmd notifications from an interactive shell
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/rishi/precmd-preexec: 3/4] Support precmd notifications from an interactive shell
- Date: Wed, 9 May 2018 16:14:28 +0000 (UTC)
commit c37e4351fb366916d57d2e9963013305bc868485
Author: Debarshi Ray <debarshir gnome org>
Date: Wed May 2 17:20:30 2018 +0200
Support precmd notifications from an interactive shell
Add sequences
OSC 777 ; precmd BEL
OSC 777 ; precmd ST
that can be used from an interactive shell's precmd hook to notify the
terminal emulator that a first level prompt is about to be shown.
Examples of such hooks are Bash's PROMPT_COMMAND and Zsh's precmd.
The OSC 777 escape sequence is taken from Enlightenment's Terminology:
https://phab.enlightenment.org/T1765
https://bugzilla.gnome.org/show_bug.cgi?id=711060
src/vte.cc | 7 +++++++
src/vte.sh | 2 +-
src/vte/vteterminal.h | 3 ++-
src/vtegtk.cc | 18 ++++++++++++++++++
src/vtegtk.hh | 1 +
src/vteinternal.hh | 1 +
src/vteseq.cc | 4 +++-
7 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 1a7b533..c129bf2 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -10769,6 +10769,13 @@ VteTerminalPrivate::emit_pending_signals()
m_shell_preexec = FALSE;
}
+ if (m_shell_precmd) {
+ _vte_debug_print (VTE_DEBUG_SIGNALS,
+ "Emitting `shell-precmd'.\n");
+ g_signal_emit(object, signals[SIGNAL_SHELL_PRECMD], 0);
+ m_shell_precmd = FALSE;
+ }
+
if (m_window_title_changed) {
if (m_window_title != m_window_title_pending) {
m_window_title.swap(m_window_title_pending);
diff --git a/src/vte.sh b/src/vte.sh
index 4ade59d..ca87d00 100644
--- a/src/vte.sh
+++ b/src/vte.sh
@@ -52,7 +52,7 @@ __vte_osc7 () {
__vte_prompt_command() {
local pwd='~'
[ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
- printf "\u009D0;%s@%s:%s\u009C%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
+ printf "\u009D777;precmd\u009C\u009D0;%s@%s:%s\u009C%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
"$(__vte_osc7)"
}
case "$TERM" in
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 5f3d325..2ab9c51 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -104,10 +104,11 @@ struct _VteTerminalClass {
void (*bell)(VteTerminal* terminal);
+ void (*shell_precmd)(VteTerminal* terminal);
void (*shell_preexec)(VteTerminal* terminal);
/* Padding for future expansion. */
- gpointer padding[15];
+ gpointer padding[14];
VteTerminalClassPrivate *priv;
};
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 1e5282c..c956905 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -700,6 +700,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
klass->child_exited = NULL;
klass->encoding_changed = NULL;
klass->char_size_changed = NULL;
+ klass->shell_precmd = NULL;
klass->shell_preexec = NULL;
klass->window_title_changed = NULL;
klass->icon_title_changed = NULL;
@@ -777,6 +778,23 @@ vte_terminal_class_init(VteTerminalClass *klass)
1, G_TYPE_INT);
/**
+ * VteTerminal::shell-precmd:
+ * @vteterminal: the object which received the signal
+ *
+ * Emitted right before an interactive shell shows a
+ * first-level prompt.
+ */
+ signals[SIGNAL_SHELL_PRECMD] =
+ g_signal_new(I_("shell-precmd"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteTerminalClass, shell_precmd),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* VteTerminal::shell-preexec:
* @vteterminal: the object which received the signal
*
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index cb7b02f..7fbb9a3 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -52,6 +52,7 @@ enum {
SIGNAL_RESIZE_WINDOW,
SIGNAL_RESTORE_WINDOW,
SIGNAL_SELECTION_CHANGED,
+ SIGNAL_SHELL_PRECMD,
SIGNAL_SHELL_PREEXEC,
SIGNAL_TEXT_DELETED,
SIGNAL_TEXT_INSERTED,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 1c1db50..550aed2 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -572,6 +572,7 @@ public:
gboolean m_cursor_moved_pending;
gboolean m_contents_changed_pending;
+ gboolean m_shell_precmd;
gboolean m_shell_preexec;
std::string m_window_title{};
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 5c6492a..2e62d65 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -1348,7 +1348,9 @@ VteTerminalPrivate::handle_urxvt_extension(vte::parser::Sequence const& seq,
return;
}
- if (*token == "preexec") {
+ if (*token == "precmd") {
+ m_shell_precmd = TRUE;
+ } else if (*token == "preexec") {
m_shell_preexec = TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]