Improve drag select (dragging outside LHS doesn't now select first
[u/mdw/putty] / putty.h
CommitLineData
374330e2 1#ifndef PUTTY_PUTTY_H
2#define PUTTY_PUTTY_H
3
4#define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
5
6/*
7 * Global variables. Most modules declare these `extern', but
8 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
9 * module, and so will get them properly defined.
10 */
11#ifdef PUTTY_DO_GLOBALS
12#define GLOBAL
13#else
14#define GLOBAL extern
15#endif
16
17#define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */
18#define ATTR_PASCURS 0x40000000UL /* passive cursor (box) */
19#define ATTR_INVALID 0x20000000UL
20#define ATTR_WRAPPED 0x10000000UL
21
22#define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
23#define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
24#define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
25
26#define ATTR_BOLD 0x00000100UL
27#define ATTR_UNDER 0x00000200UL
28#define ATTR_REVERSE 0x00000400UL
29#define ATTR_FGMASK 0x0000F000UL
30#define ATTR_BGMASK 0x000F0000UL
31#define ATTR_FGSHIFT 12
32#define ATTR_BGSHIFT 16
33
34#define ATTR_DEFAULT 0x00098000UL
35#define ATTR_DEFFG 0x00008000UL
36#define ATTR_DEFBG 0x00090000UL
37#define ATTR_CUR_XOR 0x000BA000UL
38#define ERASE_CHAR (ATTR_DEFAULT | ' ')
39#define ATTR_MASK 0xFFFFFF00UL
40#define CHAR_MASK 0x000000FFUL
41
42typedef HDC Context;
43#define SEL_NL { 13, 10 }
44
45GLOBAL int rows, cols, savelines;
46
47GLOBAL int font_width, font_height;
48
49#define INBUF_SIZE 2048
50#define INBUF_MASK (INBUF_SIZE-1)
51GLOBAL unsigned char inbuf[INBUF_SIZE];
52GLOBAL int inbuf_head, inbuf_reap;
53
54#define OUTBUF_SIZE 2048
55#define OUTBUF_MASK (OUTBUF_SIZE-1)
56GLOBAL unsigned char outbuf[OUTBUF_SIZE];
57GLOBAL int outbuf_head, outbuf_reap;
58
59GLOBAL int has_focus;
60
61GLOBAL int app_cursor_keys, app_keypad_keys;
62
63#define WM_NETEVENT (WM_USER + 1)
64
65typedef enum {
66 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
67 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
68} Telnet_Special;
69
70typedef enum {
71 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
72} Mouse_Button;
73
74typedef enum {
75 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
76} Mouse_Action;
77
78typedef enum {
79 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
80} VT_Mode;
81
82typedef struct {
83 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
84 int (*msg) (WPARAM wParam, LPARAM lParam);
85 void (*send) (char *buf, int len);
86 void (*size) (void);
87 void (*special) (Telnet_Special code);
88} Backend;
89
90GLOBAL Backend *back;
91
92typedef struct {
93 /* Basic options */
94 char host[512];
95 int port;
96 enum { PROT_TELNET, PROT_SSH } protocol;
97 int close_on_exit;
fef97f43 98 /* SSH options */
99 int nopty;
374330e2 100 /* Telnet options */
101 char termtype[32];
102 char termspeed[32];
37508af4 103 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
374330e2 104 char username[32];
105 int rfc_environ;
106 /* Keyboard options */
107 int bksp_is_delete;
108 int rxvt_homeend;
109 int linux_funkeys;
110 int app_cursor;
111 int app_keypad;
112 /* Terminal options */
113 int savelines;
114 int dec_om;
115 int wrap_mode;
fef97f43 116 int lfhascr;
374330e2 117 int win_name_always;
118 int width, height;
119 char font[64];
120 int fontisbold;
121 int fontheight;
122 VT_Mode vtmode;
123 /* Colour options */
124 int try_palette;
125 int bold_colour;
126 unsigned char colours[22][3];
127 /* Selection options */
128 int mouse_is_xterm;
129 short wordness[256];
130} Config;
131
132GLOBAL Config cfg;
133
134/*
135 * Exports from window.c.
136 */
137void request_resize (int, int);
138void do_text (Context, int, int, char *, int, unsigned long);
139void set_title (char *);
140void set_icon (char *);
141void set_sbar (int, int, int);
142Context get_ctx();
143void free_ctx (Context);
144void palette_set (int, int, int, int);
145void palette_reset (void);
146void write_clip (void *, int);
147void get_clip (void **, int *);
148void optimised_move (int, int, int);
149void fatalbox (char *, ...);
150void beep (void);
151#define OPTIMISE_IS_SCROLL 1
152
153/*
154 * Exports from noise.c.
155 */
156void noise_get_heavy(void (*func) (void *, int));
157void noise_get_light(void (*func) (void *, int));
158void noise_ultralight(DWORD data);
159void random_save_seed(void);
160
161/*
162 * Exports from windlg.c.
163 */
164int do_config (void);
165int do_reconfig (HWND);
166void do_defaults (char *);
167void lognegot (char *);
168void shownegot (HWND);
169void showabout (HWND);
170void verify_ssh_host_key(char *host, struct RSAKey *key);
171
172/*
173 * Exports from terminal.c.
174 */
175
176void term_init (void);
177void term_size (int, int, int);
178void term_out (void);
179void term_paint (Context, int, int, int, int);
180void term_scroll (int, int);
181void term_pwron (void);
182void term_clrsb (void);
183void term_mouse (Mouse_Button, Mouse_Action, int, int);
184void term_deselect (void);
185void term_update (void);
186void term_invalidate(void);
187
188/*
189 * Exports from telnet.c.
190 */
191
192Backend telnet_backend;
193
194/*
195 * Exports from ssh.c.
196 */
197
198Backend ssh_backend;
199
200/*
201 * Exports from sshrand.c.
202 */
203
204void random_add_noise(void *noise, int length);
205void random_init(void);
206int random_byte(void);
207void random_get_savedata(void **data, int *len);
208
209/*
210 * Exports from misc.c.
211 */
212
213/* #define MALLOC_LOG do this if you suspect putty of leaking memory */
214#ifdef MALLOC_LOG
215#define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
216#define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
217#define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
218void mlog(char *, int);
219#else
220#define smalloc safemalloc
221#define srealloc saferealloc
222#define sfree safefree
223#endif
224
225void *safemalloc(size_t);
226void *saferealloc(void *, size_t);
227void safefree(void *);
228
229/*
230 * A debug system.
231 */
232#ifdef DEBUG
233#include <stdarg.h>
234#define debug(x) (dprintf x)
235static void dprintf(char *fmt, ...) {
236 char buf[2048];
237 DWORD dw;
238 va_list ap;
239 static int gotconsole = 0;
240
241 if (!gotconsole) {
242 AllocConsole();
243 gotconsole = 1;
244 }
245
246 va_start(ap, fmt);
247 vsprintf(buf, fmt, ap);
248 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);
249 va_end(ap);
250}
251#else
252#define debug(x)
253#endif
254
255#endif