[libvtemm] Get rid of NULL risks.



commit a1d575968065975bfe3e7febfe2aa0c7c9771fc8
Author: Krzesimir Nowak <krnowak svn gnome org>
Date:   Tue May 19 23:36:31 2009 +0200

    Get rid of NULL risks.
    
    * build_shared/Makefile_shared.am_fragment: Clean up a bit. Add
    files_internal to EXTRA_DIST.
    * examples/simple/main.cc:
    * examples/simple/simple.cc:
    * examples/simple/simple.h: Adapt it to recent API/ABI changes.
    Get rid of redundant getting user's shell - passing empty string
    to fork_command does the trick. Grab focus, not default.
    * src/libvtemm/Makefile.am: Create files_internal and add
    internalroutines files to them. Add shared.h to files_extra_h.
    * src/libvtemm/g/libvte_docs_override.xml: Lots of fixes. Removed
    all 'Since:'. Removed all notions about passing NULL to functions.
    * src/libvtemm/g/terminal.ccg:
    * src/libvtemm/g/terminal.hg: Wrapped fork_command and forkpty,
    added set_default_color_cursor, set_default_color_highlight,
    set_default_emulation and overloaded set_default_colors - just to
    take care about passing NULL to functions.
    * src/libvtemm/pty.cc:
    * src/libvtemm/pty.h: Replaced Glib::StringArrayHandle with
    StdStringArrayHandle.
---
 build_shared/Makefile_shared.am_fragment |   16 +-
 examples/simple/main.cc                  |    1 +
 examples/simple/simple.cc                |   30 +--
 examples/simple/simple.h                 |    2 +-
 src/libvtemm/Makefile.am                 |    7 +-
 src/libvtemm/g/libvte_docs_override.xml  |  522 ++++++++++++++++++++++++++----
 src/libvtemm/g/terminal.ccg              |   98 +++++--
 src/libvtemm/g/terminal.hg               |   50 +++-
 src/libvtemm/pty.cc                      |   19 +-
 src/libvtemm/pty.h                       |   18 +-
 10 files changed, 612 insertions(+), 151 deletions(-)

diff --git a/build_shared/Makefile_shared.am_fragment b/build_shared/Makefile_shared.am_fragment
index 993fa2f..f60f111 100644
--- a/build_shared/Makefile_shared.am_fragment
+++ b/build_shared/Makefile_shared.am_fragment
@@ -3,6 +3,8 @@
 ## needs defined:
 ##  files_extra_h
 ##  files_extra_cc
+##  files_internal_h
+##  files_internal_cc
 ## returns:
 ##  many variables
 ##  but only
@@ -34,8 +36,6 @@ generated_private_headers = $(patsubst %.hg,$(srcdir)/private/%_p.h,$(files_hg))
 tools_dir = $(top_srcdir)/tools
 tools_dir_m4 = $(tools_dir)/m4
 
-# this is not included. I don't know why...
-#include $(tools_dir)/Makefile_list_of_sources.am_fragment
 include $(top_srcdir)/tools/Makefile_list_of_sources.am_fragment
 # defined:
 #  files_tools_m4
@@ -50,8 +50,6 @@ gen_wrap_init_args = --namespace=Gnome --namespace=$(sublib_namespace) --parent_
 run_gen_wrap_init  = $(gen_wrap_init_path) $(gen_wrap_init_args)
 files_hg_with_path = $(patsubst %.hg,$(srcdir)/g/%.hg,$(files_hg))
 
-# # # #
-# commented for now, because hack needs to be used
 BUILT_SOURCES = $(generated_sources_h) $(generated_sources_cc) $(generated_private_headers)
 
 $(srcdir)/private/%_p.h: %.h
@@ -60,8 +58,6 @@ $(srcdir)/private/%_p.h: %.h
 
 %.h: $(srcdir)/g/%.hg $(srcdir)/g/%.ccg $(tools_m4) $(files_defs_from_g)
 	$(run_gmmproc) $(notdir $*) $(srcdir)/g $(srcdir)
-# end of "commented for now"
-# # # #
 
 $(srcdir)/wrap_init.cc: $(gen_wrap_init_path) $(files_hg_with_path)
 	$(run_gen_wrap_init) $(files_hg_with_path) >$@
@@ -76,18 +72,12 @@ common_ldflags = -version-info $(sublib_libversion) $(no_undefined)
 
 all_includes = -I$(top_builddir)/src -I$(top_srcdir)/src $(sublib_cflags)
 
-EXTRA_DIST = $(generated_sources_cc) $(files_extra_cc) $(generated_sources_h) $(files_extra_h)
-# DISTFILES = $(DIST_COMMON) $(dist_sources) $(TEXINFOS) $(EXTRA_DIST)
+EXTRA_DIST = $(generated_sources_cc) $(files_extra_cc) $(files_internal_cc) $(generated_sources_h) $(files_extra_h) $(files_internal_h)
 
 DEFS = @DEFS@ -DG_LOG_DOMAIN=\"$(sublib_name)\"
