2005-06-22 11:20:32 -07:00
|
|
|
/*
|
|
|
|
* mooterm/mootermbuffer-private.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOOTERM_MOOTERMBUFFER_PRIVATE_H
|
|
|
|
#define MOOTERM_MOOTERMBUFFER_PRIVATE_H
|
|
|
|
|
|
|
|
#ifndef MOOTERM_COMPILATION
|
|
|
|
#error "This file may not be included directly"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gdk/gdkregion.h>
|
|
|
|
#include "mooterm/mootermbuffer.h"
|
|
|
|
#include "mooterm/mootermline.h"
|
2005-07-10 19:54:58 -07:00
|
|
|
#include "mooterm/mooterm-vt.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2005-07-04 12:22:02 -07:00
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
struct _MooTermBufferPrivate {
|
|
|
|
gboolean constructed;
|
|
|
|
|
2005-07-06 09:39:02 -07:00
|
|
|
GPtrArray *lines; /* array of MooTermLine* */
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
guint8 modes[MODE_MAX];
|
2005-06-22 11:20:32 -07:00
|
|
|
MooTermTextAttr current_attr;
|
|
|
|
gboolean cursor_visible;
|
|
|
|
|
2005-07-06 11:48:09 -07:00
|
|
|
int single_shift;
|
|
|
|
gunichar *graph_sets[4];
|
|
|
|
gunichar *current_graph_set;
|
|
|
|
gboolean use_ascii_graphics;
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
/* these are real position and
|
|
|
|
dimensions of the screen */
|
|
|
|
guint _screen_offset;
|
2005-07-06 09:39:02 -07:00
|
|
|
guint screen_width;
|
|
|
|
guint screen_height;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-04 12:22:02 -07:00
|
|
|
/* scrolling region - top and bottom rows */
|
2005-07-06 09:39:02 -07:00
|
|
|
guint top_margin;
|
|
|
|
guint bottom_margin;
|
2005-07-04 12:22:02 -07:00
|
|
|
gboolean scrolling_region_set;
|
|
|
|
|
|
|
|
/* always absolute */
|
2005-07-06 09:39:02 -07:00
|
|
|
guint cursor_row;
|
|
|
|
guint cursor_col;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-06 09:39:02 -07:00
|
|
|
GList *tab_stops;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GdkRegion *changed;
|
2005-06-23 06:50:25 -07:00
|
|
|
gboolean changed_all;
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
gboolean freeze_changed_notify;
|
|
|
|
gboolean freeze_cursor_notify;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
void moo_term_buffer_changed_clear (MooTermBuffer *buf);
|
|
|
|
|
|
|
|
void moo_term_buffer_changed (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_scrollback_changed (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_cursor_moved (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_feed_child (MooTermBuffer *buf,
|
|
|
|
const char *string,
|
|
|
|
int len);
|
|
|
|
|
|
|
|
void moo_term_buffer_freeze_changed_notify (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_freeze_cursor_notify (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_thaw_changed_notify (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_thaw_cursor_notify (MooTermBuffer *buf);
|
|
|
|
|
|
|
|
void moo_term_buffer_set_mode (MooTermBuffer *buf,
|
|
|
|
int mode,
|
|
|
|
gboolean val);
|
|
|
|
|
|
|
|
void moo_term_buffer_set_screen_width (MooTermBuffer *buf,
|
|
|
|
guint columns);
|
|
|
|
void moo_term_buffer_set_screen_height (MooTermBuffer *buf,
|
|
|
|
guint rows);
|
|
|
|
void moo_term_buffer_set_screen_size (MooTermBuffer *buf,
|
|
|
|
guint columns,
|
|
|
|
guint rows);
|
|
|
|
|
|
|
|
void moo_term_buffer_cursor_move (MooTermBuffer *buf,
|
|
|
|
int rows,
|
|
|
|
int cols);
|
|
|
|
void moo_term_buffer_cursor_move_to (MooTermBuffer *buf,
|
|
|
|
int row,
|
|
|
|
int col);
|
|
|
|
|
|
|
|
void moo_term_buffer_reset_tab_stops (MooTermBuffer *buf);
|
|
|
|
guint moo_term_buffer_next_tab_stop (MooTermBuffer *buf,
|
|
|
|
guint current);
|
|
|
|
guint moo_term_buffer_prev_tab_stop (MooTermBuffer *buf,
|
|
|
|
guint current);
|
|
|
|
void moo_term_buffer_clear_tab_stop (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_set_tab_stop (MooTermBuffer *buf);
|
|
|
|
|
|
|
|
void moo_term_buffer_select_charset (MooTermBuffer *buf,
|
|
|
|
guint set_num,
|
|
|
|
guint charset);
|
|
|
|
void moo_term_buffer_shift (MooTermBuffer *buf,
|
|
|
|
guint set);
|
|
|
|
void moo_term_buffer_single_shift (MooTermBuffer *buf,
|
|
|
|
guint set);
|
|
|
|
|
|
|
|
void moo_term_buffer_set_scrolling_region (MooTermBuffer *buf,
|
|
|
|
guint top_margin,
|
|
|
|
guint bottom_margin);
|
|
|
|
|
|
|
|
|
|
|
|
inline static guint buf_scrollback (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
if (buf_get_mode (MODE_CA))
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return buf->priv->_screen_offset;
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_total_height (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
return buf_scrollback (buf) + buf->priv->screen_height;
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_screen_width (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
return buf->priv->screen_width;
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_screen_height (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
return buf->priv->screen_height;
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_cursor_row (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
return buf->priv->cursor_row;
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_cursor_row_abs (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
return buf->priv->cursor_row + buf_scrollback (buf);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static guint buf_cursor_col (MooTermBuffer *buf)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
|
|
|
return buf->priv->cursor_col;
|
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static GdkRegion *buf_get_changed(MooTermBuffer *buf)
|
2005-06-23 06:50:25 -07:00
|
|
|
{
|
|
|
|
return buf->priv->changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_changed_add_rect(rect) \
|
|
|
|
{ \
|
|
|
|
if (!buf->priv->changed_all) \
|
|
|
|
{ \
|
|
|
|
if (buf->priv->changed) \
|
|
|
|
gdk_region_union_with_rect (buf->priv->changed, &rect); \
|
|
|
|
else \
|
|
|
|
buf->priv->changed = gdk_region_rectangle (&rect); \
|
|
|
|
} \
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_changed_add_range(row, start, len) \
|
|
|
|
{ \
|
|
|
|
if (!buf->priv->changed_all) \
|
|
|
|
{ \
|
|
|
|
GdkRectangle rec = {start, row, len, 1}; \
|
|
|
|
buf_changed_add_rect (rec); \
|
|
|
|
} \
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_changed_set_all() \
|
|
|
|
{ \
|
|
|
|
if (!buf->priv->changed_all) \
|
|
|
|
{ \
|
|
|
|
GdkRectangle rec = { \
|
|
|
|
0, 0, buf->priv->screen_width, buf->priv->screen_height \
|
|
|
|
}; \
|
|
|
|
buf_changed_add_rect (rec); \
|
|
|
|
buf->priv->changed_all = TRUE; \
|
|
|
|
} \
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_set_attrs_mask(mask_) buf->priv->current_attr.mask = (mask_)
|
|
|
|
#define buf_add_attrs_mask(mask_) buf->priv->current_attr.mask |= (mask_)
|
|
|
|
#define buf_remove_attrs_mask(mask_) buf->priv->current_attr.mask &= ~(mask_)
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_set_ansi_foreground(color) \
|
|
|
|
if ((color) < MOO_TERM_COLOR_MAX) \
|
|
|
|
{ \
|
|
|
|
buf->priv->current_attr.mask |= MOO_TERM_TEXT_FOREGROUND; \
|
|
|
|
buf->priv->current_attr.foreground = (color); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
buf->priv->current_attr.mask &= ~MOO_TERM_TEXT_FOREGROUND; \
|
|
|
|
}
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define buf_set_ansi_background(color) \
|
|
|
|
if ((color) < MOO_TERM_COLOR_MAX) \
|
|
|
|
{ \
|
|
|
|
buf->priv->current_attr.mask |= MOO_TERM_TEXT_BACKGROUND; \
|
|
|
|
buf->priv->current_attr.background = (color); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
buf->priv->current_attr.mask &= ~MOO_TERM_TEXT_BACKGROUND; \
|
|
|
|
}
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static MooTermLine *buf_line (MooTermBuffer *buf,
|
|
|
|
guint n)
|
2005-07-04 12:22:02 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
if (buf_get_mode (MODE_CA))
|
2005-07-04 12:22:02 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
g_assert (n < buf->priv->screen_height);
|
|
|
|
return g_ptr_array_index (buf->priv->lines,
|
|
|
|
n + buf->priv->_screen_offset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert (n < buf->priv->_screen_offset + buf->priv->screen_height);
|
|
|
|
return g_ptr_array_index (buf->priv->lines, n);
|
2005-07-04 12:22:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
inline static MooTermLine *buf_screen_line (MooTermBuffer *buf,
|
|
|
|
guint n)
|
2005-07-04 12:22:02 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
g_assert (n < buf->priv->screen_height);
|
2005-07-06 09:39:02 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
return g_ptr_array_index (buf->priv->lines,
|
|
|
|
n + buf->priv->_screen_offset);
|
2005-07-04 12:22:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Terminal stuff
|
|
|
|
*/
|
|
|
|
|
|
|
|
void moo_term_buffer_new_line (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_index (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_backspace (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_tab (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_linefeed (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_carriage_return (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_reverse_index (MooTermBuffer *buf);
|
|
|
|
void moo_term_buffer_sgr (MooTermBuffer *buf,
|
|
|
|
int *args,
|
|
|
|
guint args_len);
|
|
|
|
void moo_term_buffer_delete_char (MooTermBuffer *buf,
|
|
|
|
guint n);
|
|
|
|
// void moo_term_buffer_delete_line (MooTermBuffer *buf,
|
|
|
|
// guint n);
|
|
|
|
void moo_term_buffer_erase_char (MooTermBuffer *buf,
|
|
|
|
guint n);
|
|
|
|
void moo_term_buffer_erase_in_display (MooTermBuffer *buf,
|
|
|
|
guint what);
|
|
|
|
void moo_term_buffer_erase_in_line (MooTermBuffer *buf,
|
|
|
|
guint what);
|
|
|
|
void moo_term_buffer_insert_char (MooTermBuffer *buf,
|
|
|
|
guint n);
|
|
|
|
// void moo_term_buffer_insert_line (MooTermBuffer *buf,
|
|
|
|
// guint n);
|
|
|
|
|
|
|
|
void moo_term_buffer_erase_range (MooTermBuffer *buf,
|
|
|
|
guint row,
|
|
|
|
guint col,
|
|
|
|
guint len);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* MOOTERM_MOOTERMBUFFER_PRIVATE_H */
|