2005-06-22 11:20:32 -07:00
|
|
|
/*
|
2005-07-07 04:06:23 -07:00
|
|
|
* mooterm/mooterm-private.h
|
2005-06-22 11:20:32 -07:00
|
|
|
*
|
|
|
|
* 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.
|
2005-06-23 13:18:45 -07:00
|
|
|
*/
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
#ifndef MOOTERM_MOOTERM_PRIVATE_H
|
|
|
|
#define MOOTERM_MOOTERM_PRIVATE_H
|
|
|
|
|
|
|
|
#include "mooterm/mooterm.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-12 07:23:08 -07:00
|
|
|
#if 0
|
|
|
|
#define term_implement_me_warning g_warning
|
|
|
|
#else
|
|
|
|
#define term_implement_me_warning g_message
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define term_implement_me() term_implement_me_warning ("%s: implement me", G_STRFUNC)
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define ADJUSTMENT_PRIORITY G_PRIORITY_HIGH_IDLE
|
|
|
|
#define ADJUSTMENT_DELTA 30.0
|
|
|
|
#define EXPOSE_PRIORITY G_PRIORITY_DEFAULT
|
|
|
|
#define EXPOSE_TIMEOUT 2
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define PT_WRITER_PRIORITY G_PRIORITY_DEFAULT
|
|
|
|
#define PT_READER_PRIORITY G_PRIORITY_DEFAULT
|
2005-07-01 02:53:39 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define MIN_TERMINAL_WIDTH 10
|
|
|
|
#define MIN_TERMINAL_HEIGHT 10
|
2005-06-22 11:20:32 -07:00
|
|
|
#define MAX_TERMINAL_WIDTH 4096
|
2005-07-10 19:54:58 -07:00
|
|
|
|
2005-07-01 02:53:39 -07:00
|
|
|
#define DEFAULT_MONOSPACE_FONT "Courier New 9"
|
2005-06-22 11:20:32 -07:00
|
|
|
#define DEFAULT_MONOSPACE_FONT2 "Monospace"
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CURSOR_NONE = 0,
|
|
|
|
CURSOR_TEXT = 1,
|
|
|
|
CURSOR_POINTER = 2,
|
|
|
|
CURSORS_NUM = 3
|
|
|
|
} TermCursorType;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NORMAL = 0,
|
|
|
|
SELECTED = 1,
|
|
|
|
CURSOR = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CARET_BLOCK,
|
|
|
|
CARET_UNDERLINE
|
|
|
|
} TermCaretShape;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _TermFontInfo TermFontInfo;
|
2005-07-10 19:54:58 -07:00
|
|
|
typedef struct _TermSelection TermSelection;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
|
|
|
struct _MooTermPrivate {
|
2005-07-10 19:54:58 -07:00
|
|
|
struct _MooTermPt *pt;
|
|
|
|
struct _MooTermParser *parser;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
struct _MooTermBuffer *buffer;
|
|
|
|
struct _MooTermBuffer *primary_buffer;
|
|
|
|
struct _MooTermBuffer *alternate_buffer;
|
2005-07-06 16:41:14 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
guint8 modes[MODE_MAX];
|
|
|
|
guint8 saved_modes[MODE_MAX];
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
gboolean _scrolled;
|
|
|
|
guint _top_line;
|
|
|
|
guint width;
|
|
|
|
guint height;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
guint cursor_row;
|
|
|
|
guint cursor_col;
|
2005-07-01 02:53:39 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
TermSelection *selection;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
TermFontInfo *font_info;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GdkPixmap *back_pixmap;
|
|
|
|
GdkRegion *changed_content; /* buffer coordinates, relative to top_line */
|
|
|
|
GdkGC *clip;
|
|
|
|
gboolean font_changed;
|
|
|
|
PangoLayout *layout;
|
|
|
|
gboolean cursor_visible;
|
|
|
|
guint pending_expose;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GdkGC *fg[MOO_TERM_COLOR_MAX + 1][3];
|
|
|
|
GdkGC *bg[MOO_TERM_COLOR_MAX + 1][3];
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
TermCaretShape caret_shape;
|
|
|
|
guint caret_height;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GdkCursor *cursor[CURSORS_NUM];
|
|
|
|
GtkIMContext *im;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
gboolean scroll_on_keystroke;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
guint pending_adjustment_changed;
|
|
|
|
guint pending_adjustment_value_changed;
|
|
|
|
};
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
void moo_term_set_window_title (MooTerm *term,
|
|
|
|
const char *title);
|
|
|
|
void moo_term_set_icon_name (MooTerm *term,
|
|
|
|
const char *title);
|
|
|
|
|
|
|
|
void moo_term_set_alternate_buffer (MooTerm *term,
|
|
|
|
gboolean alternate);
|
|
|
|
|
|
|
|
void moo_term_buf_content_changed (MooTerm *term,
|
|
|
|
MooTermBuffer *buf);
|
|
|
|
void moo_term_cursor_moved (MooTerm *term,
|
|
|
|
MooTermBuffer *buf);
|
|
|
|
|
|
|
|
void moo_term_size_changed (MooTerm *term);
|
|
|
|
void moo_term_buf_size_changed (MooTerm *term);
|
|
|
|
|
|
|
|
void moo_term_init_font_stuff (MooTerm *term);
|
|
|
|
void moo_term_setup_palette (MooTerm *term);
|
|
|
|
void moo_term_im_commit (GtkIMContext *imcontext,
|
|
|
|
gchar *arg,
|
|
|
|
MooTerm *term);
|
|
|
|
|
|
|
|
gboolean moo_term_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
gboolean moo_term_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
gboolean moo_term_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *event);
|
|
|
|
gboolean moo_term_key_release (GtkWidget *widget,
|
|
|
|
GdkEventKey *event);
|
2005-07-01 02:53:39 -07:00
|
|
|
|
2005-07-06 16:41:14 -07:00
|
|
|
void moo_term_init_back_pixmap (MooTerm *term);
|
|
|
|
void moo_term_resize_back_pixmap (MooTerm *term);
|
|
|
|
void moo_term_update_back_pixmap (MooTerm *term);
|
|
|
|
void moo_term_invalidate_content_all (MooTerm *term);
|
|
|
|
void moo_term_invalidate_content_rect(MooTerm *term,
|
|
|
|
GdkRectangle *rect);
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
gboolean moo_term_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
|
|
|
void moo_term_invalidate_rect (MooTerm *term,
|
|
|
|
GdkRectangle *rect);
|
|
|
|
void moo_term_force_update (MooTerm *term);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
inline static void moo_term_invalidate_all (MooTerm *term)
|
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
GdkRectangle rec = {0, 0, term->priv->width, term->priv->height};
|
2005-06-22 11:20:32 -07:00
|
|
|
moo_term_invalidate_rect (term, &rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
/*************************************************************************/
|
|
|
|
/* vt commands
|
|
|
|
*/
|
|
|
|
|
|
|
|
void moo_term_bell (MooTerm *term);
|
|
|
|
void moo_term_decid (MooTerm *term);
|
2005-07-12 07:23:08 -07:00
|
|
|
void moo_term_set_dec_modes (MooTerm *term,
|
|
|
|
int *modes,
|
|
|
|
guint n_modes,
|
|
|
|
gboolean set);
|
|
|
|
void moo_term_save_dec_modes (MooTerm *term,
|
|
|
|
int *modes,
|
|
|
|
guint n_modes);
|
|
|
|
void moo_term_restore_dec_modes (MooTerm *term,
|
|
|
|
int *modes,
|
|
|
|
guint n_modes);
|
|
|
|
void moo_term_set_ansi_modes (MooTerm *term,
|
|
|
|
int *modes,
|
|
|
|
guint n_modes,
|
|
|
|
gboolean set);
|
|
|
|
void moo_term_set_mode (MooTerm *term,
|
|
|
|
int mode,
|
|
|
|
gboolean set);
|
|
|
|
void moo_term_set_ca_mode (MooTerm *term,
|
|
|
|
gboolean set);
|
|
|
|
/* these two are in mootermdraw.c */
|
|
|
|
void moo_term_invert_colors (MooTerm *term,
|
|
|
|
gboolean invert);
|
|
|
|
void moo_term_set_caret_visible (MooTerm *term,
|
|
|
|
gboolean visible);
|
|
|
|
/* this one is in mooterminput.c, tracking_type == -1 means turn it off */
|
|
|
|
void moo_term_set_mouse_tracking (MooTerm *term,
|
|
|
|
int tracking_type);
|
|
|
|
|
|
|
|
void moo_term_da1 (MooTerm *term);
|
|
|
|
void moo_term_da2 (MooTerm *term);
|
|
|
|
void moo_term_da3 (MooTerm *term);
|
2005-07-10 19:54:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* font info
|
|
|
|
*/
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
struct _TermFontInfo {
|
|
|
|
PangoContext *ctx;
|
|
|
|
guint width;
|
|
|
|
guint height;
|
|
|
|
guint ascent;
|
|
|
|
};
|
|
|
|
|
|
|
|
void term_font_info_calculate (TermFontInfo *info);
|
|
|
|
void term_font_info_set_font (TermFontInfo *info,
|
|
|
|
PangoFontDescription *font_desc);
|
|
|
|
TermFontInfo *term_font_info_new (PangoContext *ctx);
|
|
|
|
void term_font_info_free (TermFontInfo *info);
|
|
|
|
|
|
|
|
|
2005-07-10 19:54:58 -07:00
|
|
|
#define term_top_line(term) \
|
|
|
|
((term)->priv->_scrolled ? \
|
|
|
|
(term)->priv->_top_line : \
|
|
|
|
buf_scrollback ((term)->priv->buffer))
|
|
|
|
|
|
|
|
|
2005-07-01 02:53:39 -07:00
|
|
|
/*************************************************************************/
|
|
|
|
/* TermSelection
|
|
|
|
*/
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
enum {
|
|
|
|
NOT_SELECTED = 0,
|
|
|
|
FULL_SELECTED = 1,
|
|
|
|
PART_SELECTED = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SELECT_SCROLL_NONE (0)
|
|
|
|
#define SELECT_SCROLL_UP (-1)
|
|
|
|
#define SELECT_SCROLL_DOWN (1)
|
|
|
|
|
|
|
|
struct _TermSelection {
|
2005-07-06 09:39:02 -07:00
|
|
|
guint screen_width;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
// absolute coordinates in the buffer
|
|
|
|
// selected range is [(l_row, l_col), (r_row, r_col))
|
|
|
|
// l_row, l_col and r_row are valid
|
|
|
|
// r_col may be equal to _width
|
2005-07-06 09:39:02 -07:00
|
|
|
guint l_row;
|
|
|
|
guint l_col;
|
|
|
|
guint r_row;
|
|
|
|
guint r_col;
|
2005-06-22 11:20:32 -07:00
|
|
|
gboolean empty;
|
|
|
|
|
|
|
|
gboolean button_pressed;
|
|
|
|
int click;
|
|
|
|
gboolean drag;
|
|
|
|
// buffer coordinates
|
2005-07-06 09:39:02 -07:00
|
|
|
guint drag_begin_row;
|
|
|
|
guint drag_begin_col;
|
|
|
|
guint drag_end_row;
|
|
|
|
guint drag_end_col;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
int scroll;
|
|
|
|
guint st_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TermSelection *term_selection_new (void);
|
|
|
|
inline static void term_selection_free (TermSelection *sel)
|
|
|
|
{
|
|
|
|
g_free (sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void term_set_selection (MooTerm *term,
|
2005-07-06 09:39:02 -07:00
|
|
|
guint row1,
|
|
|
|
guint col1,
|
|
|
|
guint row2,
|
|
|
|
guint col2);
|
2005-06-22 11:20:32 -07:00
|
|
|
void term_selection_clear (MooTerm *term);
|
|
|
|
|
|
|
|
inline static void term_selection_set_width (MooTerm *term,
|
2005-07-06 09:39:02 -07:00
|
|
|
guint width)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
|
|
|
term->priv->selection->screen_width = width;
|
|
|
|
term_selection_clear (term);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static int term_selection_row_selected (TermSelection *sel,
|
2005-07-06 09:39:02 -07:00
|
|
|
guint row)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
|
|
|
if (sel->empty || sel->r_row < row || row < sel->l_row)
|
|
|
|
return NOT_SELECTED;
|
|
|
|
else if (sel->l_row < row && row < sel->r_row)
|
|
|
|
return FULL_SELECTED;
|
|
|
|
else
|
|
|
|
return PART_SELECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static gboolean term_selected (TermSelection *sel,
|
2005-07-06 09:39:02 -07:00
|
|
|
guint row,
|
|
|
|
guint col)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
|
|
|
if (sel->empty || sel->r_row < row || row < sel->l_row)
|
|
|
|
return FALSE;
|
|
|
|
else if (sel->l_row < row && row < sel->r_row)
|
|
|
|
return TRUE;
|
|
|
|
else if (sel->l_row == sel->r_row)
|
|
|
|
return sel->l_col <= col && col < sel->r_col;
|
|
|
|
else if (sel->l_row == row)
|
|
|
|
return sel->l_col <= col;
|
|
|
|
else
|
|
|
|
return col < sel->r_row;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* MOOTERM_MOOTERM_PRIVATE_H */
|