-# DEFAULT_INCLUDES =
 INCLUDES = $(strip $(all_includes)) $(DISABLE_DEPRECATED_CFLAGS) $(DISABLE_DEPRECATED_API_CFLAGS)
 
 sublib_includedir = $(includedir)/$(sublib_libname)/$(sublib_name)
 sublib_include_HEADERS = $(generated_sources_h) $(files_extra_h)
 
-# # # #
-# commented for now, because hack needs to be used
 MOSTLYCLEANFILES = $(generated_sources_cc) $(generated_sources_h) $(generated_private_headers)
-# end of "commented for now"
-# # # #
diff --git a/examples/simple/main.cc b/examples/simple/main.cc
index e98dddf..b70d5aa 100644
--- a/examples/simple/main.cc
+++ b/examples/simple/main.cc
@@ -19,6 +19,7 @@
  */
 
 #include <gtkmm.h>
+#include <libvtemm/init.h>
 #include "simple.h"
 
 int main(int argc, char *argv[])
diff --git a/examples/simple/simple.cc b/examples/simple/simple.cc
index d6ba6ab..584f553 100644
--- a/examples/simple/simple.cc
+++ b/examples/simple/simple.cc
@@ -18,18 +18,10 @@
  * along with Terminal Example.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <string>
 #include <vector>
 
-#include <unistd.h>
-#include <sys/types.h>
-#include <pwd.h>
-
 #include "simple.h"
 
-static std::string
-get_shell();
-
 Simple::Simple()
 :
   m_box(),
@@ -44,17 +36,11 @@ Simple::Simple()
   // put box into window.
   add(m_box);
   // set up a terminal.
-  /*
-  we are making a NULL terminated string vector. as we are passing neither
-  argv nor envv, the string vector contains one empty string only.
-  */
-  std::vector<std::string> nil(1, std::string());
-  std::string command(get_shell());
-  m_terminal.fork_command(command, nil, nil, std::string(), false, false, false);
+  m_terminal.fork_command();
   m_terminal.set_size(80, 24);
   m_terminal.signal_child_exited().connect(sigc::mem_fun(*this, &Simple::on_child_exited));
-  m_terminal.set_flags(Gtk::CAN_DEFAULT);
-  m_terminal.grab_default();
+  m_terminal.set_flags(Gtk::CAN_FOCUS);
+  m_terminal.grab_focus();
   // setting geometry hints is based on gnome-terminal code.
   Gdk::Geometry hints;
   Gnome::Vte::Padding pads(m_terminal.get_padding());
@@ -82,13 +68,3 @@ Simple::on_child_exited()
 {
   hide();
 }
-
-// static
-
-static std::string
-get_shell()
-{
-  uid_t uid(getuid());
-  passwd* pwd(getpwuid(uid));
-  return pwd->pw_shell;
-}
diff --git a/examples/simple/simple.h b/examples/simple/simple.h
index a022265..6a9a5ad 100644
--- a/examples/simple/simple.h
+++ b/examples/simple/simple.h
@@ -22,7 +22,7 @@
 #define _LIBVTEMM_EXAMPLE_SIMPLE_H_
 
 #include <gtkmm.h>
