4 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
7 #define OPTIMISE_SCROLL
16 #endif /* macintosh */
25 #define ATTR_ACTCURS 0x80000000UL /* active cursor (block) */
26 #define ATTR_PASCURS 0x40000000UL /* passive cursor (box) */
27 #define ATTR_INVALID 0x20000000UL
28 #define ATTR_WRAPPED 0x10000000UL
30 #define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
31 #define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
32 #define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
34 #define ATTR_BOLD 0x00000100UL
35 #define ATTR_UNDER 0x00000200UL
36 #define ATTR_REVERSE 0x00000400UL
37 #define ATTR_FGMASK 0x0000F000UL
38 #define ATTR_BGMASK 0x000F0000UL
39 #define ATTR_FGSHIFT 12
40 #define ATTR_BGSHIFT 16
42 #define ATTR_DEFAULT 0x00098000UL
43 #define ATTR_DEFFG 0x00008000UL
44 #define ATTR_DEFBG 0x00090000UL
45 #define ATTR_CUR_XOR 0x000BA000UL
46 #define ERASE_CHAR (ATTR_DEFAULT | ' ')
47 #define ATTR_MASK 0xFFFFFF00UL
48 #define CHAR_MASK 0x000000FFUL
53 #define SEL_NL { 13, 10 }
57 * Global variables. Most modules declare these `extern', but
58 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
59 * module, and so will get them properly defined.
61 #ifdef PUTTY_DO_GLOBALS
67 #define INBUF_SIZE 2048
68 #define INBUF_MASK (INBUF_SIZE-1)
70 #define OUTBUF_SIZE 2048
71 #define OUTBUF_MASK (OUTBUF_SIZE-1)
73 #define WM_NETEVENT (WM_USER + 1)
76 TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
77 TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
81 MB_NOTHING, MB_SELECT, MB_EXTEND, MB_PASTE
85 MA_NOTHING, MA_CLICK, MA_2CLK, MA_3CLK, MA_DRAG, MA_RELEASE
89 VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN
92 typedef struct Session Session;
96 char *(*init) (Session *, char *host, int port, char **realhost);
97 int (*msg)(Session *);
98 #else /* not macintosh */
99 char *(*init) (HWND hwnd, char *host, int port, char **realhost);
100 int (*msg) (WPARAM wParam, LPARAM lParam);
101 #endif /* not macintosh */
102 void (*send) (Session *, char *buf, int len);
103 void (*size) (Session *);
104 void (*special) (Session *, Telnet_Special code);
111 enum { PROT_TELNET, PROT_SSH } protocol;
118 char environmt[1024]; /* VAR\tvalue\0VAR\tvalue\0\0 */
121 /* Keyboard options */
128 /* Terminal options */
143 PaletteHandle colours;
144 #else /* not macintosh */
145 unsigned char colours[22][3];
146 #endif /* not macintosh */
147 /* Selection options */
156 /* Display buffers and pointers within them */
157 unsigned long *text; /* buffer of text on terminal screen */
158 unsigned long *scrtop; /* top of working screen */
159 unsigned long *disptop; /* top of displayed screen */
160 unsigned long *sbtop; /* top of scrollback */
161 unsigned long *cpos; /* cursor position (convenience) */
162 unsigned long *disptext; /* buffer of text on real screen */
163 unsigned long *wanttext; /* buffer of text we want on screen */
164 unsigned long *alttext; /* buffer of text on alt. screen */
165 unsigned char *selspace; /* buffer for building selections in */
168 unsigned long curr_attr;
169 int curs_x, curs_y; /* cursor */
170 int cset; /* 0 or 1: which char set is in GL */
171 unsigned long cset_attr[2]; /* G0 and G1 char sets */
174 unsigned long save_attr;
175 int save_x, save_y; /* saved cursor position */
176 int save_cset, save_csattr; /* saved with cursor position */
178 int marg_t, marg_b; /* scroll margins */
181 int dec_om; /* DEC origin mode flag */
182 int wrap, wrapnext; /* wrap flags */
183 int insert; /* insert-mode flag */
184 int rvideo; /* global reverse video flag */
187 * Saved settings on the alternate screen.
189 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins, alt_cset;
193 /* Escape sequence handler state */
194 #define ARGS_MAX 32 /* max # of esc sequence arguments */
195 int esc_args[ARGS_MAX];
198 #define OSC_STR_MAX 2048
200 char osc_string[OSC_STR_MAX+1];
207 TOPLEVEL, IGNORE_NEXT,
208 SEEN_ESC, SEEN_CSI, SET_GL, SET_GR,
209 SEEN_OSC, SEEN_OSC_P, SEEN_OSC_W, OSC_STRING, OSC_MAYBE_ST,
214 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
217 SM_CHAR, SM_WORD, SM_LINE
219 unsigned long *selstart, *selend, *selanchor;
223 typedef struct Session {
224 /* Config that created this session */
226 /* Terminal emulator internal state */
229 int rows, cols, savelines;
230 int font_width, font_height;
233 unsigned char inbuf[INBUF_SIZE];
234 int inbuf_head, inbuf_reap;
235 unsigned char outbuf[OUTBUF_SIZE];
236 int outbuf_head, outbuf_reap;
238 int app_cursor_keys, app_keypad_keys;
242 unsigned long attr_mask; /* Mask of attributes to display */
249 PaletteHandle palette;
250 ControlHandle scrollbar;
257 * Exports from display system
259 extern void request_resize(Session *, int, int);
260 extern void do_text(Session *, int, int, char *, int, unsigned long);
261 extern void set_title(Session *, char *);
262 extern void set_icon(Session *, char *);
263 extern void set_sbar(Session *, int, int, int);
264 extern void pre_paint(Session *);
265 extern void post_paint(Session *);
266 extern void palette_set(Session *, int, int, int, int);
267 extern void palette_reset(Session *);
268 void write_clip (void *, int);
269 void get_clip (void **, int *);
270 extern void do_scroll(Session *, int, int, int);
271 void fatalbox (const char *, ...);
273 #pragma noreturn (fatalbox)
275 extern void beep (Session *s);
276 #define OPTIMISE_IS_SCROLL 1
279 * Exports from noise.c.
281 void noise_get_heavy(void (*func) (void *, int));
282 void noise_get_light(void (*func) (void *, int));
283 void noise_ultralight(DWORD data);
284 void random_save_seed(void);
288 * Exports from windlg.c.
290 int do_config (void);
291 int do_reconfig (HWND);
292 void do_defaults (char *);
293 void lognegot (char *);
294 void shownegot (HWND);
295 void showabout (HWND);
296 void verify_ssh_host_key(char *host, struct RSAKey *key);
300 * Exports from terminal.c.
303 extern void term_init(Session *);
304 extern void term_size(Session *, int, int, int);
305 extern void term_out(Session *);
306 extern void term_paint(Session *, int, int, int, int);
307 extern void term_scroll(Session *, int, int);
308 extern void term_pwron(Session *);
309 extern void term_clrsb(Session *);
310 extern void term_mouse(Session *, Mouse_Button, Mouse_Action, int, int);
311 extern void term_copy(Session *);
312 extern void term_paste(Session *);
313 extern int term_hasselection(Session *);
314 extern void term_deselect (Session *);
315 extern void term_update (Session *);
316 extern void term_invalidate(Session *);
319 * Exports from telnet.c.
322 extern Backend telnet_backend;
325 * Exports from ssh.c.
328 extern Backend ssh_backend;
331 * Exports from sshrand.c.
334 void random_add_noise(void *noise, int length);
335 void random_init(void);
336 int random_byte(void);
337 void random_get_savedata(void **data, int *len);
340 * Exports from misc.c.
343 /* #define MALLOC_LOG do this if you suspect putty of leaking memory */
345 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
346 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
347 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
348 void mlog(char *, int);
350 #define smalloc safemalloc
351 #define srealloc saferealloc
352 #define sfree safefree
355 void *safemalloc(size_t);
356 void *saferealloc(void *, size_t);
357 void safefree(void *);
360 * Exports from testback.c
363 extern Backend null_backend;
364 extern Backend loop_backend;
365 extern Backend hexdump_backend;
368 * Exports from version.c.
377 #define debug(x) (dprintf x)
378 static void dprintf(char *fmt, ...) {
382 static int gotconsole = 0;
390 vsprintf(buf, fmt, ap);
391 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, NULL);