1 /* $Id: macterm.c,v 1.54 2003/01/25 16:16:44 ben Exp $ */
3 * Copyright (c) 1999 Simon Tatham
4 * Copyright (c) 1999, 2002 Ben Harris
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * macterm.c -- Macintosh terminal front-end
35 #include <ControlDefinitions.h>
40 #include <MacMemory.h>
41 #include <MacWindows.h>
42 #include <MixedMode.h>
44 #include <Quickdraw.h>
45 #include <QuickdrawText.h>
46 #include <Resources.h>
50 #include <TextCommon.h>
51 #include <ToolUtils.h>
52 #include <UnicodeConverter.h>
66 #define NCOLOURS (lenof(((Config *)0)->colours))
69 #define DEFAULT_FG_BOLD 17
71 #define DEFAULT_BG_BOLD 19
75 #define PTOCC(x) ((x) < 0 ? -(-(x - s->font_width - 1) / s->font_width) : \
77 #define PTOCR(y) ((y) < 0 ? -(-(y - s->font_height - 1) / s->font_height) : \
80 static void mac_initfont(Session
*);
81 static pascal OSStatus
uni_to_font_fallback(UniChar
*, ByteCount
, ByteCount
*,
82 TextPtr
, ByteCount
, ByteCount
*,
84 ConstUnicodeMappingPtr
);
85 static void mac_initpalette(Session
*);
86 static void mac_adjustwinbg(Session
*);
87 static void mac_adjustsize(Session
*, int, int);
88 static void mac_drawgrowicon(Session
*s
);
89 static pascal void mac_growtermdraghook(void);
90 static pascal void mac_scrolltracker(ControlHandle
, short);
91 static pascal void do_text_for_device(short, short, GDHandle
, long);
92 static int mac_keytrans(Session
*, EventRecord
*, unsigned char *);
93 static void text_click(Session
*, EventRecord
*);
95 void pre_paint(Session
*s
);
96 void post_paint(Session
*s
);
99 static RoutineDescriptor mac_scrolltracker_upp
=
100 BUILD_ROUTINE_DESCRIPTOR(uppControlActionProcInfo
,
101 (ProcPtr
)mac_scrolltracker
);
102 static RoutineDescriptor do_text_for_device_upp
=
103 BUILD_ROUTINE_DESCRIPTOR(uppDeviceLoopDrawingProcInfo
,
104 (ProcPtr
)do_text_for_device
);
105 #else /* not TARGET_RT_MAC_CFM */
106 #define mac_scrolltracker_upp mac_scrolltracker
107 #define do_text_for_device_upp do_text_for_device
108 #endif /* not TARGET_RT_MAC_CFM */
110 void mac_startsession(Session
*s
)
118 * Select protocol. This is farmed out into a table in a
119 * separate file to enable an ssh-free variant.
122 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
123 if (backends
[i
].protocol
== s
->cfg
.protocol
) {
124 s
->back
= backends
[i
].backend
;
128 fatalbox("Unsupported protocol number found");
130 /* XXX: Own storage management? */
132 s
->window
= GetNewCWindow(wTerminal
, NULL
, (WindowPtr
)-1);
134 s
->window
= GetNewWindow(wTerminal
, NULL
, (WindowPtr
)-1);
135 SetWRefCon(s
->window
, (long)s
);
136 s
->scrollbar
= GetNewControl(cVScroll
, s
->window
);
137 s
->term
= term_init(&s
->cfg
, &s
->ucsdata
, s
);
141 if (HAVE_COLOR_QD()) {
142 /* Set to FALSE to not get palette updates in the background. */
143 SetPalette(s
->window
, s
->palette
, TRUE
);
144 ActivatePalette(s
->window
);
147 s
->logctx
= log_init(s
, &s
->cfg
);
148 term_provide_logctx(s
->term
, s
->logctx
);
150 errmsg
= s
->back
->init(s
->term
, &s
->backhandle
, &s
->cfg
, s
->cfg
.host
,
151 s
->cfg
.port
, &s
->realhost
, s
->cfg
.tcp_nodelay
);
153 fatalbox("%s", errmsg
);
154 s
->back
->provide_logctx(s
->backhandle
, s
->logctx
);
155 set_title(s
, s
->realhost
);
157 term_provide_resize_fn(s
->term
, s
->back
->size
, s
->backhandle
);
159 mac_adjustsize(s
, s
->cfg
.height
, s
->cfg
.width
);
160 term_size(s
->term
, s
->cfg
.height
, s
->cfg
.width
, s
->cfg
.savelines
);
162 s
->ldisc
= ldisc_create(&s
->cfg
, s
->term
, s
->back
, s
->backhandle
, s
);
163 ldisc_send(s
->ldisc
, NULL
, 0, 0);/* cause ldisc to notice changes */
165 ShowWindow(s
->window
);
169 s
->next
->prev
= &s
->next
;
174 * Try to work out a horizontal scaling factor for the current font
175 * that will give a chracter width of wantwidth. Return it in numer
176 * and denom (suitable for passing to StdText()).
178 static void mac_workoutfontscale(Session
*s
, int wantwidth
,
179 Point
*numerp
, Point
*denomp
)
181 Point numer
, denom
, tmpnumer
, tmpdenom
;
183 const char text
= 'W';
186 numer
.v
= denom
.v
= 1; /* always */
187 numer
.h
= denom
.h
= 1;
188 for (i
= 0; i
< 3; i
++) {
191 if (s
->window
->grafProcs
!= NULL
)
192 gotwidth
= InvokeQDTxMeasUPP(1, &text
, &tmpnumer
, &tmpdenom
, &fi
,
193 s
->window
->grafProcs
->txMeasProc
);
195 gotwidth
= StdTxMeas(1, &text
, &tmpnumer
, &tmpdenom
, &fi
);
196 /* The result of StdTxMeas must be scaled by the factors it returns. */
197 gotwidth
= FixRound(FixMul(gotwidth
<< 16,
198 FixRatio(tmpnumer
.h
, tmpdenom
.h
)));
199 if (gotwidth
== wantwidth
)
201 numer
.h
*= wantwidth
;
208 static UnicodeToTextFallbackUPP uni_to_font_fallback_upp
;
210 static void mac_initfont(Session
*s
) {
217 c2pstrcpy(macfont
, s
->cfg
.font
);
218 GetFNum(macfont
, &s
->fontnum
);
219 TextFont(s
->fontnum
);
220 TextFace(s
->cfg
.fontisbold ? bold
: 0);
221 TextSize(s
->cfg
.fontheight
);
223 s
->font_width
= CharWidth('W'); /* Well, it's what NCSA uses. */
224 s
->font_ascent
= fi
.ascent
;
225 s
->font_leading
= fi
.leading
;
226 s
->font_height
= s
->font_ascent
+ fi
.descent
+ s
->font_leading
;
227 mac_workoutfontscale(s
, s
->font_width
,
228 &s
->font_stdnumer
, &s
->font_stddenom
);
229 mac_workoutfontscale(s
, s
->font_width
* 2,
230 &s
->font_widenumer
, &s
->font_widedenom
);
231 TextSize(s
->cfg
.fontheight
* 2);
232 mac_workoutfontscale(s
, s
->font_width
* 2,
233 &s
->font_bignumer
, &s
->font_bigdenom
);
234 TextSize(s
->cfg
.fontheight
);
235 if (!s
->cfg
.bold_colour
) {
237 s
->font_boldadjust
= s
->font_width
- CharWidth('W');
239 s
->font_boldadjust
= 0;
241 if (s
->uni_to_font
!= NULL
)
242 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
243 if (mac_gestalts
.encvvers
!= 0 &&
244 UpgradeScriptInfoToTextEncoding(kTextScriptDontCare
,
245 kTextLanguageDontCare
,
246 kTextRegionDontCare
, macfont
,
248 CreateUnicodeToTextInfoByEncoding(enc
, &s
->uni_to_font
) == noErr
) {
249 if (uni_to_font_fallback_upp
== NULL
)
250 uni_to_font_fallback_upp
=
251 NewUnicodeToTextFallbackProc(&uni_to_font_fallback
);
252 fbflags
= kUnicodeFallbackCustomOnly
;
253 if (mac_gestalts
.uncvattr
& kTECAddFallbackInterruptMask
)
254 fbflags
|= kUnicodeFallbackInterruptSafeMask
;
255 if (SetFallbackUnicodeToText(s
->uni_to_font
,
256 uni_to_font_fallback_upp
, fbflags
, NULL
) != noErr
) {
257 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
262 s
->uni_to_font
= NULL
;
264 charset_from_macenc(FontToScript(s
->fontnum
),
265 GetScriptManagerVariable(smRegionCode
),
266 mac_gestalts
.sysvers
, s
->cfg
.font
);
269 mac_adjustsize(s
, s
->term
->rows
, s
->term
->cols
);
272 static pascal OSStatus
uni_to_font_fallback(UniChar
*ucp
,
273 ByteCount ilen
, ByteCount
*iusedp
, TextPtr obuf
, ByteCount olen
,
274 ByteCount
*ousedp
, LogicalAddress
*cookie
, ConstUnicodeMappingPtr mapping
)
278 return kTECOutputBufferFullStatus
;
280 * What I'd _like_ to do here is to somehow generate the
281 * missing-character glyph that every font is required to have.
282 * Unfortunately (and somewhat surprisingly), I can't find any way
283 * to actually ask for it explicitly. Bah.
292 * Called every time round the event loop.
294 void mac_pollterm(void)
298 for (s
= sesslist
; s
!= NULL
; s
= s
->next
) {
300 term_update(s
->term
);
305 * To be called whenever the window size changes.
306 * rows and cols should be desired values.
307 * It's assumed the terminal emulator will be informed, and will set rows
310 static void mac_adjustsize(Session
*s
, int newrows
, int newcols
) {
311 int winwidth
, winheight
;
313 winwidth
= newcols
* s
->font_width
+ 15;
314 winheight
= newrows
* s
->font_height
;
315 SizeWindow(s
->window
, winwidth
, winheight
, true);
316 HideControl(s
->scrollbar
);
317 MoveControl(s
->scrollbar
, winwidth
- 15, -1);
318 SizeControl(s
->scrollbar
, 16, winheight
- 13);
319 ShowControl(s
->scrollbar
);
323 static void mac_initpalette(Session
*s
) {
325 if (!HAVE_COLOR_QD())
328 * Most colours should be inhibited on 2bpp displays.
329 * Palette manager documentation suggests inhibiting all tolerant colours
330 * on greyscale displays.
332 #define PM_NORMAL ( pmTolerant | pmInhibitC2 | \
333 pmInhibitG2 | pmInhibitG4 | pmInhibitG8 )
334 #define PM_TOLERANCE 0x2000
335 s
->palette
= NewPalette(22, NULL
, PM_NORMAL
, PM_TOLERANCE
);
336 if (s
->palette
== NULL
)
337 fatalbox("Unable to create palette");
338 /* In 2bpp, these are the colours we want most. */
339 SetEntryUsage(s
->palette
, DEFAULT_BG
,
340 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
341 SetEntryUsage(s
->palette
, DEFAULT_FG
,
342 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
343 SetEntryUsage(s
->palette
, DEFAULT_FG_BOLD
,
344 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
345 SetEntryUsage(s
->palette
, CURSOR_BG
,
346 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
351 * Set the background colour of the window correctly. Should be
352 * called whenever the default background changes.
354 static void mac_adjustwinbg(Session
*s
) {
356 if (!HAVE_COLOR_QD())
359 if (mac_gestalts
.windattr
& gestaltWindowMgrPresent
)
360 SetWindowContentColor(s
->window
,
361 &(*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
);
365 if (s
->wctab
== NULL
)
366 s
->wctab
= (WCTabHandle
)NewHandle(sizeof(**s
->wctab
));
367 if (s
->wctab
== NULL
)
368 return; /* do without */
369 (*s
->wctab
)->wCSeed
= 0;
370 (*s
->wctab
)->wCReserved
= 0;
371 (*s
->wctab
)->ctSize
= 0;
372 (*s
->wctab
)->ctTable
[0].value
= wContentColor
;
373 (*s
->wctab
)->ctTable
[0].rgb
= (*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
;
374 SetWinColor(s
->window
, s
->wctab
);
379 * Set the cursor shape correctly
381 void mac_adjusttermcursor(WindowPtr window
, Point mouse
, RgnHandle cursrgn
) {
383 ControlHandle control
;
388 s
= (Session
*)GetWRefCon(window
);
389 GlobalToLocal(&mouse
);
390 part
= FindControl(mouse
, window
, &control
);
391 if (control
== s
->scrollbar
) {
392 SetCursor(&qd
.arrow
);
393 RectRgn(cursrgn
, &(*s
->scrollbar
)->contrlRect
);
394 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
396 x
= mouse
.h
/ s
->font_width
;
397 y
= mouse
.v
/ s
->font_height
;
399 SetCursor(&qd
.arrow
);
401 SetCursor(*GetCursor(iBeamCursor
));
402 /* Ask for shape changes if we leave this character cell. */
403 SetRectRgn(cursrgn
, x
* s
->font_width
, y
* s
->font_height
,
404 (x
+ 1) * s
->font_width
, (y
+ 1) * s
->font_height
);
405 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
410 * Enable/disable menu items based on the active terminal window.
412 void mac_adjusttermmenus(WindowPtr window
) {
417 s
= (Session
*)GetWRefCon(window
);
418 menu
= GetMenuHandle(mFile
);
419 DisableItem(menu
, iSave
); /* XXX enable if modified */
420 EnableItem(menu
, iSaveAs
);
421 EnableItem(menu
, iDuplicate
);
422 menu
= GetMenuHandle(mEdit
);
424 DisableItem(menu
, iUndo
);
425 DisableItem(menu
, iCut
);
426 if (1/*s->term->selstate == SELECTED*/)
427 EnableItem(menu
, iCopy
);
429 DisableItem(menu
, iCopy
);
430 if (GetScrap(NULL
, 'TEXT', &offset
) == noTypeErr
)
431 DisableItem(menu
, iPaste
);
433 EnableItem(menu
, iPaste
);
434 DisableItem(menu
, iClear
);
435 EnableItem(menu
, iSelectAll
);
438 void mac_menuterm(WindowPtr window
, short menu
, short item
) {
441 s
= (Session
*)GetWRefCon(window
);
449 term_do_paste(s
->term
);
455 void mac_clickterm(WindowPtr window
, EventRecord
*event
) {
458 ControlHandle control
;
461 s
= (Session
*)GetWRefCon(window
);
463 mouse
= event
->where
;
464 GlobalToLocal(&mouse
);
465 part
= FindControl(mouse
, window
, &control
);
466 if (control
== s
->scrollbar
) {
468 case kControlIndicatorPart
:
469 if (TrackControl(control
, mouse
, NULL
) == kControlIndicatorPart
)
470 term_scroll(s
->term
, +1, GetControlValue(control
));
472 case kControlUpButtonPart
:
473 case kControlDownButtonPart
:
474 case kControlPageUpPart
:
475 case kControlPageDownPart
:
476 TrackControl(control
, mouse
, &mac_scrolltracker_upp
);
480 text_click(s
, event
);
484 static void text_click(Session
*s
, EventRecord
*event
) {
487 static UInt32 lastwhen
= 0;
488 static Session
*lastsess
= NULL
;
489 static int lastrow
= -1, lastcol
= -1;
490 static Mouse_Action lastact
= MA_NOTHING
;
493 localwhere
= event
->where
;
494 GlobalToLocal(&localwhere
);
496 col
= PTOCC(localwhere
.h
);
497 row
= PTOCR(localwhere
.v
);
498 if (event
->when
- lastwhen
< GetDblTime() &&
499 row
== lastrow
&& col
== lastcol
&& s
== lastsess
)
500 lastact
= (lastact
== MA_CLICK ? MA_2CLK
:
501 lastact
== MA_2CLK ? MA_3CLK
:
502 lastact
== MA_3CLK ? MA_CLICK
: MA_NOTHING
);
505 term_mouse(s
->term
, MBT_LEFT
,
506 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
507 lastact
, col
, row
, event
->modifiers
& shiftKey
,
508 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
512 while (StillDown()) {
513 GetMouse(&localwhere
);
514 col
= PTOCC(localwhere
.h
);
515 row
= PTOCR(localwhere
.v
);
516 term_mouse(s
->term
, MBT_LEFT
,
517 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
518 MA_DRAG
, col
, row
, event
->modifiers
& shiftKey
,
519 event
->modifiers
& controlKey
,
520 event
->modifiers
& optionKey
);
521 if (row
> s
->term
->rows
- 1)
522 term_scroll(s
->term
, 0, row
- (s
->term
->rows
- 1));
524 term_scroll(s
->term
, 0, row
);
526 term_mouse(s
->term
, MBT_LEFT
,
527 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
528 MA_RELEASE
, col
, row
, event
->modifiers
& shiftKey
,
529 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
530 lastwhen
= TickCount();
533 void write_clip(void *cookie
, wchar_t *data
, int len
, int must_deselect
) {
536 * See "Programming with the Text Encoding Conversion Manager"
537 * Appendix E for Unicode scrap conventions.
539 * XXX Need to support TEXT/styl scrap as well.
540 * See STScrpRec in TextEdit (Inside Macintosh: Text) for styl details.
541 * XXX Maybe PICT scrap too.
543 if (ZeroScrap() != noErr
)
545 PutScrap(len
* sizeof(*data
), 'utxt', data
);
548 void get_clip(void *frontend
, wchar_t **p
, int *lenp
) {
549 Session
*s
= frontend
;
550 static Handle h
= NULL
;
559 /* XXX Support TEXT-format scrap as well. */
560 if (GetScrap(NULL
, 'utxt', &offset
) > 0) {
562 *lenp
= GetScrap(h
, 'utxt', &offset
) / sizeof(**p
);
565 if (*p
== NULL
|| *lenp
<= 0)
566 fatalbox("Empty scrap");
573 static pascal void mac_scrolltracker(ControlHandle control
, short part
) {
576 s
= (Session
*)GetWRefCon((*control
)->contrlOwner
);
578 case kControlUpButtonPart
:
579 term_scroll(s
->term
, 0, -1);
581 case kControlDownButtonPart
:
582 term_scroll(s
->term
, 0, +1);
584 case kControlPageUpPart
:
585 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
587 case kControlPageDownPart
:
588 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
609 #define K_INSERT 0x7200
610 #define K_HOME 0x7300
611 #define K_PRIOR 0x7400
612 #define K_DELETE 0x7500
614 #define K_NEXT 0x7900
615 #define K_LEFT 0x7b00
616 #define K_RIGHT 0x7c00
617 #define K_DOWN 0x7d00
629 #define KP_CLEAR 0x4700
630 #define KP_EQUAL 0x5100
631 #define KP_SLASH 0x4b00
632 #define KP_STAR 0x4300
633 #define KP_PLUS 0x4500
634 #define KP_MINUS 0x4e00
635 #define KP_DOT 0x4100
636 #define KP_ENTER 0x4c00
638 void mac_keyterm(WindowPtr window
, EventRecord
*event
) {
639 unsigned char buf
[20];
643 s
= (Session
*)GetWRefCon(window
);
644 len
= mac_keytrans(s
, event
, buf
);
645 ldisc_send(s
->ldisc
, (char *)buf
, len
, 1);
647 term_seen_key_event(s
->term
);
649 term_update(s
->term
);
652 static int mac_keytrans(Session
*s
, EventRecord
*event
,
653 unsigned char *output
) {
654 unsigned char *p
= output
;
657 /* No meta key yet -- that'll be rather fun. */
659 /* Keys that we handle locally */
660 if (event
->modifiers
& shiftKey
) {
661 switch (event
->message
& keyCodeMask
) {
662 case K_PRIOR
: /* shift-pageup */
663 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
665 case K_NEXT
: /* shift-pagedown */
666 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
672 * Control-2 should return ^@ (0x00), Control-6 should return
673 * ^^ (0x1E), and Control-Minus should return ^_ (0x1F). Since
674 * the DOS keyboard handling did it, and we have nothing better
675 * to do with the key combo in question, we'll also map
676 * Control-Backquote to ^\ (0x1C).
679 if (event
->modifiers
& controlKey
) {
680 switch (event
->message
& charCodeMask
) {
697 * First, all the keys that do tilde codes. (ESC '[' nn '~',
698 * for integer decimal nn.)
700 * We also deal with the weird ones here. Linux VCs replace F1
701 * to F5 by ESC [ [ A to ESC [ [ E. rxvt doesn't do _that_, but
702 * does replace Home and End (1~ and 4~) by ESC [ H and ESC O w
706 switch (event
->message
& keyCodeMask
) {
707 case K_F1
: code
= (event
->modifiers
& shiftKey ?
23 : 11); break;
708 case K_F2
: code
= (event
->modifiers
& shiftKey ?
24 : 12); break;
709 case K_F3
: code
= (event
->modifiers
& shiftKey ?
25 : 13); break;
710 case K_F4
: code
= (event
->modifiers
& shiftKey ?
26 : 14); break;
711 case K_F5
: code
= (event
->modifiers
& shiftKey ?
28 : 15); break;
712 case K_F6
: code
= (event
->modifiers
& shiftKey ?
29 : 17); break;
713 case K_F7
: code
= (event
->modifiers
& shiftKey ?
31 : 18); break;
714 case K_F8
: code
= (event
->modifiers
& shiftKey ?
32 : 19); break;
715 case K_F9
: code
= (event
->modifiers
& shiftKey ?
33 : 20); break;
716 case K_F10
: code
= (event
->modifiers
& shiftKey ?
34 : 21); break;
717 case K_F11
: code
= 23; break;
718 case K_F12
: code
= 24; break;
719 case K_HOME
: code
= 1; break;
720 case K_INSERT
: code
= 2; break;
721 case K_DELETE
: code
= 3; break;
722 case K_END
: code
= 4; break;
723 case K_PRIOR
: code
= 5; break;
724 case K_NEXT
: code
= 6; break;
726 if (s
->cfg
.funky_type
== 1 && code
>= 11 && code
<= 15) {
727 p
+= sprintf((char *)p
, "\x1B[[%c", code
+ 'A' - 11);
730 if (s
->cfg
.rxvt_homeend
&& (code
== 1 || code
== 4)) {
731 p
+= sprintf((char *)p
, code
== 1 ?
"\x1B[H" : "\x1BOw");
735 p
+= sprintf((char *)p
, "\x1B[%d~", code
);
739 if (s
->term
->app_keypad_keys
) {
740 switch (event
->message
& keyCodeMask
) {
741 case KP_ENTER
: p
+= sprintf((char *)p
, "\x1BOM"); return p
- output
;
742 case KP_CLEAR
: p
+= sprintf((char *)p
, "\x1BOP"); return p
- output
;
743 case KP_EQUAL
: p
+= sprintf((char *)p
, "\x1BOQ"); return p
- output
;
744 case KP_SLASH
: p
+= sprintf((char *)p
, "\x1BOR"); return p
- output
;
745 case KP_STAR
: p
+= sprintf((char *)p
, "\x1BOS"); return p
- output
;
746 case KP_PLUS
: p
+= sprintf((char *)p
, "\x1BOl"); return p
- output
;
747 case KP_MINUS
: p
+= sprintf((char *)p
, "\x1BOm"); return p
- output
;
748 case KP_DOT
: p
+= sprintf((char *)p
, "\x1BOn"); return p
- output
;
749 case KP_0
: p
+= sprintf((char *)p
, "\x1BOp"); return p
- output
;
750 case KP_1
: p
+= sprintf((char *)p
, "\x1BOq"); return p
- output
;
751 case KP_2
: p
+= sprintf((char *)p
, "\x1BOr"); return p
- output
;
752 case KP_3
: p
+= sprintf((char *)p
, "\x1BOs"); return p
- output
;
753 case KP_4
: p
+= sprintf((char *)p
, "\x1BOt"); return p
- output
;
754 case KP_5
: p
+= sprintf((char *)p
, "\x1BOu"); return p
- output
;
755 case KP_6
: p
+= sprintf((char *)p
, "\x1BOv"); return p
- output
;
756 case KP_7
: p
+= sprintf((char *)p
, "\x1BOw"); return p
- output
;
757 case KP_8
: p
+= sprintf((char *)p
, "\x1BOx"); return p
- output
;
758 case KP_9
: p
+= sprintf((char *)p
, "\x1BOy"); return p
- output
;
762 switch (event
->message
& keyCodeMask
) {
764 p
+= sprintf((char *)p
,
765 s
->term
->app_cursor_keys ?
"\x1BOA" : "\x1B[A");
768 p
+= sprintf((char *)p
,
769 s
->term
->app_cursor_keys ?
"\x1BOB" : "\x1B[B");
772 p
+= sprintf((char *)p
,
773 s
->term
->app_cursor_keys ?
"\x1BOC" : "\x1B[C");
776 p
+= sprintf((char *)p
,
777 s
->term
->app_cursor_keys ?
"\x1BOD" : "\x1B[D");
783 *p
++ = (s
->cfg
.bksp_is_delete ?
0x7f : 0x08);
786 *p
++ = event
->message
& charCodeMask
;
791 void request_paste(void *frontend
)
793 Session
*s
= frontend
;
796 * In the Mac OS, pasting is synchronous: we can read the
797 * clipboard with no difficulty, so request_paste() can just go
800 term_do_paste(s
->term
);
811 void mac_growterm(WindowPtr window
, EventRecord
*event
) {
814 int newrows
, newcols
;
816 DragGrayRgnUPP draghooksave
;
820 s
= (Session
*)GetWRefCon(window
);
822 draghooksave
= LMGetDragHook();
823 growterm_state
.oldmsg
[0] = '\0';
824 growterm_state
.zeromouse
= event
->where
;
825 growterm_state
.zeromouse
.h
-= s
->term
->cols
* s
->font_width
;
826 growterm_state
.zeromouse
.v
-= s
->term
->rows
* s
->font_height
;
827 growterm_state
.s
= s
;
830 BackColor(whiteColor
);
831 ForeColor(blackColor
);
832 TextFont(systemFont
);
836 SetRect(&growterm_state
.msgrect
, 0, 0,
837 StringWidth("\p99999x99999") + 4, fi
.ascent
+ fi
.descent
+ 4);
838 SetPt(&growterm_state
.msgorigin
, 2, fi
.ascent
+ 2);
839 LMSetDragHook(NewDragGrayRgnUPP(mac_growtermdraghook
));
841 SetRect(&limits
, s
->font_width
+ 15, s
->font_height
, SHRT_MAX
, SHRT_MAX
);
842 grow_result
= GrowWindow(window
, event
->where
, &limits
);
844 DisposeDragGrayRgnUPP(LMGetDragHook());
845 LMSetDragHook(draghooksave
);
846 InvalRect(&growterm_state
.msgrect
);
850 if (grow_result
!= 0) {
851 newrows
= HiWord(grow_result
) / s
->font_height
;
852 newcols
= (LoWord(grow_result
) - 15) / s
->font_width
;
853 mac_adjustsize(s
, newrows
, newcols
);
854 term_size(s
->term
, newrows
, newcols
, s
->cfg
.savelines
);
858 static pascal void mac_growtermdraghook(void)
860 Session
*s
= growterm_state
.s
;
864 unsigned char pbuf
[20];
865 int newrows
, newcols
;
868 newrows
= (mouse
.v
- growterm_state
.zeromouse
.v
) / s
->font_height
;
869 if (newrows
< 1) newrows
= 1;
870 newcols
= (mouse
.h
- growterm_state
.zeromouse
.h
) / s
->font_width
;
871 if (newcols
< 1) newcols
= 1;
872 sprintf(buf
, "%dx%d", newcols
, newrows
);
873 if (strcmp(buf
, growterm_state
.oldmsg
) == 0)
875 strcpy(growterm_state
.oldmsg
, buf
);
876 c2pstrcpy(pbuf
, buf
);
879 SetPort(growterm_state
.s
->window
);
880 EraseRect(&growterm_state
.msgrect
);
881 MoveTo(growterm_state
.msgorigin
.h
, growterm_state
.msgorigin
.v
);
886 void mac_closeterm(WindowPtr window
)
888 Session
*s
= (Session
*)GetWRefCon(window
);
890 /* XXX warn on close */
891 HideWindow(s
->window
);
893 s
->next
->prev
= s
->prev
;
894 ldisc_free(s
->ldisc
);
895 s
->back
->free(s
->backhandle
);
897 if (s
->uni_to_font
!= NULL
)
898 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
900 DisposeWindow(s
->window
);
901 DisposePalette(s
->palette
);
905 void mac_activateterm(WindowPtr window
, Boolean active
) {
908 s
= (Session
*)GetWRefCon(window
);
909 s
->term
->has_focus
= active
;
910 term_update(s
->term
);
912 ShowControl(s
->scrollbar
);
915 PmBackColor(DEFAULT_BG
);/* HideControl clears behind the control */
917 BackColor(blackColor
);
918 HideControl(s
->scrollbar
);
923 void mac_updateterm(WindowPtr window
) {
926 s
= (Session
*)GetWRefCon(window
);
930 term_paint(s
->term
, s
,
931 PTOCC((*window
->visRgn
)->rgnBBox
.left
),
932 PTOCR((*window
->visRgn
)->rgnBBox
.top
),
933 PTOCC((*window
->visRgn
)->rgnBBox
.right
),
934 PTOCR((*window
->visRgn
)->rgnBBox
.bottom
), 1);
935 /* Restore default colours in case the Window Manager uses them */
936 if (HAVE_COLOR_QD()) {
937 PmForeColor(DEFAULT_FG
);
938 PmBackColor(DEFAULT_BG
);
940 ForeColor(whiteColor
);
941 BackColor(blackColor
);
943 if (FrontWindow() != window
)
944 EraseRect(&(*s
->scrollbar
)->contrlRect
);
945 UpdateControls(window
, window
->visRgn
);
951 static void mac_drawgrowicon(Session
*s
) {
957 * Stop DrawGrowIcon giving us space for a horizontal scrollbar
958 * See Tech Note TB575 for details.
960 clip
= s
->window
->portRect
;
961 clip
.left
= clip
.right
- 15;
965 DrawGrowIcon(s
->window
);
970 struct do_text_args
{
981 * Call from the terminal emulator to draw a bit of text
983 * x and y are text row and column (zero-based)
985 void do_text(Context ctx
, int x
, int y
, char *text
, int len
,
986 unsigned long attr
, int lattr
) {
989 struct do_text_args a
;
990 RgnHandle textrgn
, saveclip
;
991 char mactextbuf
[1024];
992 UniChar unitextbuf
[1024];
995 ByteCount iread
, olen
;
1002 fontwidth
= s
->font_width
;
1003 if ((lattr
& LATTR_MODE
) != LATTR_NORM
)
1006 /* First check this text is relevant */
1007 a
.textrect
.top
= y
* s
->font_height
;
1008 a
.textrect
.bottom
= (y
+ 1) * s
->font_height
;
1009 a
.textrect
.left
= x
* fontwidth
;
1010 a
.textrect
.right
= (x
+ len
) * fontwidth
;
1011 if (a
.textrect
.right
> s
->term
->cols
* s
->font_width
)
1012 a
.textrect
.right
= s
->term
->cols
* s
->font_width
;
1013 if (!RectInRgn(&a
.textrect
, s
->window
->visRgn
))
1016 /* Unpack Unicode from the mad format we get passed */
1017 for (i
= 0; i
< len
; i
++)
1018 unitextbuf
[i
] = (unsigned char)text
[i
] | (attr
& CSET_MASK
);
1020 if (s
->uni_to_font
!= NULL
) {
1021 err
= ConvertFromUnicodeToText(s
->uni_to_font
, len
* sizeof(UniChar
),
1022 unitextbuf
, kUnicodeUseFallbacksMask
,
1023 0, NULL
, NULL
, NULL
,
1024 1024, &iread
, &olen
, mactextbuf
);
1025 if (err
!= noErr
&& err
!= kTECUsedFallbacksStatus
)
1027 } else if (s
->font_charset
!= CS_NONE
) {
1028 /* XXX this is bogus if wchar_t and UniChar are different sizes. */
1029 unitextptr
= (wchar_t *)unitextbuf
;
1030 olen
= charset_from_unicode(&unitextptr
, &len
, mactextbuf
, 1024,
1031 s
->font_charset
, NULL
, ".", 1);
1036 a
.text
= mactextbuf
;
1040 switch (lattr
& LATTR_MODE
) {
1042 TextSize(s
->cfg
.fontheight
);
1043 a
.numer
= s
->font_stdnumer
;
1044 a
.denom
= s
->font_stddenom
;
1047 TextSize(s
->cfg
.fontheight
);
1048 a
.numer
= s
->font_widenumer
;
1049 a
.denom
= s
->font_widedenom
;
1053 TextSize(s
->cfg
.fontheight
* 2);
1054 a
.numer
= s
->font_bignumer
;
1055 a
.denom
= s
->font_bigdenom
;
1059 TextFont(s
->fontnum
);
1060 if (s
->cfg
.fontisbold
|| (attr
& ATTR_BOLD
) && !s
->cfg
.bold_colour
)
1062 if (attr
& ATTR_UNDER
)
1066 if (HAVE_COLOR_QD())
1068 SpaceExtra(s
->font_boldadjust
<< 16);
1069 CharExtra(s
->font_boldadjust
<< 16);
1074 saveclip
= NewRgn();
1076 ClipRect(&a
.textrect
);
1078 RectRgn(textrgn
, &a
.textrect
);
1079 if (HAVE_COLOR_QD())
1080 DeviceLoop(textrgn
, &do_text_for_device_upp
, (long)&a
, 0);
1082 do_text_for_device(1, 0, NULL
, (long)&a
);
1084 DisposeRgn(saveclip
);
1085 DisposeRgn(textrgn
);
1086 /* Tell the window manager about it in case this isn't an update */
1087 ValidRect(&a
.textrect
);
1090 static pascal void do_text_for_device(short depth
, short devflags
,
1091 GDHandle device
, long cookie
) {
1092 struct do_text_args
*a
;
1093 int bgcolour
, fgcolour
, bright
, reverse
, tmp
;
1095 a
= (struct do_text_args
*)cookie
;
1097 bright
= (a
->attr
& ATTR_BOLD
) && a
->s
->cfg
.bold_colour
;
1098 reverse
= a
->attr
& ATTR_REVERSE
;
1100 if (depth
== 1 && (a
->attr
& TATTR_ACTCURS
))
1103 if (HAVE_COLOR_QD()) {
1105 fgcolour
= ((a
->attr
& ATTR_FGMASK
) >> ATTR_FGSHIFT
) * 2;
1106 bgcolour
= ((a
->attr
& ATTR_BGMASK
) >> ATTR_BGSHIFT
) * 2;
1109 * NB: bold reverse in 2bpp breaks with the usual PuTTY model and
1110 * boldens the background, because that's all we can do.
1112 fgcolour
= bright ? DEFAULT_FG_BOLD
: DEFAULT_FG
;
1113 bgcolour
= DEFAULT_BG
;
1117 fgcolour
= bgcolour
;
1120 if (bright
&& depth
> 2)
1122 if ((a
->attr
& TATTR_ACTCURS
) && depth
> 1) {
1123 fgcolour
= CURSOR_FG
;
1124 bgcolour
= CURSOR_BG
;
1126 PmForeColor(fgcolour
);
1127 PmBackColor(bgcolour
);
1128 } else { /* No Color Quickdraw */
1129 /* XXX This should be done with a _little_ more configurability */
1131 ForeColor(blackColor
);
1132 BackColor(whiteColor
);
1134 ForeColor(whiteColor
);
1135 BackColor(blackColor
);
1139 EraseRect(&a
->textrect
);
1140 switch (a
->lattr
& LATTR_MODE
) {
1143 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
);
1146 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
* 2);
1149 MoveTo(a
->textrect
.left
,
1150 a
->textrect
.top
- a
->s
->font_height
+ a
->s
->font_ascent
* 2);
1153 /* FIXME: Sort out bold width adjustments on Original QuickDraw. */
1154 if (a
->s
->window
->grafProcs
!= NULL
)
1155 InvokeQDTextUPP(a
->len
, a
->text
, a
->numer
, a
->denom
,
1156 a
->s
->window
->grafProcs
->textProc
);
1158 StdText(a
->len
, a
->text
, a
->numer
, a
->denom
);
1160 if (a
->attr
& TATTR_PASCURS
) {
1167 PmForeColor(CURSOR_BG
);
1170 FrameRect(&a
->textrect
);
1174 void do_cursor(Context ctx
, int x
, int y
, char *text
, int len
,
1175 unsigned long attr
, int lattr
)
1178 do_text(ctx
, x
, y
, text
, len
, attr
, lattr
);
1182 * Call from the terminal emulator to get its graphics context.
1183 * Should probably be called start_redraw or something.
1185 void pre_paint(Session
*s
) {
1187 Rect myrect
, tmprect
;
1189 if (HAVE_COLOR_QD()) {
1190 s
->term
->attr_mask
= 0;
1192 myrect
= (*s
->window
->visRgn
)->rgnBBox
;
1193 LocalToGlobal((Point
*)&myrect
.top
);
1194 LocalToGlobal((Point
*)&myrect
.bottom
);
1195 for (gdh
= GetDeviceList();
1197 gdh
= GetNextDevice(gdh
)) {
1198 if (TestDeviceAttribute(gdh
, screenDevice
) &&
1199 TestDeviceAttribute(gdh
, screenActive
) &&
1200 SectRect(&(*gdh
)->gdRect
, &myrect
, &tmprect
)) {
1201 switch ((*(*gdh
)->gdPMap
)->pixelSize
) {
1203 if (s
->cfg
.bold_colour
)
1204 s
->term
->attr_mask
|= ~(ATTR_COLOURS
|
1205 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1208 s
->term
->attr_mask
|= ~ATTR_COLOURS
;
1211 s
->term
->attr_mask
= ~0;
1212 return; /* No point checking more screens. */
1217 s
->term
->attr_mask
= ~(ATTR_COLOURS
|
1218 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1221 Context
get_ctx(void *frontend
) {
1222 Session
*s
= frontend
;
1228 void free_ctx(Context ctx
) {
1233 * Presumably this does something in Windows
1235 void post_paint(Session
*s
) {
1240 * Set the scroll bar position
1242 * total is the line number of the bottom of the working screen
1243 * start is the line number of the top of the display
1244 * page is the length of the displayed page
1246 void set_sbar(void *frontend
, int total
, int start
, int page
) {
1247 Session
*s
= frontend
;
1249 /* We don't redraw until we've set everything up, to avoid glitches */
1250 (*s
->scrollbar
)->contrlMin
= 0;
1251 (*s
->scrollbar
)->contrlMax
= total
- page
;
1252 SetControlValue(s
->scrollbar
, start
);
1254 if (mac_gestalts
.cntlattr
& gestaltControlMgrPresent
)
1255 SetControlViewSize(s
->scrollbar
, page
);
1259 void sys_cursor(void *frontend
, int x
, int y
)
1262 * I think his is meaningless under Mac OS.
1267 * This is still called when mode==BELL_VISUAL, even though the
1268 * visual bell is handled entirely within terminal.c, because we
1269 * may want to perform additional actions on any kind of bell (for
1270 * example, taskbar flashing in Windows).
1272 void beep(void *frontend
, int mode
)
1274 if (mode
!= BELL_VISUAL
)
1277 * XXX We should indicate the relevant window and/or use the
1278 * Notification Manager
1282 int char_width(Context ctx
, int uc
)
1285 * Until we support exciting character-set stuff, assume all chars are
1292 * Set icon string -- a no-op here (Windowshade?)
1294 void set_icon(void *frontend
, char *icon
) {
1295 Session
*s
= frontend
;
1300 * Set the window title
1302 void set_title(void *frontend
, char *title
) {
1303 Session
*s
= frontend
;
1306 c2pstrcpy(mactitle
, title
);
1307 SetWTitle(s
->window
, mactitle
);
1311 * set or clear the "raw mouse message" mode
1313 void set_raw_mouse_mode(void *frontend
, int activate
)
1315 Session
*s
= frontend
;
1317 s
->raw_mouse
= activate
;
1318 /* FIXME: Should call mac_updatetermcursor as appropriate. */
1322 * Resize the window at the emulator's request
1324 void request_resize(void *frontend
, int w
, int h
) {
1325 Session
*s
= frontend
;
1327 term_size(s
->term
, h
, w
, s
->cfg
.savelines
);
1332 * Iconify (actually collapse) the window at the emulator's request.
1334 void set_iconic(void *frontend
, int iconic
)
1336 Session
*s
= frontend
;
1339 if (mac_gestalts
.apprvers
>= 0x0100 &&
1340 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1341 (features
& kWindowCanCollapse
))
1342 CollapseWindow(s
->window
, iconic
);
1346 * Move the window in response to a server-side request.
1348 void move_window(void *frontend
, int x
, int y
)
1350 Session
*s
= frontend
;
1352 MoveWindow(s
->window
, x
, y
, FALSE
);
1356 * Move the window to the top or bottom of the z-order in response
1357 * to a server-side request.
1359 void set_zorder(void *frontend
, int top
)
1361 Session
*s
= frontend
;
1364 * We also change the input focus to point to the topmost window,
1365 * since that's probably what the Human Interface Guidelines would
1369 SelectWindow(s
->window
);
1371 SendBehind(s
->window
, NULL
);
1375 * Refresh the window in response to a server-side request.
1377 void refresh_window(void *frontend
)
1379 Session
*s
= frontend
;
1381 term_invalidate(s
->term
);
1385 * Maximise or restore the window in response to a server-side
1388 void set_zoomed(void *frontend
, int zoomed
)
1390 Session
*s
= frontend
;
1392 ZoomWindow(s
->window
, zoomed ? inZoomOut
: inZoomIn
, FALSE
);
1396 * Report whether the window is iconic, for terminal reports.
1398 int is_iconic(void *frontend
)
1400 Session
*s
= frontend
;
1403 if (mac_gestalts
.apprvers
>= 0x0100 &&
1404 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1405 (features
& kWindowCanCollapse
))
1406 return IsWindowCollapsed(s
->window
);
1411 * Report the window's position, for terminal reports.
1413 void get_window_pos(void *frontend
, int *x
, int *y
)
1415 Session
*s
= frontend
;
1417 *x
= s
->window
->portRect
.left
;
1418 *y
= s
->window
->portRect
.top
;
1422 * Report the window's pixel size, for terminal reports.
1424 void get_window_pixels(void *frontend
, int *x
, int *y
)
1426 Session
*s
= frontend
;
1428 *x
= s
->window
->portRect
.right
- s
->window
->portRect
.left
;
1429 *y
= s
->window
->portRect
.bottom
- s
->window
->portRect
.top
;
1433 * Return the window or icon title.
1435 char *get_window_title(void *frontend
, int icon
)
1437 Session
*s
= frontend
;
1439 static char title
[256];
1441 GetWTitle(s
->window
, ptitle
);
1442 p2cstrcpy(title
, ptitle
);
1447 * real_palette_set(): This does the actual palette-changing work on behalf
1448 * of palette_set(). Does _not_ call ActivatePalette() in case the caller
1449 * is doing a batch of updates.
1451 static void real_palette_set(Session
*s
, int n
, int r
, int g
, int b
)
1455 if (!HAVE_COLOR_QD())
1457 col
.red
= r
* 0x0101;
1458 col
.green
= g
* 0x0101;
1459 col
.blue
= b
* 0x0101;
1460 SetEntryColor(s
->palette
, n
, &col
);
1464 * Set the logical palette. Called by the terminal emulator.
1466 void palette_set(void *frontend
, int n
, int r
, int g
, int b
) {
1467 Session
*s
= frontend
;
1468 static const int first
[21] = {
1469 0, 2, 4, 6, 8, 10, 12, 14,
1470 1, 3, 5, 7, 9, 11, 13, 15,
1474 if (!HAVE_COLOR_QD())
1476 real_palette_set(s
, first
[n
], r
, g
, b
);
1478 real_palette_set(s
, first
[n
]+1, r
, g
, b
);
1479 if (first
[n
] == DEFAULT_BG
)
1481 ActivatePalette(s
->window
);
1485 * Reset to the default palette
1487 void palette_reset(void *frontend
) {
1488 Session
*s
= frontend
;
1489 /* This maps colour indices in cfg to those used in our palette. */
1490 static const int ww
[] = {
1491 6, 7, 8, 9, 10, 11, 12, 13,
1492 14, 15, 16, 17, 18, 19, 20, 21,
1497 if (!HAVE_COLOR_QD())
1500 assert(lenof(ww
) == NCOLOURS
);
1502 for (i
= 0; i
< NCOLOURS
; i
++) {
1503 real_palette_set(s
, i
,
1504 s
->cfg
.colours
[ww
[i
]][0],
1505 s
->cfg
.colours
[ww
[i
]][1],
1506 s
->cfg
.colours
[ww
[i
]][2]);
1509 ActivatePalette(s
->window
);
1510 /* Palette Manager will generate update events as required. */
1514 * Scroll the screen. (`lines' is +ve for scrolling forward, -ve
1517 void do_scroll(void *frontend
, int topline
, int botline
, int lines
) {
1518 Session
*s
= frontend
;
1520 RgnHandle scrollrgn
= NewRgn();
1521 RgnHandle movedupdate
= NewRgn();
1522 RgnHandle update
= NewRgn();
1523 Point g2l
= { 0, 0 };
1528 * Work out the part of the update region that will scrolled by
1532 SetRectRgn(scrollrgn
, 0, (topline
+ lines
) * s
->font_height
,
1533 s
->term
->cols
* s
->font_width
,
1534 (botline
+ 1) * s
->font_height
);
1536 SetRectRgn(scrollrgn
, 0, topline
* s
->font_height
,
1537 s
->term
->cols
* s
->font_width
,
1538 (botline
- lines
+ 1) * s
->font_height
);
1539 CopyRgn(((WindowPeek
)s
->window
)->updateRgn
, movedupdate
);
1540 GlobalToLocal(&g2l
);
1541 OffsetRgn(movedupdate
, g2l
.h
, g2l
.v
); /* Convert to local co-ords. */
1542 SectRgn(scrollrgn
, movedupdate
, movedupdate
); /* Clip scrolled section. */
1543 ValidRgn(movedupdate
);
1544 OffsetRgn(movedupdate
, 0, -lines
* s
->font_height
); /* Scroll it. */
1547 if (HAVE_COLOR_QD())
1548 PmBackColor(DEFAULT_BG
);
1550 BackColor(blackColor
); /* XXX make configurable */
1551 SetRect(&r
, 0, topline
* s
->font_height
,
1552 s
->term
->cols
* s
->font_width
, (botline
+ 1) * s
->font_height
);
1553 ScrollRect(&r
, 0, - lines
* s
->font_height
, update
);
1556 InvalRgn(movedupdate
);
1558 DisposeRgn(scrollrgn
);
1559 DisposeRgn(movedupdate
);
1563 void logevent(void *frontend
, char *str
) {
1565 fprintf(stderr
, "%s\n", str
);
1568 /* Dummy routine, only required in plink. */
1569 void ldisc_update(void *frontend
, int echo
, int edit
)
1574 * Mac PuTTY doesn't support printing yet.
1576 printer_job
*printer_start_job(char *printer
)
1582 void printer_job_data(printer_job
*pj
, void *data
, int len
)
1586 void printer_finish_job(printer_job
*pj
)
1590 void frontend_keypress(void *handle
)
1593 * Keypress termination in non-Close-On-Exit mode is not
1594 * currently supported in PuTTY proper, because the window
1595 * always has a perfectly good Close button anyway. So we do
1602 * Ask whether to wipe a session log file before writing to it.
1603 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
1605 int askappend(void *frontend
, char *filename
)
1608 /* FIXME: not implemented yet. */
1615 * c-file-style: "simon"