-#include <libvtemm.h>
+#include <libvtemm/terminal.h>
 
 class Simple : public Gtk::Window
 {
diff --git a/src/libvtemm/Makefile.am b/src/libvtemm/Makefile.am
index 5b345b0..d67b8ab 100644
--- a/src/libvtemm/Makefile.am
+++ b/src/libvtemm/Makefile.am
@@ -4,16 +4,19 @@
 SUBDIRS = g private
 
 files_extra_h = cursorposition.h init.h match.h padding.h pty.h \
-	textandcharattrs.h wrap_init.h
+	textandcharattrs.h wrap_init.h shared.h
 files_extra_cc = cursorposition.cc init.cc match.cc padding.cc pty.cc \
 	textandcharattrs.cc
 
+files_internal_h = internalroutines.h
+files_internal_cc = internalroutines.cc
+
 include $(top_srcdir)/build_shared/Makefile_shared.am_fragment
 #defined:
 # generated_sources_cc
 
 lib_LTLIBRARIES = libvtemm-1.1.la
-libvtemm_1_1_la_SOURCES = $(files_extra_cc) $(generated_sources_cc)
+libvtemm_1_1_la_SOURCES = $(files_extra_cc) $(generated_sources_cc) $(files_internal_cc)
 libvtemm_1_1_la_LDFLAGS = $(common_ldflags)
 libvtemm_1_1_la_LIBADD = @LIBVTEMM_LIBS@
 
diff --git a/src/libvtemm/g/libvte_docs_override.xml b/src/libvtemm/g/libvte_docs_override.xml
index 039aa01..c8fc7c3 100644
--- a/src/libvtemm/g/libvte_docs_override.xml
+++ b/src/libvtemm/g/libvte_docs_override.xml
@@ -25,8 +25,6 @@ to mess with your users.
 <description>
 Sends a block of binary data to the child.
 
-Since: 0.12.1
-
 </description>
 <parameters>
 <parameter name="terminal">
@@ -67,13 +65,9 @@ and background colors, the bold foreground color, the dim foreground
 color, an eight color palette, bold versions of the eight color palette,
 and a dim version of the the eight color palette.
 
-Size of @palette must be either 0, 8, 16, or 24.  If @foreground is %NULL and
-size of @palette is greater than 0, the new foreground color is taken from
- palette[7]   If @background is %NULL and size of @palette is greater than 0,
-the new background color is taken from @palette[0].  If
-size of @palette is 8 or 16, the third (dim) and possibly the second (bold)
-8-color palettes are extrapolated from the new background color and the items
-in @palette.
+Size of @palette must be either 0, 8, 16, or 24. If size of @palette is 8 or 16,
+the third (dim) and possibly the second (bold) 8-color palettes are extrapolated
+from the new background color and the items in @palette.
 
 
 </description>
@@ -83,11 +77,11 @@ in @palette.
 </parameter_description>
 </parameter>
 <parameter name="foreground">
-<parameter_description> the new foreground color, or %NULL
+<parameter_description> the new foreground color
 </parameter_description>
 </parameter>
 <parameter name="background">
-<parameter_description> the new background color, or %NULL
+<parameter_description> the new background color
 </parameter_description>
 </parameter>
 <parameter name="palette">
@@ -100,12 +94,11 @@ in @palette.
 
 <function name="vte_terminal_get_text_include_trailing_spaces">
 <description>
-Extracts a view of the visible part of the terminal.  If @slot is not
-%NULL, characters will only be read if @slot returns %TRUE after being
-passed the column and row, respectively.  A #VteCharAttributes structure
-is added to #TextAndCharAttrs return value for each byte added to the returned
-string detailing the character&apos;s position, colors, and other
-characteristics. This function differs from vte_terminal_get_text in that
+Extracts a view of the visible part of the terminal. Characters will only be
+read if @slot returns %true after being passed the column and row, respectively.
+A #VteCharAttributes structure is added to #TextAndCharAttrs return value for
+each byte added to the returned string detailing the character&apos;s position,
+colors, and other characteristics. This function differs from get_text() in that
 trailing spaces at the end of lines are included.
 
 
@@ -121,18 +114,17 @@ trailing spaces at the end of lines are included.
 </parameter>
 </parameters>
 <return> a #TextAndCharAttrs with text that may be empty and stored text
-attributes.
+attributes
 </return>
 </function>
 
 <function name="vte_terminal_get_text">
 <description>
-Extracts a view of the visible part of the terminal.  If @slot is not
-%NULL, characters will only be read if @slot returns %TRUE after being
-passed the column and row, respectively.  A #VteCharAttributes structure
-is added to #TextAndCharAttrs return value for each byte added to the returned
-string detailing the character&apos;s position, colors, and other
-characteristics.
+Extracts a view of the visible part of the terminal. Characters will only be
+read if @slot returns %true after being passed the column and row, respectively.
+A #VteCharAttributes structure is added to #TextAndCharAttrs return value for
+each byte added to the returned string detailing the character&apos;s position,
+colors, and other characteristics.
 
 
 </description>
@@ -147,19 +139,18 @@ characteristics.
 </parameter>
 </parameters>
 <return> a #TextAndCharAttrs with text that may be empty and stored text
-attributes.
+attributes
 </return>
 </function>
 
 <function name="vte_terminal_get_text_range">
 <description>
-Extracts a view of the visible part of the terminal.  If @slot is not
-%NULL, characters will only be read if @slot returns %TRUE after being
-passed the column and row, respectively.  A #VteCharAttributes structure
-is added to #TextAndCharAttrs return value for each byte added to the returned
-string detailing the character&apos;s position, colors, and other
-characteristics. The entire scrollback buffer is scanned, so it is possible to
-read the entire contents of the buffer using this function.
+Extracts a view of the visible part of the terminal. Characters will only be
+read if @slot returns %true after being passed the column and row, respectively.
+A #VteCharAttributes structure is added to #TextAndCharAttrs return value for
+each byte added to the returned string detailing the character&apos;s position,
+colors, and other characteristics. The entire scrollback buffer is scanned, so
+it is possible to read the entire contents of the buffer using this function.
 
 
 </description>
@@ -190,7 +181,7 @@ read the entire contents of the buffer using this function.
 </parameter>
 </parameters>
 <return> a #TextAndCharAttrs with text that may be empty and stored text
-attributes.
+attributes
 </return>
 </function>
 
@@ -198,7 +189,7 @@ attributes.
 <description>
 Starts a new child process under a newly-allocated controlling
 pseudo-terminal.  TERM is automatically set to reflect the terminal widget&apos;s
-emulation setting.  If @lastlog, @utmp, or @wtmp are %TRUE, logs the session
+emulation setting.  If @lastlog, @utmp, or @wtmp are %true, logs the session
 to the specified system log files.
 
 
@@ -209,42 +200,39 @@ to the specified system log files.
 </parameter_description>
 </parameter>
 <parameter name="envv">
-<parameter_description> an empty string terminated list of environment variables to be
+<parameter_description> a list of environment variables to be
 added to the environment before starting returning in the child process
 </parameter_description>
 </parameter>
 <parameter name="directory">
-<parameter_description> the name of a directory the child process should change to, or
-empty string
+<parameter_description> the name of a directory the command should start in, or
+empty string to inherit starting directory from parent
 </parameter_description>
 </parameter>
 <parameter name="lastlog">
-<parameter_description> %TRUE if the session should be logged to the lastlog
+<parameter_description> %true if the session should be logged to the lastlog
 </parameter_description>
 </parameter>
 <parameter name="utmp">
-<parameter_description> %TRUE if the session should be logged to the utmp/utmpx log
+<parameter_description> %true if the session should be logged to the utmp/utmpx log
 </parameter_description>
 </parameter>
 <parameter name="wtmp">
-<parameter_description> %TRUE if the session should be logged to the wtmp/wtmpx log
+<parameter_description> %true if the session should be logged to the wtmp/wtmpx log
 </parameter_description>
 </parameter>
 </parameters>
 <return> the ID of the new process in the parent
-
-Since: 0.11.11
 </return>
 </function>
 
 <function name="vte_terminal_fork_command">
 <description>
 Starts the specified command under a newly-allocated controlling
-pseudo-terminal.  The @argv and @envv lists should be empty string terminated, and
-argv[0] is expected to be the name of the file being run, as it would be if
-execve() were being called. TERM is automatically set to reflect the
-terminal widget&apos;s emulation setting.  If @lastlog, @utmp, or @wtmp are %TRUE,
-logs the session to the specified system log files.
+pseudo-terminal.  The argv[0] is expected to be the name of the file being run,
+as it would be if execve() were being called. TERM is automatically set to
+reflect the terminal widget&apos;s emulation setting. If @lastlog, @utmp, or
+ wtmp are %true, logs the session to the specified system log files.
 
 
 </description>
@@ -254,32 +242,33 @@ logs the session to the specified system log files.
 </parameter_description>
 </parameter>
 <parameter name="command">
-<parameter_description> the name of a binary to run, or %NULL to get user&apos;s shell
+<parameter_description> the name of a binary to run, or empty string to get user&apos;s shell
 </parameter_description>
 </parameter>
 <parameter name="argv">
-<parameter_description> the empty string terminated argument list to be passed to @command
+<parameter_description> an argument list to be passed to @command
 </parameter_description>
 </parameter>
 <parameter name="envv">
-<parameter_description> an empty string terminated list of environment variables to be
+<parameter_description> a list of environment variables to be
 added to the environment before starting @command
 </parameter_description>
 </parameter>
 <parameter name="directory">
-<parameter_description> the name of a directory the command should start in, or empty string
+<parameter_description> the name of a directory the command should start in, or
+empty string to inherit starting directory from parent
 </parameter_description>
 </parameter>
 <parameter name="lastlog">
-<parameter_description> %TRUE if the session should be logged to the lastlog
+<parameter_description> %true if the session should be logged to the lastlog
 </parameter_description>
 </parameter>
 <parameter name="utmp">
-<parameter_description> %TRUE if the session should be logged to the utmp/utmpx log
+<parameter_description> %true if the session should be logged to the utmp/utmpx log
 </parameter_description>
 </parameter>
 <parameter name="wtmp">
-<parameter_description> %TRUE if the session should be logged to the wtmp/wtmpx log
+<parameter_description> %true if the session should be logged to the wtmp/wtmpx log
 </parameter_description>
 </parameter>
 </parameters>
@@ -290,12 +279,12 @@ added to the environment before starting @command
 <function name="vte_terminal_match_check">
 <description>
 Checks if the text in and around the specified position matches any of the
-regular expressions previously set using vte_terminal_match_add().  If a
-match exists, the text string is returned and the number associated with
-the matched regular expression will be stored in @tag.
+regular expressions previously set using vte_terminal_match_add_gregex(). If a
+match exists, the text string and the number associated with the matched regular
+expression is returned.
 
 If more than one regular expression has been set with
-vte_terminal_match_add(), then expressions are checked in the order in
+vte_terminal_match_add_gregex(), then expressions are checked in the order in
 which they were added.
 
 
@@ -313,13 +302,9 @@ which they were added.
 <parameter_description> the text row
 </parameter_description>
 </parameter>
-<parameter name="tag">
-<parameter_description> pointer to an integer
-</parameter_description>
-</parameter>
 </parameters>
-<return> a string which matches one of the previously set regular
-expressions.
+<return> a #Gnome::Vte::Match instance holding string which matches one of the
+previously set regular expressions and a tag of matched regular expression.
 </return>
 </function>
 
@@ -359,7 +344,414 @@ used in each direction, and do not need to be doubled.
 </parameter_description>
 </parameter>
 </parameters>
-<return>#Gnome::Vte::Padding instance holding both paddings</return>
+<return> #Gnome::Vte::Padding instance holding both paddings
+</return>
+</function>
+
+<function name="vte_terminal_get_child_exit_status">
+<description>
+Gets the exit status of the command started by vte_terminal_fork_command().
+See your C library's documentation for more details on how to interpret the
+exit status.
+
+Note that this function may only be called from the signal handler of
+the &quot;child-exited&quot; signal.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> the child's exit status
+</return>
+</function>
+
+<function name="vte_terminal_get_cursor_blink_mode">
+<description>
+Gets cursor blink mode.
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> cursor blink mode
+</return>
+</function>
+
+<function name="vte_terminal_get_cursor_shape">
+<description>
+Gets cursor shape.
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> cursor shape
+</return>
+</function>
+
+<function name="vte_terminal_get_default_emulation">
+<description>
+Queries the terminal for its default emulation, which is attempted if
+vte_terminal_set_default_emulation() is used.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> the name of the default terminal type the widget attempts to emulate
+</return>
+</function>
+
+<function name="vte_terminal_get_pty">
+<description>
+Gets the file descriptor, or -1 if the terminal has no PTY.
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> the file descriptor, or -1 if the terminal has no PTY
+</return>
+</function>
+
+<function name="vte_terminal_match_add_gregex">
+<description>
+Adds the regular expression @regex to the list of matching expressions. When the
+user moves the mouse cursor over a section of displayed text which matches
+this expression, the text will be highlighted.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="regex">
+<parameter_description> a #GRegex
+</parameter_description>
+</parameter>
+<parameter name="flags">
+<parameter_description> the #GRegexMatchFlags to use when matching the regex
+</parameter_description>
+</parameter>
+</parameters>
+<return> an integer associated with this expression
+</return>
+</function>
+
+<function name="vte_terminal_match_set_cursor">
+<description>
+Sets which cursor the terminal will use if the pointer is over the pattern
+specified by @tag. The terminal keeps a reference to @cursor.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="tag">
+<parameter_description> the tag of the regex which should use the specified cursor
+</parameter_description>
+</parameter>
+<parameter name="cursor">
+<parameter_description> the #GdkCursor which the terminal should use when the pattern is
+highlighted
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_match_set_cursor_name">
+<description>
+Sets which cursor the terminal will use if the pointer is over the pattern
+specified by @tag.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="tag">
+<parameter_description> the tag of the regex which should use the specified cursor
+</parameter_description>
+</parameter>
+<parameter name="cursor_name">
+<parameter_description> the name of the cursor
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_match_set_cursor_type">
+<description>
+Sets which cursor the terminal will use if the pointer is over the pattern
+specified by @tag.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="tag">
+<parameter_description> the tag of the regex which should use the specified cursor
+</parameter_description>
+</parameter>
+<parameter name="cursor_type">
+<parameter_description> a #GdkCursorType
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_select_all">
+<description>
+Selects all text within the terminal (including the scrollback buffer).
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_select_none">
+<description>
+Clears the current selection.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_background_tint_color">
+<description>
+If a background image has been set using
+vte_terminal_set_background_image(),
+vte_terminal_set_background_image_file(), or
+vte_terminal_set_background_transparent(), and the value set by
+vte_terminal_set_background_saturation() is less than one, the terminal
+will adjust the color of the image before drawing the image.  To do so,
+the terminal will create a copy of the background image (or snapshot of
+the root window) and modify its pixel values.  The initial tint color
+is black.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="color">
+<parameter_description> a color which the terminal background should be tinted to if its
+saturation is not 1.0.
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_color_cursor">
+<description>
+Sets the background color for text which is under the cursor.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="cursor_background">
+<parameter_description> the new color to use for the text cursor
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_color_highlight">
+<description>
+Sets the background color for text which is highlighted.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="highlight_background">
+<parameter_description> the new color to use for highlighted text
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_cursor_blink_mode">
+<description>
+Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
+will use the #Gtk::Settings::property_gtk_cursor_blink setting.
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="mode">
+<parameter_description> the #VteTerminalCursorBlinkMode to use
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_cursor_shape">
+<description>
+Sets the shape of the cursor drawn.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="shape">
+<parameter_description> the #VteTerminalCursorShape to use
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_pty">
+<description>
+Attach an existing PTY master side to the terminal widget. Use
+instead of vte_terminal_fork_command() or vte_terminal_forkpty().
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="pty_master">
+<parameter_description> a file descriptor of the master end of a PTY
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_scroll_background">
+<description>
+Controls whether or not the terminal will scroll the background image (if
+one is set) when the text in the window must be scrolled.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="scroll">
+<parameter_description> %TRUE if the terminal should scroll the background image along with
+text.
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_word_chars">
+<description>
+When the user double-clicks to start selection, the terminal will extend
+the selection on word boundaries.  It will treat characters included in @spec
+as parts of words, and all other characters as word separators. Ranges of
+characters can be specified by separating them with a hyphen.
+
+As a special case, if @spec is empty string, the terminal will
+treat all graphic non-punctuation non-space characters as word characters.
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="spec">
+<parameter_description> a specification
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
+</function>
+
+<function name="vte_terminal_set_background_image">
+<description>
+Sets a background image for the widget. Text which would otherwise be
+drawn using the default background color will instead be drawn over the
+specified image. If necessary, the image will be tiled to cover the
+widget's entire visible area. If specified by
+vte_terminal_set_background_saturation(), the terminal will tint its
+in-memory copy of the image before applying it to the terminal. If @image will
+be Glib::RefPtr&lt;Gdk::PixBuf&gt;(<!-- -->) then background will be canceled.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+<parameter name="image">
+<parameter_description> a Glib::RefPtr&lt;Gdk::Pixbuf&gt; to use
+</parameter_description>
+</parameter>
+</parameters>
+<return></return>
 </function>
 
 </root>
diff --git a/src/libvtemm/g/terminal.ccg b/src/libvtemm/g/terminal.ccg
index bcebc6c..af4f66b 100644
--- a/src/libvtemm/g/terminal.ccg
+++ b/src/libvtemm/g/terminal.ccg
@@ -20,6 +20,8 @@
 
 #include <vte/vte.h>
 
+#include "internalroutines.h"
+
 namespace Gnome
 {
 
@@ -47,8 +49,74 @@ SignalProxy_selected_gtk_callback(VteTerminal *terminal, glong column, glong row
   return TRUE;
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 }
+
 } // namespace Private
 
+Glib::Pid
+Terminal::fork_command(const std::string& command, const StdStringArrayHandle& argv, const StdStringArrayHandle& envv, const std::string& directory, bool lastlog, bool utmp, bool wtmp)
+{
+  const char* c_command = get_c_string(command);
+  char** c_argv = get_c_string_vector(argv);
+  char** c_envv = get_c_string_vector(envv);
+  const char* c_directory = get_c_string(directory);
+  Glib::Pid pid = vte_terminal_fork_command(gobj(), c_command, c_argv, c_envv, c_directory, lastlog, utmp, wtmp);
+  g_strfreev(c_argv);
+  g_strfreev(c_envv);
+  return pid;
+}
+
+Glib::Pid
+Terminal::forkpty(const StdStringArrayHandle& envv, const std::string& directory, bool lastlog, bool utmp, bool wtmp)
+{
+  char** c_envv = get_c_string_vector(envv);
+  const char* c_directory = get_c_string(directory);
+  Glib::Pid pid = vte_terminal_forkpty(gobj(), c_envv, c_directory, lastlog, utmp, wtmp);
+  g_strfreev(c_envv);
+  return pid;
+}
+
+void
+Terminal::feed(const Glib::ustring& data)
+{
+  vte_terminal_feed(gobj(), data.data(), data.size());
+}
+
+void
+Terminal::feed_child(const Glib::ustring& text)
+{
+  vte_terminal_feed_child(gobj(), text.data(), text.size());
+}
+
+void
+Terminal::feed_child_binary(const std::string& data)
+{
+  vte_terminal_feed_child_binary(gobj(), data.data(), data.size());
+}
+
+void
+Terminal::set_default_color_cursor()
+{
+  vte_terminal_set_color_cursor(gobj(), 0);
+}
+
+void
+Terminal::set_default_color_highlight()
+{
+  vte_terminal_set_color_highlight(gobj(), 0);
+}
+
+void
+Terminal::set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::ArrayHandle_Color& palette)
+{
+  vte_terminal_set_colors(gobj(), foreground.gobj(), background.gobj(), palette.data(), palette.size());
+}
+
+void
+Terminal::set_default_colors(const Gdk::ArrayHandle_Color& palette)
+{
+  vte_terminal_set_colors(gobj(), 0, 0, palette.data(), palette.size());
+}
+
 bool
 Terminal::always_selected(long, long)
 {
@@ -115,6 +183,12 @@ Terminal::match_check(long column, long row)
   return Match(text, tag);
 }
 
