add a parameter to control whether or not trailing whitespace is trimmed
authorNalin Dahyabhai <nalin@src.gnome.org>
Sat, 1 May 2004 07:12:51 +0000 (07:12 +0000)
committerNalin Dahyabhai <nalin@src.gnome.org>
Sat, 1 May 2004 07:12:51 +0000 (07:12 +0000)
* src/vte.c(vte_terminal_get_text_maybe_wrapped): add a parameter to control
whether or not trailing whitespace is trimmed (padraig.obriain,
#141148).
* src/vte.c,src/vte.h(vte_terminal_get_text_include_trailing_spaces): add as a
wrapper for the new vte_terminal_get_text_maybe_wrapped()
(padraig.obriain, #141148).
* src/vteaccess.c(vte_terminal_accessible_update_private_d): use
vte_terminal_get_text_include_trailing_spaces to ensure that we get
trailing spaces (padraig.obriain, #141148).
* src/vte.c(vte_terminal_insert_char): clean up some autowrap stuff.

ChangeLog
gnome-pty-helper/gnome-login-support.c
gnome-pty-helper/gnome-pty-helper.c
gnome-pty-helper/gnome-utmp.c
src/pty.c
src/vte.c
src/vte.h
src/vteaccess.c

index 8c5ad1c..fdc87d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-05-01 nalin
+       * src/vte.c(vte_terminal_get_text_maybe_wrapped): add a parameter to
+       control whether or not trailing whitespace is trimmed (padraig.obriain,
+       #141148).
+       * src/vte.c,src/vte.h(vte_terminal_get_text_include_trailing_spaces):
+       add as a wrapper for the new vte_terminal_get_text_maybe_wrapped()
+       (padraig.obriain, #141148).
+       * src/vteaccess.c(vte_terminal_accessible_update_private_d): use
+       vte_terminal_get_text_include_trailing_spaces to ensure that we get
+       trailing spaces (padraig.obriain, #141148).
+       * src/vte.c(vte_terminal_insert_char): clean up some autowrap stuff.
+
 2004-04-30 nalin
        * vte.pc.in, vte-uninstalled.pc.in: declare the defaultemulation
        variable as one kind of variable, not that other kind (#141515).
index bf7fe88..c1a3ac6 100644 (file)
@@ -32,7 +32,7 @@ int
 login_tty (int fd)
 {
        pid_t pid = getpid ();
-        
+
        /* Create the session */
        setsid ();
 
@@ -60,7 +60,7 @@ login_tty (int fd)
 #elif defined (TIOCSPGRP)
        ioctl (0, TIOCSPGRP, &pid);
 #endif
-       
+
        dup2 (fd, 0);
        dup2 (fd, 1);
        dup2 (fd, 2);
@@ -79,7 +79,7 @@ pty_open_master_bsd (char *pty_name, int *used_bsd)
        char *ptr1, *ptr2;
 
        *used_bsd = 1;
-       
+
        strcpy (pty_name, "/dev/ptyXX");
        for (ptr1 = "pqrstuvwxyzPQRST"; *ptr1; ++ptr1)
        {
@@ -87,7 +87,7 @@ pty_open_master_bsd (char *pty_name, int *used_bsd)
                for (ptr2 = "0123456789abcdef"; *ptr2; ++ptr2)
                {
                        pty_name [9] = *ptr2;
-                       
+
                        /* Try to open master */
                        if ((pty_master = open (pty_name, O_RDWR)) == -1) {
                                if (errno == ENOENT)  /* Different from EIO */
@@ -112,11 +112,11 @@ pty_open_slave_bsd (const char *pty_name)
 {
        int pty_slave;
        struct group *group_info = getgrnam ("tty");
-       
+
        if (group_info != NULL)
        {
                /* The following two calls will only succeed if we are root */
-               
+
                chown (pty_name, getuid (), group_info->gr_gid);
                chmod (pty_name, S_IRUSR | S_IWUSR | S_IWGRP);
        }
@@ -148,7 +148,7 @@ static int
 pty_open_slave (const char *pty_name)
 {
        int pty_slave = open (pty_name, O_RDWR);
-       
+
        if (pty_slave == -1)
                return -1;
 
@@ -159,13 +159,13 @@ pty_open_slave (const char *pty_name)
                        close (pty_slave);
                        return -1;
                }
-       
+
     if (!ioctl (pty_slave, I_FIND, "ldterm"))
            if (ioctl (pty_slave, I_PUSH, "ldterm") == -1){
                    close (pty_slave);
                    return -1;
            }
-    
+
 #if !defined(sgi) && !defined(__sgi)
     if (!ioctl (pty_slave, I_FIND, "ttcompat"))
            if (ioctl (pty_slave, I_PUSH, "ttcompat") == -1)
@@ -177,7 +177,7 @@ pty_open_slave (const char *pty_name)
 #endif /* sgi || __sgi */
 #endif /* __osf__ */
 #endif /* HAVE_STROPTS_H */
-    
+
     return pty_slave;
 }
 
@@ -186,7 +186,7 @@ pty_open_master (char *pty_name, int *used_bsd)
 {
        int pty_master;
        char *slave_name;
-       
+
        strcpy (pty_name, "/dev/ptmx");
 
        pty_master = open (pty_name, O_RDWR);
@@ -238,7 +238,7 @@ openpty (int *master_fd, int *slave_fd, char *name,
                return -1;
 
        group_info = getgrnam ("tty");
-       
+
        if (group_info != NULL){
                chown (line, getuid (), group_info->gr_gid);
                chmod (line, S_IRUSR | S_IWUSR | S_IWGRP);
@@ -250,13 +250,13 @@ openpty (int *master_fd, int *slave_fd, char *name,
 #ifdef HAVE_REVOKE
        revoke (line);
 #endif
-       
+
        /* Open slave side */
        if (used_bsd)
                pty_slave = pty_open_slave_bsd (line);
        else
                pty_slave = pty_open_slave (line);
-       
+
        if (pty_slave == -1){
                close (pty_master);
 
@@ -273,7 +273,7 @@ openpty (int *master_fd, int *slave_fd, char *name,
 
        if (winp)
                ioctl (pty_slave, TIOCSWINSZ, winp);
-       
+
        if (name)
                strcpy (name, line);
 
@@ -285,7 +285,7 @@ forkpty (int *master_fd, char *name, struct termios *termp, struct winsize *winp
 {
        int master, slave;
        pid_t pid;
-       
+
        if (openpty (&master, &slave, name, termp, winp) == -1)
                return -1;
 
@@ -302,7 +302,7 @@ forkpty (int *master_fd, char *name, struct termios *termp, struct winsize *winp
                *master_fd = master;
                close (slave);
        }
-       
+
        return pid;
 }
 #endif /* HAVE_OPENPTY */
@@ -339,7 +339,7 @@ n_read (int fd, void *buf, int count)
                        break;
                }
        }
-       
+
        return n;
 }
 
@@ -375,6 +375,6 @@ n_write (int fd, const void *buf, int count)
                        break;
                }
        }
-       
+
        return n;
 }
index 9cbf6f7..e99fa04 100644 (file)
@@ -23,8 +23,8 @@
  *
  * <tag> is a pointer.  If tag is NULL, then the ptys were not allocated.
  * ptys are passed using file descriptor passing on the stdin file descriptor
- * 
- * We use as little as possible external libraries.  
+ *
+ * We use as little as possible external libraries.
  */
 #include <config.h>
 
@@ -124,7 +124,7 @@ pass_fd (int client_fd, int fd)
        msg.msg_namelen    = 0;
        msg.msg_control    = (caddr_t) cmptr;
        msg.msg_controllen = CONTROLLEN;
-               
+
        cmptr->cmsg_level = SOL_SOCKET;
        cmptr->cmsg_type  = SCM_RIGHTS;
        cmptr->cmsg_len   = CONTROLLEN;
@@ -138,12 +138,12 @@ pass_fd (int client_fd, int fd)
 
 #elif defined(__sgi) && !defined(HAVE_SENDMSG)
 
-/* 
- * IRIX 6.2 is like 4.3BSD; it will not have HAVE_SENDMSG set, 
- * because msghdr used msg_accrights and msg_accrightslen rather 
+/*
+ * IRIX 6.2 is like 4.3BSD; it will not have HAVE_SENDMSG set,
+ * because msghdr used msg_accrights and msg_accrightslen rather
  * than the newer msg_control and msg_controllen fields configure
  * checks.  The SVR4 code below doesn't work because pipe()
- * semantics are controlled by the svr3pipe systune variable, 
+ * semantics are controlled by the svr3pipe systune variable,
  * which defaults to uni-directional pipes.  Also sending
  * file descriptors through pipes isn't implemented.
  */
@@ -173,7 +173,7 @@ pass_fd (int client_fd, int fd)
   msg.msg_namelen    = 0;
   msg.msg_accrights    = (caddr_t) &fd;
   msg.msg_accrightslen = sizeof(fd);
-               
+
   if (sendmsg (client_fd, &msg, 0) != 1)
     return -1;
 
@@ -212,7 +212,7 @@ pty_remove (pty_info *pi)
        pty_info *l, *last;
 
        last = (void *) 0;
-       
+
        for (l = pty_list; l; l = l->next) {
                if (l == pi) {
                        if (last == (void *) 0)
@@ -235,7 +235,7 @@ shutdown_pty (pty_info *pi)
        if (pi->utmp || pi->wtmp || pi->lastlog)
                if (pi->data)
                        write_logout_record (pi->data, pi->utmp, pi->wtmp);
-       
+
        pty_remove (pi);
 }
 
@@ -243,7 +243,7 @@ static void
 shutdown_helper (void)
 {
        pty_info *pi;
-       
+
        for (pi = pty_list; pi; pi = pty_list)
                shutdown_pty (pi);
 }
@@ -259,7 +259,7 @@ pty_add (int utmp, int wtmp, int lastlog, char *line)
        }
 
        memset (pi, 0, sizeof (pty_info));
-       
+
        if (strncmp (line, "/dev/", 5))
                pi->line = strdup (line);
        else
@@ -269,7 +269,7 @@ pty_add (int utmp, int wtmp, int lastlog, char *line)
                shutdown_helper ();
                exit (1);
        }
-       
+
        pi->next = pty_list;
        pi->utmp = utmp;
        pi->wtmp = wtmp;
@@ -410,7 +410,7 @@ init_term_with_defaults(struct termios* term)
        /* at least 1 symbol will be read.                      */
        term->c_cc[VMIN]  = 1;
        term->c_cc[VTIME] = 0;
-       
+
        /*
         * Now set the characters. This is of course a religious matter
         * but we use the defaults, with erase bound to the key gnome-terminal
@@ -418,7 +418,7 @@ init_term_with_defaults(struct termios* term)
         *
         * These are the ones set by "stty sane".
         */
-          
+
        term->c_cc[VINTR]  = 'C'-64;
        term->c_cc[VQUIT]  = '\\'-64;
        term->c_cc[VERASE] = 127;
@@ -431,30 +431,30 @@ init_term_with_defaults(struct termios* term)
        term->c_cc[VSTOP]  = 'S'-64;
        term->c_cc[VSUSP]  = 'Z'-64;
        term->c_cc[VEOL]   = 255;
-       
+
        /*
         *      Extended stuff.
         */
-        
-#ifdef VREPRINT        
+
+#ifdef VREPRINT
        term->c_cc[VREPRINT] = 'R'-64;
 #endif
 #ifdef VSTATUS
        term->c_cc[VSTATUS]  = 'T'-64;
 #endif
-#ifdef VDISCARD        
+#ifdef VDISCARD
        term->c_cc[VDISCARD] = 'O'-64;
 #endif
 #ifdef VWERASE
        term->c_cc[VWERASE]  = 'W'-64;
-#endif 
+#endif
 #ifdef VLNEXT
        term->c_cc[VLNEXT]   = 'V'-64;
 #endif
 #ifdef VDSUSP
        term->c_cc[VDSUSP]   = 'Y'-64;
 #endif
-#ifdef VEOL2   
+#ifdef VEOL2
        term->c_cc[VEOL2]    = 255;
 #endif
     return term;
@@ -471,7 +471,7 @@ open_ptys (int utmp, int wtmp, int lastlog)
        gid_t savedGid;
        struct group *group_info;
        struct termios term;
-       
+
        term_name = (char *) g_alloca (path_max () + 1);
 
        if (term_name == NULL) {
@@ -483,7 +483,7 @@ open_ptys (int utmp, int wtmp, int lastlog)
        /* root privileges */
        savedUid = geteuid();
        savedGid = getegid();
-       
+
        /* drop privileges to the user level */
 #if defined(HAVE_SETEUID)
        seteuid (pwent->pw_uid);
@@ -521,7 +521,7 @@ open_ptys (int utmp, int wtmp, int lastlog)
        fchmod (slave_pty, S_IRUSR | S_IWUSR | S_IWGRP);
        /* It's too late to call revoke at this time... */
        /* revoke(term_name); */
-       
+
        /* add pty to the list of allocated by us */
        p = pty_add (utmp, wtmp, lastlog, term_name);
        result = 1;
@@ -537,7 +537,7 @@ open_ptys (int utmp, int wtmp, int lastlog)
                p->data = write_login_record (login_name, display_name,
                                              term_name, utmp, wtmp, lastlog);
        }
-       
+
        close (master_pty);
        close (slave_pty);
 
@@ -622,7 +622,7 @@ sanity_checks (void)
        /* Check sensible resource limits */
        for (i = 0; sensible_limits [i].value != -1; i++) {
                struct rlimit rlim;
-               
+
                if (getrlimit (sensible_limits [i].limit, &rlim) != 0)
                        continue;
 
@@ -648,7 +648,7 @@ sanity_checks (void)
                sigaddset(&sigset, SIGIO);
                sigaddset(&sigset, SIGINT);
                sigprocmask(SIG_UNBLOCK, &sigset, NULL);
-               
+
                sigaction (SIGIO, &sa, NULL);
                sigaction (SIGINT, &sa, NULL);
        }
@@ -674,8 +674,8 @@ main (int argc, char *argv [])
        display_name = getenv ("DISPLAY");
        if (!display_name)
                display_name = "localhost";
-       
-       
+
+
        if (init_msg_pass () == -1)
                exit (1);
 
@@ -691,15 +691,15 @@ main (int argc, char *argv [])
                case GNOME_PTY_OPEN_PTY_UTMP:
                        open_ptys (1, 0, 0);
                        break;
-                       
+
                case GNOME_PTY_OPEN_PTY_UWTMP:
                        open_ptys (1, 1, 0);
                        break;
-                       
+
                case GNOME_PTY_OPEN_PTY_WTMP:
                        open_ptys (0, 1, 0);
                        break;
-                       
+
                case GNOME_PTY_OPEN_PTY_LASTLOG:
                        open_ptys (0, 0, 1);
                        break;
@@ -722,7 +722,7 @@ main (int argc, char *argv [])
 
                case GNOME_PTY_RESET_TO_DEFAULTS:
                        break;
-                       
+
                case GNOME_PTY_CLOSE_PTY:
                        n = n_read (STDIN_FILENO, &tag, sizeof (tag));
                        if (n != sizeof (tag)) {
@@ -732,7 +732,7 @@ main (int argc, char *argv [])
                        close_pty_pair (tag);
                        break;
                }
-               
+
        }
 
        return 0;
index d18b1b0..833a121 100644 (file)
@@ -10,7 +10,7 @@
  *
  * FIXME: Solaris (utmpx) stuff need to be checked.
  */
+
 #include <config.h>
 #include <sys/types.h>
 #include <sys/file.h>
@@ -108,7 +108,7 @@ update_wtmp (char *file, UTMP *putmp)
        lck.l_start  = 0;
        lck.l_type   = F_WRLCK;
 #endif
-       
+
        if ((fd = open (file, O_WRONLY|O_APPEND, 0)) < 0)
                return;
 
@@ -141,7 +141,7 @@ update_wtmp (char *file, UTMP *putmp)
        write (fd, putmp, sizeof(UTMP));
 
        /* unlock the file */
-#if defined(HAVE_FCNTL)        
+#if defined(HAVE_FCNTL)
        lck.l_type = F_UNLCK;
        fcntl (fd, F_SETLK, &lck);
 #elif defined(HAVE_FLOCK)
@@ -173,10 +173,10 @@ update_utmp (UTMP *ut)
 {
        struct ttyent *ty;
        int fd, pos = 0;
-       
-       if ((fd = open (UTMP_OUTPUT_FILENAME, O_RDWR|O_CREAT, 0644)) < 0) 
+
+       if ((fd = open (UTMP_OUTPUT_FILENAME, O_RDWR|O_CREAT, 0644)) < 0)
                return;
-       
+
        setttyent ();
        while ((ty = getttyent ()) != NULL)
        {
@@ -188,7 +188,7 @@ update_utmp (UTMP *ut)
                }
        }
        endttyent ();
-       
+
        close(fd);
 }
 #else
@@ -212,9 +212,9 @@ update_lastlog(char* login_name, UTMP *ut)
        return;
 
     memset (&ll, 0, sizeof(ll));
-    
+
     lseek (fd, (off_t)pwd->pw_uid * sizeof (ll), SEEK_SET);
-    
+
     time (&ll.ll_time);
 
     strncpy (ll.ll_line, ut->ut_line, sizeof (ll.ll_line));
@@ -223,13 +223,13 @@ update_lastlog(char* login_name, UTMP *ut)
     if (ut->ut_host)
        strncpy (ll.ll_host, ut->ut_host, sizeof (ll.ll_host));
 #endif
-    
+
     write (fd, (void *)&ll, sizeof (ll));
     close (fd);
 }
 #endif /* HAVE_LASTLOG */
 
-void 
+void
 write_logout_record (void *data, int utmp, int wtmp)
 {
        UTMP put, *ut = data;
@@ -269,7 +269,7 @@ write_login_record (char *login_name, char *display_name,
 
        if ((ut=(UTMP *) malloc (sizeof (UTMP))) == NULL)
                return NULL;
-       
+
        memset (ut, 0, sizeof (UTMP));
 
 #if defined(HAVE_UT_UT_NAME)
@@ -285,20 +285,20 @@ write_login_record (char *login_name, char *display_name,
 #if defined(HAVE_STRRCHR)
        {
                char *p;
-               
+
                if (strncmp (pty, "pts", 3) &&
                    (p = strrchr (pty, '/')) != NULL)
                        pty = p + 1;
        }
 #endif
-           
+
 #if defined(HAVE_UT_UT_ID)
        /* Just a safe-guard */
        ut->ut_id [0] = '\0';
 
        /* BSD-like terminal name */
        if (strncmp (pty, "pts", 3) == 0 ||
-           strncmp (pty, "pty", 3) == 0 || 
+           strncmp (pty, "pty", 3) == 0 ||
            strncmp (pty, "tty", 3) == 0) {
                strncpy (ut->ut_id, pty+3, sizeof (ut->ut_id));
        } else {
index 5b6de3b..bdc9d4b 100644 (file)
--- a/src/pty.c
+++ b/src/pty.c
@@ -385,7 +385,7 @@ _vte_pty_run_on_pty(int fd, int ready_reader, int ready_writer,
                } else {
                        arg = g_strdup(command);
                        execlp(command, arg, NULL);
-               } 
+               }
 
                /* Avoid calling any atexit() code. */
                _exit(0);
index 61600cb..f0ea0ed 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -477,7 +477,8 @@ static char *vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal,
                                                                              glong,
                                                                              gpointer),
                                                       gpointer data,
-                                                      GArray *attributes);
+                                                      GArray *attributes,
+                                                      gboolean include_trailing_spaces);
 static char *vte_terminal_get_text_maybe_wrapped(VteTerminal *terminal,
                                                 gboolean wrap,
                                                 gboolean(*is_selected)(VteTerminal *,
@@ -485,7 +486,8 @@ static char *vte_terminal_get_text_maybe_wrapped(VteTerminal *terminal,
                                                                        glong,
                                                                        gpointer),
                                                 gpointer data,
-                                                GArray *attributes);
+                                                GArray *attributes,
+                                                gboolean include_trailing_spaces);
 static void _vte_terminal_disconnect_pty_read(VteTerminal *terminal);
 static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal);
 
@@ -6713,14 +6715,10 @@ vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
        }
 #endif
 
-       /* If we're autowrapping here (am and xn), do it, for graphic
-        * characters only. */
+       /* If we're autowrapping here, do it. */
        col = screen->cursor_current.col;
        if (col + columns > terminal->column_count) {
-               if (terminal->pvt->flags.am &&
-                   terminal->pvt->flags.xn &&
-                   terminal->pvt->flags.LP &&
-                   g_unichar_isgraph(c)) {
+               if (terminal->pvt->flags.am) {
                        /* Mark this line as soft-wrapped. */
                        row = _vte_ring_index(screen->row_data,
                                              VteRowData *,
@@ -6826,11 +6824,10 @@ vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
                }
        }
 
-       /* If we're autowrapping *here* (am but not xn), do it. */
+       /* If we're autowrapping *here*, do it. */
        col = screen->cursor_current.col;
        if (col >= terminal->column_count) {
-               if (terminal->pvt->flags.am &&
-                   !(terminal->pvt->flags.xn && terminal->pvt->flags.LP)) {
+               if (terminal->pvt->flags.am && !terminal->pvt->flags.xn) {
                        /* Mark this line as soft-wrapped. */
                        row = _vte_ring_index(screen->row_data,
                                              VteRowData *,
@@ -7657,7 +7654,7 @@ vte_terminal_process_incoming(gpointer data)
                        vte_terminal_maybe_scroll_to_bottom(terminal);
                }
                /* Deselect the current selection if its contents are changed
-                * by this insertion. */
+                * by this insertion. */
                if (terminal->pvt->has_selection) {
                        char *selection;
                        selection =
@@ -8276,7 +8273,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
        terminal = VTE_TERMINAL(widget);
 
        /* First, check if GtkWidget's behavior already does something with
-        * this key. */
+        * this key. */
        widget_class = g_type_class_peek(GTK_TYPE_WIDGET);
        if (GTK_WIDGET_CLASS(widget_class)->key_press_event) {
                if ((GTK_WIDGET_CLASS(widget_class))->key_press_event(widget,
@@ -9203,7 +9200,8 @@ vte_terminal_get_text_range(VteTerminal *terminal,
                                                         TRUE,
                                                         is_selected,
                                                         data,
-                                                        attributes);
+                                                        attributes,
+                                                        FALSE);
 }
 
 static char *
@@ -9216,7 +9214,8 @@ vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal,
                                                                 glong,
                                                                 gpointer),
                                          gpointer data,
-                                         GArray *attributes)
+                                         GArray *attributes,
+                                         gboolean include_trailing_spaces)
 {
        long col, row, last_space, last_spacecol,
             last_nonspace, last_nonspacecol, line_start;
@@ -9323,7 +9322,7 @@ vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal,
                        /* If pcell is NULL, then there was no printing
                         * character to the right of the endpoint, so truncate
                         * the string at the end of the printing chars. */
-                       if (pcell == NULL) {
+                       if ((pcell == NULL) && !include_trailing_spaces) {
                                g_string_truncate(string, last_nonspace + 1);
                        }
                }
@@ -9386,7 +9385,8 @@ vte_terminal_get_text_maybe_wrapped(VteTerminal *terminal,
                                                           glong,
                                                           gpointer),
                                    gpointer data,
-                                   GArray *attributes)
+                                   GArray *attributes,
+                                   gboolean include_trailing_spaces)
 {
        long start_row, start_col, end_row, end_col;
        start_row = terminal->pvt->screen->scroll_delta;
@@ -9401,7 +9401,8 @@ vte_terminal_get_text_maybe_wrapped(VteTerminal *terminal,
                                                         is_selected :
                                                         always_selected,
                                                         data,
-                                                        attributes);
+                                                        attributes,
+                                                        include_trailing_spaces);
 }
 
 /**
@@ -9435,7 +9436,47 @@ vte_terminal_get_text(VteTerminal *terminal,
                                                   is_selected :
                                                   always_selected,
                                                   data,
-                                                  attributes);
+                                                  attributes,
+                                                  FALSE);
+}
+
+/**
+ * vte_terminal_get_text_include_trailing_spaces:
+ * @terminal: a #VteTerminal
+ * @is_selected: a callback
+ * @data: user data to be passed to the callback
+ * @attributes: location for storing text attributes
+ *
+ * Extracts a view of the visible part of the terminal.  If @is_selected is not
+ * NULL, characters will only be read if @is_selected returns TRUE after being
+ * passed the column and row, respectively.  A #VteCharAttributes structure
+ * is added to @attributes for each byte added to the returned string detailing
+ * the character's position, colors, and other characteristics. This function
+ * differs from vte_terminal_get_text in that trailing spaces at the end of
+ * lines are included.
+ *
+ * Returns: a text string which must be freed by the caller, or NULL.
+ *
+ * Since 0.11.11
+ */
+char *
+vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
+                                             gboolean(*is_selected)(VteTerminal *,
+                                                                    glong,
+                                                                    glong,
+                                                                    gpointer),
+                                             gpointer data,
+                                             GArray *attributes)
+{
+       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+       return vte_terminal_get_text_maybe_wrapped(terminal,
+                                                  TRUE,
+                                                  is_selected ?
+                                                  is_selected :
+                                                  always_selected,
+                                                  data,
+                                                  attributes,
+                                                  TRUE);
 }
 
 /**
@@ -13819,7 +13860,7 @@ vte_terminal_paint(GtkWidget *widget, GdkRectangle *area)
                if (cell) {
                        cursor_width = MAX(cursor_width,
                                           _vte_draw_get_char_width(terminal->pvt->draw,
-                                                                   cell->c,
+                                                                   cell->c,
                                                                    cell->columns));
                }
                if (GTK_WIDGET_HAS_FOCUS(GTK_WIDGET(terminal))) {
index bf0ac1b..d8fec94 100644 (file)
--- a/src/vte.h
+++ b/src/vte.h
@@ -336,6 +336,13 @@ char *vte_terminal_get_text(VteTerminal *terminal,
                                                   gpointer data),
                            gpointer data,
                            GArray *attributes);
+char *vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
+                                                   gboolean(*is_selected)(VteTerminal *terminal,
+                                                                          glong column,
+                                                                          glong row,
+                                                                          gpointer data),
+                                                   gpointer data,
+                                                   GArray *attributes);
 char *vte_terminal_get_text_range(VteTerminal *terminal,
                                  glong start_row, glong start_col,
                                  glong end_row, glong end_col,
index 214572a..8c818b5 100644 (file)
@@ -105,7 +105,7 @@ vte_terminal_accessible_free_private_data(VteTerminalAccessiblePrivate *priv)
 }
 
 static gint
-offset_from_xy (VteTerminalAccessiblePrivate *priv, 
+offset_from_xy (VteTerminalAccessiblePrivate *priv,
                gint x, gint y)
 {
        gint offset;
@@ -118,9 +118,9 @@ offset_from_xy (VteTerminalAccessiblePrivate *priv,
        linebreak = g_array_index (priv->snapshot_linebreaks, int, y);
        if (y +1 == priv->snapshot_linebreaks->len)
                next_linebreak = priv->snapshot_characters->len;
-       else 
+       else
                next_linebreak = g_array_index (priv->snapshot_linebreaks, int, y + 1);
-       
+
        offset = linebreak + x;
        if (offset >= next_linebreak)
                offset = next_linebreak -1;
@@ -128,7 +128,7 @@ offset_from_xy (VteTerminalAccessiblePrivate *priv,
 }
 
 static void
-xy_from_offset (VteTerminalAccessiblePrivate *priv, 
+xy_from_offset (VteTerminalAccessiblePrivate *priv,
                gint offset, gint *x, gint *y)
 {
        gint i;
@@ -142,9 +142,9 @@ xy_from_offset (VteTerminalAccessiblePrivate *priv,
                linebreak = g_array_index (priv->snapshot_linebreaks, int, i);
                if (offset < linebreak) {
                        cur_x = offset - cur_offset;
-                       cur_y = i - 1;  
+                       cur_y = i - 1;
                        break;
-                       
+
                }  else {
                        cur_offset = linebreak;
                }
@@ -152,11 +152,11 @@ xy_from_offset (VteTerminalAccessiblePrivate *priv,
        if (i == priv->snapshot_linebreaks->len) {
                if (offset < priv->snapshot_characters->len) {
                        cur_x = offset - cur_offset;
-                       cur_y = i - 1;  
+                       cur_y = i - 1;
                }
        }
        *x = cur_x;
-       *y = cur_y;     
+       *y = cur_y;
 }
 
 /* "Oh yeah, that's selected.  Sure." callback. */
@@ -345,10 +345,10 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text,
                priv->snapshot_linebreaks = g_array_new(FALSE, TRUE, sizeof(int));
 
                /* Get a new view of the uber-label. */
-               tmp = vte_terminal_get_text(terminal,
-                                           all_selected,
-                                           NULL,
-                                           priv->snapshot_attributes);
+               tmp = vte_terminal_get_text_include_trailing_spaces(terminal,
+                                                                   all_selected,
+                                                                   NULL,
+                                                                   priv->snapshot_attributes);
                if (tmp == NULL) {
                        /* Aaargh!  We're screwed. */
                        return;
@@ -1239,19 +1239,19 @@ get_attribute_set (struct _VteCharAttributes attr)
        }
        at = g_new (AtkAttribute, 1);
        at->name = g_strdup ("fg-color");
-       at->value = g_strdup_printf ("%u,%u,%u", 
+       at->value = g_strdup_printf ("%u,%u,%u",
                                     attr.fore.red, attr.fore.green, attr.fore.blue);
        set = g_slist_append (set, at);
 
        at = g_new (AtkAttribute, 1);
        at->name = g_strdup ("bg-color");
-       at->value = g_strdup_printf ("%u,%u,%u", 
+       at->value = g_strdup_printf ("%u,%u,%u",
                                     attr.back.red, attr.back.green, attr.back.blue);
        set = g_slist_append (set, at);
 
        return set;
 }
-       
+
 static AtkAttributeSet *
 vte_terminal_accessible_get_run_attributes(AtkText *text, gint offset,
                                           gint *start_offset, gint *end_offset)
@@ -1279,7 +1279,7 @@ vte_terminal_accessible_get_run_attributes(AtkText *text, gint offset,
                    !gdk_color_equal (&cur_attr.back, &attr.back) ||
                    cur_attr.underline != attr.underline ||
                    cur_attr.strikethrough != attr.strikethrough) {
-                       *start_offset = i + 1;  
+                       *start_offset = i + 1;
                        break;
                }
        }
@@ -1296,7 +1296,7 @@ vte_terminal_accessible_get_run_attributes(AtkText *text, gint offset,
                        break;
                }
        }
-       
+
        return get_attribute_set (attr);
 }