*** empty log message ***
authorroot <root>
Fri, 6 Jan 2006 02:58:02 +0000 (02:58 +0000)
committerroot <root>
Fri, 6 Jan 2006 02:58:02 +0000 (02:58 +0000)
src/command.C
src/rxvtperl.xs
src/urxvt.pm

index 46fe69f..d7b8635 100644 (file)
@@ -2720,10 +2720,10 @@ rxvt_term::cmd_parse ()
         {
           seq_begin = cmdbuf_ptr;
           ch = next_char ();
-        }
 
-      if (ch == NOCHAR) // TODO: improve
-        break;
+          if (ch == NOCHAR)
+            break;
+        }
 
       if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)
         {
index d3fdf8b..db88dbc 100644 (file)
@@ -546,6 +546,36 @@ BOOT:
   sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR);
 }
 
+SV *
+new (...)
+       CODE:
+{
+       stringvec *argv = new stringvec;
+        bool success;
+
+        for (int i = 0; i < items ;i++)
+          argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
+
+        rxvt_term *term = new rxvt_term;
+
+        term->argv = argv;
+
+        try
+          {
+            if (!term->init (argv->size (), argv->begin ()))
+              term = 0;
+          }
+        catch (const class rxvt_failure_exception &e)
+          {
+            term->destroy ();
+            croak ("exception caught while initializing new terminal instance");
+          }
+
+        RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef;
+}
+       OUTPUT:
+        RETVAL
+
 void
 set_should_invoke (int htype, int value)
        CODE:
@@ -618,6 +648,9 @@ SET_CUSTOM (int rend, int new_value)
 
 MODULE = urxvt             PACKAGE = urxvt::term
 
+void
+rxvt_term::destroy ()
+
 int
 rxvt_term::strwidth (SV *str)
        CODE:
@@ -979,6 +1012,25 @@ rxvt_term::tt_write (SV *octets)
        C_ARGS:
           str, len
 
+void
+rxvt_term::cmd_parse (SV *octets)
+       CODE:
+{
+       STRLEN len;
+        char *str = SvPVbyte (octets, len);
+
+        char *old_cmdbuf_ptr  = THIS->cmdbuf_ptr;
+        char *old_cmdbuf_endp = THIS->cmdbuf_endp;
+
+        THIS->cmdbuf_ptr  = str;
+        THIS->cmdbuf_endp = str + len;
+
+        THIS->cmd_parse ();
+
+        THIS->cmdbuf_ptr  = old_cmdbuf_ptr;
+        THIS->cmdbuf_endp = old_cmdbuf_endp;
+}
+
 SV *
 rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2)
        CODE:
index ce6219c..24624ef 100644 (file)
@@ -139,7 +139,10 @@ When in doubt, return a false value (preferably C<()>).
 =item on_init $term
 
 Called after a new terminal object has been initialized, but before
-windows are created or the command gets run.
+windows are created or the command gets run. Most methods are unsafe to
+call or deliver senseless data, as terminal size and other characteristics
+have not yet been determined. You can safely query and change resources,
+though.
 
 =item on_reset $term
 
@@ -277,6 +280,14 @@ variable stores the current C<urxvt::term> object.
 
 =over 4
 
+=item $term = new urxvt [arg...]
+
+Creates a new terminal, very similar as if you had started it with
+C<system $binfile, arg...>. Croaks (and probably outputs an error message)
+if the new instance couldn't be created.  Returns C<undef> if the new
+instance didn't initialise perl, and the terminal object otherwise. The
+C<init> and C<start> hooks will be called during the call.
+
 =item urxvt::fatal $errormessage
 
 Fatally aborts execution with the given error message. Avoid at all
@@ -503,6 +514,10 @@ sub urxvt::term::proxy::AUTOLOAD {
 
 =over 4
 
+=item $term->destroy
+
+Destroy the terminal object (close the window, free resources etc.).
+
 =item $value = $term->resource ($name[, $newval])
 
 Returns the current resource value associated with a given name and
@@ -652,6 +667,12 @@ Normally its not a good idea to use this function, as programs might be
 confused by changes in cursor position or scrolling. Its useful inside a
 C<on_add_lines> hook, though.
 
+=item $term->cmd_parse ($octets)
+
+Similar to C<scr_add_lines>, but the argument must be in the
+locale-specific encoding of the terminal and can contain command sequences
+(escape codes) that will be interpreted.
+
 =item $term->tt_write ($octets)
 
 Write the octets given in C<$data> to the tty (i.e. as program input). To