+void
+Terminal::set_default_emulation()
+{
+  vte_terminal_set_emulation(gobj(), 0);
+}
+
 Padding
 Terminal::get_padding() const
 {
@@ -123,30 +197,6 @@ Terminal::get_padding() const
   return Padding(xpad, ypad);
 }
 
-void
-Terminal::set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::ArrayHandle_Color& palette)
-{
-  vte_terminal_set_colors(gobj(), foreground.gobj(), background.gobj(), palette.data(), palette.size());
-}
-
-void
-Terminal::feed(const Glib::ustring& data)
-{
-  vte_terminal_feed(gobj(), data.data(), data.size());
-}
-
-void
-Terminal::feed_child(const Glib::ustring& text)
-{
-  vte_terminal_feed_child(gobj(), text.data(), text.size());
-}
-
-void
-Terminal::feed_child_binary(const std::string& data)
-{
-  vte_terminal_feed_child_binary(gobj(), data.data(), data.size());
-}
-
 } // namespace Vte
 
 } // namespace Gnome
diff --git a/src/libvtemm/g/terminal.hg b/src/libvtemm/g/terminal.hg
index 84089b1..b3abd9c 100644
--- a/src/libvtemm/g/terminal.hg
+++ b/src/libvtemm/g/terminal.hg
@@ -29,6 +29,7 @@ _PINCLUDE(gtkmm/private/widget_p.h)
 #include <libvtemm/cursorposition.h>
 #include <libvtemm/match.h>
 #include <libvtemm/padding.h>
