1999-08-17 16:01:18 -07:00
/*
* File : screen . c
*
*/
static const char cvs_ident [ ] = " $Id$ " ;
1999-08-17 18:12:47 -07:00
# include "config.h"
# include "feature.h"
1999-08-17 16:01:18 -07:00
1999-08-17 18:12:47 -07:00
/* includes */
2000-02-17 15:15:19 -08:00
# include <stdio.h>
Wed Apr 12 21:18:19 PDT 2000 Michael Jennings <mej@eterm.org>
This is the initial commit with Imlib2 support. READ THIS CAREFULLY.
There is important information in this commit message that will keep
you from getting screwed.
First off, support for Imlib 1.x is GONE. It is no longer supported
as of now. If you want to continue using it, do NOT install this
version. I tried to support both for awhile, but the code ended up
being way too ugly and hackish. Imlib2 is the future. And trust me,
when you see what we do with this future, you'll be happy for the
switch.
The good news is that most of the basics work. Transparency still
works, and the basic image stuff works. Most users won't notice any
major problems, so long as your Imlib2 is 100% up-to-date.
However, a few things still don't work:
1. Auto mode is a bit broken. You'll get X errors in XFree86 4.0.
Don't use it if you're running XFree 4.
2. Color modifiers for images don't work. At all.
3. Transparency shading/tinting will not work in 8bpp or lower. Life
blows sometimes. Sorry. Time for a real video card. :-)
4. The built-in icon is broken.
5. You WILL need to update your theme.cfg files. The borders on the
horizontal and vertical bar images were incorrect when combined with
the new anti-aliased scaling. The horizontal bars should have a right
border of 3. Vertical bars should have a bottom border of 3. The
menu images should have both right *and* bottom borders of 3. You can
either make those changes by hand, or use the --with-theme-update
option to autogen.sh. Your call.
I think that covers everything I've run into. I will point out that
I don't really take advantage of a lot of the Imlib2 features just
yet. My first priority is to make all the stuff that worked before
work again (or at least the important stuff). Then I'll work on
new features.
So there it is. If you're not ready for it, don't use it. But if you
are, I hope you like it.
SVN revision: 2478
2000-04-12 21:19:05 -07:00
# include <stdlib.h>
1999-08-17 16:01:18 -07:00
# ifdef HAVE_SYS_TIME_H
# include <sys / time.h>
# endif
# include <sys/types.h>
2000-02-17 15:15:19 -08:00
# include <sys/stat.h>
1999-08-17 16:01:18 -07:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
# ifdef HAVE_SYS_IOCTL_H
# include <sys / ioctl.h>
# endif
Wed Apr 12 21:18:19 PDT 2000 Michael Jennings <mej@eterm.org>
This is the initial commit with Imlib2 support. READ THIS CAREFULLY.
There is important information in this commit message that will keep
you from getting screwed.
First off, support for Imlib 1.x is GONE. It is no longer supported
as of now. If you want to continue using it, do NOT install this
version. I tried to support both for awhile, but the code ended up
being way too ugly and hackish. Imlib2 is the future. And trust me,
when you see what we do with this future, you'll be happy for the
switch.
The good news is that most of the basics work. Transparency still
works, and the basic image stuff works. Most users won't notice any
major problems, so long as your Imlib2 is 100% up-to-date.
However, a few things still don't work:
1. Auto mode is a bit broken. You'll get X errors in XFree86 4.0.
Don't use it if you're running XFree 4.
2. Color modifiers for images don't work. At all.
3. Transparency shading/tinting will not work in 8bpp or lower. Life
blows sometimes. Sorry. Time for a real video card. :-)
4. The built-in icon is broken.
5. You WILL need to update your theme.cfg files. The borders on the
horizontal and vertical bar images were incorrect when combined with
the new anti-aliased scaling. The horizontal bars should have a right
border of 3. Vertical bars should have a bottom border of 3. The
menu images should have both right *and* bottom borders of 3. You can
either make those changes by hand, or use the --with-theme-update
option to autogen.sh. Your call.
I think that covers everything I've run into. I will point out that
I don't really take advantage of a lot of the Imlib2 features just
yet. My first priority is to make all the stuff that worked before
work again (or at least the important stuff). Then I'll work on
new features.
So there it is. If you're not ready for it, don't use it. But if you
are, I hope you like it.
SVN revision: 2478
2000-04-12 21:19:05 -07:00
# include <fcntl.h>
2000-02-17 15:15:19 -08:00
# include <errno.h>
1999-08-17 16:01:18 -07:00
# include <X11/Xatom.h>
2002-05-04 07:25:30 -07:00
# include <X11/Xmd.h> /* CARD32 */
2000-03-01 19:31:41 -08:00
# ifdef HAVE_X11_XMU_ATOMS_H
# include <X11 / Xmu / Atoms.h>
# endif
1999-08-17 16:01:18 -07:00
2000-02-16 14:59:54 -08:00
# include "buttons.h"
1999-08-17 16:01:18 -07:00
# include "command.h"
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
# include "font.h"
1999-10-07 15:18:14 -07:00
# include "startup.h"
1999-08-17 16:01:18 -07:00
# include "screen.h"
1999-09-28 12:38:43 -07:00
# include "scrollbar.h"
1999-08-17 16:01:18 -07:00
# include "options.h"
2000-07-06 23:41:12 -07:00
# include "pixmap.h"
2000-03-14 19:17:45 -08:00
# include "profile.h"
1999-08-17 18:12:47 -07:00
# include "term.h"
1999-08-17 16:01:18 -07:00
2002-06-02 17:24:22 -07:00
# ifdef ESCREEN
# include "screamcfg.h"
# endif
static int pb = 0 ;
2000-03-03 20:25:23 -08:00
/* These arrays store the text and rendering info that were last drawn to the screen. */
1999-08-17 16:01:18 -07:00
static text_t * * drawn_text = NULL ;
static rend_t * * drawn_rend = NULL ;
2000-03-03 20:25:23 -08:00
/* These are used for buffering during text scrolls. */
1999-08-17 16:01:18 -07:00
static text_t * * buf_text = NULL ;
static rend_t * * buf_rend = NULL ;
2000-03-03 20:25:23 -08:00
/* Tab stop locations */
static char * tabs = NULL ;
1999-08-17 16:01:18 -07:00
2002-05-22 08:38:35 -07:00
# ifndef ESCREEN
static
# endif
screen_t screen = {
2002-05-04 07:25:30 -07:00
NULL , NULL , 0 , 0 , 0 , 0 , 0 , Screen_DefaultFlags
1999-08-17 16:01:18 -07:00
} ;
2002-05-04 07:25:30 -07:00
static screen_t swap = {
NULL , NULL , 0 , 0 , 0 , 0 , 0 , Screen_DefaultFlags
1999-08-17 16:01:18 -07:00
} ;
2002-05-04 07:25:30 -07:00
static save_t save = {
0 , 0 , 0 , ' B ' , DEFAULT_RSTYLE
1999-08-17 16:01:18 -07:00
} ;
2002-05-04 07:25:30 -07:00
static selection_t selection = {
NULL , 0 , SELECTION_CLEAR , PRIMARY , 0 ,
{ 0 , 0 } ,
{ 0 , 0 } ,
{ 0 , 0 }
1999-08-17 16:01:18 -07:00
} ;
2002-05-04 07:25:30 -07:00
static char charsets [ 4 ] = {
' B ' , ' B ' , ' B ' , ' B ' /* all ascii */
1999-08-17 16:01:18 -07:00
} ;
static short current_screen = PRIMARY ;
static rend_t rstyle = DEFAULT_RSTYLE ;
2000-03-03 20:25:23 -08:00
static short rvideo = 0 ;
int prev_nrow = - 1 , prev_ncol = - 1 ;
unsigned char refresh_all = 0 ;
1999-08-17 16:01:18 -07:00
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
1999-08-17 16:01:18 -07:00
static short multi_byte = 0 ;
2000-07-05 19:32:08 -07:00
static short lost_multi = 0 ;
1999-08-17 16:01:18 -07:00
static enum {
2002-05-04 07:25:30 -07:00
SBYTE , WBYTE
1999-08-17 16:01:18 -07:00
} chstat = SBYTE ;
2000-07-05 19:32:08 -07:00
encoding_t encoding_method = LATIN1 ;
1999-08-17 16:01:18 -07:00
# define RESET_CHSTAT if (chstat == WBYTE) chstat = SBYTE, lost_multi = 1
# else
# define RESET_CHSTAT
# endif
/* Fill part/all of a drawn line with blanks. */
2000-03-14 19:17:45 -08:00
inline void blank_line ( text_t * , rend_t * , int , rend_t ) ;
inline void
2000-09-01 21:12:16 -07:00
blank_line ( text_t * et , rend_t * er , int width , rend_t efs )
1999-08-17 16:01:18 -07:00
{
/* int i = width; */
2002-05-04 07:25:30 -07:00
register unsigned int i = width ;
rend_t * r = er , fs = efs ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
MEMSET ( et , ' ' , i ) ;
for ( ; i - - ; )
* r + + = fs ;
1999-08-17 16:01:18 -07:00
}
2000-03-03 20:25:23 -08:00
/* Create a new row in the screen buffer and initialize it. */
2000-03-14 19:17:45 -08:00
inline void blank_screen_mem ( text_t * * , rend_t * * , int , rend_t ) ;
inline void
1999-12-30 04:44:45 -08:00
blank_screen_mem ( text_t * * tp , rend_t * * rp , int row , rend_t efs )
{
2002-10-07 19:18:09 -07:00
register unsigned int i = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
rend_t * r , fs = efs ;
1999-12-30 04:44:45 -08:00
2002-05-04 07:25:30 -07:00
if ( tp [ row ] = = NULL ) {
2002-10-07 19:18:09 -07:00
tp [ row ] = MALLOC ( sizeof ( text_t ) * ( TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ) ) ;
rp [ row ] = MALLOC ( sizeof ( rend_t ) * TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
2002-05-04 07:25:30 -07:00
}
MEMSET ( tp [ row ] , ' ' , i ) ;
tp [ row ] [ i ] = 0 ;
for ( r = rp [ row ] ; i - - ; )
* r + + = fs ;
1999-12-30 04:44:45 -08:00
}
1999-08-17 16:01:18 -07:00
void
scr_reset ( void )
{
2002-05-04 07:25:30 -07:00
int total_rows , prev_total_rows , chscr = 0 ;
register int i , j , k ;
text_t tc ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_reset() \n " ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
TermWin . view_start = 0 ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
if ( TERM_WINDOW_GET_REPORTED_COLS ( ) = = prev_ncol & & TERM_WINDOW_GET_REPORTED_ROWS ( ) = = prev_nrow )
2002-05-04 07:25:30 -07:00
return ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( current_screen ! = PRIMARY ) {
short tmp = TermWin . nrow ;
TermWin . nrow = prev_nrow ;
chscr = scr_change_screen ( PRIMARY ) ;
TermWin . nrow = tmp ;
}
if ( TermWin . ncol < = 0 )
TermWin . ncol = 80 ;
if ( TermWin . nrow < = 0 )
TermWin . nrow = 24 ;
if ( TermWin . saveLines < = 0 )
TermWin . saveLines = 0 ;
total_rows = TermWin . nrow + TermWin . saveLines ;
prev_total_rows = prev_nrow + TermWin . saveLines ;
screen . tscroll = 0 ;
2002-10-07 19:18:09 -07:00
screen . bscroll = ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
if ( prev_nrow = = - 1 ) {
/*
* A : first time called so just malloc everything : don ' t rely on realloc
* Note : this is still needed so that all the scrollback lines are NULL
*/
screen . text = CALLOC ( text_t * , total_rows ) ;
buf_text = CALLOC ( text_t * , total_rows ) ;
2002-10-07 19:18:09 -07:00
drawn_text = CALLOC ( text_t * , TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
swap . text = CALLOC ( text_t * , TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
2002-05-04 07:25:30 -07:00
screen . rend = CALLOC ( rend_t * , total_rows ) ;
buf_rend = CALLOC ( rend_t * , total_rows ) ;
2002-10-07 19:18:09 -07:00
drawn_rend = CALLOC ( rend_t * , TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
swap . rend = CALLOC ( rend_t * , TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
2002-06-02 17:24:22 -07:00
D_SCREEN ( ( " screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p \n " , screen . text , screen . rend , swap . text , swap . rend ) ) ;
2002-05-04 07:25:30 -07:00
2002-10-07 19:18:09 -07:00
for ( i = 0 ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i + + ) {
2002-05-04 07:25:30 -07:00
j = i + TermWin . saveLines ;
blank_screen_mem ( screen . text , screen . rend , j , DEFAULT_RSTYLE ) ;
blank_screen_mem ( swap . text , swap . rend , i , DEFAULT_RSTYLE ) ;
blank_screen_mem ( drawn_text , drawn_rend , i , DEFAULT_RSTYLE ) ;
}
TermWin . nscrolled = 0 ; /* no saved lines */
1999-12-30 04:44:45 -08:00
2002-05-04 07:25:30 -07:00
} else {
/*
* B1 : add or delete rows as appropriate
*/
2002-10-07 19:18:09 -07:00
if ( TERM_WINDOW_GET_REPORTED_ROWS ( ) < prev_nrow ) {
2002-05-04 07:25:30 -07:00
/* delete rows */
2002-10-07 19:18:09 -07:00
k = MIN ( TermWin . nscrolled , prev_nrow - TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
2002-05-04 07:25:30 -07:00
scroll_text ( 0 , prev_nrow - 1 , k , 1 ) ;
2002-10-07 19:18:09 -07:00
for ( i = TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i < prev_nrow ; i + + ) {
2002-05-04 07:25:30 -07:00
j = i + TermWin . saveLines ;
if ( screen . text [ j ] ) {
FREE ( screen . text [ j ] ) ;
FREE ( screen . rend [ j ] ) ;
}
if ( swap . text [ i ] ) {
FREE ( swap . text [ i ] ) ;
FREE ( swap . rend [ i ] ) ;
}
if ( drawn_text [ i ] ) {
FREE ( drawn_text [ i ] ) ;
FREE ( drawn_rend [ i ] ) ;
}
}
screen . text = REALLOC ( screen . text , total_rows * sizeof ( text_t * ) ) ;
buf_text = REALLOC ( buf_text , total_rows * sizeof ( text_t * ) ) ;
2002-10-07 19:18:09 -07:00
drawn_text = REALLOC ( drawn_text , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( text_t * ) ) ;
swap . text = REALLOC ( swap . text , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( text_t * ) ) ;
2002-05-04 07:25:30 -07:00
screen . rend = REALLOC ( screen . rend , total_rows * sizeof ( rend_t * ) ) ;
buf_rend = REALLOC ( buf_rend , total_rows * sizeof ( rend_t * ) ) ;
2002-10-07 19:18:09 -07:00
drawn_rend = REALLOC ( drawn_rend , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( rend_t * ) ) ;
swap . rend = REALLOC ( swap . rend , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( rend_t * ) ) ;
2002-06-02 17:24:22 -07:00
D_SCREEN ( ( " screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p \n " , screen . text , screen . rend , swap . text , swap . rend ) ) ;
2002-05-04 07:25:30 -07:00
/* we have fewer rows so fix up number of scrolled lines */
2002-10-07 19:18:09 -07:00
UPPER_BOUND ( screen . row , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
2002-10-07 19:18:09 -07:00
} else if ( TERM_WINDOW_GET_REPORTED_ROWS ( ) > prev_nrow ) {
2002-05-04 07:25:30 -07:00
/* add rows */
screen . text = REALLOC ( screen . text , total_rows * sizeof ( text_t * ) ) ;
buf_text = REALLOC ( buf_text , total_rows * sizeof ( text_t * ) ) ;
2002-10-07 19:18:09 -07:00
drawn_text = REALLOC ( drawn_text , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( text_t * ) ) ;
swap . text = REALLOC ( swap . text , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( text_t * ) ) ;
2002-05-04 07:25:30 -07:00
screen . rend = REALLOC ( screen . rend , total_rows * sizeof ( rend_t * ) ) ;
buf_rend = REALLOC ( buf_rend , total_rows * sizeof ( rend_t * ) ) ;
2002-10-07 19:18:09 -07:00
drawn_rend = REALLOC ( drawn_rend , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( rend_t * ) ) ;
swap . rend = REALLOC ( swap . rend , TERM_WINDOW_GET_REPORTED_ROWS ( ) * sizeof ( rend_t * ) ) ;
2002-06-02 17:24:22 -07:00
D_SCREEN ( ( " screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p \n " , screen . text , screen . rend , swap . text , swap . rend ) ) ;
2002-05-04 07:25:30 -07:00
2002-10-07 19:18:09 -07:00
k = MIN ( TermWin . nscrolled , TERM_WINDOW_GET_REPORTED_ROWS ( ) - prev_nrow ) ;
2002-05-04 07:25:30 -07:00
for ( i = prev_total_rows ; i < total_rows - k ; i + + ) {
screen . text [ i ] = NULL ;
blank_screen_mem ( screen . text , screen . rend , i , DEFAULT_RSTYLE ) ;
}
for ( /* i = total_rows - k */ ; i < total_rows ; i + + ) {
screen . text [ i ] = NULL ;
screen . rend [ i ] = NULL ;
}
2002-10-07 19:18:09 -07:00
for ( i = prev_nrow ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i + + ) {
2002-05-04 07:25:30 -07:00
swap . text [ i ] = NULL ;
drawn_text [ i ] = NULL ;
blank_screen_mem ( swap . text , swap . rend , i , DEFAULT_RSTYLE ) ;
blank_screen_mem ( drawn_text , drawn_rend , i , DEFAULT_RSTYLE ) ;
}
if ( k > 0 ) {
2002-10-07 19:18:09 -07:00
scroll_text ( 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 , - k , 1 ) ;
2002-05-04 07:25:30 -07:00
screen . row + = k ;
TermWin . nscrolled - = k ;
for ( i = TermWin . saveLines - TermWin . nscrolled ; k - - ; i - - ) {
if ( screen . text [ i ] = = NULL ) {
blank_screen_mem ( screen . text , screen . rend , i , DEFAULT_RSTYLE ) ;
}
}
}
}
/* B2: resize columns */
2002-10-07 19:18:09 -07:00
if ( TERM_WINDOW_GET_REPORTED_COLS ( ) ! = prev_ncol ) {
2002-05-04 07:25:30 -07:00
for ( i = 0 ; i < total_rows ; i + + ) {
if ( screen . text [ i ] ) {
tc = screen . text [ i ] [ prev_ncol ] ;
2002-10-07 19:18:09 -07:00
screen . text [ i ] = REALLOC ( screen . text [ i ] , ( TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ) * sizeof ( text_t ) ) ;
screen . rend [ i ] = REALLOC ( screen . rend [ i ] , TERM_WINDOW_GET_REPORTED_COLS ( ) * sizeof ( rend_t ) ) ;
screen . text [ i ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] = MIN ( tc , TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
if ( TERM_WINDOW_GET_REPORTED_COLS ( ) > prev_ncol )
blank_line ( & ( screen . text [ i ] [ prev_ncol ] ) , & ( screen . rend [ i ] [ prev_ncol ] ) , TERM_WINDOW_GET_REPORTED_COLS ( ) - prev_ncol , DEFAULT_RSTYLE ) ;
2002-05-04 07:25:30 -07:00
}
}
2002-10-07 19:18:09 -07:00
for ( i = 0 ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i + + ) {
drawn_text [ i ] = REALLOC ( drawn_text [ i ] , ( TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ) * sizeof ( text_t ) ) ;
drawn_rend [ i ] = REALLOC ( drawn_rend [ i ] , TERM_WINDOW_GET_REPORTED_COLS ( ) * sizeof ( rend_t ) ) ;
2002-05-04 07:25:30 -07:00
if ( swap . text [ i ] ) {
tc = swap . text [ i ] [ prev_ncol ] ;
2002-10-07 19:18:09 -07:00
swap . text [ i ] = REALLOC ( swap . text [ i ] , ( TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ) * sizeof ( text_t ) ) ;
swap . rend [ i ] = REALLOC ( swap . rend [ i ] , TERM_WINDOW_GET_REPORTED_COLS ( ) * sizeof ( rend_t ) ) ;
swap . text [ i ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] = MIN ( tc , TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
if ( TERM_WINDOW_GET_REPORTED_COLS ( ) > prev_ncol )
blank_line ( & ( swap . text [ i ] [ prev_ncol ] ) , & ( swap . rend [ i ] [ prev_ncol ] ) , TERM_WINDOW_GET_REPORTED_COLS ( ) - prev_ncol , DEFAULT_RSTYLE ) ;
2002-05-04 07:25:30 -07:00
}
2002-10-07 19:18:09 -07:00
if ( TERM_WINDOW_GET_REPORTED_COLS ( ) > prev_ncol )
blank_line ( & ( drawn_text [ i ] [ prev_ncol ] ) , & ( drawn_rend [ i ] [ prev_ncol ] ) , TERM_WINDOW_GET_REPORTED_COLS ( ) - prev_ncol , DEFAULT_RSTYLE ) ;
2002-05-04 07:25:30 -07:00
}
1999-12-30 04:44:45 -08:00
}
2002-05-04 07:25:30 -07:00
if ( tabs )
FREE ( tabs ) ;
}
2002-10-07 19:18:09 -07:00
tabs = MALLOC ( TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
2002-05-04 07:25:30 -07:00
2002-10-07 19:18:09 -07:00
for ( i = 0 ; i < TERM_WINDOW_GET_REPORTED_COLS ( ) ; i + + )
2002-05-04 07:25:30 -07:00
tabs [ i ] = ( i % TABSIZE = = 0 ) ? 1 : 0 ;
2002-10-07 19:18:09 -07:00
prev_nrow = TERM_WINDOW_GET_REPORTED_ROWS ( ) ;
prev_ncol = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
tt_resize ( ) ;
if ( chscr ) {
scr_change_screen ( chscr ) ;
1999-08-17 16:01:18 -07:00
}
}
2000-03-03 20:25:23 -08:00
/* Release all screen memory. */
1999-08-17 16:01:18 -07:00
void
scr_release ( void )
{
2002-05-04 07:25:30 -07:00
int total_rows ;
register int i ;
2002-10-07 19:18:09 -07:00
total_rows = TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ;
2002-05-04 07:25:30 -07:00
for ( i = 0 ; i < total_rows ; i + + ) {
if ( screen . text [ i ] ) {
FREE ( screen . text [ i ] ) ;
FREE ( screen . rend [ i ] ) ;
}
}
2002-10-07 19:18:09 -07:00
for ( i = 0 ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i + + ) {
2002-05-04 07:25:30 -07:00
FREE ( drawn_text [ i ] ) ;
FREE ( drawn_rend [ i ] ) ;
FREE ( swap . text [ i ] ) ;
FREE ( swap . rend [ i ] ) ;
}
FREE ( screen . text ) ;
FREE ( screen . rend ) ;
FREE ( drawn_text ) ;
FREE ( drawn_rend ) ;
FREE ( swap . text ) ;
FREE ( swap . rend ) ;
FREE ( buf_text ) ;
FREE ( buf_rend ) ;
FREE ( tabs ) ;
1999-08-17 16:01:18 -07:00
}
2000-03-03 20:25:23 -08:00
/* Perform a full reset on the terminal. Called by the "\ec" sequence or by an xterm color change. */
1999-08-17 16:01:18 -07:00
void
scr_poweron ( void )
{
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_poweron() \n " ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
/* Reset all character sets to Latin1 */
MEMSET ( charsets , ' B ' , sizeof ( charsets ) ) ;
rvideo = 0 ;
/* Reset the rendering style to the default colors/style */
scr_rendition ( 0 , ~ RS_None ) ;
1999-08-17 16:01:18 -07:00
# if NSCREENS
2003-08-24 08:09:32 -07:00
if ( BITFIELD_IS_SET ( vt_options , VT_OPTIONS_SECONDARY_SCREEN ) ) {
2002-09-21 21:35:54 -07:00
/* Reset the secondary screen */
scr_change_screen ( SECONDARY ) ;
scr_erase_screen ( 2 ) ;
swap . tscroll = 0 ;
2002-10-07 19:18:09 -07:00
swap . bscroll = TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ;
2002-09-21 21:35:54 -07:00
swap . row = swap . col = 0 ;
swap . charset = 0 ;
swap . flags = Screen_DefaultFlags ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
/* Reset the primary screen */
scr_change_screen ( PRIMARY ) ;
scr_erase_screen ( 2 ) ;
screen . row = screen . col = 0 ;
screen . charset = 0 ;
screen . flags = Screen_DefaultFlags ;
scr_cursor ( SAVE ) ;
TermWin . nscrolled = 0 ;
scr_reset ( ) ;
scr_refresh ( SLOW_REFRESH ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Save and Restore cursor
* XTERM_SEQ : Save cursor : ESC 7
* XTERM_SEQ : Restore cursor : ESC 8
*/
void
scr_cursor ( int mode )
{
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_cursor(%s) \n " , ( mode = = SAVE ? " SAVE " : " RESTORE " ) ) ) ;
switch ( mode ) {
case SAVE :
save . row = screen . row ;
save . col = screen . col ;
save . rstyle = rstyle ;
save . charset = screen . charset ;
save . charset_char = charsets [ screen . charset ] ;
break ;
case RESTORE :
screen . row = save . row ;
screen . col = save . col ;
rstyle = save . rstyle ;
screen . charset = save . charset ;
charsets [ screen . charset ] = save . charset_char ;
set_font_style ( ) ;
break ;
}
1999-08-17 16:01:18 -07:00
}
/*
* Swap between primary and secondary screens
* XTERM_SEQ : Primary screen : ESC [ ? 4 7 h
* XTERM_SEQ : Secondary screen : ESC [ ? 4 7 l
*/
int
scr_change_screen ( int scrn )
{
2002-05-04 07:25:30 -07:00
int i , offset , tmp ;
text_t * t0 ;
rend_t * r0 ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_change_screen(%d) \n " , scrn ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
TermWin . view_start = 0 ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( current_screen = = scrn )
return current_screen ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
SWAP_IT ( current_screen , scrn , tmp ) ;
1999-08-17 16:01:18 -07:00
# if NSCREENS
2003-08-24 08:09:32 -07:00
if ( BITFIELD_IS_SET ( vt_options , VT_OPTIONS_SECONDARY_SCREEN ) ) {
2002-09-21 21:35:54 -07:00
offset = TermWin . saveLines ;
if ( ! screen . text | | ! screen . rend )
return ( current_screen ) ;
2002-10-07 19:18:09 -07:00
for ( i = TERM_WINDOW_GET_REPORTED_ROWS ( ) ; i - - ; ) {
2002-09-21 21:35:54 -07:00
SWAP_IT ( screen . text [ i + offset ] , swap . text [ i ] , t0 ) ;
SWAP_IT ( screen . rend [ i + offset ] , swap . rend [ i ] , r0 ) ;
}
SWAP_IT ( screen . row , swap . row , tmp ) ;
SWAP_IT ( screen . col , swap . col , tmp ) ;
SWAP_IT ( screen . charset , swap . charset , tmp ) ;
SWAP_IT ( screen . flags , swap . flags , tmp ) ;
screen . flags | = Screen_VisibleCursor ;
swap . flags | = Screen_VisibleCursor ;
2002-05-04 07:25:30 -07:00
}
1999-08-17 16:01:18 -07:00
# else
# ifndef DONT_SCROLL_ME
2002-09-21 21:35:54 -07:00
if ( current_screen = = PRIMARY ) {
2002-10-07 19:18:09 -07:00
scroll_text ( 0 , ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) , TERM_WINDOW_GET_REPORTED_ROWS ( ) , 0 ) ;
for ( i = TermWin . saveLines ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ; i + + )
2002-09-21 21:35:54 -07:00
if ( screen . text [ i ] = = NULL ) {
blank_screen_mem ( screen . text , screen . rend , i , DEFAULT_RSTYLE ) ;
}
}
1999-08-17 16:01:18 -07:00
# endif
# endif
2000-06-09 22:16:26 -07:00
2002-05-04 07:25:30 -07:00
return scrn ;
1999-08-17 16:01:18 -07:00
}
/*
1999-08-17 18:12:47 -07:00
* Change the color for following text
1999-08-17 16:01:18 -07:00
*/
void
scr_color ( unsigned int color , unsigned int Intensity )
{
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_color(%u, %u) called. \n " , color , Intensity ) ) ;
if ( color = = restoreFG )
color = fgColor ;
else if ( color = = restoreBG )
color = bgColor ;
else {
if ( Xdepth < = 2 ) { /* Monochrome - ignore color changes */
switch ( Intensity ) {
case RS_Bold :
color = fgColor ;
break ;
case RS_Blink :
color = bgColor ;
break ;
}
} else {
1999-08-17 16:01:18 -07:00
# ifndef NO_BRIGHTCOLOR
2003-07-29 19:50:13 -07:00
if ( ( rstyle & Intensity ) & & color > = minColor & & color < = maxColor ) {
2002-05-04 07:25:30 -07:00
color + = ( minBright - minColor ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
}
switch ( Intensity ) {
case RS_Bold :
rstyle = SET_FGCOLOR ( rstyle , color ) ;
break ;
case RS_Blink :
rstyle = SET_BGCOLOR ( rstyle , color ) ;
break ;
1999-08-17 16:01:18 -07:00
}
}
/*
* Change the rendition style for following text
*/
void
scr_rendition ( int set , int style )
{
2002-05-04 07:25:30 -07:00
unsigned int color ;
int old_style = rstyle ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_rendition(%d, %d) called. \n " , set , style ) ) ;
if ( set ) {
1999-08-17 16:01:18 -07:00
/* A: Set style */
2002-05-04 07:25:30 -07:00
rstyle | = style ;
switch ( style ) {
case RS_RVid :
if ( rvideo )
rstyle & = ~ RS_RVid ;
break ;
1999-08-17 16:01:18 -07:00
# ifndef NO_BRIGHTCOLOR
2002-05-04 07:25:30 -07:00
case RS_Bold :
color = GET_FGCOLOR ( rstyle ) ;
scr_color ( ( color = = fgColor ? GET_FGCOLOR ( colorfgbg ) : color ) , RS_Bold ) ;
break ;
case RS_Blink :
color = GET_BGCOLOR ( rstyle ) ;
scr_color ( ( color = = bgColor ? GET_BGCOLOR ( colorfgbg ) : color ) , RS_Blink ) ;
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
} else {
1999-08-17 16:01:18 -07:00
/* B: Unset style */
2002-05-04 07:25:30 -07:00
rstyle & = ~ style ;
switch ( style ) {
case ~ RS_None : /* default fg/bg colors */
rstyle = DEFAULT_RSTYLE | ( old_style & RS_fontMask ) ;
/* FALLTHROUGH */
case RS_RVid :
if ( rvideo )
rstyle | = RS_RVid ;
break ;
1999-08-17 16:01:18 -07:00
# ifndef NO_BRIGHTCOLOR
2002-05-04 07:25:30 -07:00
case RS_Bold :
color = GET_FGCOLOR ( rstyle ) ;
if ( color > = minBright & & color < = maxBright ) {
scr_color ( color , RS_Bold ) ;
if ( ( rstyle & RS_fgMask ) = = ( colorfgbg & RS_fgMask ) )
scr_color ( restoreFG , RS_Bold ) ;
}
break ;
case RS_Blink :
color = GET_BGCOLOR ( rstyle ) ;
if ( color > = minBright & & color < = maxBright ) {
scr_color ( color , RS_Blink ) ;
if ( ( rstyle & RS_bgMask ) = = ( colorfgbg & RS_bgMask ) )
scr_color ( restoreBG , RS_Blink ) ;
}
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
1999-08-17 16:01:18 -07:00
}
}
2000-03-03 20:25:23 -08:00
/* Scroll text region from <row1> through <row2> by <count> lines */
1999-08-17 16:01:18 -07:00
int
scroll_text ( int row1 , int row2 , int count , int spec )
{
2002-05-04 07:25:30 -07:00
register int i , j ;
PROF_INIT ( scroll_text ) ;
D_SCREEN ( ( " scroll_text(%d,%d,%d,%d): %s \n " , row1 , row2 , count , spec , ( current_screen = = PRIMARY ) ? " Primary " : " Secondary " ) ) ;
if ( count = = 0 | | ( row1 > row2 ) )
return 0 ;
if ( ( count > 0 ) & & ( row1 = = 0 ) & & ( current_screen = = PRIMARY ) ) {
TermWin . nscrolled + = count ;
UPPER_BOUND ( TermWin . nscrolled , TermWin . saveLines ) ;
} else if ( ! spec )
row1 + = TermWin . saveLines ;
row2 + = TermWin . saveLines ;
if ( selection . op & & current_screen = = selection . screen ) {
i = selection . beg . row + TermWin . saveLines ;
j = selection . end . row + TermWin . saveLines ;
if ( ( i < row1 & & j > row1 )
| | ( i < row2 & & j > row2 )
| | ( i - count < row1 & & i > = row1 )
| | ( i - count > row2 & & i < = row2 )
| | ( j - count < row1 & & j > = row1 )
| | ( j - count > row2 & & j < = row2 ) ) {
CLEAR_ALL_SELECTION ;
selection . op = SELECTION_CLEAR ;
} else if ( j > = row1 & & j < = row2 ) {
/* move selected region too */
selection . beg . row - = count ;
selection . end . row - = count ;
selection . mark . row - = count ;
}
}
CHECK_SELECTION ;
if ( count > 0 ) {
1999-08-17 16:01:18 -07:00
/* A: scroll up */
2002-05-04 07:25:30 -07:00
UPPER_BOUND ( count , row2 - row1 + 1 ) ;
1999-08-17 16:01:18 -07:00
/* A1: Copy and blank out lines that will get clobbered by the rotation */
2002-05-04 07:25:30 -07:00
for ( i = 0 , j = row1 ; i < count ; i + + , j + + ) {
buf_text [ i ] = screen . text [ j ] ;
buf_rend [ i ] = screen . rend [ j ] ;
if ( buf_text [ i ] = = NULL ) {
/* A new ALLOC is done with size ncol and
blankline with size prev_ncol - - Sebastien van K */
buf_text [ i ] = MALLOC ( sizeof ( text_t ) * ( prev_ncol + 1 ) ) ;
buf_rend [ i ] = MALLOC ( sizeof ( rend_t ) * prev_ncol ) ;
}
blank_line ( buf_text [ i ] , buf_rend [ i ] , prev_ncol , DEFAULT_RSTYLE ) ;
buf_text [ i ] [ prev_ncol ] = 0 ;
}
1999-08-17 16:01:18 -07:00
/* A2: Rotate lines */
2002-05-04 07:25:30 -07:00
for ( j = row1 ; ( j + count ) < = row2 ; j + + ) {
screen . text [ j ] = screen . text [ j + count ] ;
screen . rend [ j ] = screen . rend [ j + count ] ;
}
1999-08-17 16:01:18 -07:00
/* A3: Resurrect lines */
2002-05-04 07:25:30 -07:00
for ( i = 0 ; i < count ; i + + , j + + ) {
screen . text [ j ] = buf_text [ i ] ;
screen . rend [ j ] = buf_rend [ i ] ;
}
} else if ( count < 0 ) {
1999-08-17 16:01:18 -07:00
/* B: scroll down */
2002-05-04 07:25:30 -07:00
count = MIN ( - count , row2 - row1 + 1 ) ;
1999-08-17 16:01:18 -07:00
/* B1: Copy and blank out lines that will get clobbered by the rotation */
2002-05-04 07:25:30 -07:00
for ( i = 0 , j = row2 ; i < count ; i + + , j - - ) {
buf_text [ i ] = screen . text [ j ] ;
buf_rend [ i ] = screen . rend [ j ] ;
if ( buf_text [ i ] = = NULL ) {
/* A new ALLOC is done with size ncol and
blankline with size prev_ncol - - Sebastien van K */
buf_text [ i ] = MALLOC ( sizeof ( text_t ) * ( prev_ncol + 1 ) ) ;
buf_rend [ i ] = MALLOC ( sizeof ( rend_t ) * prev_ncol ) ;
}
blank_line ( buf_text [ i ] , buf_rend [ i ] , prev_ncol , DEFAULT_RSTYLE ) ;
buf_text [ i ] [ prev_ncol ] = 0 ;
}
1999-08-17 16:01:18 -07:00
/* B2: Rotate lines */
2002-05-04 07:25:30 -07:00
for ( j = row2 ; ( j - count ) > = row1 ; j - - ) {
screen . text [ j ] = screen . text [ j - count ] ;
screen . rend [ j ] = screen . rend [ j - count ] ;
}
1999-08-17 16:01:18 -07:00
/* B3: Resurrect lines */
2002-05-04 07:25:30 -07:00
for ( i = 0 , j = row1 ; i < count ; i + + , j + + ) {
screen . text [ j ] = buf_text [ i ] ;
screen . rend [ j ] = buf_rend [ i ] ;
}
count = - count ;
1999-08-17 16:01:18 -07:00
}
2002-05-04 07:25:30 -07:00
PROF_DONE ( scroll_text ) ;
PROF_TIME ( scroll_text ) ;
return count ;
1999-08-17 16:01:18 -07:00
}
/*
* Add text given in < str > of length < len > to screen struct
*/
void
scr_add_lines ( const unsigned char * str , int nlines , int len )
{
/* char c; */
2002-05-04 07:25:30 -07:00
register char c ;
1999-08-17 16:01:18 -07:00
/* int i, j, row, last_col; */
2002-05-04 07:25:30 -07:00
int last_col ;
register int i , j , row ;
text_t * stp ;
rend_t * srp ;
row_col_t beg , end ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( len < = 0 ) /* sanity */
return ;
2002-10-07 19:18:09 -07:00
last_col = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_add_lines(*,%d,%d) \n " , nlines , len ) ) ;
ZERO_SCROLLBACK ;
if ( nlines > 0 ) {
nlines + = ( screen . row - screen . bscroll ) ;
D_SCREEN ( ( " -> screen.row == %d, screen.bscroll == %d, new nlines == %d \n " , screen . row , screen . bscroll , nlines ) ) ;
2002-10-07 19:18:09 -07:00
if ( ( nlines > 0 ) & & ( screen . tscroll = = 0 ) & & ( screen . bscroll = = ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ) ) {
2002-05-04 07:25:30 -07:00
/* _at least_ this many lines need to be scrolled */
scroll_text ( screen . tscroll , screen . bscroll , nlines , 0 ) ;
for ( i = nlines , row = screen . bscroll + TermWin . saveLines + 1 ; row > 0 & & i - - ; ) {
/* Move row-- to beginning of loop to avoid segfault. -- added by Sebastien van K */
row - - ;
blank_screen_mem ( screen . text , screen . rend , row , rstyle ) ;
}
screen . row - = nlines ;
}
}
UPPER_BOUND ( screen . col , last_col - 1 ) ;
2002-10-07 19:18:09 -07:00
BOUND ( screen . row , - TermWin . nscrolled , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
1999-11-17 17:21:26 -08:00
2002-05-04 07:25:30 -07:00
row = screen . row + TermWin . saveLines ;
if ( screen . text [ row ] = = NULL ) {
blank_screen_mem ( screen . text , screen . rend , row , DEFAULT_RSTYLE ) ;
} /* avoid segfault -- added by Sebastien van K */
beg . row = screen . row ;
beg . col = screen . col ;
stp = screen . text [ row ] ;
srp = screen . rend [ row ] ;
1999-08-17 16:01:18 -07:00
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
if ( lost_multi & & screen . col > 0 & & ( ( srp [ screen . col - 1 ] & RS_multiMask ) = = RS_multi1 )
& & * str ! = ' \n ' & & * str ! = ' \r ' & & * str ! = ' \t ' )
chstat = WBYTE ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
for ( i = 0 ; i < len ; ) {
c = str [ i + + ] ;
# ifdef MULTI_CHARSET
if ( ( encoding_method ! = LATIN1 ) & & ( chstat = = WBYTE ) ) {
2002-06-08 08:44:08 -07:00
rstyle | = RS_multiMask ; /* multibyte 2nd byte */
2002-05-04 07:25:30 -07:00
chstat = SBYTE ;
if ( encoding_method = = EUCJ ) {
c | = 0x80 ; /* maybe overkill, but makes it selectable */
}
} else if ( chstat = = SBYTE ) {
2002-06-08 08:44:08 -07:00
if ( ( encoding_method ! = LATIN1 ) & & ( multi_byte | | ( c & 0x80 ) ) ) { /* multibyte 1st byte */
2002-05-04 07:25:30 -07:00
rstyle & = ~ RS_multiMask ;
rstyle | = RS_multi1 ;
chstat = WBYTE ;
if ( encoding_method = = EUCJ ) {
c | = 0x80 ; /* maybe overkill, but makes it selectable */
}
} else
# endif
switch ( c ) {
case 127 :
continue ; /* ummmm..... */
case ' \t ' :
scr_tab ( 1 ) ;
continue ;
case ' \n ' :
LOWER_BOUND ( stp [ last_col ] , screen . col ) ;
screen . flags & = ~ Screen_WrapNext ;
if ( screen . row = = screen . bscroll ) {
scroll_text ( screen . tscroll , screen . bscroll , 1 , 0 ) ;
j = screen . bscroll + TermWin . saveLines ;
blank_screen_mem ( screen . text , screen . rend , j , rstyle & ~ RS_Uline ) ;
2002-10-07 19:18:09 -07:00
} else if ( screen . row < ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ) {
2002-05-04 07:25:30 -07:00
screen . row + + ;
row = screen . row + TermWin . saveLines ;
}
2002-06-08 08:44:08 -07:00
stp = screen . text [ row ] ; /* _must_ refresh */
srp = screen . rend [ row ] ; /* _must_ refresh */
2002-05-04 07:25:30 -07:00
continue ;
case ' \r ' :
LOWER_BOUND ( stp [ last_col ] , screen . col ) ;
screen . flags & = ~ Screen_WrapNext ;
screen . col = 0 ;
continue ;
default :
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
rstyle & = ~ RS_multiMask ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
break ;
}
# ifdef MULTI_CHARSET
}
# endif
if ( screen . flags & Screen_WrapNext ) {
stp [ last_col ] = WRAP_CHAR ;
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
if ( screen . row = = screen . bscroll ) {
2002-05-04 07:25:30 -07:00
scroll_text ( screen . tscroll , screen . bscroll , 1 , 0 ) ;
j = screen . bscroll + TermWin . saveLines ;
/* blank_line(screen.text[j], screen.rend[j], TermWin.ncol,
rstyle ) ; Bug fix from John Ellison - need to reset rstyle */
blank_screen_mem ( screen . text , screen . rend , j , rstyle & ~ RS_Uline ) ;
2002-10-07 19:18:09 -07:00
} else if ( screen . row < ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ) {
2002-05-04 07:25:30 -07:00
screen . row + + ;
row = screen . row + TermWin . saveLines ;
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
}
2002-06-08 08:44:08 -07:00
stp = screen . text [ row ] ; /* _must_ refresh */
srp = screen . rend [ row ] ; /* _must_ refresh */
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
screen . col = 0 ;
2002-05-04 07:25:30 -07:00
screen . flags & = ~ Screen_WrapNext ;
}
if ( screen . flags & Screen_Insert )
scr_insdel_chars ( 1 , INSERT ) ;
stp [ screen . col ] = c ;
srp [ screen . col ] = rstyle ;
if ( screen . col < ( last_col - 1 ) )
screen . col + + ;
else {
stp [ last_col ] = last_col ;
if ( screen . flags & Screen_Autowrap )
screen . flags | = Screen_WrapNext ;
else
screen . flags & = ~ Screen_WrapNext ;
}
}
LOWER_BOUND ( stp [ last_col ] , screen . col ) ;
if ( screen . col = = 0 ) {
end . col = last_col - 1 ;
end . row = screen . row - 1 ;
} else {
end . col = screen . col - 1 ;
end . row = screen . row ;
}
if ( ( ( selection . end . row > beg . row )
| | ( selection . end . row = = beg . row & & selection . end . col > = beg . col ) )
& & ( ( selection . beg . row < end . row )
| | ( selection . beg . row = = end . row & & selection . beg . col < = end . col ) ) )
selection_reset ( ) ;
# ifdef ESCREEN
2002-06-08 08:44:08 -07:00
if ( NS_MAGIC_LINE ( TermWin . screen_mode ) ) {
2002-10-07 19:18:09 -07:00
if ( screen . row > = TERM_WINDOW_GET_ROWS ( ) ) { /* last row -> upd-flag */
2002-05-04 07:25:30 -07:00
TermWin . screen_pending | = 1 ;
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
}
}
1999-08-17 16:01:18 -07:00
# endif
}
/*
* Process Backspace . Move back the cursor back a position , wrap if have to
* XTERM_SEQ : CTRL - H
*/
void
scr_backspace ( void )
{
2002-05-04 07:25:30 -07:00
RESET_CHSTAT ;
if ( screen . col = = 0 & & screen . row > 0 ) {
2002-10-07 19:18:09 -07:00
screen . col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
screen . row - - ;
} else if ( screen . flags & Screen_WrapNext ) {
screen . flags & = ~ Screen_WrapNext ;
} else
scr_gotorc ( 0 , - 1 , RELATIVE ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Process Horizontal Tab
* count : + ve = forward ; - ve = backwards
* XTERM_SEQ : CTRL - I
*/
void
scr_tab ( int count )
{
2002-05-04 07:25:30 -07:00
int i , x ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
RESET_CHSTAT ;
x = screen . col ;
if ( count = = 0 )
return ;
else if ( count > 0 ) {
2002-10-07 19:18:09 -07:00
for ( i = x + 1 ; i < TERM_WINDOW_GET_REPORTED_COLS ( ) ; i + + ) {
2002-05-04 07:25:30 -07:00
if ( tabs [ i ] ) {
x = i ;
if ( ! - - count )
break ;
}
}
} else if ( count < 0 ) {
for ( i = x - 1 ; i > = 0 ; i - - ) {
if ( tabs [ i ] ) {
x = i ;
if ( ! + + count )
break ;
}
}
}
if ( x ! = screen . col )
scr_gotorc ( 0 , x , R_RELATIVE ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Goto Row / Column
*/
void
scr_gotorc ( int row , int col , int relative )
{
2002-05-04 07:25:30 -07:00
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
screen . col = ( ( relative & C_RELATIVE ) ? ( screen . col + col ) : col ) ;
2002-10-07 19:18:09 -07:00
BOUND ( screen . col , 0 , TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( screen . flags & Screen_WrapNext ) {
screen . flags & = ~ Screen_WrapNext ;
}
if ( relative & R_RELATIVE ) {
if ( row > 0 ) {
if ( screen . row < = screen . bscroll & & ( screen . row + row ) > screen . bscroll )
screen . row = screen . bscroll ;
else
screen . row + = row ;
} else if ( row < 0 ) {
if ( screen . row > = screen . tscroll & & ( screen . row + row ) < screen . tscroll )
screen . row = screen . tscroll ;
else
screen . row + = row ;
}
} else {
2002-06-08 08:44:08 -07:00
if ( screen . flags & Screen_Relative ) { /* relative origin mode */
2002-05-04 07:25:30 -07:00
screen . row = row + screen . tscroll ;
UPPER_BOUND ( screen . row , screen . bscroll ) ;
} else
screen . row = row ;
}
# ifdef ESCREEN
2002-06-08 08:44:08 -07:00
if ( NS_MAGIC_LINE ( TermWin . screen_mode ) ) {
2002-10-07 19:18:09 -07:00
if ( screen . row > = TERM_WINDOW_GET_ROWS ( ) ) { /* last row -> upd-flag */
2002-05-04 07:25:30 -07:00
TermWin . screen_pending | = 1 ;
2002-06-08 08:44:08 -07:00
} else if ( TermWin . screen_pending ) { /* left last -> upd-finis */
2002-05-04 07:25:30 -07:00
TermWin . screen_pending | = 2 ;
}
}
# endif
2002-10-07 19:18:09 -07:00
BOUND ( screen . row , 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* direction should be UP or DN
*/
void
scr_index ( int direction )
{
2002-05-04 07:25:30 -07:00
int dirn ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
dirn = ( ( direction = = UP ) ? 1 : - 1 ) ;
D_SCREEN ( ( " scr_index(%d) \n " , dirn ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( screen . flags & Screen_WrapNext ) {
screen . flags & = ~ Screen_WrapNext ;
}
if ( ( screen . row = = screen . bscroll & & direction = = UP )
| | ( screen . row = = screen . tscroll & & direction = = DN ) ) {
scroll_text ( screen . tscroll , screen . bscroll , dirn , 0 ) ;
if ( direction = = UP )
dirn = screen . bscroll + TermWin . saveLines ;
else
dirn = screen . tscroll + TermWin . saveLines ;
blank_screen_mem ( screen . text , screen . rend , dirn , rstyle ) ;
} else
screen . row + = dirn ;
2002-10-07 19:18:09 -07:00
BOUND ( screen . row , 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
CHECK_SELECTION ;
1999-08-17 16:01:18 -07:00
}
/*
* Erase part or whole of a line
* XTERM_SEQ : Clear line to right : ESC [ 0 K
* XTERM_SEQ : Clear line to left : ESC [ 1 K
* XTERM_SEQ : Clear whole line : ESC [ 2 K
*/
void
scr_erase_line ( int mode )
{
2002-05-04 07:25:30 -07:00
int row , col , num ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_erase_line(%d) at screen row: %d \n " , mode , screen . row ) ) ;
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-06-08 09:50:38 -07:00
if ( screen . flags & Screen_WrapNext ) {
2002-05-04 07:25:30 -07:00
screen . flags & = ~ Screen_WrapNext ;
2002-06-08 09:50:38 -07:00
}
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
row = TermWin . saveLines + screen . row ;
2002-10-07 19:18:09 -07:00
ASSERT ( row < TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ) ;
2002-06-08 09:50:38 -07:00
2002-05-04 07:25:30 -07:00
if ( screen . text [ row ] ) {
switch ( mode ) {
case 0 : /* erase to end of line */
col = screen . col ;
2002-10-07 19:18:09 -07:00
num = TERM_WINDOW_GET_REPORTED_COLS ( ) - col ;
UPPER_BOUND ( screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] , col ) ;
2002-05-04 07:25:30 -07:00
break ;
case 1 : /* erase to beginning of line */
col = 0 ;
num = screen . col + 1 ;
break ;
case 2 : /* erase whole line */
col = 0 ;
2002-10-07 19:18:09 -07:00
num = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] = 0 ;
2002-05-04 07:25:30 -07:00
break ;
default :
return ;
}
blank_line ( & ( screen . text [ row ] [ col ] ) , & ( screen . rend [ row ] [ col ] ) , num , rstyle & ~ RS_Uline ) ;
} else {
blank_screen_mem ( screen . text , screen . rend , row , rstyle & ~ RS_Uline ) ;
2000-06-26 16:37:05 -07:00
}
1999-08-17 16:01:18 -07:00
}
/*
* Erase part of whole of the screen
* XTERM_SEQ : Clear screen after cursor : ESC [ 0 J
* XTERM_SEQ : Clear screen before cursor : ESC [ 1 J
* XTERM_SEQ : Clear whole screen : ESC [ 2 J
*/
void
scr_erase_screen ( int mode )
{
2002-05-04 07:25:30 -07:00
int row , num , row_offset ;
rend_t ren ;
long gcmask ;
XGCValues gcvalue ;
Pixmap pmap = None ;
Drawable draw_buffer ;
if ( buffer_pixmap ) {
draw_buffer = buffer_pixmap ;
pmap = images [ image_bg ] . current - > pmap - > pixmap ;
} else {
draw_buffer = TermWin . vt ;
}
D_SCREEN ( ( " scr_erase_screen(%d) at screen row: %d \n " , mode , screen . row ) ) ;
REFRESH_ZERO_SCROLLBACK ;
RESET_CHSTAT ;
row_offset = TermWin . saveLines ;
switch ( mode ) {
case 0 : /* erase to end of screen */
scr_erase_line ( 0 ) ;
row = screen . row + 1 ; /* possible OOB */
2002-10-07 19:18:09 -07:00
num = TERM_WINDOW_GET_REPORTED_ROWS ( ) - row ;
2002-05-04 07:25:30 -07:00
break ;
case 1 : /* erase to beginning of screen */
scr_erase_line ( 1 ) ;
row = 0 ; /* possible OOB */
num = screen . row ;
break ;
case 2 : /* erase whole screen */
row = 0 ;
2002-10-07 19:18:09 -07:00
num = TERM_WINDOW_GET_REPORTED_ROWS ( ) ;
2002-05-04 07:25:30 -07:00
break ;
default :
return ;
}
2002-10-07 19:18:09 -07:00
if ( row > = 0 & & row < = TERM_WINDOW_GET_REPORTED_ROWS ( ) ) { /* check OOB */
UPPER_BOUND ( num , ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - row ) ) ;
2002-05-04 07:25:30 -07:00
if ( rstyle & RS_RVid | | rstyle & RS_Uline )
ren = - 1 ;
else {
if ( GET_BGCOLOR ( rstyle ) = = bgColor ) {
ren = DEFAULT_RSTYLE ;
CLEAR_ROWS ( row , num ) ;
} else {
ren = ( rstyle & ( RS_fgMask | RS_bgMask ) ) ;
gcvalue . foreground = PixColors [ GET_BGCOLOR ( ren ) ] ;
gcmask = GCForeground ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
ERASE_ROWS ( row , num ) ;
gcvalue . foreground = PixColors [ fgColor ] ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
}
}
for ( ; num - - ; row + + ) {
blank_screen_mem ( screen . text , screen . rend , row + row_offset , rstyle & ~ ( RS_RVid | RS_Uline ) ) ;
blank_screen_mem ( drawn_text , drawn_rend , row , ren ) ;
}
}
1999-08-17 16:01:18 -07:00
}
/*
* Fill the screen with ` E ' s
* XTERM_SEQ : Screen Alignment Test : ESC # 8
*/
void
scr_E ( void )
{
2002-05-04 07:25:30 -07:00
int i , j ;
text_t * t ;
rend_t * r , fs ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
fs = rstyle ;
2002-10-07 19:18:09 -07:00
for ( i = TermWin . saveLines ; i < TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ; i + + ) {
2002-05-04 07:25:30 -07:00
t = screen . text [ i ] ;
r = screen . rend [ i ] ;
2002-10-07 19:18:09 -07:00
for ( j = 0 ; j < TERM_WINDOW_GET_REPORTED_COLS ( ) ; j + + ) {
2002-05-04 07:25:30 -07:00
* t + + = ' E ' ;
* r + + = fs ;
}
* t = ' \0 ' ;
1999-08-17 16:01:18 -07:00
}
}
/*
* Insert / Delete < count > lines
*/
void
scr_insdel_lines ( int count , int insdel )
{
2002-05-04 07:25:30 -07:00
int end ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( screen . row > screen . bscroll )
return ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
end = screen . bscroll - screen . row + 1 ;
if ( count > end ) {
if ( insdel = = DELETE )
return ;
else if ( insdel = = INSERT )
count = end ;
}
if ( screen . flags & Screen_WrapNext ) {
screen . flags & = ~ Screen_WrapNext ;
}
scroll_text ( screen . row , screen . bscroll , insdel * count , 0 ) ;
1999-08-17 16:01:18 -07:00
/* fill the inserted or new lines with rstyle. TODO: correct for delete? */
2002-05-04 07:25:30 -07:00
if ( insdel = = DELETE ) {
end = screen . bscroll + TermWin . saveLines ;
} else if ( insdel = = INSERT ) {
end = screen . row + count - 1 + TermWin . saveLines ;
}
for ( ; count - - ; end - - ) {
blank_screen_mem ( screen . text , screen . rend , end , rstyle ) ;
}
1999-08-17 16:01:18 -07:00
}
/*
* Insert / Delete < count > characters from the current position
*/
void
scr_insdel_chars ( int count , int insdel )
{
2002-05-04 07:25:30 -07:00
int col , row ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
ZERO_SCROLLBACK ;
RESET_CHSTAT ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( count < = 0 )
return ;
CHECK_SELECTION ;
2002-10-07 19:18:09 -07:00
UPPER_BOUND ( count , ( TERM_WINDOW_GET_REPORTED_COLS ( ) - screen . col ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
row = screen . row + TermWin . saveLines ;
screen . flags & = ~ Screen_WrapNext ;
switch ( insdel ) {
case INSERT :
2002-10-07 19:18:09 -07:00
for ( col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ; ( col - count ) > = screen . col ; col - - ) {
2002-05-04 07:25:30 -07:00
screen . text [ row ] [ col ] = screen . text [ row ] [ col - count ] ;
screen . rend [ row ] [ col ] = screen . rend [ row ] [ col - count ] ;
}
2002-10-07 19:18:09 -07:00
screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] + = count ;
UPPER_BOUND ( screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] , TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
2002-05-04 07:25:30 -07:00
/* FALLTHROUGH */
case ERASE :
blank_line ( & ( screen . text [ row ] [ screen . col ] ) , & ( screen . rend [ row ] [ screen . col ] ) , count , rstyle ) ;
break ;
case DELETE :
2002-10-07 19:18:09 -07:00
for ( col = screen . col ; ( col + count ) < TERM_WINDOW_GET_REPORTED_COLS ( ) ; col + + ) {
2002-05-04 07:25:30 -07:00
screen . text [ row ] [ col ] = screen . text [ row ] [ col + count ] ;
screen . rend [ row ] [ col ] = screen . rend [ row ] [ col + count ] ;
}
2002-10-07 19:18:09 -07:00
blank_line ( & ( screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) - count ] ) , & ( screen . rend [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) - count ] ) , count , rstyle ) ;
screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] - = count ;
2003-08-21 20:19:43 -07:00
if ( ( ( signed char ) screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ) < 0 )
2002-10-07 19:18:09 -07:00
screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] = 0 ;
2002-05-04 07:25:30 -07:00
break ;
}
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
if ( ( screen . rend [ row ] [ 0 ] & RS_multiMask ) = = RS_multi2 ) {
screen . rend [ row ] [ 0 ] & = ~ RS_multiMask ;
screen . text [ row ] [ 0 ] = ' ' ;
}
2002-10-07 19:18:09 -07:00
if ( ( screen . rend [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ] & RS_multiMask ) = = RS_multi1 ) {
screen . rend [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ] & = ~ RS_multiMask ;
screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ] = ' ' ;
2002-05-04 07:25:30 -07:00
}
1999-08-17 16:01:18 -07:00
# endif
}
/*
* Set the scrolling region
* XTERM_SEQ : Set region < top > - < bot > inclusive : ESC [ < top > ; < bot > r
*/
void
scr_scroll_region ( int top , int bot )
{
2002-05-04 07:25:30 -07:00
LOWER_BOUND ( top , 0 ) ;
2002-10-07 19:18:09 -07:00
UPPER_BOUND ( bot , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
if ( top > bot )
return ;
screen . tscroll = top ;
screen . bscroll = bot ;
scr_gotorc ( 0 , 0 , 0 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Make the cursor visible / invisible
* XTERM_SEQ : Make cursor visible : ESC [ ? 25 h
* XTERM_SEQ : Make cursor invisible : ESC [ ? 25 l
*/
void
scr_cursor_visible ( int mode )
{
2002-05-04 07:25:30 -07:00
if ( mode )
screen . flags | = Screen_VisibleCursor ;
else
screen . flags & = ~ Screen_VisibleCursor ;
1999-08-17 16:01:18 -07:00
}
/*
* Set / unset automatic wrapping
* XTERM_SEQ : Set Wraparound : ESC [ ? 7 h
* XTERM_SEQ : Unset Wraparound : ESC [ ? 7 l
*/
void
scr_autowrap ( int mode )
{
2002-05-04 07:25:30 -07:00
if ( mode )
screen . flags | = Screen_Autowrap ;
else
screen . flags & = ~ Screen_Autowrap ;
1999-08-17 16:01:18 -07:00
}
/*
* Set / unset margin origin mode
* Absolute mode : line numbers are counted relative to top margin of screen
* and the cursor can be moved outside the scrolling region .
* Relative mode : line numbers are relative to top margin of scrolling region
* and the cursor cannot be moved outside .
* XTERM_SEQ : Set Absolute : ESC [ ? 6 h
* XTERM_SEQ : Set Relative : ESC [ ? 6 l
*/
void
scr_relative_origin ( int mode )
{
2002-05-04 07:25:30 -07:00
if ( mode )
screen . flags | = Screen_Relative ;
else
screen . flags & = ~ Screen_Relative ;
scr_gotorc ( 0 , 0 , 0 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Set insert / replace mode
* XTERM_SEQ : Set Insert mode : ESC [ ? 4 h
* XTERM_SEQ : Set Replace mode : ESC [ ? 4 l
*/
void
scr_insert_mode ( int mode )
{
2002-05-04 07:25:30 -07:00
if ( mode )
screen . flags | = Screen_Insert ;
else
screen . flags & = ~ Screen_Insert ;
1999-08-17 16:01:18 -07:00
}
/*
* Set / Unset tabs
* XTERM_SEQ : Set tab at current column : ESC H
* XTERM_SEQ : Clear tab at current column : ESC [ 0 g
* XTERM_SEQ : Clear all tabs : ESC [ 3 g
*/
void
scr_set_tab ( int mode )
{
2002-05-04 07:25:30 -07:00
if ( mode < 0 )
2002-10-07 19:18:09 -07:00
MEMSET ( tabs , 0 , ( unsigned int ) TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
else if ( screen . col < TERM_WINDOW_GET_REPORTED_COLS ( ) )
2002-05-04 07:25:30 -07:00
tabs [ screen . col ] = ( mode ? 1 : 0 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Set reverse / normal video
* XTERM_SEQ : Reverse video : ESC [ ? 5 h
* XTERM_SEQ : Normal video : ESC [ ? 5 l
*/
void
scr_rvideo_mode ( int mode )
{
2002-05-04 07:25:30 -07:00
int i , j , maxlines ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( rvideo ! = mode ) {
rvideo = mode ;
rstyle ^ = RS_RVid ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
maxlines = TermWin . saveLines + TERM_WINDOW_GET_REPORTED_ROWS ( ) ;
2002-05-04 07:25:30 -07:00
for ( i = TermWin . saveLines ; i < maxlines ; i + + )
2002-10-07 19:18:09 -07:00
for ( j = 0 ; j < TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ; j + + )
2002-05-04 07:25:30 -07:00
screen . rend [ i ] [ j ] ^ = RS_RVid ;
scr_refresh ( SLOW_REFRESH ) ;
}
1999-08-17 16:01:18 -07:00
}
/*
* Report current cursor position
* XTERM_SEQ : Report position : ESC [ 6 n
*/
void
scr_report_position ( void )
{
2002-05-04 07:25:30 -07:00
tt_printf ( ( unsigned char * ) " \033 [%d;%dR " , screen . row + 1 , screen . col + 1 ) ;
1999-08-17 16:01:18 -07:00
}
2000-03-03 20:25:23 -08:00
/* Set font style */
1999-08-17 16:01:18 -07:00
void
set_font_style ( void )
{
2002-05-04 07:25:30 -07:00
rstyle & = ~ RS_fontMask ;
switch ( charsets [ screen . charset ] ) {
case ' 0 ' : /* DEC Special Character & Line Drawing Set */
rstyle | = RS_acsFont ;
break ;
case ' A ' : /* United Kingdom (UK) */
rstyle | = RS_ukFont ;
break ;
case ' B ' : /* United States (USASCII) */
break ;
case ' < ' : /* Multinational character set */
break ;
case ' 5 ' : /* Finnish character set */
break ;
case ' C ' : /* Finnish character set */
break ;
case ' K ' : /* German character set */
break ;
}
1999-08-17 16:01:18 -07:00
}
/*
* Choose a font
* XTERM_SEQ : Invoke G0 character set : CTRL - O
* XTERM_SEQ : Invoke G1 character set : CTRL - N
* XTERM_SEQ : Invoke G2 character set : ESC N
* XTERM_SEQ : Invoke G3 character set : ESC O
*/
void
scr_charset_choose ( int set )
{
2002-05-04 07:25:30 -07:00
screen . charset = set ;
set_font_style ( ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Set a font
* XTERM_SEQ : Set G0 character set : ESC ( < C >
* XTERM_SEQ : Set G1 character set : ESC ) < C >
* XTERM_SEQ : Set G2 character set : ESC * < C >
* XTERM_SEQ : Set G3 character set : ESC + < C >
* See set_font_style for possible values for < C >
*/
void
scr_charset_set ( int set , unsigned int ch )
{
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
multi_byte = ( set < 0 ) ;
set = abs ( set ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
charsets [ set ] = ( unsigned char ) ch ;
set_font_style ( ) ;
1999-08-17 16:01:18 -07:00
}
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
1999-08-17 16:01:18 -07:00
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
static void latin1 ( unsigned char * str , int len ) ;
1999-08-17 18:12:47 -07:00
static void eucj2jis ( unsigned char * str , int len ) ;
static void sjis2jis ( unsigned char * str , int len ) ;
static void big5dummy ( unsigned char * str , int len ) ;
1999-08-17 16:01:18 -07:00
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
static void ( * multichar_decode ) ( unsigned char * str , int len ) = latin1 ;
static void
latin1 ( unsigned char * str , int len )
{
2002-05-04 07:25:30 -07:00
return ;
str = NULL ;
len = 0 ;
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
}
1999-08-17 18:12:47 -07:00
static void
1999-08-17 16:01:18 -07:00
eucj2jis ( unsigned char * str , int len )
{
2002-05-04 07:25:30 -07:00
register int i ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
for ( i = 0 ; i < len ; i + + )
str [ i ] & = 0x7F ;
1999-08-17 16:01:18 -07:00
}
1999-08-17 18:12:47 -07:00
static void
1999-08-17 16:01:18 -07:00
sjis2jis ( unsigned char * str , int len )
{
2002-05-04 07:25:30 -07:00
register int i ;
unsigned char * high , * low ;
for ( i = 0 ; i < len ; i + = 2 , str + = 2 ) {
high = str ;
low = str + 1 ;
( * high ) - = ( * high > 0x9F ? 0xB1 : 0x71 ) ;
* high = ( * high ) * 2 + 1 ;
if ( * low > 0x9E ) {
* low - = 0x7E ;
( * high ) + + ;
} else {
if ( * low > 0x7E )
( * low ) - - ;
* low - = 0x1F ;
}
1999-08-17 16:01:18 -07:00
}
}
1999-08-17 18:12:47 -07:00
static void
big5dummy ( unsigned char * str , int len )
{
2002-05-04 07:25:30 -07:00
str = NULL ;
len = 0 ;
1999-08-17 18:12:47 -07:00
}
# endif
1999-08-17 16:01:18 -07:00
void
1999-08-17 18:12:47 -07:00
set_multichar_encoding ( const char * str )
1999-08-17 16:01:18 -07:00
{
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
if ( str & & * str ) {
if ( ! strcasecmp ( str , " sjis " ) ) {
encoding_method = SJIS ;
multichar_decode = sjis2jis ;
} else if ( ! strcasecmp ( str , " eucj " ) | | ! strcasecmp ( str , " euckr " ) | | ! strcasecmp ( str , " gb " ) ) {
encoding_method = EUCJ ;
multichar_decode = eucj2jis ;
} else if ( ! strcasecmp ( str , " big5 " ) ) {
encoding_method = BIG5 ;
multichar_decode = big5dummy ;
} else {
encoding_method = LATIN1 ;
multichar_decode = latin1 ;
}
1999-08-17 16:01:18 -07:00
}
1999-10-18 13:43:03 -07:00
# else
2002-05-04 07:25:30 -07:00
return ;
str = NULL ;
1999-08-17 18:12:47 -07:00
# endif /* MULTI_CHARSET */
1999-08-17 16:01:18 -07:00
}
1999-10-11 12:29:45 -07:00
/* Refresh an area */
1999-08-17 16:01:18 -07:00
void
scr_expose ( int x , int y , int width , int height )
{
2002-05-04 07:25:30 -07:00
int i ;
register short nc , nr ;
row_col_t rect_beg , rect_end ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
REQUIRE ( drawn_text ! = NULL ) ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
nc = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
nr = TERM_WINDOW_GET_ROWS ( ) - 1 ;
1999-08-27 19:40:00 -07:00
2002-05-04 07:25:30 -07:00
rect_beg . col = Pixel2Col ( x ) ;
BOUND ( rect_beg . col , 0 , nc ) ;
rect_beg . row = Pixel2Row ( y ) ;
BOUND ( rect_beg . row , 0 , nr ) ;
rect_end . col = Pixel2Width ( x + width + TermWin . fwidth - 1 ) ;
BOUND ( rect_end . col , 0 , nc ) ;
rect_end . row = Pixel2Row ( y + height + TermWin . fheight - 1 ) ;
BOUND ( rect_end . row , 0 , nr ) ;
2000-03-03 20:25:23 -08:00
2002-06-02 17:24:22 -07:00
D_SCREEN ( ( " scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d) \n " , x , y , width , height , rect_beg . col , rect_beg . row , rect_end . col , rect_end . row ) ) ;
2000-03-03 20:25:23 -08:00
2002-05-04 07:25:30 -07:00
for ( i = rect_beg . row ; i < = rect_end . row ; i + + ) {
MEMSET ( & ( drawn_text [ i ] [ rect_beg . col ] ) , 0 , rect_end . col - rect_beg . col + 1 ) ;
}
1999-08-17 16:01:18 -07:00
}
2000-03-03 20:25:23 -08:00
/* Move the display so that the line represented by scrollbar value Y is at
the top of the screen */
1999-08-17 16:01:18 -07:00
int
scr_move_to ( int y , int len )
{
2002-05-04 07:25:30 -07:00
int start ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
start = TermWin . view_start ;
2002-10-07 19:18:09 -07:00
TermWin . view_start = ( ( len - y ) * ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 + TermWin . nscrolled )
/ ( len ) ) - ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_move_to(%d, %d) view_start:%d \n " , y , len , TermWin . view_start ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
BOUND ( TermWin . view_start , 0 , TermWin . nscrolled ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
return ( TermWin . view_start - start ) ;
1999-08-17 16:01:18 -07:00
}
2000-03-03 20:25:23 -08:00
/* Scroll the visible region up/down by <nlines> lines */
1999-08-17 16:01:18 -07:00
int
scr_page ( int direction , int nlines )
{
2002-05-04 07:25:30 -07:00
int start ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " scr_page(%s, %d) view_start:%d \n " , ( ( direction = = UP ) ? " UP " : " DN " ) , nlines , TermWin . view_start ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
start = TermWin . view_start ;
2002-10-07 19:18:09 -07:00
BOUND ( nlines , 1 , TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ;
2002-05-04 07:25:30 -07:00
TermWin . view_start + = ( ( direction = = UP ) ? nlines : ( - nlines ) ) ;
BOUND ( TermWin . view_start , 0 , TermWin . nscrolled ) ;
return ( TermWin . view_start - start ) ;
1999-08-17 16:01:18 -07:00
}
void
scr_bell ( void )
{
# ifndef NO_MAPALERT
# ifdef MAPALERT_OPTION
2003-08-24 08:09:32 -07:00
if ( BITFIELD_IS_SET ( vt_options , VT_OPTIONS_MAP_ALERT ) )
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
XMapWindow ( Xdisplay , TermWin . parent ) ;
1999-08-17 16:01:18 -07:00
# endif
2003-08-24 08:09:32 -07:00
if ( BITFIELD_IS_SET ( vt_options , VT_OPTIONS_VISUAL_BELL ) ) {
2002-05-04 07:25:30 -07:00
scr_rvideo_mode ( ! rvideo ) ;
scr_rvideo_mode ( ! rvideo ) ;
} else
XBell ( Xdisplay , 0 ) ;
1999-08-17 16:01:18 -07:00
}
void
scr_printscreen ( int fullhist )
{
# ifdef PRINTPIPE
2002-05-04 07:25:30 -07:00
int i , r , nrows , row_offset ;
text_t * t ;
FILE * fd ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( ( fd = popen_printer ( ) ) = = NULL )
return ;
2002-10-07 19:18:09 -07:00
nrows = TERM_WINDOW_GET_REPORTED_ROWS ( ) ;
2002-05-04 07:25:30 -07:00
if ( fullhist ) {
/* Print the entire scrollback buffer. Always start from the top and go all the way to the bottom. */
nrows + = TermWin . nscrolled ;
row_offset = TermWin . saveLines - TermWin . nscrolled ;
} else {
/* Just print what's on the screen. */
row_offset = TermWin . saveLines - TermWin . view_start ;
}
for ( r = 0 ; r < nrows ; r + + ) {
t = screen . text [ r + row_offset ] ;
2002-10-07 19:18:09 -07:00
for ( i = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ; i > = 0 ; i - - )
2002-05-04 07:25:30 -07:00
if ( ! isspace ( t [ i ] ) )
break ;
fprintf ( fd , " %.*s \n " , ( i + 1 ) , t ) ;
}
pclose_printer ( fd ) ;
1999-08-17 16:01:18 -07:00
# endif
}
2000-12-29 14:59:13 -08:00
# ifdef MULTI_CHARSET
int
scr_multi1 ( void )
{
2002-05-04 07:25:30 -07:00
rend_t rend ;
2000-12-29 14:59:13 -08:00
2002-05-04 07:25:30 -07:00
rend = screen . rend [ screen . row + TermWin . saveLines ] [ screen . col ] ;
return ( ( rend & RS_multiMask ) = = RS_multi1 ) ;
2000-12-29 14:59:13 -08:00
}
int
scr_multi2 ( void )
{
2002-05-04 07:25:30 -07:00
rend_t rend ;
2000-12-29 14:59:13 -08:00
2002-05-04 07:25:30 -07:00
if ( screen . col = = 0 )
return 0 ;
rend = screen . rend [ screen . row + TermWin . saveLines ] [ screen . col - 1 ] ;
return ( ( rend & RS_multiMask ) = = RS_multi2 ) ;
2000-12-29 14:59:13 -08:00
}
# endif /* MULTI_CHARSET */
1999-08-17 16:01:18 -07:00
/*
* Refresh the screen
* drawn_text / drawn_rend contain the screen information before the update .
* screen . text / screen . rend contain what the screen will change to .
*/
void
scr_refresh ( int type )
{
2002-05-04 07:25:30 -07:00
int i , /* tmp */
scrrow , /* screen row offset */
row_offset , /* basic offset in screen structure */
boldlast = 0 , /* last character in some row was bold */
len , wlen , /* text length screen/buffer */
fprop , /* proportional font used */
is_cursor , /* cursor this position */
rvid , /* reverse video this position */
fore , back , /* desired foreground/background */
wbyte , /* we're in multibyte */
xpixel , /* x offset for start of drawing (font) */
ypixel ; /* y offset for start of drawing (font) */
register int col , row , /* column/row we're processing */
rend ; /* rendition */
static int focus = - 1 ; /* screen in focus? */
long gcmask ; /* Graphics Context mask */
unsigned long ltmp ;
rend_t rt1 , rt2 , /* tmp rend values */
lastrend ; /* rend type of last char in drawing set */
text_t lasttext ; /* last char being replaced in drawing set */
rend_t * drp , * srp ; /* drawn-rend-pointer, screen-rend-pointer */
text_t * dtp , * stp ; /* drawn-text-pointer, screen-text-pointer */
XGCValues gcvalue ; /* Graphics Context values */
char buf [ MAX_COLS + 1 ] ;
register char * buffer = buf ;
Pixmap pmap = images [ image_bg ] . current - > pmap - > pixmap ;
int ( * draw_string ) ( ) , ( * draw_image_string ) ( ) ;
register int low_x = 99999 , low_y = 99999 , high_x = 0 , high_y = 0 ;
Drawable draw_buffer ;
2002-06-02 17:24:22 -07:00
1999-08-17 16:01:18 -07:00
# ifndef NO_BOLDFONT
2002-05-04 07:25:30 -07:00
int bfont = 0 ; /* we've changed font to bold font */
1999-08-17 16:01:18 -07:00
# endif
# ifdef OPTIMIZE_HACKS
2002-10-07 19:18:09 -07:00
register int nrows = TERM_WINDOW_GET_ROWS ( ) ;
register int ncols = TERM_WINDOW_GET_COLS ( ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
int ascent , descent ;
2002-05-04 08:12:59 -07:00
PROF_INIT ( scr_refresh ) ;
2002-05-04 07:25:30 -07:00
switch ( type ) {
case NO_REFRESH :
D_SCREEN ( ( " scr_refresh(NO_REFRESH) called. \n " ) ) ;
break ;
case SLOW_REFRESH :
D_SCREEN ( ( " scr_refresh(SLOW_REFRESH) called. \n " ) ) ;
break ;
case FAST_REFRESH :
D_SCREEN ( ( " scr_refresh(FAST_REFRESH) called. \n " ) ) ;
break ;
}
if ( type = = NO_REFRESH )
return ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( buffer_pixmap ) {
draw_buffer = buffer_pixmap ;
} else {
draw_buffer = TermWin . vt ;
}
2000-05-02 16:53:27 -07:00
2002-05-04 07:25:30 -07:00
row_offset = TermWin . saveLines - TermWin . view_start ;
fprop = TermWin . fprop ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
gcvalue . foreground = PixColors [ fgColor ] ;
gcvalue . background = PixColors [ bgColor ] ;
wbyte = 0 ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
XSetFont ( Xdisplay , TermWin . gc , TermWin . font - > fid ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
draw_string = XDrawString ;
draw_image_string = XDrawImageString ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
BOUND ( screen . row , 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
BOUND ( screen . col , 0 , TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ) ;
2000-06-09 22:16:26 -07:00
2002-05-04 07:25:30 -07:00
row = screen . row + TermWin . saveLines ;
col = screen . col ;
if ( screen . flags & Screen_VisibleCursor ) {
screen . rend [ row ] [ col ] | = RS_Cursor ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & screen . rend [ row ] [ col ] ;
if ( ( col < ncols - 1 ) & & ( ( srp [ 0 ] & RS_multiMask ) = = RS_multi1 )
& & ( ( srp [ 1 ] & RS_multiMask ) = = RS_multi2 ) ) {
screen . rend [ row ] [ col + 1 ] | = RS_Cursor ;
} else if ( ( col > 0 ) & & ( ( srp [ 0 ] & RS_multiMask ) = = RS_multi2 )
& & ( ( srp [ - 1 ] & RS_multiMask ) = = RS_multi1 ) ) {
screen . rend [ row ] [ col - 1 ] | = RS_Cursor ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
if ( focus ! = TermWin . focus ) {
focus = TermWin . focus ;
if ( ( i = screen . row - TermWin . view_start ) > = 0 ) {
drawn_rend [ i ] [ col ] = RS_attrMask ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
if ( ( col < ncols - 1 ) & & ( ( srp [ 1 ] & RS_multiMask ) = = RS_multi2 ) ) {
drawn_rend [ i ] [ col + 1 ] = RS_attrMask ;
} else if ( ( col > 0 ) & & ( ( srp [ - 1 ] & RS_multiMask ) = = RS_multi1 ) ) {
drawn_rend [ i ] [ col - 1 ] = RS_attrMask ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
}
}
for ( row = 0 ; row < nrows ; row + + ) {
scrrow = row + row_offset ;
stp = screen . text [ scrrow ] ;
srp = screen . rend [ scrrow ] ;
dtp = drawn_text [ row ] ;
drp = drawn_rend [ row ] ;
for ( col = 0 ; col < ncols ; col + + ) {
if ( ! refresh_all ) {
/* compare new text with old - if exactly the same then continue */
rt1 = srp [ col ] ;
rt2 = drp [ col ] ;
2002-06-08 08:44:08 -07:00
if ( ( stp [ col ] = = dtp [ col ] ) /* must match characters to skip */
& & ( ( rt1 = = rt2 ) /* either rendition the same or */
| | ( ( stp [ col ] = = ' ' ) /* space w/ no bg change */
2002-05-04 07:25:30 -07:00
& & ( GET_BGATTR ( rt1 ) = = GET_BGATTR ( rt2 ) ) ) ) ) {
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
/* if first byte is multibyte then compare second bytes */
if ( ( rt1 & RS_multiMask ) ! = RS_multi1 )
continue ;
else if ( stp [ col + 1 ] = = dtp [ col + 1 ] ) {
/* assume no corrupt characters on the screen */
col + + ;
continue ;
}
1999-08-17 16:01:18 -07:00
# else
2002-05-04 07:25:30 -07:00
continue ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
}
lasttext = dtp [ col ] ;
lastrend = drp [ col ] ;
/* redraw one or more characters */
dtp [ col ] = stp [ col ] ;
rend = drp [ col ] = srp [ col ] ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
len = 0 ;
buffer [ len + + ] = stp [ col ] ;
xpixel = Col2Pixel ( col ) ;
wlen = 1 ;
1999-08-17 16:01:18 -07:00
/*
* Find out the longest string we can write out at once
*/
2002-05-04 07:25:30 -07:00
if ( fprop = = 0 ) { /* Fixed width font */
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
if ( ( ( rend & RS_multiMask ) = = RS_multi1 ) & & ( col < ncols - 1 )
& & ( ( srp [ col + 1 ] ) & RS_multiMask ) = = RS_multi2 ) {
if ( ! wbyte ) {
wbyte = 1 ;
XSetFont ( Xdisplay , TermWin . gc , TermWin . mfont - > fid ) ;
draw_string = XDrawString16 ;
draw_image_string = XDrawImageString16 ;
}
/* double stepping - we're in Multibyte mode */
for ( ; + + col < ncols ; ) {
/* XXX: could check sanity on 2nd byte */
dtp [ col ] = stp [ col ] ;
drp [ col ] = srp [ col ] ;
buffer [ len + + ] = stp [ col ] ;
col + + ;
if ( ( col = = ncols ) | | ( srp [ col ] ! = ( unsigned int ) rend ) )
break ;
if ( ( stp [ col ] = = dtp [ col ] )
& & ( srp [ col ] = = drp [ col ] )
& & ( stp [ col + 1 ] = = dtp [ col + 1 ] ) )
break ;
if ( len = = MAX_COLS )
break ;
dtp [ col ] = stp [ col ] ;
drp [ col ] = srp [ col ] ;
buffer [ len + + ] = stp [ col ] ;
}
col - - ;
if ( buffer [ 0 ] & 0x80 )
multichar_decode ( buffer , len ) ;
wlen = len / 2 ;
} else {
if ( ( rend & RS_multiMask ) = = RS_multi1 ) {
/* XXX : maybe do the same thing for RS_multi2 */
/* corrupt character - you're outta there */
rend & = ~ RS_multiMask ;
2002-06-08 08:44:08 -07:00
drp [ col ] = rend ; /* TODO check: may also want */
dtp [ col ] = ' ' ; /* to poke into stp/srp */
2002-05-04 07:25:30 -07:00
buffer [ 0 ] = ' ' ;
}
if ( wbyte ) {
wbyte = 0 ;
XSetFont ( Xdisplay , TermWin . gc , TermWin . font - > fid ) ;
draw_string = XDrawString ;
draw_image_string = XDrawImageString ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
/* single stepping - `normal' mode */
for ( ; + + col < ncols - 1 ; ) {
if ( ( unsigned int ) rend ! = srp [ col ] )
break ;
if ( ( stp [ col ] = = dtp [ col ] ) & & ( srp [ col ] = = drp [ col ] ) )
break ;
if ( len = = MAX_COLS )
break ;
lasttext = dtp [ col ] ;
lastrend = drp [ col ] ;
dtp [ col ] = stp [ col ] ;
drp [ col ] = srp [ col ] ;
buffer [ len + + ] = stp [ col ] ;
}
col - - ;
wlen = len ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
buffer [ len ] = ' \0 ' ;
/* Determine the attributes for the string */
fore = GET_FGCOLOR ( rend ) ;
back = GET_BGCOLOR ( rend ) ;
rend = GET_ATTR ( rend ) ;
gcmask = 0 ;
rvid = ( rend & RS_RVid ) ? 1 : 0 ;
if ( rend & RS_Select )
rvid = ! rvid ;
if ( rend & RS_Cursor ) {
if ( focus ) {
2002-06-08 08:44:08 -07:00
is_cursor = 2 ; /* normal cursor */
2002-05-04 07:25:30 -07:00
rvid = ! rvid ;
} else {
2002-06-08 08:44:08 -07:00
is_cursor = 1 ; /* outline cursor */
2002-05-04 07:25:30 -07:00
rend & = ~ RS_Cursor ;
}
srp [ col ] & = ~ RS_Cursor ;
} else
is_cursor = 0 ;
switch ( rend & RS_fontMask ) {
case RS_acsFont :
for ( i = 0 ; i < len ; i + + )
if ( buffer [ i ] = = 0x5f )
buffer [ i ] = 0x7f ;
else if ( buffer [ i ] > 0x5f & & buffer [ i ] < 0x7f )
buffer [ i ] - = 0x5f ;
break ;
case RS_ukFont :
for ( i = 0 ; i < len ; i + + )
if ( buffer [ i ] = = ' # ' )
buffer [ i ] = 0x1e ;
break ;
}
if ( rvid )
SWAP_IT ( fore , back , i ) ;
if ( back ! = bgColor ) {
gcvalue . background = PixColors [ back ] ;
gcmask | = GCBackground ;
}
if ( fore ! = fgColor ) {
gcvalue . foreground = PixColors [ fore ] ;
gcmask | = GCForeground ;
}
1999-08-17 16:01:18 -07:00
# ifndef NO_BOLDUNDERLINE
2002-05-04 07:25:30 -07:00
else if ( rend & RS_Bold ) {
if ( PixColors [ fore ] ! = PixColors [ colorBD ]
& & PixColors [ back ] ! = PixColors [ colorBD ] ) {
gcvalue . foreground = PixColors [ colorBD ] ;
gcmask | = GCForeground ;
}
} else if ( rend & RS_Uline ) {
if ( PixColors [ fore ] ! = PixColors [ colorUL ]
& & PixColors [ back ] ! = PixColors [ colorUL ] ) {
gcvalue . foreground = PixColors [ colorUL ] ;
gcmask | = GCForeground ;
}
}
1999-08-17 16:01:18 -07:00
# endif
# ifndef NO_CURSORCOLOR
2002-05-04 07:25:30 -07:00
if ( rend & RS_Cursor ) {
if ( PixColors [ cursorColor ] ! = PixColors [ bgColor ] ) {
gcvalue . background = PixColors [ cursorColor ] ;
back = cursorColor ;
gcmask | = GCBackground ;
}
if ( PixColors [ cursorColor2 ] ! = PixColors [ fgColor ] ) {
gcvalue . foreground = PixColors [ cursorColor2 ] ;
gcmask | = GCForeground ;
}
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
if ( gcmask ) {
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
}
1999-08-17 16:01:18 -07:00
# ifndef NO_BOLDFONT
2002-05-04 07:25:30 -07:00
if ( ! wbyte & & MONO_BOLD ( rend ) & & TermWin . boldFont ! = NULL ) {
XSetFont ( Xdisplay , TermWin . gc , TermWin . boldFont - > fid ) ;
bfont = 1 ;
} else if ( bfont ) {
bfont = 0 ;
XSetFont ( Xdisplay , TermWin . gc , TermWin . font - > fid ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2000-03-03 20:25:23 -08:00
2000-06-20 19:44:29 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
ascent = MAX ( ( encoding_method = = LATIN1 ? 0 : TermWin . mfont - > ascent ) , TermWin . font - > ascent ) ;
descent = MAX ( ( encoding_method = = LATIN1 ? 0 : TermWin . mfont - > descent ) , TermWin . font - > descent ) ;
2000-06-26 09:33:23 -07:00
# else
2002-05-04 07:25:30 -07:00
ascent = TermWin . font - > ascent ;
descent = TermWin . font - > descent ;
2000-06-20 19:44:29 -07:00
# endif
2002-05-04 07:25:30 -07:00
ypixel = ascent + Row2Pixel ( row ) ;
/* The actual drawing of the string is done here. */
if ( fprop ) {
if ( back ! = bgColor ) {
SWAP_IT ( gcvalue . foreground , gcvalue . background , ltmp ) ;
gcmask | = ( GCForeground | GCBackground ) ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
XFillRectangle ( Xdisplay , draw_buffer , TermWin . gc , xpixel , ypixel - ascent , Width2Pixel ( 1 ) , Height2Pixel ( 1 ) ) ;
SWAP_IT ( gcvalue . foreground , gcvalue . background , ltmp ) ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
} else {
CLEAR_CHARS ( xpixel , ypixel - ascent , 1 ) ;
}
if ( TermWin . font - > per_char ) {
int fw , cw ;
fw = TermWin . fwidth ;
cw = TermWin . font - > per_char [ ( ( int ) ( * buffer ) ) ] . width ;
if ( cw > 0 & & cw < TermWin . font - > max_bounds . width ) {
if ( fw > cw ) {
xpixel + = ( ( fw - cw ) > > 1 ) ;
} else {
xpixel - = ( ( cw - fw ) > > 1 ) ;
if ( col < ncols - 1 ) {
dtp [ col + 1 ] = 0 ;
}
}
}
}
DRAW_STRING ( draw_string , xpixel , ypixel , buffer , 1 ) ;
UPDATE_BOX ( xpixel , ypixel - ascent , xpixel + Width2Pixel ( 1 ) , ypixel + Height2Pixel ( 1 ) ) ;
1999-08-17 16:01:18 -07:00
# ifndef NO_BOLDOVERSTRIKE
2002-05-04 07:25:30 -07:00
if ( MONO_BOLD ( rend ) ) {
DRAW_STRING ( draw_string , xpixel + 1 , ypixel , buffer , 1 ) ;
UPDATE_BOX ( xpixel + 1 , ypixel - ascent , xpixel + 1 + Width2Pixel ( 1 ) , ypixel + Height2Pixel ( 1 ) ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
} else {
1999-08-17 16:01:18 -07:00
# ifdef PIXMAP_SUPPORT
2002-05-04 07:25:30 -07:00
if ( background_is_pixmap ( ) & & ( back = = bgColor ) ) {
if ( fshadow . do_shadow ) {
Pixel tmp ;
int xx , yy , ww , hh ;
tmp = gcvalue . foreground ;
xx = xpixel ;
yy = ypixel - ascent ;
ww = Width2Pixel ( wlen ) ;
hh = Height2Pixel ( 1 ) ;
CLEAR_CHARS ( xpixel , ypixel - ascent , len ) ;
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] | | fshadow . shadow [ SHADOW_TOP_RIGHT ] ) {
yy - - ;
hh + + ;
}
if ( fshadow . shadow [ SHADOW_BOTTOM_LEFT ] | | fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] ) {
hh + + ;
if ( row < nrows - 1 ) {
int ii ;
for ( ii = col - len + 1 ; ii < = col ; ii + + ) {
drawn_text [ row + 1 ] [ ii ] = 0 ;
}
}
}
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] ) {
XSetForeground ( Xdisplay , TermWin . gc , fshadow . color [ SHADOW_TOP_LEFT ] ) ;
DRAW_STRING ( draw_string , xpixel - 1 , ypixel - 1 , buffer , wlen ) ;
if ( col ) {
dtp [ col - 1 ] = 0 ;
}
}
if ( fshadow . shadow [ SHADOW_TOP_RIGHT ] ) {
XSetForeground ( Xdisplay , TermWin . gc , fshadow . color [ SHADOW_TOP_RIGHT ] ) ;
DRAW_STRING ( draw_string , xpixel + 1 , ypixel - 1 , buffer , wlen ) ;
if ( col < ncols - 1 ) {
dtp [ col + 1 ] = 0 ;
}
}
if ( fshadow . shadow [ SHADOW_BOTTOM_LEFT ] ) {
XSetForeground ( Xdisplay , TermWin . gc , fshadow . color [ SHADOW_BOTTOM_LEFT ] ) ;
DRAW_STRING ( draw_string , xpixel - 1 , ypixel + 1 , buffer , wlen ) ;
if ( col ) {
dtp [ col - 1 ] = 0 ;
}
}
if ( fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] ) {
XSetForeground ( Xdisplay , TermWin . gc , fshadow . color [ SHADOW_BOTTOM_RIGHT ] ) ;
DRAW_STRING ( draw_string , xpixel + 1 , ypixel + 1 , buffer , wlen ) ;
if ( col < ncols - 1 ) {
dtp [ col + 1 ] = 0 ;
}
}
XSetForeground ( Xdisplay , TermWin . gc , tmp ) ;
DRAW_STRING ( draw_string , xpixel , ypixel , buffer , wlen ) ;
UPDATE_BOX ( xx , yy , xx + ww , yy + hh ) ;
} else {
CLEAR_CHARS ( xpixel , ypixel - ascent , len ) ;
DRAW_STRING ( draw_string , xpixel , ypixel , buffer , wlen ) ;
UPDATE_BOX ( xpixel , ypixel - ascent , xpixel + Width2Pixel ( wlen ) , ypixel + Height2Pixel ( 1 ) ) ;
}
} else
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
{
1999-08-17 16:01:18 -07:00
# ifdef FORCE_CLEAR_CHARS
2002-05-04 07:25:30 -07:00
CLEAR_CHARS ( xpixel , ypixel - ascent , len ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
DRAW_STRING ( draw_image_string , xpixel , ypixel , buffer , wlen ) ;
2000-06-26 09:33:23 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
{
XFontStruct * font = wbyte ? TermWin . mfont : TermWin . font ;
if ( font - > ascent < ascent | | font - > descent < descent ) {
SWAP_IT ( gcvalue . foreground , gcvalue . background , ltmp ) ;
gcmask | = ( GCForeground | GCBackground ) ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
if ( font - > ascent < ascent ) {
2002-06-02 17:24:22 -07:00
XFillRectangle ( Xdisplay , draw_buffer , TermWin . gc , xpixel , Row2Pixel ( row ) , Width2Pixel ( len ) , ascent - font - > ascent ) ;
2002-05-04 07:25:30 -07:00
}
if ( font - > descent < descent ) {
2002-06-02 17:24:22 -07:00
XFillRectangle ( Xdisplay , draw_buffer , TermWin . gc , xpixel , Row2Pixel ( row ) + ascent + font - > descent , Width2Pixel ( len ) , descent - font - > descent ) ;
2002-05-04 07:25:30 -07:00
}
SWAP_IT ( gcvalue . foreground , gcvalue . background , ltmp ) ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
}
}
2000-06-26 09:33:23 -07:00
# endif
2002-05-04 07:25:30 -07:00
UPDATE_BOX ( xpixel , ypixel - ascent , xpixel + Width2Pixel ( wlen ) , ypixel + Height2Pixel ( 1 ) ) ;
}
}
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
/* do the convoluted bold overstrike */
1999-08-17 16:01:18 -07:00
# ifndef NO_BOLDOVERSTRIKE
2002-05-04 07:25:30 -07:00
if ( MONO_BOLD ( rend ) ) {
DRAW_STRING ( draw_string , xpixel + 1 , ypixel , buffer , wlen ) ;
UPDATE_BOX ( xpixel + 1 , ypixel - ascent , xpixel + 1 + Width2Pixel ( wlen ) , ypixel + Height2Pixel ( 1 ) ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
if ( rend & RS_Uline ) {
if ( descent > 1 ) {
XDrawLine ( Xdisplay , draw_buffer , TermWin . gc , xpixel , ypixel + 1 , xpixel + Width2Pixel ( wlen ) - 1 , ypixel + 1 ) ;
UPDATE_BOX ( xpixel , ypixel + 1 , xpixel + Width2Pixel ( wlen ) - 1 , ypixel + 1 ) ;
} else {
XDrawLine ( Xdisplay , draw_buffer , TermWin . gc , xpixel , ypixel - 1 , xpixel + Width2Pixel ( wlen ) - 1 , ypixel - 1 ) ;
UPDATE_BOX ( xpixel , ypixel - 1 , xpixel + Width2Pixel ( wlen ) - 1 , ypixel - 1 ) ;
}
}
if ( is_cursor = = 1 ) {
1999-08-17 16:01:18 -07:00
# ifndef NO_CURSORCOLOR
2002-05-04 07:25:30 -07:00
if ( PixColors [ cursorColor ] ! = PixColors [ bgColor ] ) {
XSetForeground ( Xdisplay , TermWin . gc , PixColors [ cursorColor ] ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
XDrawRectangle ( Xdisplay , draw_buffer , TermWin . gc , xpixel , ypixel - ascent , Width2Pixel ( 1 + wbyte ) - 1 , Height2Pixel ( 1 ) - 1 ) ;
UPDATE_BOX ( xpixel , ypixel - ascent , Width2Pixel ( 1 + wbyte ) - 1 , Height2Pixel ( 1 ) - 1 ) ;
XSetForeground ( Xdisplay , TermWin . gc , PixColors [ fgColor ] ) ;
}
if ( gcmask ) { /* restore normal colors */
gcvalue . foreground = PixColors [ fgColor ] ;
gcvalue . background = PixColors [ bgColor ] ;
XChangeGC ( Xdisplay , TermWin . gc , gcmask , & gcvalue ) ;
}
if ( MONO_BOLD ( lastrend ) ) {
if ( col < ncols - 1 ) {
dtp [ col + 1 ] = 0 ;
} else {
boldlast = 1 ;
}
}
2002-10-07 19:18:09 -07:00
} /* for (col = 0; col < TERM_WINDOW_GET_REPORTED_COLS(); col++) */
} /* for (row = 0; row < TERM_WINDOW_GET_REPORTED_ROWS(); row++) */
2002-05-04 07:25:30 -07:00
row = screen . row + TermWin . saveLines ;
col = screen . col ;
if ( screen . flags & Screen_VisibleCursor ) {
screen . rend [ row ] [ col ] & = ~ RS_Cursor ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
/* very low overhead so don't check properly, just wipe it all out */
if ( screen . col < ncols - 1 )
screen . rend [ row ] [ col + 1 ] & = ~ RS_Cursor ;
if ( screen . col > 0 )
screen . rend [ row ] [ col - 1 ] & = ~ RS_Cursor ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
if ( buffer_pixmap ) {
2002-06-02 17:24:22 -07:00
D_SCREEN ( ( " Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d \n " , low_x , low_y , high_x , high_y , high_x - low_x + 1 , high_y - low_y + 1 ) ) ;
2002-05-04 07:25:30 -07:00
XClearArea ( Xdisplay , TermWin . vt , low_x , low_y , high_x - low_x + 1 , high_y - low_y + 1 , False ) ;
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] | | fshadow . shadow [ SHADOW_BOTTOM_LEFT ] ) {
2002-06-02 17:24:22 -07:00
XCopyArea ( Xdisplay , pmap , buffer_pixmap , TermWin . gc , TermWin . internalBorder - 1 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , TermWin . internalBorder - 1 , 0 ) ;
2002-05-04 07:25:30 -07:00
XClearArea ( Xdisplay , TermWin . vt , TermWin . internalBorder - 1 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , False ) ;
}
if ( fshadow . shadow [ SHADOW_TOP_RIGHT ] | | fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] | | boldlast ) {
2002-06-02 17:24:22 -07:00
XCopyArea ( Xdisplay , pmap , buffer_pixmap , TermWin . gc , TermWin_TotalWidth ( ) - 2 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , TermWin_TotalWidth ( ) - 2 , 0 ) ;
2002-05-04 07:25:30 -07:00
XClearArea ( Xdisplay , TermWin . vt , TermWin_TotalWidth ( ) - 2 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , False ) ;
}
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] | | fshadow . shadow [ SHADOW_TOP_RIGHT ] ) {
2002-06-02 17:24:22 -07:00
XCopyArea ( Xdisplay , pmap , buffer_pixmap , TermWin . gc , 0 , TermWin . internalBorder - 1 , TermWin_TotalWidth ( ) - 1 , 1 , 0 , TermWin . internalBorder - 1 ) ;
2002-05-04 07:25:30 -07:00
XClearArea ( Xdisplay , TermWin . vt , 0 , TermWin . internalBorder - 1 , TermWin_TotalWidth ( ) - 1 , 1 , False ) ;
}
if ( fshadow . shadow [ SHADOW_BOTTOM_LEFT ] | | fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] ) {
XCopyArea ( Xdisplay , pmap , buffer_pixmap , TermWin . gc , 0 , TermWin_TotalHeight ( ) - TermWin . internalBorder ,
TermWin_TotalWidth ( ) - 1 , 1 , 0 , TermWin_TotalHeight ( ) - TermWin . internalBorder ) ;
XClearArea ( Xdisplay , TermWin . vt , 0 , TermWin_TotalHeight ( ) - TermWin . internalBorder , TermWin_TotalWidth ( ) - 1 , 1 , False ) ;
}
} else {
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] | | fshadow . shadow [ SHADOW_BOTTOM_LEFT ] ) {
XClearArea ( Xdisplay , TermWin . vt , TermWin . internalBorder - 1 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , False ) ;
}
if ( ( fshadow . shadow [ SHADOW_TOP_RIGHT ] | | fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] | | boldlast ) & & TermWin . internalBorder ) {
XClearArea ( Xdisplay , TermWin . vt , TermWin_TotalWidth ( ) - 2 , 0 , 1 , TermWin_TotalHeight ( ) - 1 , False ) ;
}
if ( fshadow . shadow [ SHADOW_TOP_LEFT ] | | fshadow . shadow [ SHADOW_TOP_RIGHT ] ) {
XClearArea ( Xdisplay , TermWin . vt , 0 , TermWin . internalBorder - 1 , TermWin_TotalWidth ( ) - 1 , 1 , False ) ;
}
if ( fshadow . shadow [ SHADOW_BOTTOM_LEFT ] | | fshadow . shadow [ SHADOW_BOTTOM_RIGHT ] ) {
XClearArea ( Xdisplay , TermWin . vt , 0 , TermWin_TotalHeight ( ) - TermWin . internalBorder , TermWin_TotalWidth ( ) - 1 , 1 , False ) ;
}
}
if ( type = = SLOW_REFRESH ) {
XSync ( Xdisplay , False ) ;
}
refresh_all = 0 ;
D_SCREEN ( ( " Exiting. \n " ) ) ;
PROF_DONE ( scr_refresh ) ;
PROF_TIME ( scr_refresh ) ;
1999-08-17 16:01:18 -07:00
}
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
int
scr_strmatch ( unsigned long row , unsigned long col , const char * str )
{
2002-05-04 07:25:30 -07:00
unsigned char c ;
const char * s ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
2002-05-04 07:25:30 -07:00
for ( c = screen . text [ row ] [ col ] , s = str ; s ; s + + ) {
if ( c ! = * s ) {
return ( 0 ) ;
}
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
2002-05-04 07:25:30 -07:00
return 1 ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
/* Find and highlight all occurances of "str" in the scrollback. */
void
scr_search_scrollback ( char * str )
{
2002-05-04 07:25:30 -07:00
unsigned char * c ;
char * s ;
static char * last_str = NULL ;
unsigned int * i ;
unsigned long row , lrow , col , rows , cols , len , k ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
2002-05-04 07:25:30 -07:00
if ( str = = NULL ) {
if ( ( str = last_str ) = = NULL ) {
return ;
}
} else {
last_str = STRDUP ( str ) ;
}
2002-10-07 19:18:09 -07:00
lrow = rows = TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ;
cols = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
len = strlen ( str ) ;
D_SCREEN ( ( " %d, %d \n " , rows , cols ) ) ;
for ( row = 0 ; row < rows ; row + + ) {
if ( screen . text [ row ] ) {
c = screen . text [ row ] ;
for ( s = strstr ( c , str ) ; s ; s = strstr ( s + 1 , str ) ) {
unsigned long j ;
2003-04-22 08:14:20 -07:00
col = ( long ) s - ( long ) c ;
2002-05-04 07:25:30 -07:00
for ( i = screen . rend [ row ] + col , j = 0 ; j < len ; i + + , j + + ) {
if ( * i & RS_RVid ) {
* i & = ~ RS_RVid ;
} else {
* i | = RS_RVid ;
}
}
if ( ( long ) row < = TermWin . saveLines ) {
lrow = row ;
}
}
for ( s = screen . text [ row ] + cols - len + 1 , k = len - 1 ; k ; s + + , k - - ) {
unsigned long j ;
if ( ( row < rows - 1 ) & & ! strncasecmp ( s , str , k ) & & screen . text [ row + 1 ]
& & ! strncasecmp ( screen . text [ row + 1 ] , str + k , len - k ) ) {
2003-04-22 08:14:20 -07:00
col = ( long ) s - ( long ) c ;
2002-05-04 07:25:30 -07:00
for ( i = & ( screen . rend [ row ] [ cols - k ] ) , j = 0 ; j < k ; i + + , j + + ) {
( * i & RS_RVid ) ? ( * i & = ~ RS_RVid ) : ( * i | = RS_RVid ) ;
}
for ( i = screen . rend [ row + 1 ] , j = 0 , k = len - k ; j < k ; i + + , j + + ) {
( * i & RS_RVid ) ? ( * i & = ~ RS_RVid ) : ( * i | = RS_RVid ) ;
}
if ( ( long ) row < = TermWin . saveLines ) {
lrow = row ;
}
break ;
}
}
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
}
2002-05-04 07:25:30 -07:00
if ( last_str = = str ) {
FREE ( last_str ) ;
} else {
if ( lrow ! = rows ) {
2002-10-07 19:18:09 -07:00
TermWin . view_start = rows - lrow - TERM_WINDOW_GET_REPORTED_ROWS ( ) ;
2002-05-04 07:25:30 -07:00
BOUND ( TermWin . view_start , 0 , TermWin . nscrolled ) ;
D_SCREEN ( ( " New view start is %d \n " , TermWin . view_start ) ) ;
}
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
2002-05-04 07:25:30 -07:00
scr_refresh ( refresh_type ) ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
/* Dump the entire contents of the scrollback buffer to stderr in hex and ASCII */
void
scr_dump ( void )
{
2002-05-04 07:25:30 -07:00
unsigned char * c ;
unsigned int * i ;
unsigned long row , col , rows , cols ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
2002-10-07 19:18:09 -07:00
rows = TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ;
cols = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " %d, %d \n " , rows , cols ) ) ;
for ( row = 0 ; row < rows ; row + + ) {
fprintf ( stderr , " %lu: " , row ) ;
if ( screen . text [ row ] ) {
for ( col = 0 , c = screen . text [ row ] ; col < cols ; c + + , col + + ) {
fprintf ( stderr , " %02x " , * c ) ;
}
fprintf ( stderr , " \" " ) ;
for ( col = 0 , c = screen . text [ row ] ; col < cols ; c + + , col + + ) {
fprintf ( stderr , " %c " , ( ( isprint ( * c ) ) ? ( * c ) : ' . ' ) ) ;
}
fprintf ( stderr , " \" " ) ;
for ( col = 0 , i = screen . rend [ row ] ; col < cols ; i + + , col + + ) {
fprintf ( stderr , " %08x " , * i ) ;
}
} else {
fprintf ( stderr , " NULL " ) ;
}
fprintf ( stderr , " \n " ) ;
fflush ( stderr ) ;
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
}
}
2000-02-17 15:15:19 -08:00
/* Dump the entire contents of the scrollback buffer to a file */
void
scr_dump_to_file ( const char * fname )
{
2002-05-04 07:25:30 -07:00
int outfd ;
char * buff , * src , * dest ;
unsigned long row , col , rows , cols ;
struct stat st ;
2000-02-17 15:15:19 -08:00
2002-05-04 07:25:30 -07:00
REQUIRE ( fname ! = NULL ) ;
2000-02-17 15:15:19 -08:00
2002-10-07 19:18:09 -07:00
rows = TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ;
cols = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
D_SCREEN ( ( " Dumping to file \" %s \" . %d rows, %d cols \n " , fname , rows , cols ) ) ;
2000-02-17 15:15:19 -08:00
2002-05-04 07:25:30 -07:00
/* Remove it if it's there. If this fails, we don't
care , because open ( ) will do the right thing . */
if ( ( stat ( fname , & st ) = = 0 ) | | ( errno ! = ENOENT ) ) {
D_SCREEN ( ( " Refusing to use log file \" %s \" -- %s \n " , fname , ( errno ? strerror ( errno ) : " File exists " ) ) ) ;
return ;
}
2000-02-17 15:15:19 -08:00
2002-05-04 07:25:30 -07:00
/* Only open if it's a new file, and open with permissions 0600 */
outfd = open ( fname , O_CREAT | O_EXCL | O_NDELAY | O_WRONLY , S_IRUSR | S_IWUSR ) ;
if ( outfd < 0 ) {
D_SCREEN ( ( " Unable to open \" %s \" for writing -- %s \n " , fname , strerror ( errno ) ) ) ;
return ;
2000-02-17 15:15:19 -08:00
}
2002-05-04 07:25:30 -07:00
if ( stat ( fname , & st ) | | ! S_ISREG ( st . st_mode ) ) {
D_SCREEN ( ( " Race condition exploit attempt detected on \" %s \" ! \n " , fname ) ) ;
close ( outfd ) ;
return ;
}
buff = MALLOC ( cols + 1 ) ;
for ( row = 0 ; row < rows ; row + + ) {
if ( screen . text [ row ] ) {
for ( src = screen . text [ row ] , dest = buff , col = 0 ; col < cols ; col + + )
* dest + + = * src + + ;
* dest + + = ' \n ' ;
* dest = 0 ;
write ( outfd , buff , dest - buff ) ;
}
}
close ( outfd ) ;
FREE ( buff ) ;
2000-02-17 15:15:19 -08:00
}
1999-08-17 16:01:18 -07:00
/*
* If ( row , col ) is within a selected region of text , remove the selection
* - TermWin . nscrolled < = ( selection row ) < = TermWin . nrow - 1
*/
void
selection_check ( void )
{
2002-05-04 07:25:30 -07:00
int c1 , c2 , r1 , r2 ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( current_screen ! = selection . screen )
return ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( ( selection . mark . row < - TermWin . nscrolled )
2002-10-07 19:18:09 -07:00
| | ( selection . mark . row > = TERM_WINDOW_GET_ROWS ( ) )
2002-05-04 07:25:30 -07:00
| | ( selection . beg . row < - TermWin . nscrolled )
2002-10-07 19:18:09 -07:00
| | ( selection . beg . row > = TERM_WINDOW_GET_ROWS ( ) )
2002-05-04 07:25:30 -07:00
| | ( selection . end . row < - TermWin . nscrolled )
2002-10-07 19:18:09 -07:00
| | ( selection . end . row > = TERM_WINDOW_GET_ROWS ( ) ) ) {
2002-05-04 07:25:30 -07:00
selection_reset ( ) ;
return ;
}
r1 = ( screen . row - TermWin . view_start ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
c1 = ( ( r1 - selection . mark . row ) * ( r1 - selection . end . row ) ) ;
1999-08-17 16:01:18 -07:00
/*
* selection . mark . row > screen . row - TermWin . view_start
* or
* selection . end . row > screen . row - TermWin . view_start
*/
2002-05-04 07:25:30 -07:00
if ( c1 < 0 )
selection_reset ( ) ;
else if ( c1 = = 0 ) {
if ( ( selection . mark . row < selection . end . row )
| | ( ( selection . mark . row = = selection . end . row )
& & ( selection . mark . col < selection . end . col ) ) ) {
r1 = selection . mark . row ;
c1 = selection . mark . col ;
r2 = selection . end . row ;
c2 = selection . end . col ;
} else {
r1 = selection . end . row ;
c1 = selection . end . col ;
r2 = selection . mark . row ;
c2 = selection . mark . col ;
}
if ( ( screen . row = = r1 ) & & ( screen . row = = r2 ) ) {
if ( ( screen . col > = c1 ) & & ( screen . col < = c2 ) )
selection_reset ( ) ;
} else if ( ( ( screen . row = = r1 ) & & ( screen . col > = c1 ) )
| | ( ( screen . row = = r2 ) & & ( screen . col < = c2 ) ) )
selection_reset ( ) ;
1999-08-17 16:01:18 -07:00
}
}
2001-05-18 23:56:45 -07:00
/* Write the selection out to the tty. */
1999-08-17 16:01:18 -07:00
void
2001-05-18 23:56:45 -07:00
selection_write ( unsigned char * data , size_t len )
1999-08-17 16:01:18 -07:00
{
2002-05-04 07:25:30 -07:00
size_t num ;
unsigned char * p , * cr = " \r " ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " Writing %lu characters of selection data to tty. \n " , len ) ) ;
D_SELECT ( ( " \n %s \n \n " , safe_print_string ( ( char * ) data , len ) ) ) ;
for ( p = data , num = 0 ; len - - ; p + + ) {
/* Write out each line, replacing newlines with carriage returns. */
if ( * p ! = ' \n ' ) {
num + + ;
} else {
tt_write ( data , num ) ;
tt_write ( cr , 1 ) ;
data + = num + 1 ;
num = 0 ;
}
}
/* If there's anything left, write it out too. */
if ( num ) {
tt_write ( data , num ) ;
1999-08-17 16:01:18 -07:00
}
}
2001-05-18 23:56:45 -07:00
/* Fetch the selection from the specified property and write it to the tty. */
1999-08-17 16:01:18 -07:00
void
2001-05-18 23:56:45 -07:00
selection_fetch ( Window win , unsigned prop , int delete )
1999-08-17 16:01:18 -07:00
{
2002-05-04 07:25:30 -07:00
long nread ;
unsigned long bytes_after , nitems ;
unsigned char * data ;
Atom actual_type ;
int actual_fmt ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " Fetching selection in property %d from window 0x%08x \n " , ( int ) prop , ( int ) win ) ) ;
if ( prop = = None ) {
return ;
2000-03-01 19:31:41 -08:00
}
2002-05-04 07:25:30 -07:00
for ( nread = 0 , bytes_after = 1 ; bytes_after > 0 ; ) {
2002-06-02 17:24:22 -07:00
if ( ( XGetWindowProperty ( Xdisplay , win , prop , ( nread / 4 ) , PROP_SIZE , delete , AnyPropertyType , & actual_type , & actual_fmt , & nitems , & bytes_after , & data ) ! = Success )
2002-05-04 07:25:30 -07:00
| | ( actual_type = = None ) | | ( data = = NULL ) ) {
D_SELECT ( ( " Unable to fetch the value of property %d from window 0x%08x \n " , ( int ) prop , ( int ) win ) ) ;
if ( data ! = NULL ) {
XFree ( data ) ;
}
return ;
}
nread + = nitems ;
2002-06-02 17:24:22 -07:00
D_SELECT ( ( " Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over. \n " , ( int ) actual_type , actual_fmt , nitems , data , bytes_after ) ) ;
2002-05-04 07:25:30 -07:00
if ( nitems = = 0 ) {
D_SELECT ( ( " Retrieval of incremental selection complete. \n " ) ) ;
TermWin . mask & = ~ ( PropertyChangeMask ) ;
XSelectInput ( Xdisplay , TermWin . vt , TermWin . mask ) ;
return ;
}
if ( actual_type = = XA_STRING ) {
/* We can handle strings directly. */
selection_write ( data , nitems ) ;
} else if ( actual_type = = props [ PROP_SELECTION_INCR ] ) {
D_SELECT ( ( " Incremental selection transfer initiated. Length is at least %u bytes. \n " , ( unsigned ) * ( ( unsigned * ) data ) ) ) ;
TermWin . mask | = PropertyChangeMask ;
XSelectInput ( Xdisplay , TermWin . vt , TermWin . mask ) ;
} else {
int size , i ;
XTextProperty xtextp ;
char * * cl = NULL ;
/* It's not a string, so convert it to one (or more). */
D_SELECT ( ( " Selection is not a string. Converting. \n " ) ) ;
xtextp . value = data ;
xtextp . encoding = actual_type ;
xtextp . format = actual_fmt ;
xtextp . nitems = nitems ;
XmbTextPropertyToTextList ( Xdisplay , & xtextp , & cl , & size ) ;
if ( cl ) {
D_SELECT ( ( " Got string list 0x%08x with %d strings. \n " , cl , size ) ) ;
for ( i = 0 ; i < size ; i + + ) {
if ( cl [ i ] ) {
selection_write ( cl [ i ] , strlen ( cl [ i ] ) ) ;
}
}
XFreeStringList ( cl ) ;
}
}
if ( data ) {
XFree ( data ) ;
}
2000-03-14 19:17:45 -08:00
}
1999-08-17 16:01:18 -07:00
}
2001-05-18 23:56:45 -07:00
/* Copy a specific string of a given length to the buffer specified. */
1999-08-17 16:01:18 -07:00
void
2001-05-24 00:17:03 -07:00
selection_copy_string ( Atom sel , char * str , size_t len )
1999-08-17 16:01:18 -07:00
{
2002-05-04 07:25:30 -07:00
if ( str = = NULL | | len = = 0 ) {
return ;
}
if ( IS_SELECTION ( sel ) ) {
D_SELECT ( ( " Copying selection to selection %d \n " , ( int ) sel ) ) ;
XSetSelectionOwner ( Xdisplay , sel , TermWin . vt , CurrentTime ) ;
if ( XGetSelectionOwner ( Xdisplay , sel ) ! = TermWin . vt ) {
print_error ( " Can't take ownership of selection \n " ) ;
}
} else {
D_SELECT ( ( " Copying selection to cut buffer %d \n " , ( int ) sel ) ) ;
XChangeProperty ( Xdisplay , Xroot , sel , XA_STRING , 8 , PropModeReplace , str , len ) ;
2001-05-24 00:17:03 -07:00
}
2000-11-15 14:21:02 -08:00
}
2001-05-18 23:56:45 -07:00
/* Copy the currently-selected text to the buffer specified. */
2000-11-15 14:21:02 -08:00
void
2001-05-24 00:17:03 -07:00
selection_copy ( Atom sel )
2000-11-15 14:21:02 -08:00
{
2002-05-04 07:25:30 -07:00
selection_copy_string ( sel , selection . text , selection . len ) ;
2000-11-15 14:21:02 -08:00
}
2001-05-18 23:56:45 -07:00
/* Paste the specified selection from the specified buffer. */
2000-11-15 14:21:02 -08:00
void
2001-05-24 00:17:03 -07:00
selection_paste ( Atom sel )
2000-11-15 14:21:02 -08:00
{
2002-05-04 07:25:30 -07:00
if ( selection . text ! = NULL ) {
/* If we have a selection of our own, paste it. */
D_SELECT ( ( " Pasting my current selection of length %lu \n " , selection . len ) ) ;
selection_write ( selection . text , selection . len ) ;
} else if ( IS_SELECTION ( sel ) ) {
if ( XGetSelectionOwner ( Xdisplay , sel ) = = None ) {
/* If nobody owns the current selection, just try to paste it ourselves. */
D_SELECT ( ( " Current selection %d unowned. Attempting to paste the default cut buffer. \n " , ( int ) sel ) ) ;
selection_fetch ( Xroot , XA_CUT_BUFFER0 , False ) ;
} else {
/* If someone owns the current selection, send a request to that client to
convert the selection to the appropriate form ( usually XA_STRING ) and
save it for us in the VT_SELECTION property . We ' ll then get a SelectionNotify . */
D_SELECT ( ( " Requesting current selection (%d) -> VT_SELECTION (%d) \n " , sel , props [ PROP_SELECTION_DEST ] ) ) ;
2001-05-24 00:17:03 -07:00
# if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
2002-05-04 07:25:30 -07:00
if ( encoding_method ! = LATIN1 ) {
XConvertSelection ( Xdisplay , sel , XA_COMPOUND_TEXT ( Xdisplay ) , props [ PROP_SELECTION_DEST ] , TermWin . vt , CurrentTime ) ;
} else {
XConvertSelection ( Xdisplay , sel , XA_STRING , props [ PROP_SELECTION_DEST ] , TermWin . vt , CurrentTime ) ;
}
2000-11-15 14:21:02 -08:00
# else
2002-05-04 07:25:30 -07:00
XConvertSelection ( Xdisplay , sel , XA_STRING , props [ PROP_SELECTION_DEST ] , TermWin . vt , CurrentTime ) ;
2000-11-15 14:21:02 -08:00
# endif
2002-05-04 07:25:30 -07:00
}
} else {
D_SELECT ( ( " Pasting cut buffer %d. \n " , ( int ) sel ) ) ;
selection_fetch ( Xroot , sel , False ) ;
2001-05-24 00:17:03 -07:00
}
2000-11-15 14:21:02 -08:00
}
2001-05-18 23:56:45 -07:00
/* Clear the selected state of all selected text. */
1999-08-17 16:01:18 -07:00
void
selection_reset ( void )
{
2002-05-04 07:25:30 -07:00
int i , j , lrow , lcol ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_reset() \n " ) ) ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
lrow = TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines ;
lcol = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
selection . op = SELECTION_CLEAR ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
i = ( current_screen = = PRIMARY ) ? 0 : TermWin . saveLines ;
for ( ; i < lrow ; i + + ) {
if ( screen . text [ i ] ) {
for ( j = 0 ; j < lcol ; j + + ) {
screen . rend [ i ] [ j ] & = ~ RS_Select ;
}
}
2000-01-31 22:01:25 -08:00
}
1999-08-17 16:01:18 -07:00
}
2002-05-04 07:25:30 -07:00
2001-05-18 23:56:45 -07:00
/* Delete the current selection. */
1999-08-17 16:01:18 -07:00
void
selection_clear ( void )
{
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_clear() \n " ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( selection . text ) {
FREE ( selection . text ) ;
}
selection . len = 0 ;
selection_reset ( ) ;
1999-08-17 16:01:18 -07:00
}
2001-05-18 23:56:45 -07:00
/* Set or clear between selected points (inclusive) */
1999-08-17 16:01:18 -07:00
void
selection_setclr ( int set , int startr , int startc , int endr , int endc )
{
2002-05-04 07:25:30 -07:00
int row , col , last_col ;
rend_t * rend ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_setclr(%d) %s (%d,%d)-(%d,%d) \n " , set , ( set ? " set " : " clear " ) , startc , startr , endc , endr ) ) ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
if ( ( startr < - TermWin . nscrolled ) | | ( endr > = TERM_WINDOW_GET_REPORTED_ROWS ( ) ) ) {
2002-05-04 07:25:30 -07:00
selection_reset ( ) ;
return ;
}
2002-10-07 19:18:09 -07:00
last_col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
LOWER_BOUND ( startc , 0 ) ;
UPPER_BOUND ( endc , last_col ) ;
2002-10-07 19:18:09 -07:00
BOUND ( startr , - TermWin . nscrolled , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
BOUND ( endr , - TermWin . nscrolled , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
startr + = TermWin . saveLines ;
endr + = TermWin . saveLines ;
col = startc ;
if ( set ) {
for ( row = startr ; row < endr ; row + + ) {
rend = & ( screen . rend [ row ] [ col ] ) ;
for ( ; col < = last_col ; col + + , rend + + )
* rend | = RS_Select ;
col = 0 ;
}
rend = & ( screen . rend [ row ] [ col ] ) ;
for ( ; col < = endc ; col + + , rend + + )
* rend | = RS_Select ;
} else {
for ( row = startr ; row < endr ; row + + ) {
rend = & ( screen . rend [ row ] [ col ] ) ;
for ( ; col < = last_col ; col + + , rend + + )
* rend & = ~ RS_Select ;
col = 0 ;
}
rend = & ( screen . rend [ row ] [ col ] ) ;
for ( ; col < = endc ; col + + , rend + + )
* rend & = ~ RS_Select ;
}
1999-08-17 16:01:18 -07:00
}
/*
* Mark a selection at the specified x / y pixel location
*/
void
selection_start ( int x , int y )
{
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_start(%d, %d) \n " , x , y ) ) ;
selection_start_colrow ( Pixel2Col ( x ) , Pixel2Row ( y ) ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Mark a selection at the specified col / row
*/
void
selection_start_colrow ( int col , int row )
{
2002-05-04 07:25:30 -07:00
int end_col ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_start_colrow(%d, %d) \n " , col , row ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( selection . op ) {
/* clear the old selection */
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( selection . beg . row < - TermWin . nscrolled )
selection_reset ( ) ;
else
selection_setclr ( 0 , selection . beg . row , selection . beg . col , selection . end . row , selection . end . col ) ;
}
selection . op = SELECTION_INIT ;
2002-10-07 19:18:09 -07:00
BOUND ( row , 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
row - = TermWin . view_start ;
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row + TermWin . saveLines ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col ! = WRAP_CHAR & & col > end_col )
2002-10-07 19:18:09 -07:00
col = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
selection . mark . col = col ;
selection . mark . row = row ;
1999-08-17 16:01:18 -07:00
}
/*
* Copy a selection into the cut buffer
* EXT : button 1 or 3 release
*/
void
selection_make ( Time tm )
{
2002-05-04 07:25:30 -07:00
int i , col , end_col , row , end_row ;
text_t * new_selection_text ;
char * str ;
text_t * t ;
D_SELECT ( ( " selection.op=%d, selection.clicks=%d \n " , selection . op , selection . clicks ) ) ;
switch ( selection . op ) {
case SELECTION_CONT :
break ;
case SELECTION_INIT :
selection_reset ( ) ;
selection . end . row = selection . beg . row = selection . mark . row ;
selection . end . col = selection . beg . col = selection . mark . col ;
/* FALLTHROUGH */
case SELECTION_BEGIN :
selection . op = SELECTION_DONE ;
/* FALLTHROUGH */
default :
return ;
}
selection . op = SELECTION_DONE ;
if ( selection . clicks = = 4 )
return ; /* nothing selected, go away */
2002-10-07 19:18:09 -07:00
if ( selection . beg . row < - TermWin . nscrolled | | selection . end . row > = TERM_WINDOW_GET_REPORTED_ROWS ( ) ) {
2002-05-04 07:25:30 -07:00
selection_reset ( ) ;
return ;
}
2002-10-07 19:18:09 -07:00
i = ( selection . end . row - selection . beg . row + 1 ) * ( TERM_WINDOW_GET_REPORTED_COLS ( ) + 1 ) + 1 ;
2002-05-04 07:25:30 -07:00
str = MALLOC ( i * sizeof ( char ) ) ;
new_selection_text = ( unsigned char * ) str ;
col = MAX ( selection . beg . col , 0 ) ;
row = selection . beg . row + TermWin . saveLines ;
end_row = selection . end . row + TermWin . saveLines ;
1999-08-17 16:01:18 -07:00
/*
* A : rows before end row
*/
2002-05-04 07:25:30 -07:00
for ( ; row < end_row ; row + + ) {
t = & ( screen . text [ row ] [ col ] ) ;
2002-10-07 19:18:09 -07:00
if ( ( end_col = screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ) = = WRAP_CHAR )
end_col = TERM_WINDOW_GET_REPORTED_COLS ( ) ;
2002-05-04 07:25:30 -07:00
for ( ; col < end_col ; col + + )
* str + + = * t + + ;
col = 0 ;
2002-10-07 19:18:09 -07:00
if ( screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ! = WRAP_CHAR ) {
2003-08-24 08:09:32 -07:00
if ( ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_SELECT_TRAILING_SPACES ) ) ) {
2002-05-04 07:25:30 -07:00
for ( str - - ; * str = = ' ' | | * str = = ' \t ' ; str - - ) ;
str + + ;
}
* str + + = ' \n ' ;
}
}
1999-08-17 16:01:18 -07:00
/*
* B : end row
*/
2002-05-04 07:25:30 -07:00
t = & ( screen . text [ row ] [ col ] ) ;
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col = = WRAP_CHAR | | selection . end . col < = end_col ) {
i = 0 ;
end_col = selection . end . col + 1 ;
} else
i = 1 ;
2002-10-07 19:18:09 -07:00
UPPER_BOUND ( end_col , TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
2002-05-04 07:25:30 -07:00
for ( ; col < end_col ; col + + )
* str + + = * t + + ;
2003-08-24 08:09:32 -07:00
if ( ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_SELECT_TRAILING_SPACES ) ) ) {
2002-05-04 07:25:30 -07:00
for ( str - - ; * str = = ' ' | | * str = = ' \t ' ; str - - ) ;
str + + ;
}
if ( i )
* str + + = ' \n ' ;
* str = ' \0 ' ;
if ( ( i = strlen ( ( char * ) new_selection_text ) ) = = 0 ) {
FREE ( new_selection_text ) ;
return ;
}
selection . len = i ;
if ( selection . text )
FREE ( selection . text ) ;
selection . text = new_selection_text ;
selection . screen = current_screen ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
selection_copy ( XA_PRIMARY ) ;
D_SELECT ( ( " selection.len=%d \n " , selection . len ) ) ;
return ;
tm = 0 ;
1999-08-17 16:01:18 -07:00
}
/*
* Mark or select text based upon number of clicks : 1 , 2 , or 3
* EXT : button 1 press
*/
void
selection_click ( int clicks , int x , int y )
{
/*
* int r , c ;
* row_col_t ext_beg , ext_end ;
*/
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_click(%d, %d, %d) \n " , clicks , x , y ) ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
clicks = ( ( clicks - 1 ) % 3 ) + 1 ;
selection . clicks = clicks ; /* save clicks so extend will work */
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
selection_start ( x , y ) ; /* adjusts for scroll offset */
if ( clicks = = 2 | | clicks = = 3 )
selection_extend_colrow ( selection . mark . col , selection . mark . row + TermWin . view_start , 0 , 1 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Select text for 2 clicks
* row is given as a normal selection row value
* beg . row , end . row are returned as normal selection row values
*/
/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
# ifdef CUTCHAR_OPTION
# define DELIMIT_TEXT(x) (strchr((rs_cutchars?rs_cutchars:CUTCHARS), (x)) != NULL)
# else
# define DELIMIT_TEXT(x) (strchr(CUTCHARS, (x)) != NULL)
# endif
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
1999-08-17 16:01:18 -07:00
# define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0)
# endif
void
2000-09-01 21:12:16 -07:00
selection_delimit_word ( int col , int row , row_col_t * beg , row_col_t * end )
1999-08-17 16:01:18 -07:00
{
2002-05-04 07:25:30 -07:00
int beg_col , beg_row , end_col , end_row , last_col ;
int row_offset , w1 ;
text_t * stp , * stp1 , t ;
1999-08-17 16:01:18 -07:00
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
int w2 ;
rend_t * srp , r ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
if ( selection . clicks ! = 2 ) /* We only handle double clicks: go away */
return ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
if ( ! screen . text | | ! screen . rend )
return ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
last_col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
1999-08-17 16:01:18 -07:00
2002-10-07 19:18:09 -07:00
if ( row > = TERM_WINDOW_GET_REPORTED_ROWS ( ) ) {
row = TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
col = last_col ;
} else if ( row < - TermWin . saveLines ) {
row = - TermWin . saveLines ;
col = 0 ;
}
beg_col = end_col = col ;
beg_row = end_row = row ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
row_offset = TermWin . saveLines ;
1999-08-17 16:01:18 -07:00
/* A: find the beginning of the word */
2002-05-04 07:25:30 -07:00
if ( ! screen . text [ beg_row + row_offset ] | | ! screen . rend [ beg_row + row_offset ] )
return ;
if ( ! screen . text [ end_row + row_offset ] | | ! screen . rend [ end_row + row_offset ] )
return ;
1999-08-17 16:01:18 -07:00
#if 0
2002-05-04 07:25:30 -07:00
if ( ! screen . text [ beg_row + row_offset - 1 ] | | ! screen . rend [ beg_row + row_offset - 1 ] )
return ;
if ( ! screen . text [ end_row + row_offset + 1 ] | | ! screen . rend [ end_row + row_offset + 1 ] )
return ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
stp1 = stp = & ( screen . text [ beg_row + row_offset ] [ beg_col ] ) ;
w1 = DELIMIT_TEXT ( * stp ) ;
if ( w1 = = 2 )
w1 = 0 ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & ( screen . rend [ beg_row + row_offset ] [ beg_col ] ) ;
w2 = DELIMIT_REND ( * srp ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
for ( ; ; ) {
for ( ; beg_col > 0 ; beg_col - - ) {
t = * - - stp ;
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( t ) ! = w1 | | ( w1 & & * stp1 ! = t & & BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) )
2002-05-04 07:25:30 -07:00
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
r = * - - srp ;
if ( DELIMIT_REND ( r ) ! = w2 )
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
2003-08-24 08:09:32 -07:00
if ( ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) {
2002-05-04 07:25:30 -07:00
if ( beg_col = = col & & beg_col > 0 ) {
2002-06-08 08:44:08 -07:00
if ( DELIMIT_TEXT ( * stp ) ) /* space or tab or cutchar */
2002-05-04 07:25:30 -07:00
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & ( screen . rend [ beg_row + row_offset ] [ beg_col - 1 ] ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
for ( ; - - beg_col > 0 ; ) {
t = * - - stp ;
if ( DELIMIT_TEXT ( t ) )
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
r = * - - srp ;
if ( DELIMIT_REND ( r ) ! = w2 )
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
}
}
if ( beg_col = = 0 & & ( beg_row > - TermWin . nscrolled ) ) {
stp = & ( screen . text [ beg_row + row_offset - 1 ] [ last_col + 1 ] ) ;
if ( * stp = = WRAP_CHAR ) {
t = * ( stp - 1 ) ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & ( screen . rend [ beg_row + row_offset - 1 ] [ last_col + 1 ] ) ;
r = * ( srp - 1 ) ;
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( t ) = = w1 & & ( ! w1 | | * stp = = t | | ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) & & DELIMIT_REND ( r ) = = w2 ) {
2002-05-04 07:25:30 -07:00
srp - - ;
1999-08-17 16:01:18 -07:00
# else
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( t ) = = w1 & & ( ! w1 | | * stp = = t | | ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) ) {
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
stp - - ;
beg_row - - ;
beg_col = last_col ;
continue ;
}
}
}
break ;
1999-08-17 16:01:18 -07:00
}
/* B: find the end of the word */
# ifdef OPTIMIZE_HACKS
2002-05-04 07:25:30 -07:00
stp = stp1 ;
1999-08-17 16:01:18 -07:00
# else
2002-05-04 07:25:30 -07:00
stp1 = stp = & ( screen . text [ end_row + row_offset ] [ end_col ] ) ;
1999-08-17 16:01:18 -07:00
# endif
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & ( screen . rend [ end_row + row_offset ] [ end_col ] ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
for ( ; ; ) {
for ( ; end_col < last_col ; end_col + + ) {
t = * + + stp ;
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( t ) ! = w1 | | ( w1 & & * stp1 ! = t & & BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) )
2002-05-04 07:25:30 -07:00
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
r = * + + srp ;
if ( DELIMIT_REND ( r ) ! = w2 )
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
2003-08-24 08:09:32 -07:00
if ( ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) {
2002-05-04 07:25:30 -07:00
if ( end_col = = col & & end_col < last_col ) {
2002-06-08 08:44:08 -07:00
if ( DELIMIT_TEXT ( * stp ) ) /* space or tab or cutchar */
2002-05-04 07:25:30 -07:00
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = & ( screen . rend [ end_row + row_offset ] [ end_col + 1 ] ) ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
for ( ; + + end_col < last_col ; ) {
t = * + + stp ;
if ( DELIMIT_TEXT ( t ) )
break ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
r = * + + srp ;
if ( DELIMIT_REND ( r ) ! = w2 )
break ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
}
}
}
2002-10-07 19:18:09 -07:00
if ( end_col = = last_col & & ( end_row < ( TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ) ) {
2002-05-04 07:25:30 -07:00
if ( * + + stp = = WRAP_CHAR ) {
stp = screen . text [ end_row + row_offset + 1 ] ;
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
srp = screen . rend [ end_row + row_offset + 1 ] ;
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( * stp ) = = w1 & & ( ! w1 | | * stp1 = = * stp | | ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) & & DELIMIT_REND ( * srp ) = = w2 ) {
1999-08-17 16:01:18 -07:00
# else
2003-08-24 08:09:32 -07:00
if ( DELIMIT_TEXT ( * stp ) = = w1 & & ( ! w1 | | * stp1 = = * stp | | ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_XTERM_SELECT ) ) ) ) {
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
end_row + + ;
end_col = 0 ;
continue ;
}
}
}
break ;
1999-08-17 16:01:18 -07:00
}
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_delimit_word(%d, %d) says (%d,%d)->(%d,%d) \n " , col , row , beg_col , beg_row , end_col , end_row ) ) ;
1999-08-17 16:01:18 -07:00
/* Poke the values back in */
2002-05-04 07:25:30 -07:00
beg - > col = beg_col ;
beg - > row = beg_row ;
end - > col = end_col ;
end - > row = end_row ;
1999-08-17 16:01:18 -07:00
}
/*
* Extend the selection to the specified x / y pixel location
* EXT : button 3 press ; button 1 or 3 drag
* flag = = 0 = = > button 1
* flag ! = 0 = = > button 3
*/
void
selection_extend ( int x , int y , int flag )
{
2002-05-04 07:25:30 -07:00
int col , row ;
1999-08-17 16:01:18 -07:00
/*
* If we ' re selecting characters ( single click ) then we must check first
* if we are at the same place as the original mark . If we are then
* select nothing . Otherwise , if we ' re to the right of the mark , you have to
* be _past_ a character for it to be selected .
*/
2002-05-04 07:25:30 -07:00
col = Pixel2Col ( x ) ;
row = Pixel2Row ( y ) ;
2002-10-07 19:18:09 -07:00
BOUND ( row , 0 , TERM_WINDOW_GET_REPORTED_ROWS ( ) - 1 ) ;
2002-05-04 07:25:30 -07:00
if ( ( ( selection . clicks % 3 ) = = 1 ) & & ! flag & & ( col = = selection . mark . col & & ( row = = selection . mark . row + TermWin . view_start ) ) ) {
/* select nothing */
selection_setclr ( 0 , selection . beg . row , selection . beg . col , selection . end . row , selection . end . col ) ;
selection . beg . row = selection . end . row = selection . mark . row ;
selection . beg . col = selection . end . col = selection . mark . col ;
selection . clicks = 4 ;
D_SELECT ( ( " selection.clicks = 4 \n " ) ) ;
return ;
}
if ( selection . clicks = = 4 )
selection . clicks = 1 ;
selection_extend_colrow ( col , row , flag , 0 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* Extend the selection to the specified col / row
*/
void
selection_extend_colrow ( int col , int row , int flag , int cont )
{
2002-05-04 07:25:30 -07:00
int old_col , end_col ;
row_col_t new_beg1 , new_beg2 , new_end1 , new_end2 , old_beg , old_end ;
enum {
LEFT , RIGHT
} closeto = RIGHT ;
1999-08-17 16:01:18 -07:00
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
int r ;
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " selection_extend_colrow(%d, %d, %d, %d) clicks:%d \n " , col , row , flag , cont , selection . clicks ) ) ;
switch ( selection . op ) {
case SELECTION_INIT :
selection_reset ( ) ;
selection . end . col = selection . beg . col = selection . mark . col ;
selection . end . row = selection . beg . row = selection . mark . row ;
selection . op = SELECTION_BEGIN ;
/* FALLTHROUGH */
case SELECTION_BEGIN :
break ;
case SELECTION_DONE :
selection . op = SELECTION_CONT ;
/* FALLTHROUGH */
case SELECTION_CONT :
break ;
case SELECTION_CLEAR :
selection_start_colrow ( col , row ) ;
/* FALLTHROUGH */
default :
return ;
}
if ( ( selection . beg . row < - TermWin . nscrolled )
| | ( selection . end . row < - TermWin . nscrolled ) ) {
selection_reset ( ) ;
return ;
}
old_col = col ;
2002-10-07 19:18:09 -07:00
BOUND ( col , - 1 , TERM_WINDOW_GET_REPORTED_COLS ( ) ) ;
2002-05-04 07:25:30 -07:00
old_beg . col = selection . beg . col ;
old_beg . row = selection . beg . row ;
old_end . col = selection . end . col ;
old_end . row = selection . end . row ;
if ( ( selection . op = = SELECTION_BEGIN ) & & ( cont | | ( row ! = selection . mark . row | | col ! = selection . mark . col ) ) )
selection . op = SELECTION_CONT ;
row - = TermWin . view_start ; /* adjust for scroll */
if ( flag ) {
if ( row < selection . beg . row | | ( row = = selection . beg . row & & col < selection . beg . col ) )
closeto = LEFT ;
else if ( row > selection . end . row | | ( row = = selection . end . row & & col > = selection . end . col ) ) {
/* */ ;
} else if ( ( ( col - selection . beg . col )
2002-10-07 19:18:09 -07:00
+ ( ( row - selection . beg . row ) * TERM_WINDOW_GET_REPORTED_COLS ( ) ) )
2002-05-04 07:25:30 -07:00
< ( ( selection . end . col - col )
2002-10-07 19:18:09 -07:00
+ ( ( selection . end . row - row ) * TERM_WINDOW_GET_REPORTED_COLS ( ) ) ) )
2002-05-04 07:25:30 -07:00
closeto = LEFT ;
}
if ( selection . clicks = = 1 ) {
1999-08-17 16:01:18 -07:00
/*
* A1 : extension on single click - selection between points
*/
2002-05-04 07:25:30 -07:00
if ( flag ) { /* button 3 extension */
if ( closeto = = LEFT ) {
selection . beg . row = row ;
selection . beg . col = col ;
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row + TermWin . saveLines ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col ! = WRAP_CHAR & & selection . beg . col > end_col ) {
if ( selection . beg . row < selection . end . row ) {
selection . beg . col = - 1 ;
selection . beg . row + + ;
} else {
selection . beg . col = selection . mark . col ;
selection . beg . row = selection . mark . row ;
}
}
} else {
selection . end . row = row ;
selection . end . col = col - 1 ;
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row + TermWin . saveLines ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col ! = WRAP_CHAR & & selection . end . col > = end_col )
2002-10-07 19:18:09 -07:00
selection . end . col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
}
} else if ( ( row < selection . mark . row )
| | ( row = = selection . mark . row & & col < selection . mark . col ) ) {
/* select left of mark character excluding mark */
selection . beg . row = row ;
selection . beg . col = col ;
selection . end . row = selection . mark . row ;
selection . end . col = selection . mark . col - 1 ;
if ( selection . end . col > = 0 ) {
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row + TermWin . saveLines ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col ! = WRAP_CHAR & & selection . beg . col > end_col ) {
if ( selection . beg . row < selection . end . row ) {
selection . beg . col = - 1 ;
selection . beg . row + + ;
} else {
selection . beg . col = selection . mark . col ;
selection . beg . row = selection . mark . row ;
}
}
}
} else {
/* select right of mark character including mark */
selection . beg . row = selection . mark . row ;
selection . beg . col = selection . mark . col ;
selection . end . row = row ;
selection . end . col = col - 1 ;
if ( old_col > = 0 ) {
2002-10-07 19:18:09 -07:00
end_col = screen . text [ row + TermWin . saveLines ] [ TERM_WINDOW_GET_REPORTED_COLS ( ) ] ;
2002-05-04 07:25:30 -07:00
if ( end_col ! = WRAP_CHAR & & selection . end . col > = end_col )
2002-10-07 19:18:09 -07:00
selection . end . col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
}
}
1999-08-17 18:12:47 -07:00
# ifdef MULTI_CHARSET
2002-10-07 19:18:09 -07:00
if ( ( selection . beg . col > 0 ) & & ( selection . beg . col < TERM_WINDOW_GET_REPORTED_COLS ( ) ) ) {
2002-05-04 07:25:30 -07:00
r = selection . beg . row + TermWin . saveLines ;
if ( ( ( screen . rend [ r ] [ selection . beg . col ] & RS_multiMask ) = = RS_multi2 )
& & ( ( screen . rend [ r ] [ selection . beg . col - 1 ] & RS_multiMask ) = = RS_multi1 ) )
selection . beg . col - - ;
}
2002-10-07 19:18:09 -07:00
if ( ( selection . end . col > 0 ) & & ( selection . end . col < ( TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ) ) ) {
2002-05-04 07:25:30 -07:00
r = selection . end . row + TermWin . saveLines ;
if ( ( ( screen . rend [ r ] [ selection . end . col ] & RS_multiMask ) = = RS_multi1 )
& & ( ( screen . rend [ r ] [ selection . end . col + 1 ] & RS_multiMask ) = = RS_multi2 ) )
selection . end . col + + ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
} else if ( selection . clicks = = 2 ) {
1999-08-17 16:01:18 -07:00
/*
* A2 : extension on double click - selection between words
*/
2002-05-04 07:25:30 -07:00
selection_delimit_word ( col , row , & new_beg2 , & new_end2 ) ;
if ( flag & & closeto = = LEFT )
selection_delimit_word ( selection . end . col , selection . end . row , & new_beg1 , & new_end1 ) ;
else if ( flag & & closeto = = RIGHT )
selection_delimit_word ( selection . beg . col , selection . beg . row , & new_beg1 , & new_end1 ) ;
else
selection_delimit_word ( selection . mark . col , selection . mark . row , & new_beg1 , & new_end1 ) ;
if ( ( ! flag & & ( selection . mark . row < row | | ( selection . mark . row = = row & & selection . mark . col < = col ) ) )
| | ( flag & & closeto = = RIGHT ) ) {
selection . beg . col = new_beg1 . col ;
selection . beg . row = new_beg1 . row ;
selection . end . col = new_end2 . col ;
selection . end . row = new_end2 . row ;
} else {
selection . beg . col = new_beg2 . col ;
selection . beg . row = new_beg2 . row ;
selection . end . col = new_end1 . col ;
selection . end . row = new_end1 . row ;
}
} else if ( selection . clicks = = 3 ) {
1999-08-17 16:01:18 -07:00
/*
* A3 : extension on triple click - selection between lines
*/
2002-05-04 07:25:30 -07:00
if ( flag ) {
if ( closeto = = LEFT )
selection . beg . row = row ;
else
selection . end . row = row ;
} else if ( row < = selection . mark . row ) {
selection . beg . row = row ;
selection . end . row = selection . mark . row ;
} else {
selection . beg . row = selection . mark . row ;
selection . end . row = row ;
}
2003-08-24 08:09:32 -07:00
if ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_SELECT_WHOLE_LINE ) ) {
2002-05-04 07:25:30 -07:00
selection . beg . col = 0 ;
} else {
selection . clicks = 2 ;
selection_delimit_word ( col , row , & new_beg2 , & new_end2 ) ;
selection . beg . col = new_beg2 . col ;
selection . clicks = 3 ;
}
2002-10-07 19:18:09 -07:00
selection . end . col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
1999-08-17 16:01:18 -07:00
}
2002-05-04 07:25:30 -07:00
D_SELECT ( ( " (c:%d,r:%d)-(c:%d,r:%d) old (c:%d,r:%d)-(c:%d,r:%d) \n " , selection . beg . col , selection . beg . row ,
selection . end . col , selection . end . row , old_beg . col , old_beg . row , old_end . col , old_end . row ) ) ;
1999-08-17 16:01:18 -07:00
/*
* B1 : clear anything before the current selection
*/
2002-05-04 07:25:30 -07:00
if ( ( old_beg . row < selection . beg . row ) | | ( old_beg . row = = selection . beg . row & & old_beg . col < selection . beg . col ) ) {
2002-10-07 19:18:09 -07:00
if ( selection . beg . col < TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ) {
2002-05-04 07:25:30 -07:00
row = selection . beg . row ;
col = selection . beg . col + 1 ;
} else {
row = selection . beg . row + 1 ;
col = 0 ;
}
selection_setclr ( 0 , old_beg . row , old_beg . col , row , col ) ;
1999-08-17 16:01:18 -07:00
}
/*
* B2 : clear anything after the current selection
*/
2002-05-04 07:25:30 -07:00
if ( ( old_end . row > selection . end . row ) | | ( old_end . row = = selection . end . row & & old_end . col > selection . end . col ) ) {
if ( selection . end . col > 0 ) {
row = selection . end . row ;
col = selection . end . col - 1 ;
} else {
row = selection . end . row - 1 ;
2002-10-07 19:18:09 -07:00
col = TERM_WINDOW_GET_REPORTED_COLS ( ) - 1 ;
2002-05-04 07:25:30 -07:00
}
selection_setclr ( 0 , row , col , old_end . row , old_end . col ) ;
1999-08-17 16:01:18 -07:00
}
/*
* B3 : set everything
*/
/* TODO: optimise this */
2002-05-04 07:25:30 -07:00
selection_setclr ( 1 , selection . beg . row , selection . beg . col , selection . end . row , selection . end . col ) ;
return ;
1999-08-17 16:01:18 -07:00
}
/*
* Double click on button 3 when already selected
* EXT : button 3 double click
*/
void
selection_rotate ( int x , int y )
{
2002-05-04 07:25:30 -07:00
int col , row ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
col = Pixel2Col ( x ) ;
row = Pixel2Row ( y ) ;
selection . clicks = selection . clicks % 3 + 1 ;
selection_extend_colrow ( col , row , 1 , 0 ) ;
1999-08-17 16:01:18 -07:00
}
/*
* On some systems , the Atom typedef is 64 bits wide . We need to have a type
* that is exactly 32 bits wide , because a format of 64 is not allowed by
* the X11 protocol .
*/
typedef CARD32 Atom32 ;
/*
* Respond to a request for our current selection
* EXT : SelectionRequest
*/
void
selection_send ( XSelectionRequestEvent * rq )
{
2002-05-04 07:25:30 -07:00
XEvent ev ;
Atom32 target_list [ 2 ] ;
ev . xselection . type = SelectionNotify ;
ev . xselection . property = None ;
ev . xselection . display = rq - > display ;
ev . xselection . requestor = rq - > requestor ;
ev . xselection . selection = rq - > selection ;
ev . xselection . target = rq - > target ;
ev . xselection . time = rq - > time ;
if ( rq - > target = = props [ PROP_SELECTION_TARGETS ] ) {
target_list [ 0 ] = ( Atom32 ) props [ PROP_SELECTION_TARGETS ] ;
target_list [ 1 ] = ( Atom32 ) XA_STRING ;
XChangeProperty ( Xdisplay , rq - > requestor , rq - > property , rq - > target ,
2002-06-02 17:24:22 -07:00
( 8 * sizeof ( target_list [ 0 ] ) ) , PropModeReplace , ( unsigned char * ) target_list , ( sizeof ( target_list ) / sizeof ( target_list [ 0 ] ) ) ) ;
2002-05-04 07:25:30 -07:00
ev . xselection . property = rq - > property ;
2000-07-05 19:32:08 -07:00
# if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
2002-05-04 07:25:30 -07:00
} else if ( rq - > target = = XA_TEXT ( Xdisplay ) | | rq - > target = = XA_COMPOUND_TEXT ( Xdisplay ) ) {
XTextProperty xtextp ;
char * l [ 1 ] ;
* l = selection . text ;
xtextp . value = NULL ;
xtextp . nitems = 0 ;
if ( XmbTextListToTextProperty ( Xdisplay , l , 1 , XCompoundTextStyle , & xtextp ) = = Success ) {
if ( xtextp . nitems > 0 & & xtextp . value ! = NULL ) {
2002-06-02 17:24:22 -07:00
XChangeProperty ( Xdisplay , rq - > requestor , rq - > property , XA_COMPOUND_TEXT ( Xdisplay ) , 8 , PropModeReplace , xtextp . value , xtextp . nitems ) ;
2002-05-04 07:25:30 -07:00
ev . xselection . property = rq - > property ;
}
}
# endif
} else if ( rq - > target = = XA_STRING ) {
XChangeProperty ( Xdisplay , rq - > requestor , rq - > property , rq - > target , 8 , PropModeReplace , selection . text , selection . len ) ;
2000-03-01 19:31:41 -08:00
ev . xselection . property = rq - > property ;
}
2002-05-04 07:25:30 -07:00
XSendEvent ( Xdisplay , rq - > requestor , False , 0 , & ev ) ;
1999-08-17 16:01:18 -07:00
}
2002-06-02 17:24:22 -07:00
void /* drag report as used by the "twin" program */
2003-02-19 08:42:27 -08:00
twin_mouse_drag_report ( XButtonEvent * ev )
2002-06-02 17:24:22 -07:00
{
int button_number , key_state , x = Pixel2Col ( ev - > x ) , y = Pixel2Row ( ev - > y ) ;
switch ( ev - > button ) {
case AnyButton : /* Button release */
2002-06-08 08:44:08 -07:00
button_number = pb + Button1 ; /* yeah, yeah */
2002-06-02 17:24:22 -07:00
break ;
case Button1 : /* Button press */
case Button2 :
case Button3 :
pb = button_number = ev - > button - Button1 ;
break ;
default : /* Wheel mouse */
button_number = 64 + ev - > button - Button3 - 1 ;
break ;
}
key_state = ( ( ev - > state & ( ShiftMask | ControlMask ) )
+ ( ( ev - > state & Mod1Mask ) ? 2 : 0 ) ) ;
tt_printf ( ( unsigned char * ) " \033 [5M%c%c%c%c%c " ,
( 32 + button_number + ( key_state < < 2 ) ) , ( 32 + ( x & 0x7f ) + 1 ) , ( 32 + ( ( x > > 7 ) & 0x7f ) + 1 ) , ( 32 + ( y & 0x7f ) + 1 ) , ( 32 + ( ( y > > 7 ) & 0x7f ) + 1 ) ) ;
}
1999-08-17 16:01:18 -07:00
void
mouse_report ( XButtonEvent * ev )
{
2002-05-04 07:25:30 -07:00
int button_number , key_state ;
switch ( ev - > button ) {
case AnyButton : /* Button release */
button_number = 3 ;
break ;
case Button1 : /* Button press */
case Button2 :
case Button3 :
2002-06-02 17:24:22 -07:00
pb = button_number = ev - > button - Button1 ;
2002-05-04 07:25:30 -07:00
break ;
default : /* Wheel mouse */
button_number = 64 + ev - > button - Button3 - 1 ;
break ;
}
key_state = ( ( ev - > state & ( ShiftMask | ControlMask ) )
+ ( ( ev - > state & Mod1Mask ) ? 2 : 0 ) ) ;
2002-06-02 17:24:22 -07:00
tt_printf ( ( unsigned char * ) " \033 [M%c%c%c " , ( 32 + button_number + ( key_state < < 2 ) ) , ( 32 + Pixel2Col ( ev - > x ) + 1 ) , ( 32 + Pixel2Row ( ev - > y ) + 1 ) ) ;
1999-08-17 16:01:18 -07:00
}
void
debug_colors ( void )
{
2002-05-04 07:25:30 -07:00
int color ;
char * name [ ] = {
" fg " , " bg " ,
" black " , " red " , " green " , " yellow " , " blue " , " magenta " , " cyan " , " white "
} ;
fprintf ( stderr , " Color ( " ) ;
if ( rstyle & RS_RVid )
fprintf ( stderr , " rvid " ) ;
if ( rstyle & RS_Bold )
fprintf ( stderr , " bold " ) ;
if ( rstyle & RS_Blink )
fprintf ( stderr , " blink " ) ;
if ( rstyle & RS_Uline )
fprintf ( stderr , " uline " ) ;
fprintf ( stderr , " ): " ) ;
color = GET_FGCOLOR ( rstyle ) ;
1999-08-17 16:01:18 -07:00
# ifndef NO_BRIGHTCOLOR
2002-05-04 07:25:30 -07:00
if ( color > = minBright & & color < = maxBright ) {
color - = ( minBright - minColor ) ;
fprintf ( stderr , " bright " ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
fprintf ( stderr , " %s on " , name [ color ] ) ;
1999-08-17 16:01:18 -07:00
2002-05-04 07:25:30 -07:00
color = GET_BGCOLOR ( rstyle ) ;
1999-08-17 16:01:18 -07:00
# ifndef NO_BRIGHTCOLOR
2002-05-04 07:25:30 -07:00
if ( color > = minBright & & color < = maxBright ) {
color - = ( minBright - minColor ) ;
fprintf ( stderr , " bright " ) ;
}
1999-08-17 16:01:18 -07:00
# endif
2002-05-04 07:25:30 -07:00
fprintf ( stderr , " %s \n " , name [ color ] ) ;
1999-08-17 16:01:18 -07:00
}
1999-08-17 18:12:47 -07:00
# ifdef USE_XIM
2002-05-04 07:25:30 -07:00
void
xim_get_position ( XPoint * pos )
1999-08-17 18:12:47 -07:00
{
2002-05-04 07:25:30 -07:00
pos - > x = Col2Pixel ( screen . col ) ;
2003-08-24 08:09:32 -07:00
if ( scrollbar_is_visible ( ) & & ! ( BITFIELD_IS_SET ( eterm_options , ETERM_OPTIONS_SCROLLBAR_RIGHT ) ) ) {
2002-05-04 07:25:30 -07:00
pos - > x + = scrollbar_trough_width ( ) ;
}
pos - > y = ( Height2Pixel ( screen . row )
2000-06-28 13:57:52 -07:00
# ifdef MULTI_CHARSET
2002-05-04 07:25:30 -07:00
+ MAX ( ( encoding_method = = LATIN1 ? 0 : TermWin . mfont - > ascent ) , TermWin . font - > ascent )
2000-06-28 13:57:52 -07:00
# else
2002-05-04 07:25:30 -07:00
+ TermWin . font - > ascent
2000-06-28 13:57:52 -07:00
# endif
2002-05-04 07:25:30 -07:00
+ TermWin . internalBorder + bbar_calc_docked_height ( BBAR_DOCKED_TOP ) ) ;
}
# endif
# ifdef ESCREEN
2002-06-02 17:24:22 -07:00
# ifdef NS_HAVE_SCREEN
2002-05-04 07:25:30 -07:00
void
parse_screen_status_if_necessary ( void )
{
2002-10-07 19:18:09 -07:00
ns_parse_screen ( TermWin . screen , ( TermWin . screen_pending > 1 ) ,
TERM_WINDOW_GET_REPORTED_COLS ( ) , screen . text [ TERM_WINDOW_GET_REPORTED_ROWS ( ) + TermWin . saveLines - 1 ] ) ;
2002-05-04 07:25:30 -07:00
if ( TermWin . screen_pending > 1 )
TermWin . screen_pending = 0 ;
1999-08-17 18:12:47 -07:00
}
2002-06-02 17:24:22 -07:00
# endif
1999-08-17 18:12:47 -07:00
# endif