1 /* $Id: macterm.c,v 1.58 2003/01/27 23:03:30 simon 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 void text_click(Session
*, EventRecord
*);
94 void pre_paint(Session
*s
);
95 void post_paint(Session
*s
);
98 static RoutineDescriptor mac_scrolltracker_upp
=
99 BUILD_ROUTINE_DESCRIPTOR(uppControlActionProcInfo
,
100 (ProcPtr
)mac_scrolltracker
);
101 static RoutineDescriptor do_text_for_device_upp
=
102 BUILD_ROUTINE_DESCRIPTOR(uppDeviceLoopDrawingProcInfo
,
103 (ProcPtr
)do_text_for_device
);
104 #else /* not TARGET_RT_MAC_CFM */
105 #define mac_scrolltracker_upp mac_scrolltracker
106 #define do_text_for_device_upp do_text_for_device
107 #endif /* not TARGET_RT_MAC_CFM */
109 void mac_startsession(Session
*s
)
117 * Select protocol. This is farmed out into a table in a
118 * separate file to enable an ssh-free variant.
121 for (i
= 0; backends
[i
].backend
!= NULL
; i
++)
122 if (backends
[i
].protocol
== s
->cfg
.protocol
) {
123 s
->back
= backends
[i
].backend
;
127 fatalbox("Unsupported protocol number found");
129 /* XXX: Own storage management? */
131 s
->window
= GetNewCWindow(wTerminal
, NULL
, (WindowPtr
)-1);
133 s
->window
= GetNewWindow(wTerminal
, NULL
, (WindowPtr
)-1);
134 SetWRefCon(s
->window
, (long)s
);
135 s
->scrollbar
= GetNewControl(cVScroll
, s
->window
);
136 s
->term
= term_init(&s
->cfg
, &s
->ucsdata
, s
);
140 if (HAVE_COLOR_QD()) {
141 /* Set to FALSE to not get palette updates in the background. */
142 SetPalette(s
->window
, s
->palette
, TRUE
);
143 ActivatePalette(s
->window
);
146 s
->logctx
= log_init(s
, &s
->cfg
);
147 term_provide_logctx(s
->term
, s
->logctx
);
149 errmsg
= s
->back
->init(s
->term
, &s
->backhandle
, &s
->cfg
, s
->cfg
.host
,
150 s
->cfg
.port
, &s
->realhost
, s
->cfg
.tcp_nodelay
);
152 fatalbox("%s", errmsg
);
153 s
->back
->provide_logctx(s
->backhandle
, s
->logctx
);
154 set_title(s
, s
->realhost
);
156 term_provide_resize_fn(s
->term
, s
->back
->size
, s
->backhandle
);
158 mac_adjustsize(s
, s
->cfg
.height
, s
->cfg
.width
);
159 term_size(s
->term
, s
->cfg
.height
, s
->cfg
.width
, s
->cfg
.savelines
);
161 s
->ldisc
= ldisc_create(&s
->cfg
, s
->term
, s
->back
, s
->backhandle
, s
);
162 ldisc_send(s
->ldisc
, NULL
, 0, 0);/* cause ldisc to notice changes */
164 ShowWindow(s
->window
);
168 s
->next
->prev
= &s
->next
;
173 * Try to work out a horizontal scaling factor for the current font
174 * that will give a chracter width of wantwidth. Return it in numer
175 * and denom (suitable for passing to StdText()).
177 static void mac_workoutfontscale(Session
*s
, int wantwidth
,
178 Point
*numerp
, Point
*denomp
)
180 Point numer
, denom
, tmpnumer
, tmpdenom
;
182 const char text
= 'W';
185 numer
.v
= denom
.v
= 1; /* always */
186 numer
.h
= denom
.h
= 1;
187 for (i
= 0; i
< 3; i
++) {
190 if (s
->window
->grafProcs
!= NULL
)
191 gotwidth
= InvokeQDTxMeasUPP(1, &text
, &tmpnumer
, &tmpdenom
, &fi
,
192 s
->window
->grafProcs
->txMeasProc
);
194 gotwidth
= StdTxMeas(1, &text
, &tmpnumer
, &tmpdenom
, &fi
);
195 /* The result of StdTxMeas must be scaled by the factors it returns. */
196 gotwidth
= FixRound(FixMul(gotwidth
<< 16,
197 FixRatio(tmpnumer
.h
, tmpdenom
.h
)));
198 if (gotwidth
== wantwidth
)
200 numer
.h
*= wantwidth
;
207 static UnicodeToTextFallbackUPP uni_to_font_fallback_upp
;
209 static void mac_initfont(Session
*s
) {
216 c2pstrcpy(macfont
, s
->cfg
.font
);
217 GetFNum(macfont
, &s
->fontnum
);
218 TextFont(s
->fontnum
);
219 TextFace(s
->cfg
.fontisbold ? bold
: 0);
220 TextSize(s
->cfg
.fontheight
);
222 s
->font_width
= CharWidth('W'); /* Well, it's what NCSA uses. */
223 s
->font_ascent
= fi
.ascent
;
224 s
->font_leading
= fi
.leading
;
225 s
->font_height
= s
->font_ascent
+ fi
.descent
+ s
->font_leading
;
226 mac_workoutfontscale(s
, s
->font_width
,
227 &s
->font_stdnumer
, &s
->font_stddenom
);
228 mac_workoutfontscale(s
, s
->font_width
* 2,
229 &s
->font_widenumer
, &s
->font_widedenom
);
230 TextSize(s
->cfg
.fontheight
* 2);
231 mac_workoutfontscale(s
, s
->font_width
* 2,
232 &s
->font_bignumer
, &s
->font_bigdenom
);
233 TextSize(s
->cfg
.fontheight
);
234 if (!s
->cfg
.bold_colour
) {
236 s
->font_boldadjust
= s
->font_width
- CharWidth('W');
238 s
->font_boldadjust
= 0;
240 if (s
->uni_to_font
!= NULL
)
241 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
242 if (mac_gestalts
.encvvers
!= 0 &&
243 UpgradeScriptInfoToTextEncoding(kTextScriptDontCare
,
244 kTextLanguageDontCare
,
245 kTextRegionDontCare
, macfont
,
247 CreateUnicodeToTextInfoByEncoding(enc
, &s
->uni_to_font
) == noErr
) {
248 if (uni_to_font_fallback_upp
== NULL
)
249 uni_to_font_fallback_upp
=
250 NewUnicodeToTextFallbackProc(&uni_to_font_fallback
);
251 fbflags
= kUnicodeFallbackCustomOnly
;
252 if (mac_gestalts
.uncvattr
& kTECAddFallbackInterruptMask
)
253 fbflags
|= kUnicodeFallbackInterruptSafeMask
;
254 if (SetFallbackUnicodeToText(s
->uni_to_font
,
255 uni_to_font_fallback_upp
, fbflags
, NULL
) != noErr
) {
256 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
261 s
->uni_to_font
= NULL
;
263 charset_from_macenc(FontToScript(s
->fontnum
),
264 GetScriptManagerVariable(smRegionCode
),
265 mac_gestalts
.sysvers
, s
->cfg
.font
);
268 mac_adjustsize(s
, s
->term
->rows
, s
->term
->cols
);
271 static pascal OSStatus
uni_to_font_fallback(UniChar
*ucp
,
272 ByteCount ilen
, ByteCount
*iusedp
, TextPtr obuf
, ByteCount olen
,
273 ByteCount
*ousedp
, LogicalAddress
*cookie
, ConstUnicodeMappingPtr mapping
)
277 return kTECOutputBufferFullStatus
;
279 * What I'd _like_ to do here is to somehow generate the
280 * missing-character glyph that every font is required to have.
281 * Unfortunately (and somewhat surprisingly), I can't find any way
282 * to actually ask for it explicitly. Bah.
291 * Called every time round the event loop.
293 void mac_pollterm(void)
297 for (s
= sesslist
; s
!= NULL
; s
= s
->next
) {
299 term_update(s
->term
);
304 * To be called whenever the window size changes.
305 * rows and cols should be desired values.
306 * It's assumed the terminal emulator will be informed, and will set rows
309 static void mac_adjustsize(Session
*s
, int newrows
, int newcols
) {
310 int winwidth
, winheight
;
312 winwidth
= newcols
* s
->font_width
+ 15;
313 winheight
= newrows
* s
->font_height
;
314 SizeWindow(s
->window
, winwidth
, winheight
, true);
315 HideControl(s
->scrollbar
);
316 MoveControl(s
->scrollbar
, winwidth
- 15, -1);
317 SizeControl(s
->scrollbar
, 16, winheight
- 13);
318 ShowControl(s
->scrollbar
);
322 static void mac_initpalette(Session
*s
) {
324 if (!HAVE_COLOR_QD())
327 * Most colours should be inhibited on 2bpp displays.
328 * Palette manager documentation suggests inhibiting all tolerant colours
329 * on greyscale displays.
331 #define PM_NORMAL ( pmTolerant | pmInhibitC2 | \
332 pmInhibitG2 | pmInhibitG4 | pmInhibitG8 )
333 #define PM_TOLERANCE 0x2000
334 s
->palette
= NewPalette(22, NULL
, PM_NORMAL
, PM_TOLERANCE
);
335 if (s
->palette
== NULL
)
336 fatalbox("Unable to create palette");
337 /* In 2bpp, these are the colours we want most. */
338 SetEntryUsage(s
->palette
, DEFAULT_BG
,
339 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
340 SetEntryUsage(s
->palette
, DEFAULT_FG
,
341 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
342 SetEntryUsage(s
->palette
, DEFAULT_FG_BOLD
,
343 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
344 SetEntryUsage(s
->palette
, CURSOR_BG
,
345 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
350 * Set the background colour of the window correctly. Should be
351 * called whenever the default background changes.
353 static void mac_adjustwinbg(Session
*s
) {
355 if (!HAVE_COLOR_QD())
358 if (mac_gestalts
.windattr
& gestaltWindowMgrPresent
)
359 SetWindowContentColor(s
->window
,
360 &(*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
);
364 if (s
->wctab
== NULL
)
365 s
->wctab
= (WCTabHandle
)NewHandle(sizeof(**s
->wctab
));
366 if (s
->wctab
== NULL
)
367 return; /* do without */
368 (*s
->wctab
)->wCSeed
= 0;
369 (*s
->wctab
)->wCReserved
= 0;
370 (*s
->wctab
)->ctSize
= 0;
371 (*s
->wctab
)->ctTable
[0].value
= wContentColor
;
372 (*s
->wctab
)->ctTable
[0].rgb
= (*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
;
373 SetWinColor(s
->window
, s
->wctab
);
378 * Set the cursor shape correctly
380 void mac_adjusttermcursor(WindowPtr window
, Point mouse
, RgnHandle cursrgn
) {
382 ControlHandle control
;
387 s
= (Session
*)GetWRefCon(window
);
388 GlobalToLocal(&mouse
);
389 part
= FindControl(mouse
, window
, &control
);
390 if (control
== s
->scrollbar
) {
391 SetCursor(&qd
.arrow
);
392 RectRgn(cursrgn
, &(*s
->scrollbar
)->contrlRect
);
393 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
395 x
= mouse
.h
/ s
->font_width
;
396 y
= mouse
.v
/ s
->font_height
;
398 SetCursor(&qd
.arrow
);
400 SetCursor(*GetCursor(iBeamCursor
));
401 /* Ask for shape changes if we leave this character cell. */
402 SetRectRgn(cursrgn
, x
* s
->font_width
, y
* s
->font_height
,
403 (x
+ 1) * s
->font_width
, (y
+ 1) * s
->font_height
);
404 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
409 * Enable/disable menu items based on the active terminal window.
411 void mac_adjusttermmenus(WindowPtr window
) {
416 s
= (Session
*)GetWRefCon(window
);
417 menu
= GetMenuHandle(mFile
);
418 DisableItem(menu
, iSave
); /* XXX enable if modified */
419 EnableItem(menu
, iSaveAs
);
420 EnableItem(menu
, iDuplicate
);
421 menu
= GetMenuHandle(mEdit
);
423 DisableItem(menu
, iUndo
);
424 DisableItem(menu
, iCut
);
425 if (1/*s->term->selstate == SELECTED*/)
426 EnableItem(menu
, iCopy
);
428 DisableItem(menu
, iCopy
);
429 if (GetScrap(NULL
, 'TEXT', &offset
) == noTypeErr
)
430 DisableItem(menu
, iPaste
);
432 EnableItem(menu
, iPaste
);
433 DisableItem(menu
, iClear
);
434 EnableItem(menu
, iSelectAll
);
437 void mac_menuterm(WindowPtr window
, short menu
, short item
) {
440 s
= (Session
*)GetWRefCon(window
);
448 term_do_paste(s
->term
);
454 void mac_clickterm(WindowPtr window
, EventRecord
*event
) {
457 ControlHandle control
;
460 s
= (Session
*)GetWRefCon(window
);
462 mouse
= event
->where
;
463 GlobalToLocal(&mouse
);
464 part
= FindControl(mouse
, window
, &control
);
465 if (control
== s
->scrollbar
) {
467 case kControlIndicatorPart
:
468 if (TrackControl(control
, mouse
, NULL
) == kControlIndicatorPart
)
469 term_scroll(s
->term
, +1, GetControlValue(control
));
471 case kControlUpButtonPart
:
472 case kControlDownButtonPart
:
473 case kControlPageUpPart
:
474 case kControlPageDownPart
:
475 TrackControl(control
, mouse
, &mac_scrolltracker_upp
);
479 text_click(s
, event
);
483 static void text_click(Session
*s
, EventRecord
*event
) {
486 static UInt32 lastwhen
= 0;
487 static Session
*lastsess
= NULL
;
488 static int lastrow
= -1, lastcol
= -1;
489 static Mouse_Action lastact
= MA_NOTHING
;
492 localwhere
= event
->where
;
493 GlobalToLocal(&localwhere
);
495 col
= PTOCC(localwhere
.h
);
496 row
= PTOCR(localwhere
.v
);
497 if (event
->when
- lastwhen
< GetDblTime() &&
498 row
== lastrow
&& col
== lastcol
&& s
== lastsess
)
499 lastact
= (lastact
== MA_CLICK ? MA_2CLK
:
500 lastact
== MA_2CLK ? MA_3CLK
:
501 lastact
== MA_3CLK ? MA_CLICK
: MA_NOTHING
);
504 term_mouse(s
->term
, MBT_LEFT
,
505 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
506 lastact
, col
, row
, event
->modifiers
& shiftKey
,
507 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
511 while (StillDown()) {
512 GetMouse(&localwhere
);
513 col
= PTOCC(localwhere
.h
);
514 row
= PTOCR(localwhere
.v
);
515 term_mouse(s
->term
, MBT_LEFT
,
516 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
517 MA_DRAG
, col
, row
, event
->modifiers
& shiftKey
,
518 event
->modifiers
& controlKey
,
519 event
->modifiers
& optionKey
);
520 if (row
> s
->term
->rows
- 1)
521 term_scroll(s
->term
, 0, row
- (s
->term
->rows
- 1));
523 term_scroll(s
->term
, 0, row
);
525 term_mouse(s
->term
, MBT_LEFT
,
526 event
->modifiers
& shiftKey ? MBT_EXTEND
: MBT_SELECT
,
527 MA_RELEASE
, col
, row
, event
->modifiers
& shiftKey
,
528 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
529 lastwhen
= TickCount();
532 void write_clip(void *cookie
, wchar_t *data
, int len
, int must_deselect
)
536 ByteCount iread
, olen
;
544 * See "Programming with the Text Encoding Conversion Manager"
545 * Appendix E for Unicode scrap conventions.
547 * XXX Maybe PICT scrap too.
549 if (ZeroScrap() != noErr
)
551 PutScrap(len
* sizeof(*data
), 'utxt', data
);
553 /* Replace LINE SEPARATORs with CR for TEXT output. */
554 for (i
= 0; i
< len
; i
++)
555 if (data
[i
] == 0x2028)
558 mactextbuf
= smalloc(len
); /* XXX DBCS */
559 if (s
->uni_to_font
!= NULL
) {
560 err
= ConvertFromUnicodeToText(s
->uni_to_font
, len
* sizeof(UniChar
),
562 kUnicodeUseFallbacksMask
,
564 len
, &iread
, &olen
, mactextbuf
);
565 if (err
!= noErr
&& err
!= kTECUsedFallbacksStatus
)
567 } else if (s
->font_charset
!= CS_NONE
) {
569 olen
= charset_from_unicode(&unitextptr
, &len
, mactextbuf
, 1024,
570 s
->font_charset
, NULL
, ".", 1);
573 PutScrap(olen
, 'TEXT', mactextbuf
);
576 stsz
= offsetof(StScrpRec
, scrpStyleTab
) + sizeof(ScrpSTElement
);
577 stsc
= smalloc(stsz
);
578 stsc
->scrpNStyles
= 1;
579 stsc
->scrpStyleTab
[0].scrpStartChar
= 0;
580 stsc
->scrpStyleTab
[0].scrpHeight
= s
->font_height
;
581 stsc
->scrpStyleTab
[0].scrpAscent
= s
->font_ascent
;
582 stsc
->scrpStyleTab
[0].scrpFont
= s
->fontnum
;
583 stsc
->scrpStyleTab
[0].scrpFace
= 0;
584 stsc
->scrpStyleTab
[0].scrpSize
= s
->cfg
.fontheight
;
585 stsc
->scrpStyleTab
[0].scrpColor
.red
= 0;
586 stsc
->scrpStyleTab
[0].scrpColor
.green
= 0;
587 stsc
->scrpStyleTab
[0].scrpColor
.blue
= 0;
588 PutScrap(stsz
, 'styl', stsc
);
592 void get_clip(void *frontend
, wchar_t **p
, int *lenp
) {
593 Session
*s
= frontend
;
594 static Handle h
= NULL
;
595 static wchar_t *data
= NULL
;
600 TextToUnicodeInfo scrap_to_uni
;
601 ByteCount iread
, olen
;
615 if (GetScrap(NULL
, 'utxt', &offset
) > 0) {
618 *lenp
= GetScrap(h
, 'utxt', &offset
) / sizeof(**p
);
621 } else if (GetScrap(NULL
, 'TEXT', &offset
) > 0) {
622 texth
= NewHandle(0);
623 textlen
= GetScrap(texth
, 'TEXT', &offset
);
625 data
= smalloc(textlen
* 2);
626 /* XXX should use 'styl' scrap if it's there. */
627 if (mac_gestalts
.encvvers
!= 0 &&
628 UpgradeScriptInfoToTextEncoding(smSystemScript
,
629 kTextLanguageDontCare
,
630 kTextRegionDontCare
, NULL
,
632 CreateTextToUnicodeInfoByEncoding(enc
, &scrap_to_uni
) ==
634 err
= ConvertFromTextToUnicode(scrap_to_uni
, textlen
,
635 *texth
, 0, 0, NULL
, NULL
, NULL
,
637 &iread
, &olen
, data
);
638 DisposeTextToUnicodeInfo(&scrap_to_uni
);
641 *lenp
= olen
/ sizeof(**p
);
648 charset_from_macenc(GetScriptManagerVariable(smSysScript
),
649 GetScriptManagerVariable(smRegionCode
),
650 mac_gestalts
.sysvers
, NULL
);
651 if (charset
!= CS_NONE
) {
653 *lenp
= charset_to_unicode(&tptr
, &textlen
, data
,
654 textlen
* 2, charset
, NULL
,
659 DisposeHandle(texth
);
667 static pascal void mac_scrolltracker(ControlHandle control
, short part
) {
670 s
= (Session
*)GetWRefCon((*control
)->contrlOwner
);
672 case kControlUpButtonPart
:
673 term_scroll(s
->term
, 0, -1);
675 case kControlDownButtonPart
:
676 term_scroll(s
->term
, 0, +1);
678 case kControlPageUpPart
:
679 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
681 case kControlPageDownPart
:
682 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
687 void mac_keyterm(WindowPtr window
, EventRecord
*event
) {
688 Session
*s
= (Session
*)GetWRefCon(window
);
689 Key_Sym keysym
= PK_NULL
;
690 unsigned int mods
= 0, flags
= PKF_NUMLOCK
;
695 fprintf(stderr
, "Got key event %08x\n", event
->message
);
697 /* No meta key yet -- that'll be rather fun. */
699 /* Keys that we handle locally */
700 if (event
->modifiers
& shiftKey
) {
701 switch ((event
->message
& keyCodeMask
) >> 8) {
702 case 0x74: /* shift-pageup */
703 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
705 case 0x79: /* shift-pagedown */
706 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
711 if (event
->modifiers
& shiftKey
)
713 if (event
->modifiers
& controlKey
)
715 if (event
->what
== autoKey
)
718 /* Mac key events consist of a virtual key code and a character code. */
720 switch ((event
->message
& keyCodeMask
) >> 8) {
721 case 0x24: keysym
= PK_RETURN
; break;
722 case 0x30: keysym
= PK_TAB
; break;
723 case 0x33: keysym
= PK_BACKSPACE
; break;
724 case 0x35: keysym
= PK_ESCAPE
; break;
726 case 0x7A: keysym
= PK_F1
; break;
727 case 0x78: keysym
= PK_F2
; break;
728 case 0x63: keysym
= PK_F3
; break;
729 case 0x76: keysym
= PK_F4
; break;
730 case 0x60: keysym
= PK_F5
; break;
731 case 0x61: keysym
= PK_F6
; break;
732 case 0x62: keysym
= PK_F7
; break;
733 case 0x64: keysym
= PK_F8
; break;
734 case 0x65: keysym
= PK_F9
; break;
735 case 0x6D: keysym
= PK_F10
; break;
736 case 0x67: keysym
= PK_F11
; break;
737 case 0x6F: keysym
= PK_F12
; break;
738 case 0x69: keysym
= PK_F13
; break;
739 case 0x6B: keysym
= PK_F14
; break;
740 case 0x71: keysym
= PK_F15
; break;
742 case 0x72: keysym
= PK_INSERT
; break;
743 case 0x73: keysym
= PK_HOME
; break;
744 case 0x74: keysym
= PK_PAGEUP
; break;
745 case 0x75: keysym
= PK_DELETE
; break;
746 case 0x77: keysym
= PK_END
; break;
747 case 0x79: keysym
= PK_PAGEDOWN
; break;
749 case 0x47: keysym
= PK_PF1
; break;
750 case 0x51: keysym
= PK_PF2
; break;
751 case 0x4B: keysym
= PK_PF3
; break;
752 case 0x43: keysym
= PK_PF4
; break;
753 case 0x4E: keysym
= PK_KPMINUS
; break;
754 case 0x45: keysym
= PK_KPCOMMA
; break;
755 case 0x41: keysym
= PK_KPDECIMAL
; break;
756 case 0x4C: keysym
= PK_KPENTER
; break;
757 case 0x52: keysym
= PK_KP0
; break;
758 case 0x53: keysym
= PK_KP1
; break;
759 case 0x54: keysym
= PK_KP2
; break;
760 case 0x55: keysym
= PK_KP3
; break;
761 case 0x56: keysym
= PK_KP4
; break;
762 case 0x57: keysym
= PK_KP5
; break;
763 case 0x58: keysym
= PK_KP6
; break;
764 case 0x59: keysym
= PK_KP7
; break;
765 case 0x5B: keysym
= PK_KP8
; break;
766 case 0x5C: keysym
= PK_KP9
; break;
768 case 0x7B: keysym
= PK_LEFT
; break;
769 case 0x7C: keysym
= PK_RIGHT
; break;
770 case 0x7D: keysym
= PK_DOWN
; break;
771 case 0x7E: keysym
= PK_UP
; break;
774 /* XXX Map from key script to Unicode. */
775 utxt
[0] = event
->message
& charCodeMask
;
776 term_key(s
->term
, keysym
, utxt
, 1, mods
, flags
);
779 void request_paste(void *frontend
)
781 Session
*s
= frontend
;
784 * In the Mac OS, pasting is synchronous: we can read the
785 * clipboard with no difficulty, so request_paste() can just go
788 term_do_paste(s
->term
);
799 void mac_growterm(WindowPtr window
, EventRecord
*event
) {
802 int newrows
, newcols
;
804 DragGrayRgnUPP draghooksave
;
808 s
= (Session
*)GetWRefCon(window
);
810 draghooksave
= LMGetDragHook();
811 growterm_state
.oldmsg
[0] = '\0';
812 growterm_state
.zeromouse
= event
->where
;
813 growterm_state
.zeromouse
.h
-= s
->term
->cols
* s
->font_width
;
814 growterm_state
.zeromouse
.v
-= s
->term
->rows
* s
->font_height
;
815 growterm_state
.s
= s
;
818 BackColor(whiteColor
);
819 ForeColor(blackColor
);
820 TextFont(systemFont
);
824 SetRect(&growterm_state
.msgrect
, 0, 0,
825 StringWidth("\p99999x99999") + 4, fi
.ascent
+ fi
.descent
+ 4);
826 SetPt(&growterm_state
.msgorigin
, 2, fi
.ascent
+ 2);
827 LMSetDragHook(NewDragGrayRgnUPP(mac_growtermdraghook
));
829 SetRect(&limits
, s
->font_width
+ 15, s
->font_height
, SHRT_MAX
, SHRT_MAX
);
830 grow_result
= GrowWindow(window
, event
->where
, &limits
);
832 DisposeDragGrayRgnUPP(LMGetDragHook());
833 LMSetDragHook(draghooksave
);
834 InvalRect(&growterm_state
.msgrect
);
838 if (grow_result
!= 0) {
839 newrows
= HiWord(grow_result
) / s
->font_height
;
840 newcols
= (LoWord(grow_result
) - 15) / s
->font_width
;
841 mac_adjustsize(s
, newrows
, newcols
);
842 term_size(s
->term
, newrows
, newcols
, s
->cfg
.savelines
);
846 static pascal void mac_growtermdraghook(void)
848 Session
*s
= growterm_state
.s
;
852 unsigned char pbuf
[20];
853 int newrows
, newcols
;
856 newrows
= (mouse
.v
- growterm_state
.zeromouse
.v
) / s
->font_height
;
857 if (newrows
< 1) newrows
= 1;
858 newcols
= (mouse
.h
- growterm_state
.zeromouse
.h
) / s
->font_width
;
859 if (newcols
< 1) newcols
= 1;
860 sprintf(buf
, "%dx%d", newcols
, newrows
);
861 if (strcmp(buf
, growterm_state
.oldmsg
) == 0)
863 strcpy(growterm_state
.oldmsg
, buf
);
864 c2pstrcpy(pbuf
, buf
);
867 SetPort(growterm_state
.s
->window
);
868 EraseRect(&growterm_state
.msgrect
);
869 MoveTo(growterm_state
.msgorigin
.h
, growterm_state
.msgorigin
.v
);
874 void mac_closeterm(WindowPtr window
)
876 Session
*s
= (Session
*)GetWRefCon(window
);
878 /* XXX warn on close */
879 HideWindow(s
->window
);
881 s
->next
->prev
= s
->prev
;
882 ldisc_free(s
->ldisc
);
883 s
->back
->free(s
->backhandle
);
885 if (s
->uni_to_font
!= NULL
)
886 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
888 DisposeWindow(s
->window
);
889 DisposePalette(s
->palette
);
893 void mac_activateterm(WindowPtr window
, Boolean active
) {
896 s
= (Session
*)GetWRefCon(window
);
897 s
->term
->has_focus
= active
;
898 term_update(s
->term
);
900 ShowControl(s
->scrollbar
);
903 PmBackColor(DEFAULT_BG
);/* HideControl clears behind the control */
905 BackColor(blackColor
);
906 HideControl(s
->scrollbar
);
911 void mac_updateterm(WindowPtr window
) {
914 s
= (Session
*)GetWRefCon(window
);
918 term_paint(s
->term
, s
,
919 PTOCC((*window
->visRgn
)->rgnBBox
.left
),
920 PTOCR((*window
->visRgn
)->rgnBBox
.top
),
921 PTOCC((*window
->visRgn
)->rgnBBox
.right
),
922 PTOCR((*window
->visRgn
)->rgnBBox
.bottom
), 1);
923 /* Restore default colours in case the Window Manager uses them */
924 if (HAVE_COLOR_QD()) {
925 PmForeColor(DEFAULT_FG
);
926 PmBackColor(DEFAULT_BG
);
928 ForeColor(whiteColor
);
929 BackColor(blackColor
);
931 if (FrontWindow() != window
)
932 EraseRect(&(*s
->scrollbar
)->contrlRect
);
933 UpdateControls(window
, window
->visRgn
);
939 static void mac_drawgrowicon(Session
*s
) {
945 * Stop DrawGrowIcon giving us space for a horizontal scrollbar
946 * See Tech Note TB575 for details.
948 clip
= s
->window
->portRect
;
949 clip
.left
= clip
.right
- 15;
953 DrawGrowIcon(s
->window
);
958 struct do_text_args
{
969 * Call from the terminal emulator to draw a bit of text
971 * x and y are text row and column (zero-based)
973 void do_text(Context ctx
, int x
, int y
, char *text
, int len
,
974 unsigned long attr
, int lattr
) {
977 struct do_text_args a
;
978 RgnHandle textrgn
, saveclip
;
979 char mactextbuf
[1024];
980 UniChar unitextbuf
[1024];
983 ByteCount iread
, olen
;
990 fontwidth
= s
->font_width
;
991 if ((lattr
& LATTR_MODE
) != LATTR_NORM
)
994 /* First check this text is relevant */
995 a
.textrect
.top
= y
* s
->font_height
;
996 a
.textrect
.bottom
= (y
+ 1) * s
->font_height
;
997 a
.textrect
.left
= x
* fontwidth
;
998 a
.textrect
.right
= (x
+ len
) * fontwidth
;
999 if (a
.textrect
.right
> s
->term
->cols
* s
->font_width
)
1000 a
.textrect
.right
= s
->term
->cols
* s
->font_width
;
1001 if (!RectInRgn(&a
.textrect
, s
->window
->visRgn
))
1004 /* Unpack Unicode from the mad format we get passed */
1005 for (i
= 0; i
< len
; i
++)
1006 unitextbuf
[i
] = (unsigned char)text
[i
] | (attr
& CSET_MASK
);
1008 if (s
->uni_to_font
!= NULL
) {
1009 err
= ConvertFromUnicodeToText(s
->uni_to_font
, len
* sizeof(UniChar
),
1010 unitextbuf
, kUnicodeUseFallbacksMask
,
1011 0, NULL
, NULL
, NULL
,
1012 1024, &iread
, &olen
, mactextbuf
);
1013 if (err
!= noErr
&& err
!= kTECUsedFallbacksStatus
)
1015 } else if (s
->font_charset
!= CS_NONE
) {
1016 /* XXX this is bogus if wchar_t and UniChar are different sizes. */
1017 unitextptr
= (wchar_t *)unitextbuf
;
1018 olen
= charset_from_unicode(&unitextptr
, &len
, mactextbuf
, 1024,
1019 s
->font_charset
, NULL
, ".", 1);
1024 a
.text
= mactextbuf
;
1028 switch (lattr
& LATTR_MODE
) {
1030 TextSize(s
->cfg
.fontheight
);
1031 a
.numer
= s
->font_stdnumer
;
1032 a
.denom
= s
->font_stddenom
;
1035 TextSize(s
->cfg
.fontheight
);
1036 a
.numer
= s
->font_widenumer
;
1037 a
.denom
= s
->font_widedenom
;
1041 TextSize(s
->cfg
.fontheight
* 2);
1042 a
.numer
= s
->font_bignumer
;
1043 a
.denom
= s
->font_bigdenom
;
1047 TextFont(s
->fontnum
);
1048 if (s
->cfg
.fontisbold
|| (attr
& ATTR_BOLD
) && !s
->cfg
.bold_colour
)
1050 if (attr
& ATTR_UNDER
)
1054 if (HAVE_COLOR_QD())
1056 SpaceExtra(s
->font_boldadjust
<< 16);
1057 CharExtra(s
->font_boldadjust
<< 16);
1062 saveclip
= NewRgn();
1064 ClipRect(&a
.textrect
);
1066 RectRgn(textrgn
, &a
.textrect
);
1067 if (HAVE_COLOR_QD())
1068 DeviceLoop(textrgn
, &do_text_for_device_upp
, (long)&a
, 0);
1070 do_text_for_device(1, 0, NULL
, (long)&a
);
1072 DisposeRgn(saveclip
);
1073 DisposeRgn(textrgn
);
1074 /* Tell the window manager about it in case this isn't an update */
1075 ValidRect(&a
.textrect
);
1078 static pascal void do_text_for_device(short depth
, short devflags
,
1079 GDHandle device
, long cookie
) {
1080 struct do_text_args
*a
;
1081 int bgcolour
, fgcolour
, bright
, reverse
, tmp
;
1083 a
= (struct do_text_args
*)cookie
;
1085 bright
= (a
->attr
& ATTR_BOLD
) && a
->s
->cfg
.bold_colour
;
1086 reverse
= a
->attr
& ATTR_REVERSE
;
1088 if (depth
== 1 && (a
->attr
& TATTR_ACTCURS
))
1091 if (HAVE_COLOR_QD()) {
1093 fgcolour
= ((a
->attr
& ATTR_FGMASK
) >> ATTR_FGSHIFT
);
1094 fgcolour
= (fgcolour
& 0xF) * 2 + (fgcolour
& 0x10 ?
1 : 0);
1095 bgcolour
= ((a
->attr
& ATTR_BGMASK
) >> ATTR_BGSHIFT
) * 2;
1096 bgcolour
= (bgcolour
& 0xF) * 2 + (bgcolour
& 0x10 ?
1 : 0);
1099 * NB: bold reverse in 2bpp breaks with the usual PuTTY model and
1100 * boldens the background, because that's all we can do.
1102 fgcolour
= bright ? DEFAULT_FG_BOLD
: DEFAULT_FG
;
1103 bgcolour
= DEFAULT_BG
;
1107 fgcolour
= bgcolour
;
1110 if (bright
&& depth
> 2)
1112 if ((a
->attr
& TATTR_ACTCURS
) && depth
> 1) {
1113 fgcolour
= CURSOR_FG
;
1114 bgcolour
= CURSOR_BG
;
1116 PmForeColor(fgcolour
);
1117 PmBackColor(bgcolour
);
1118 } else { /* No Color Quickdraw */
1119 /* XXX This should be done with a _little_ more configurability */
1121 ForeColor(blackColor
);
1122 BackColor(whiteColor
);
1124 ForeColor(whiteColor
);
1125 BackColor(blackColor
);
1129 EraseRect(&a
->textrect
);
1130 switch (a
->lattr
& LATTR_MODE
) {
1133 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
);
1136 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
* 2);
1139 MoveTo(a
->textrect
.left
,
1140 a
->textrect
.top
- a
->s
->font_height
+ a
->s
->font_ascent
* 2);
1143 /* FIXME: Sort out bold width adjustments on Original QuickDraw. */
1144 if (a
->s
->window
->grafProcs
!= NULL
)
1145 InvokeQDTextUPP(a
->len
, a
->text
, a
->numer
, a
->denom
,
1146 a
->s
->window
->grafProcs
->textProc
);
1148 StdText(a
->len
, a
->text
, a
->numer
, a
->denom
);
1150 if (a
->attr
& TATTR_PASCURS
) {
1157 PmForeColor(CURSOR_BG
);
1160 FrameRect(&a
->textrect
);
1164 void do_cursor(Context ctx
, int x
, int y
, char *text
, int len
,
1165 unsigned long attr
, int lattr
)
1168 do_text(ctx
, x
, y
, text
, len
, attr
, lattr
);
1172 * Call from the terminal emulator to get its graphics context.
1173 * Should probably be called start_redraw or something.
1175 void pre_paint(Session
*s
) {
1177 Rect myrect
, tmprect
;
1179 if (HAVE_COLOR_QD()) {
1180 s
->term
->attr_mask
= 0;
1182 myrect
= (*s
->window
->visRgn
)->rgnBBox
;
1183 LocalToGlobal((Point
*)&myrect
.top
);
1184 LocalToGlobal((Point
*)&myrect
.bottom
);
1185 for (gdh
= GetDeviceList();
1187 gdh
= GetNextDevice(gdh
)) {
1188 if (TestDeviceAttribute(gdh
, screenDevice
) &&
1189 TestDeviceAttribute(gdh
, screenActive
) &&
1190 SectRect(&(*gdh
)->gdRect
, &myrect
, &tmprect
)) {
1191 switch ((*(*gdh
)->gdPMap
)->pixelSize
) {
1193 if (s
->cfg
.bold_colour
)
1194 s
->term
->attr_mask
|= ~(ATTR_COLOURS
|
1195 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1198 s
->term
->attr_mask
|= ~ATTR_COLOURS
;
1201 s
->term
->attr_mask
= ~0;
1202 return; /* No point checking more screens. */
1207 s
->term
->attr_mask
= ~(ATTR_COLOURS
|
1208 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1211 Context
get_ctx(void *frontend
) {
1212 Session
*s
= frontend
;
1218 void free_ctx(Context ctx
) {
1223 * Presumably this does something in Windows
1225 void post_paint(Session
*s
) {
1230 * Set the scroll bar position
1232 * total is the line number of the bottom of the working screen
1233 * start is the line number of the top of the display
1234 * page is the length of the displayed page
1236 void set_sbar(void *frontend
, int total
, int start
, int page
) {
1237 Session
*s
= frontend
;
1239 /* We don't redraw until we've set everything up, to avoid glitches */
1240 (*s
->scrollbar
)->contrlMin
= 0;
1241 (*s
->scrollbar
)->contrlMax
= total
- page
;
1242 SetControlValue(s
->scrollbar
, start
);
1244 if (mac_gestalts
.cntlattr
& gestaltControlMgrPresent
)
1245 SetControlViewSize(s
->scrollbar
, page
);
1249 void sys_cursor(void *frontend
, int x
, int y
)
1252 * I think his is meaningless under Mac OS.
1257 * This is still called when mode==BELL_VISUAL, even though the
1258 * visual bell is handled entirely within terminal.c, because we
1259 * may want to perform additional actions on any kind of bell (for
1260 * example, taskbar flashing in Windows).
1262 void beep(void *frontend
, int mode
)
1264 if (mode
!= BELL_VISUAL
)
1267 * XXX We should indicate the relevant window and/or use the
1268 * Notification Manager
1272 int char_width(Context ctx
, int uc
)
1275 * Until we support exciting character-set stuff, assume all chars are
1282 * Set icon string -- a no-op here (Windowshade?)
1284 void set_icon(void *frontend
, char *icon
) {
1285 Session
*s
= frontend
;
1290 * Set the window title
1292 void set_title(void *frontend
, char *title
) {
1293 Session
*s
= frontend
;
1296 c2pstrcpy(mactitle
, title
);
1297 SetWTitle(s
->window
, mactitle
);
1301 * set or clear the "raw mouse message" mode
1303 void set_raw_mouse_mode(void *frontend
, int activate
)
1305 Session
*s
= frontend
;
1307 s
->raw_mouse
= activate
;
1308 /* FIXME: Should call mac_updatetermcursor as appropriate. */
1312 * Resize the window at the emulator's request
1314 void request_resize(void *frontend
, int w
, int h
) {
1315 Session
*s
= frontend
;
1317 term_size(s
->term
, h
, w
, s
->cfg
.savelines
);
1322 * Iconify (actually collapse) the window at the emulator's request.
1324 void set_iconic(void *frontend
, int iconic
)
1326 Session
*s
= frontend
;
1329 if (mac_gestalts
.apprvers
>= 0x0100 &&
1330 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1331 (features
& kWindowCanCollapse
))
1332 CollapseWindow(s
->window
, iconic
);
1336 * Move the window in response to a server-side request.
1338 void move_window(void *frontend
, int x
, int y
)
1340 Session
*s
= frontend
;
1342 MoveWindow(s
->window
, x
, y
, FALSE
);
1346 * Move the window to the top or bottom of the z-order in response
1347 * to a server-side request.
1349 void set_zorder(void *frontend
, int top
)
1351 Session
*s
= frontend
;
1354 * We also change the input focus to point to the topmost window,
1355 * since that's probably what the Human Interface Guidelines would
1359 SelectWindow(s
->window
);
1361 SendBehind(s
->window
, NULL
);
1365 * Refresh the window in response to a server-side request.
1367 void refresh_window(void *frontend
)
1369 Session
*s
= frontend
;
1371 term_invalidate(s
->term
);
1375 * Maximise or restore the window in response to a server-side
1378 void set_zoomed(void *frontend
, int zoomed
)
1380 Session
*s
= frontend
;
1382 ZoomWindow(s
->window
, zoomed ? inZoomOut
: inZoomIn
, FALSE
);
1386 * Report whether the window is iconic, for terminal reports.
1388 int is_iconic(void *frontend
)
1390 Session
*s
= frontend
;
1393 if (mac_gestalts
.apprvers
>= 0x0100 &&
1394 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1395 (features
& kWindowCanCollapse
))
1396 return IsWindowCollapsed(s
->window
);
1401 * Report the window's position, for terminal reports.
1403 void get_window_pos(void *frontend
, int *x
, int *y
)
1405 Session
*s
= frontend
;
1407 *x
= s
->window
->portRect
.left
;
1408 *y
= s
->window
->portRect
.top
;
1412 * Report the window's pixel size, for terminal reports.
1414 void get_window_pixels(void *frontend
, int *x
, int *y
)
1416 Session
*s
= frontend
;
1418 *x
= s
->window
->portRect
.right
- s
->window
->portRect
.left
;
1419 *y
= s
->window
->portRect
.bottom
- s
->window
->portRect
.top
;
1423 * Return the window or icon title.
1425 char *get_window_title(void *frontend
, int icon
)
1427 Session
*s
= frontend
;
1429 static char title
[256];
1431 GetWTitle(s
->window
, ptitle
);
1432 p2cstrcpy(title
, ptitle
);
1437 * real_palette_set(): This does the actual palette-changing work on behalf
1438 * of palette_set(). Does _not_ call ActivatePalette() in case the caller
1439 * is doing a batch of updates.
1441 static void real_palette_set(Session
*s
, int n
, int r
, int g
, int b
)
1445 if (!HAVE_COLOR_QD())
1447 col
.red
= r
* 0x0101;
1448 col
.green
= g
* 0x0101;
1449 col
.blue
= b
* 0x0101;
1450 SetEntryColor(s
->palette
, n
, &col
);
1454 * Set the logical palette. Called by the terminal emulator.
1456 void palette_set(void *frontend
, int n
, int r
, int g
, int b
) {
1457 Session
*s
= frontend
;
1458 static const int first
[21] = {
1459 0, 2, 4, 6, 8, 10, 12, 14,
1460 1, 3, 5, 7, 9, 11, 13, 15,
1464 if (!HAVE_COLOR_QD())
1466 real_palette_set(s
, first
[n
], r
, g
, b
);
1468 real_palette_set(s
, first
[n
]+1, r
, g
, b
);
1469 if (first
[n
] == DEFAULT_BG
)
1471 ActivatePalette(s
->window
);
1475 * Reset to the default palette
1477 void palette_reset(void *frontend
) {
1478 Session
*s
= frontend
;
1479 /* This maps colour indices in cfg to those used in our palette. */
1480 static const int ww
[] = {
1481 6, 7, 8, 9, 10, 11, 12, 13,
1482 14, 15, 16, 17, 18, 19, 20, 21,
1487 if (!HAVE_COLOR_QD())
1490 assert(lenof(ww
) == NCOLOURS
);
1492 for (i
= 0; i
< NCOLOURS
; i
++) {
1493 real_palette_set(s
, i
,
1494 s
->cfg
.colours
[ww
[i
]][0],
1495 s
->cfg
.colours
[ww
[i
]][1],
1496 s
->cfg
.colours
[ww
[i
]][2]);
1499 ActivatePalette(s
->window
);
1500 /* Palette Manager will generate update events as required. */
1504 * Scroll the screen. (`lines' is +ve for scrolling forward, -ve
1507 void do_scroll(void *frontend
, int topline
, int botline
, int lines
) {
1508 Session
*s
= frontend
;
1510 RgnHandle scrollrgn
= NewRgn();
1511 RgnHandle movedupdate
= NewRgn();
1512 RgnHandle update
= NewRgn();
1513 Point g2l
= { 0, 0 };
1518 * Work out the part of the update region that will scrolled by
1522 SetRectRgn(scrollrgn
, 0, (topline
+ lines
) * s
->font_height
,
1523 s
->term
->cols
* s
->font_width
,
1524 (botline
+ 1) * s
->font_height
);
1526 SetRectRgn(scrollrgn
, 0, topline
* s
->font_height
,
1527 s
->term
->cols
* s
->font_width
,
1528 (botline
- lines
+ 1) * s
->font_height
);
1529 CopyRgn(((WindowPeek
)s
->window
)->updateRgn
, movedupdate
);
1530 GlobalToLocal(&g2l
);
1531 OffsetRgn(movedupdate
, g2l
.h
, g2l
.v
); /* Convert to local co-ords. */
1532 SectRgn(scrollrgn
, movedupdate
, movedupdate
); /* Clip scrolled section. */
1533 ValidRgn(movedupdate
);
1534 OffsetRgn(movedupdate
, 0, -lines
* s
->font_height
); /* Scroll it. */
1537 if (HAVE_COLOR_QD())
1538 PmBackColor(DEFAULT_BG
);
1540 BackColor(blackColor
); /* XXX make configurable */
1541 SetRect(&r
, 0, topline
* s
->font_height
,
1542 s
->term
->cols
* s
->font_width
, (botline
+ 1) * s
->font_height
);
1543 ScrollRect(&r
, 0, - lines
* s
->font_height
, update
);
1546 InvalRgn(movedupdate
);
1548 DisposeRgn(scrollrgn
);
1549 DisposeRgn(movedupdate
);
1553 void logevent(void *frontend
, char *str
) {
1555 fprintf(stderr
, "%s\n", str
);
1558 /* Dummy routine, only required in plink. */
1559 void ldisc_update(void *frontend
, int echo
, int edit
)
1564 * Mac PuTTY doesn't support printing yet.
1566 printer_job
*printer_start_job(char *printer
)
1572 void printer_job_data(printer_job
*pj
, void *data
, int len
)
1576 void printer_finish_job(printer_job
*pj
)
1580 void frontend_keypress(void *handle
)
1583 * Keypress termination in non-Close-On-Exit mode is not
1584 * currently supported in PuTTY proper, because the window
1585 * always has a perfectly good Close button anyway. So we do
1592 * Ask whether to wipe a session log file before writing to it.
1593 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
1595 int askappend(void *frontend
, char *filename
)
1598 /* FIXME: not implemented yet. */
1605 * c-file-style: "simon"