+#include <libvtemm/shared.h>
 #include <libvtemm/textandcharattrs.h>
 #include <pangomm.h>
 #include <sigc++/sigc++.h>
@@ -55,16 +56,27 @@ class Terminal : public Gtk::Widget
   _IGNORE(vte_terminal_feed, vte_terminal_feed_child, vte_terminal_feed_child_binary,
           vte_terminal_set_colors, vte_terminal_get_text, vte_terminal_get_text_include_trailing_spaces,
           vte_terminal_get_text_range, vte_terminal_get_cursor_position, vte_terminal_match_check,
-          vte_terminal_get_padding)
+          vte_terminal_get_padding, vte_terminal_fork_command, vte_terminal_forkpty)
   _IGNORE(vte_terminal_set_cursor_blinks, vte_terminal_set_font_full, vte_terminal_get_using_xft,
           vte_terminal_set_font_from_string_full, vte_terminal_match_add, vte_terminal_get_char_ascent,
           vte_terminal_get_char_descent)
 public:
   _CTOR_DEFAULT()
-  typedef Glib::ArrayHandle<std::string> StdStringArrayHandle;
-  _WRAP_METHOD(Glib::Pid fork_command(const std::string& command, const StdStringArrayHandle& argv, const StdStringArrayHandle& envv, const std::string& directory, bool lastlog, bool utmp, bool wtmp), vte_terminal_fork_command)
-
-  _WRAP_METHOD(Glib::Pid forkpty(const StdStringArrayHandle& envv, const std::string& directory, bool lastlog, bool utmp, bool wtmp), vte_terminal_forkpty)
+  
+  _WRAP_METHOD_DOCS_ONLY(vte_terminal_fork_command)
+  Glib::Pid fork_command(const std::string& command = std::string(),
+                         const StdStringArrayHandle& argv = StdStringArrayHandle(0, Glib::OWNERSHIP_NONE),
+                         const StdStringArrayHandle& envv = StdStringArrayHandle(0, Glib::OWNERSHIP_NONE),
+                         const std::string& directory = std::string(),
+                         bool lastlog = false,
+                         bool utmp = false,
+                         bool wtmp = false);
+  _WRAP_METHOD_DOCS_ONLY(vte_terminal_forkpty)
+  Glib::Pid forkpty(const StdStringArrayHandle& envv = StdStringArrayHandle(0, Glib::OWNERSHIP_NONE),
+                    const std::string& directory = std::string(),
+                    bool lastlog = false,
+                    bool utmp = false,
+                    bool wtmp = false);
 
   _WRAP_METHOD_DOCS_ONLY(vte_terminal_feed)
   void feed(const Glib::ustring& data);
