summaryrefslogtreecommitdiff
path: root/src/terminal-screen.h
blob: c5cdb5daa3a617ba0bab3cd421e4cf3f9a525705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright © 2001 Havoc Pennington
 * Copyright © 2008 Christian Persch
 * Copyright (C) 2012-2021 MATE Developers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef TERMINAL_SCREEN_H
#define TERMINAL_SCREEN_H

#include <vte/vte.h>

#include "terminal-profile.h"

G_BEGIN_DECLS

typedef enum
{
    FLAVOR_AS_IS,
    FLAVOR_DEFAULT_TO_HTTP,
    FLAVOR_VOIP_CALL,
    FLAVOR_EMAIL,
    FLAVOR_SKEY
} TerminalURLFlavor;

/* Forward decls */
typedef struct _TerminalScreenPopupInfo TerminalScreenPopupInfo;
typedef struct _TerminalWindow        TerminalWindow;

#define TERMINAL_TYPE_SCREEN              (terminal_screen_get_type ())
#define TERMINAL_SCREEN(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), TERMINAL_TYPE_SCREEN, TerminalScreen))
#define TERMINAL_SCREEN_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_SCREEN, TerminalScreenClass))
#define TERMINAL_IS_SCREEN(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), TERMINAL_TYPE_SCREEN))
#define TERMINAL_IS_SCREEN_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_SCREEN))
#define TERMINAL_SCREEN_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_SCREEN, TerminalScreenClass))

typedef struct _TerminalScreen        TerminalScreen;
typedef struct _TerminalScreenClass   TerminalScreenClass;
typedef struct _TerminalScreenPrivate TerminalScreenPrivate;

struct _TerminalScreen
{
	VteTerminal parent_instance;

	TerminalScreenPrivate *priv;
};

struct _TerminalScreenClass
{
	VteTerminalClass parent_class;

	void (* profile_set)        (TerminalScreen *screen,
	                             TerminalProfile *old_profile);
	void (* show_popup_menu)    (TerminalScreen *screen,
	                             TerminalScreenPopupInfo *info);
	gboolean (* match_clicked)  (TerminalScreen *screen,
	                             const char *url,
	                             int url_flavor,
	                             guint state);
	void (* close_screen)       (TerminalScreen *screen);
};

GType terminal_screen_get_type (void) G_GNUC_CONST;

TerminalScreen *terminal_screen_new (TerminalProfile *profile,
                                     char           **override_command,
                                     const char      *title,
                                     const char      *working_dir,
                                     char           **child_env,
                                     double           zoom);

void terminal_screen_set_profile (TerminalScreen *screen,
                                  TerminalProfile *profile);
TerminalProfile* terminal_screen_get_profile (TerminalScreen *screen);

void         terminal_screen_set_override_command (TerminalScreen  *screen,
        char           **argv);
const char** terminal_screen_get_override_command (TerminalScreen  *screen);

void         terminal_screen_set_initial_environment (TerminalScreen  *screen,
        char           **argv);
char **      terminal_screen_get_initial_environment (TerminalScreen  *screen);

const char* terminal_screen_get_raw_title      (TerminalScreen *screen);
const char* terminal_screen_get_title          (TerminalScreen *screen);
const char* terminal_screen_get_icon_title     (TerminalScreen *screen);
gboolean    terminal_screen_get_icon_title_set (TerminalScreen *screen);

void terminal_screen_set_user_title (TerminalScreen *screen,
                                     const char *text);

void        terminal_screen_set_override_title     (TerminalScreen *screen,
        const char     *title);

const char *terminal_screen_get_dynamic_title      (TerminalScreen *screen);
const char *terminal_screen_get_dynamic_icon_title (TerminalScreen *screen);

char *terminal_screen_get_current_dir (TerminalScreen *screen);
char *terminal_screen_get_current_dir_with_fallback (TerminalScreen *screen);

void        terminal_screen_set_font (TerminalScreen *screen);
void        terminal_screen_set_font_scale    (TerminalScreen *screen,
        double          factor);
double      terminal_screen_get_font_scale    (TerminalScreen *screen);

void       terminal_screen_get_size (TerminalScreen *screen,
                                     int *width_chars,
                                     int *height_chars);
void       terminal_screen_get_cell_size (TerminalScreen *screen,
        int *width_chars,
        int *height_chars);

void _terminal_screen_update_scrollbar (TerminalScreen *screen);

void terminal_screen_save_config (TerminalScreen *screen,
                                  GKeyFile *key_file,
                                  const char *group);

gboolean terminal_screen_has_foreground_process (TerminalScreen *screen);

/* Allow scales a bit smaller and a bit larger than the usual pango ranges */
#define TERMINAL_SCALE_XXX_SMALL   (PANGO_SCALE_XX_SMALL/1.2)
#define TERMINAL_SCALE_XXXX_SMALL  (TERMINAL_SCALE_XXX_SMALL/1.2)
#define TERMINAL_SCALE_XXXXX_SMALL (TERMINAL_SCALE_XXXX_SMALL/1.2)
#define TERMINAL_SCALE_XXX_LARGE   (PANGO_SCALE_XX_LARGE*1.2)
#define TERMINAL_SCALE_XXXX_LARGE  (TERMINAL_SCALE_XXX_LARGE*1.2)
#define TERMINAL_SCALE_XXXXX_LARGE (TERMINAL_SCALE_XXXX_LARGE*1.2)
#define TERMINAL_SCALE_MINIMUM     (TERMINAL_SCALE_XXXXX_SMALL/1.2)
#define TERMINAL_SCALE_MAXIMUM     (TERMINAL_SCALE_XXXXX_LARGE*1.2)

struct _TerminalScreenPopupInfo
{
	int ref_count;
	TerminalWindow *window;
	TerminalScreen *screen;
	char *url;
	TerminalURLFlavor flavor;
	guint button;
	guint state;
	guint32 timestamp;
};

TerminalScreenPopupInfo *terminal_screen_popup_info_ref (TerminalScreenPopupInfo *info);

void terminal_screen_popup_info_unref (TerminalScreenPopupInfo *info);

G_END_DECLS

#endif /* TERMINAL_SCREEN_H */