@@ -98,10 +110,34 @@ public:
   _WRAP_METHOD(void set_color_foreground(const Gdk::Color& foreground), vte_terminal_set_color_foreground)
   _WRAP_METHOD(void set_color_background(const Gdk::Color& background), vte_terminal_set_color_background)
   _WRAP_METHOD(void set_color_cursor(const Gdk::Color& cursor_background), vte_terminal_set_color_cursor)
+  
+  /** Text under the cursor will be drawn with foreground and background colors
+   * reversed.
+   */
+  void set_default_color_cursor();
   _WRAP_METHOD(void set_color_highlight(const Gdk::Color& highlight_background), vte_terminal_set_color_highlight)
+  
+  /** Highlighted text (which is usually highlighted because it is selected)
+   * will be drawn with foreground and background colors reversed.
+   */
+  void set_default_color_highlight();
   _WRAP_METHOD_DOCS_ONLY(vte_terminal_set_colors)
   void set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::ArrayHandle_Color& palette);
   _WRAP_METHOD(void set_default_colors(), vte_terminal_set_default_colors)
+  
+  /** The terminal widget uses a 28-color model comprised of the default foreground
+   * and background colors, the bold foreground color, the dim foreground
+   * color, an eight color palette, bold versions of the eight color palette,
+   * and a dim version of the the eight color palette.
+   *
+   * Size of @a palette must be either 0, 8, 16, or 24.  If size of @a palette is greater
+   * than 0, the new foreground color is taken from @a palette[7].
+   * If size of @a palette is greater than 0, the new background color is taken from
+   * @a palette[0].  If size of @a palette is 8 or 16, the third (dim) and possibly the
+   * second (bold) 8-color palettes are extrapolated from the new background
+   * color and the items in @a palette.
+   */
+  void set_default_colors(const Gdk::ArrayHandle_Color& palette);
 
   _WRAP_METHOD(void set_background_image(const Glib::RefPtr<Gdk::Pixbuf>& image), vte_terminal_set_background_image)
   _WRAP_METHOD(void set_background_image_file(const std::string& path), vte_terminal_set_background_image_file)
@@ -188,6 +224,10 @@ public:
   Match match_check(long column, long row);
 
   _WRAP_METHOD(void set_emulation(const Glib::ustring& emulation), vte_terminal_set_emulation)
+  
+  /** Sets default type of terminal the widget attempts to emulate.
+   */
+  void set_default_emulation();
   _WRAP_METHOD(const Glib::ustring get_emulation() const, vte_terminal_get_emulation)
   _WRAP_METHOD(const Glib::ustring get_default_emulation() const, vte_terminal_get_default_emulation)
 
diff --git a/src/libvtemm/pty.cc b/src/libvtemm/pty.cc
index 0d82b83..e92e848 100644
--- a/src/libvtemm/pty.cc
+++ b/src/libvtemm/pty.cc
@@ -20,7 +20,9 @@
 
 #include <glib.h>
 #include <vte/pty.h>
-#include <libvtemm/pty.h>
+
+#include "internalroutines.h"
+#include "pty.h"
 
 namespace Gnome
 {
@@ -31,13 +33,20 @@ namespace Vte
 namespace Pty
 {
 
-int _open(Glib::Pid& child, const Glib::StringArrayHandle& env_add,
-          const std::string& command, const Glib::StringArrayHandle& argv,
+int _open(Glib::Pid& child, const StdStringArrayHandle& env_add,
+          const std::string& command, const StdStringArrayHandle& argv,
           const std::string& directory,
           int columns, int rows,
           bool lastlog, bool utmp, bool wtmp)
 {
-  return _vte_pty_open(&child, const_cast<char**>((env_add).data()), command.c_str(), const_cast<char**>((argv).data()), directory.c_str(), columns, rows, static_cast<int>(lastlog), static_cast<int>(utmp), static_cast<int>(wtmp));
+  const char* c_command = get_c_string(command);
+  const char* c_directory = get_c_string(directory);
+  char** c_env_add = get_c_string_vector(env_add);
+  char** c_argv = get_c_string_vector(argv);
+  int master = _vte_pty_open(&child, c_env_add, c_command, c_argv, c_directory, columns, rows, static_cast<gboolean>(lastlog), static_cast<gboolean>(utmp), static_cast<gboolean>(wtmp));
+  g_strfreev(c_env_add);
+  g_strfreev(c_argv);
+  return master;
 }
 
 int _get_size(int master, int& columns, int& rows)
@@ -52,7 +61,7 @@ int _set_size(int master, int columns, int rows)
 
 void _set_utf8(int pty, bool utf8)
 {
-  _vte_pty_set_utf8(pty, static_cast<int>(utf8));
+  _vte_pty_set_utf8(pty, static_cast<gboolean>(utf8));
 }
 
 void _close(int pty)
diff --git a/src/libvtemm/pty.h b/src/libvtemm/pty.h
index 44e9269..d2b5ba6 100644
--- a/src/libvtemm/pty.h
+++ b/src/libvtemm/pty.h
@@ -22,7 +22,7 @@
 #define _LIBVTEMM_PTY_H_
 
 #include <glibmm.h>
-#include <string>
+#include <libvtemm/shared.h>
 
 namespace Gnome
 {
@@ -39,18 +39,18 @@ namespace Pty
  * storing the child's PID in the given argument.
  * @param child Stored child's PID.
  * @param env_add Empty string terminated list of environment variables to be added before executing a command.
- * @param command Command to be executed (not interpreted at all).
- * @param argv Empty string terminated list of arguments given to executed binary (argv[0] should be a binary name)
- * @param directory Path where command have to be executed
+ * @param command Command to be executed (not interpreted at all). If empty, fork will be executed.
+ * @param argv Empty string terminated list of arguments given to executed binary (argv[0] should be a binary name).
+ * @param directory Path where command have to be executed. If empty, path will be inherited from parent.
  * @param columns Number of columns of pty.
  * @param rows Number of rows of pty.
- * @param lastlog %TRUE if the session should be logged to the lastlog
- * @param utmp %TRUE if the session should be logged to the utmp/utmpx log
- * @param wtmp %TRUE if the session should be logged to the wtmp/wtmpx log
+ * @param lastlog %true if the session should be logged to the lastlog.
+ * @param utmp %true if the session should be logged to the utmp/utmpx log.
+ * @param wtmp %true if the session should be logged to the wtmp/wtmpx log.
  * @return Descriptor for the master side of the PTY pair.
  */
-int _open(Glib::Pid& child, const Glib::StringArrayHandle& env_add,
-          const std::string& command, const Glib::StringArrayHandle& argv,
+int _open(Glib::Pid& child, const StdStringArrayHandle& env_add,
+          const std::string& command, const StdStringArrayHandle& argv,
           const std::string& directory,
           int columns, int rows,
           bool lastlog, bool utmp, bool wtmp);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]