1 /* $Id: macterm.c,v 1.51 2003/01/18 16:54:25 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
)
115 /* XXX: Own storage management? */
117 s
->window
= GetNewCWindow(wTerminal
, NULL
, (WindowPtr
)-1);
119 s
->window
= GetNewWindow(wTerminal
, NULL
, (WindowPtr
)-1);
120 SetWRefCon(s
->window
, (long)s
);
121 s
->scrollbar
= GetNewControl(cVScroll
, s
->window
);
122 s
->term
= term_init(&s
->cfg
, &s
->ucsdata
, s
);
126 if (HAVE_COLOR_QD()) {
127 /* Set to FALSE to not get palette updates in the background. */
128 SetPalette(s
->window
, s
->palette
, TRUE
);
129 ActivatePalette(s
->window
);
132 s
->logctx
= log_init(s
, &s
->cfg
);
133 term_provide_logctx(s
->term
, s
->logctx
);
135 errmsg
= s
->back
->init(s
->term
, &s
->backhandle
, &s
->cfg
, s
->cfg
.host
,
136 s
->cfg
.port
, &s
->realhost
, s
->cfg
.tcp_nodelay
);
138 fatalbox("%s", errmsg
);
139 s
->back
->provide_logctx(s
->backhandle
, s
->logctx
);
140 set_title(s
, s
->realhost
);
142 term_provide_resize_fn(s
->term
, s
->back
->size
, s
->backhandle
);
144 mac_adjustsize(s
, s
->cfg
.height
, s
->cfg
.width
);
145 term_size(s
->term
, s
->cfg
.height
, s
->cfg
.width
, s
->cfg
.savelines
);
147 s
->ldisc
= ldisc_create(&s
->cfg
, s
->term
, s
->back
, s
->backhandle
, s
);
148 ldisc_send(s
->ldisc
, NULL
, 0, 0);/* cause ldisc to notice changes */
150 ShowWindow(s
->window
);
154 s
->next
->prev
= &s
->next
;
159 * Try to work out a horizontal scaling factor for the current font
160 * that will give a chracter width of wantwidth. Return it in numer
161 * and denom (suitable for passing to StdText()).
163 static void mac_workoutfontscale(Session
*s
, int wantwidth
,
164 Point
*numerp
, Point
*denomp
)
166 Point numer
, denom
, tmpnumer
, tmpdenom
;
168 const char text
= 'W';
171 numer
.v
= denom
.v
= 1; /* always */
172 numer
.h
= denom
.h
= 1;
173 for (i
= 0; i
< 3; i
++) {
176 if (s
->window
->grafProcs
!= NULL
)
177 gotwidth
= InvokeQDTxMeasUPP(1, &text
, &tmpnumer
, &tmpdenom
, &fi
,
178 s
->window
->grafProcs
->txMeasProc
);
180 gotwidth
= StdTxMeas(1, &text
, &tmpnumer
, &tmpdenom
, &fi
);
181 /* The result of StdTxMeas must be scaled by the factors it returns. */
182 gotwidth
= FixRound(FixMul(gotwidth
<< 16,
183 FixRatio(tmpnumer
.h
, tmpdenom
.h
)));
184 if (gotwidth
== wantwidth
)
186 numer
.h
*= wantwidth
;
193 static UnicodeToTextFallbackUPP uni_to_font_fallback_upp
;
195 static void mac_initfont(Session
*s
) {
202 c2pstrcpy(macfont
, s
->cfg
.font
);
203 GetFNum(macfont
, &s
->fontnum
);
204 TextFont(s
->fontnum
);
205 TextFace(s
->cfg
.fontisbold ? bold
: 0);
206 TextSize(s
->cfg
.fontheight
);
208 s
->font_width
= CharWidth('W'); /* Well, it's what NCSA uses. */
209 s
->font_ascent
= fi
.ascent
;
210 s
->font_leading
= fi
.leading
;
211 s
->font_height
= s
->font_ascent
+ fi
.descent
+ s
->font_leading
;
212 mac_workoutfontscale(s
, s
->font_width
,
213 &s
->font_stdnumer
, &s
->font_stddenom
);
214 mac_workoutfontscale(s
, s
->font_width
* 2,
215 &s
->font_widenumer
, &s
->font_widedenom
);
216 TextSize(s
->cfg
.fontheight
* 2);
217 mac_workoutfontscale(s
, s
->font_width
* 2,
218 &s
->font_bignumer
, &s
->font_bigdenom
);
219 TextSize(s
->cfg
.fontheight
);
220 if (!s
->cfg
.bold_colour
) {
222 s
->font_boldadjust
= s
->font_width
- CharWidth('W');
224 s
->font_boldadjust
= 0;
226 if (s
->uni_to_font
!= NULL
)
227 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
228 if (mac_gestalts
.encvvers
!= 0 &&
229 UpgradeScriptInfoToTextEncoding(kTextScriptDontCare
,
230 kTextLanguageDontCare
,
231 kTextRegionDontCare
, macfont
,
233 CreateUnicodeToTextInfoByEncoding(enc
, &s
->uni_to_font
) == noErr
) {
234 if (uni_to_font_fallback_upp
== NULL
)
235 uni_to_font_fallback_upp
=
236 NewUnicodeToTextFallbackProc(&uni_to_font_fallback
);
237 fbflags
= kUnicodeFallbackCustomOnly
;
238 if (mac_gestalts
.uncvattr
& kTECAddFallbackInterruptMask
)
239 fbflags
|= kUnicodeFallbackInterruptSafeMask
;
240 if (SetFallbackUnicodeToText(s
->uni_to_font
,
241 uni_to_font_fallback_upp
, fbflags
, NULL
) != noErr
) {
242 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
247 s
->uni_to_font
= NULL
;
249 charset_from_macenc(FontToScript(s
->fontnum
),
250 GetScriptManagerVariable(smRegionCode
),
251 mac_gestalts
.sysvers
, s
->cfg
.font
);
254 mac_adjustsize(s
, s
->term
->rows
, s
->term
->cols
);
257 static pascal OSStatus
uni_to_font_fallback(UniChar
*ucp
,
258 ByteCount ilen
, ByteCount
*iusedp
, TextPtr obuf
, ByteCount olen
,
259 ByteCount
*ousedp
, LogicalAddress
*cookie
, ConstUnicodeMappingPtr mapping
)
263 return kTECOutputBufferFullStatus
;
265 * What I'd _like_ to do here is to somehow generate the
266 * missing-character glyph that every font is required to have.
267 * Unfortunately (and somewhat surprisingly), I can't find any way
268 * to actually ask for it explicitly. Bah.
277 * Called every time round the event loop.
279 void mac_pollterm(void)
283 for (s
= sesslist
; s
!= NULL
; s
= s
->next
) {
285 term_update(s
->term
);
290 * To be called whenever the window size changes.
291 * rows and cols should be desired values.
292 * It's assumed the terminal emulator will be informed, and will set rows
295 static void mac_adjustsize(Session
*s
, int newrows
, int newcols
) {
296 int winwidth
, winheight
;
298 winwidth
= newcols
* s
->font_width
+ 15;
299 winheight
= newrows
* s
->font_height
;
300 SizeWindow(s
->window
, winwidth
, winheight
, true);
301 HideControl(s
->scrollbar
);
302 MoveControl(s
->scrollbar
, winwidth
- 15, -1);
303 SizeControl(s
->scrollbar
, 16, winheight
- 13);
304 ShowControl(s
->scrollbar
);
308 static void mac_initpalette(Session
*s
) {
310 if (!HAVE_COLOR_QD())
313 * Most colours should be inhibited on 2bpp displays.
314 * Palette manager documentation suggests inhibiting all tolerant colours
315 * on greyscale displays.
317 #define PM_NORMAL ( pmTolerant | pmInhibitC2 | \
318 pmInhibitG2 | pmInhibitG4 | pmInhibitG8 )
319 #define PM_TOLERANCE 0x2000
320 s
->palette
= NewPalette(22, NULL
, PM_NORMAL
, PM_TOLERANCE
);
321 if (s
->palette
== NULL
)
322 fatalbox("Unable to create palette");
323 /* In 2bpp, these are the colours we want most. */
324 SetEntryUsage(s
->palette
, DEFAULT_BG
,
325 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
326 SetEntryUsage(s
->palette
, DEFAULT_FG
,
327 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
328 SetEntryUsage(s
->palette
, DEFAULT_FG_BOLD
,
329 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
330 SetEntryUsage(s
->palette
, CURSOR_BG
,
331 PM_NORMAL
&~ pmInhibitC2
, PM_TOLERANCE
);
336 * Set the background colour of the window correctly. Should be
337 * called whenever the default background changes.
339 static void mac_adjustwinbg(Session
*s
) {
341 if (!HAVE_COLOR_QD())
344 if (mac_gestalts
.windattr
& gestaltWindowMgrPresent
)
345 SetWindowContentColor(s
->window
,
346 &(*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
);
350 if (s
->wctab
== NULL
)
351 s
->wctab
= (WCTabHandle
)NewHandle(sizeof(**s
->wctab
));
352 if (s
->wctab
== NULL
)
353 return; /* do without */
354 (*s
->wctab
)->wCSeed
= 0;
355 (*s
->wctab
)->wCReserved
= 0;
356 (*s
->wctab
)->ctSize
= 0;
357 (*s
->wctab
)->ctTable
[0].value
= wContentColor
;
358 (*s
->wctab
)->ctTable
[0].rgb
= (*s
->palette
)->pmInfo
[DEFAULT_BG
].ciRGB
;
359 SetWinColor(s
->window
, s
->wctab
);
364 * Set the cursor shape correctly
366 void mac_adjusttermcursor(WindowPtr window
, Point mouse
, RgnHandle cursrgn
) {
368 ControlHandle control
;
373 s
= (Session
*)GetWRefCon(window
);
374 GlobalToLocal(&mouse
);
375 part
= FindControl(mouse
, window
, &control
);
376 if (control
== s
->scrollbar
) {
377 SetCursor(&qd
.arrow
);
378 RectRgn(cursrgn
, &(*s
->scrollbar
)->contrlRect
);
379 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
381 x
= mouse
.h
/ s
->font_width
;
382 y
= mouse
.v
/ s
->font_height
;
384 SetCursor(&qd
.arrow
);
386 SetCursor(*GetCursor(iBeamCursor
));
387 /* Ask for shape changes if we leave this character cell. */
388 SetRectRgn(cursrgn
, x
* s
->font_width
, y
* s
->font_height
,
389 (x
+ 1) * s
->font_width
, (y
+ 1) * s
->font_height
);
390 SectRgn(cursrgn
, window
->visRgn
, cursrgn
);
395 * Enable/disable menu items based on the active terminal window.
397 void mac_adjusttermmenus(WindowPtr window
) {
402 s
= (Session
*)GetWRefCon(window
);
403 menu
= GetMenuHandle(mEdit
);
405 DisableItem(menu
, iUndo
);
406 DisableItem(menu
, iCut
);
407 if (1/*s->term->selstate == SELECTED*/)
408 EnableItem(menu
, iCopy
);
410 DisableItem(menu
, iCopy
);
411 if (GetScrap(NULL
, 'TEXT', &offset
) == noTypeErr
)
412 DisableItem(menu
, iPaste
);
414 EnableItem(menu
, iPaste
);
415 DisableItem(menu
, iClear
);
416 EnableItem(menu
, iSelectAll
);
419 void mac_menuterm(WindowPtr window
, short menu
, short item
) {
422 s
= (Session
*)GetWRefCon(window
);
430 term_do_paste(s
->term
);
436 void mac_clickterm(WindowPtr window
, EventRecord
*event
) {
439 ControlHandle control
;
442 s
= (Session
*)GetWRefCon(window
);
444 mouse
= event
->where
;
445 GlobalToLocal(&mouse
);
446 part
= FindControl(mouse
, window
, &control
);
447 if (control
== s
->scrollbar
) {
449 case kControlIndicatorPart
:
450 if (TrackControl(control
, mouse
, NULL
) == kControlIndicatorPart
)
451 term_scroll(s
->term
, +1, GetControlValue(control
));
453 case kControlUpButtonPart
:
454 case kControlDownButtonPart
:
455 case kControlPageUpPart
:
456 case kControlPageDownPart
:
457 TrackControl(control
, mouse
, &mac_scrolltracker_upp
);
461 text_click(s
, event
);
465 static void text_click(Session
*s
, EventRecord
*event
) {
468 static UInt32 lastwhen
= 0;
469 static Session
*lastsess
= NULL
;
470 static int lastrow
= -1, lastcol
= -1;
471 static Mouse_Action lastact
= MA_NOTHING
;
474 localwhere
= event
->where
;
475 GlobalToLocal(&localwhere
);
477 col
= PTOCC(localwhere
.h
);
478 row
= PTOCR(localwhere
.v
);
479 if (event
->when
- lastwhen
< GetDblTime() &&
480 row
== lastrow
&& col
== lastcol
&& s
== lastsess
)
481 lastact
= (lastact
== MA_CLICK ? MA_2CLK
:
482 lastact
== MA_2CLK ? MA_3CLK
:
483 lastact
== MA_3CLK ? MA_CLICK
: MA_NOTHING
);
486 /* Fake right button with shift key */
487 term_mouse(s
->term
, event
->modifiers
& shiftKey ? MBT_RIGHT
: MBT_LEFT
,
488 lastact
, col
, row
, event
->modifiers
& shiftKey
,
489 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
493 while (StillDown()) {
494 GetMouse(&localwhere
);
495 col
= PTOCC(localwhere
.h
);
496 row
= PTOCR(localwhere
.v
);
498 event
->modifiers
& shiftKey ? MBT_RIGHT
: MBT_LEFT
,
499 MA_DRAG
, col
, row
, event
->modifiers
& shiftKey
,
500 event
->modifiers
& controlKey
,
501 event
->modifiers
& optionKey
);
502 if (row
> s
->term
->rows
- 1)
503 term_scroll(s
->term
, 0, row
- (s
->term
->rows
- 1));
505 term_scroll(s
->term
, 0, row
);
507 term_mouse(s
->term
, event
->modifiers
& shiftKey ? MBT_RIGHT
: MBT_LEFT
,
508 MA_RELEASE
, col
, row
, event
->modifiers
& shiftKey
,
509 event
->modifiers
& controlKey
, event
->modifiers
& optionKey
);
510 lastwhen
= TickCount();
513 Mouse_Button
translate_button(void *frontend
, Mouse_Button button
)
526 void write_clip(void *cookie
, wchar_t *data
, int len
, int must_deselect
) {
529 * See "Programming with the Text Encoding Conversion Manager"
530 * Appendix E for Unicode scrap conventions.
532 * XXX Need to support TEXT/styl scrap as well.
533 * See STScrpRec in TextEdit (Inside Macintosh: Text) for styl details.
534 * XXX Maybe PICT scrap too.
536 if (ZeroScrap() != noErr
)
538 PutScrap(len
* sizeof(*data
), 'utxt', data
);
541 void get_clip(void *frontend
, wchar_t **p
, int *lenp
) {
542 Session
*s
= frontend
;
543 static Handle h
= NULL
;
552 /* XXX Support TEXT-format scrap as well. */
553 if (GetScrap(NULL
, 'utxt', &offset
) > 0) {
555 *lenp
= GetScrap(h
, 'utxt', &offset
) / sizeof(**p
);
558 if (*p
== NULL
|| *lenp
<= 0)
559 fatalbox("Empty scrap");
566 static pascal void mac_scrolltracker(ControlHandle control
, short part
) {
569 s
= (Session
*)GetWRefCon((*control
)->contrlOwner
);
571 case kControlUpButtonPart
:
572 term_scroll(s
->term
, 0, -1);
574 case kControlDownButtonPart
:
575 term_scroll(s
->term
, 0, +1);
577 case kControlPageUpPart
:
578 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
580 case kControlPageDownPart
:
581 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
602 #define K_INSERT 0x7200
603 #define K_HOME 0x7300
604 #define K_PRIOR 0x7400
605 #define K_DELETE 0x7500
607 #define K_NEXT 0x7900
608 #define K_LEFT 0x7b00
609 #define K_RIGHT 0x7c00
610 #define K_DOWN 0x7d00
622 #define KP_CLEAR 0x4700
623 #define KP_EQUAL 0x5100
624 #define KP_SLASH 0x4b00
625 #define KP_STAR 0x4300
626 #define KP_PLUS 0x4500
627 #define KP_MINUS 0x4e00
628 #define KP_DOT 0x4100
629 #define KP_ENTER 0x4c00
631 void mac_keyterm(WindowPtr window
, EventRecord
*event
) {
632 unsigned char buf
[20];
636 s
= (Session
*)GetWRefCon(window
);
637 len
= mac_keytrans(s
, event
, buf
);
638 ldisc_send(s
->ldisc
, (char *)buf
, len
, 1);
640 term_seen_key_event(s
->term
);
642 term_update(s
->term
);
645 static int mac_keytrans(Session
*s
, EventRecord
*event
,
646 unsigned char *output
) {
647 unsigned char *p
= output
;
650 /* No meta key yet -- that'll be rather fun. */
652 /* Keys that we handle locally */
653 if (event
->modifiers
& shiftKey
) {
654 switch (event
->message
& keyCodeMask
) {
655 case K_PRIOR
: /* shift-pageup */
656 term_scroll(s
->term
, 0, -(s
->term
->rows
- 1));
658 case K_NEXT
: /* shift-pagedown */
659 term_scroll(s
->term
, 0, +(s
->term
->rows
- 1));
665 * Control-2 should return ^@ (0x00), Control-6 should return
666 * ^^ (0x1E), and Control-Minus should return ^_ (0x1F). Since
667 * the DOS keyboard handling did it, and we have nothing better
668 * to do with the key combo in question, we'll also map
669 * Control-Backquote to ^\ (0x1C).
672 if (event
->modifiers
& controlKey
) {
673 switch (event
->message
& charCodeMask
) {
690 * First, all the keys that do tilde codes. (ESC '[' nn '~',
691 * for integer decimal nn.)
693 * We also deal with the weird ones here. Linux VCs replace F1
694 * to F5 by ESC [ [ A to ESC [ [ E. rxvt doesn't do _that_, but
695 * does replace Home and End (1~ and 4~) by ESC [ H and ESC O w
699 switch (event
->message
& keyCodeMask
) {
700 case K_F1
: code
= (event
->modifiers
& shiftKey ?
23 : 11); break;
701 case K_F2
: code
= (event
->modifiers
& shiftKey ?
24 : 12); break;
702 case K_F3
: code
= (event
->modifiers
& shiftKey ?
25 : 13); break;
703 case K_F4
: code
= (event
->modifiers
& shiftKey ?
26 : 14); break;
704 case K_F5
: code
= (event
->modifiers
& shiftKey ?
28 : 15); break;
705 case K_F6
: code
= (event
->modifiers
& shiftKey ?
29 : 17); break;
706 case K_F7
: code
= (event
->modifiers
& shiftKey ?
31 : 18); break;
707 case K_F8
: code
= (event
->modifiers
& shiftKey ?
32 : 19); break;
708 case K_F9
: code
= (event
->modifiers
& shiftKey ?
33 : 20); break;
709 case K_F10
: code
= (event
->modifiers
& shiftKey ?
34 : 21); break;
710 case K_F11
: code
= 23; break;
711 case K_F12
: code
= 24; break;
712 case K_HOME
: code
= 1; break;
713 case K_INSERT
: code
= 2; break;
714 case K_DELETE
: code
= 3; break;
715 case K_END
: code
= 4; break;
716 case K_PRIOR
: code
= 5; break;
717 case K_NEXT
: code
= 6; break;
719 if (s
->cfg
.funky_type
== 1 && code
>= 11 && code
<= 15) {
720 p
+= sprintf((char *)p
, "\x1B[[%c", code
+ 'A' - 11);
723 if (s
->cfg
.rxvt_homeend
&& (code
== 1 || code
== 4)) {
724 p
+= sprintf((char *)p
, code
== 1 ?
"\x1B[H" : "\x1BOw");
728 p
+= sprintf((char *)p
, "\x1B[%d~", code
);
732 if (s
->term
->app_keypad_keys
) {
733 switch (event
->message
& keyCodeMask
) {
734 case KP_ENTER
: p
+= sprintf((char *)p
, "\x1BOM"); return p
- output
;
735 case KP_CLEAR
: p
+= sprintf((char *)p
, "\x1BOP"); return p
- output
;
736 case KP_EQUAL
: p
+= sprintf((char *)p
, "\x1BOQ"); return p
- output
;
737 case KP_SLASH
: p
+= sprintf((char *)p
, "\x1BOR"); return p
- output
;
738 case KP_STAR
: p
+= sprintf((char *)p
, "\x1BOS"); return p
- output
;
739 case KP_PLUS
: p
+= sprintf((char *)p
, "\x1BOl"); return p
- output
;
740 case KP_MINUS
: p
+= sprintf((char *)p
, "\x1BOm"); return p
- output
;
741 case KP_DOT
: p
+= sprintf((char *)p
, "\x1BOn"); return p
- output
;
742 case KP_0
: p
+= sprintf((char *)p
, "\x1BOp"); return p
- output
;
743 case KP_1
: p
+= sprintf((char *)p
, "\x1BOq"); return p
- output
;
744 case KP_2
: p
+= sprintf((char *)p
, "\x1BOr"); return p
- output
;
745 case KP_3
: p
+= sprintf((char *)p
, "\x1BOs"); return p
- output
;
746 case KP_4
: p
+= sprintf((char *)p
, "\x1BOt"); return p
- output
;
747 case KP_5
: p
+= sprintf((char *)p
, "\x1BOu"); return p
- output
;
748 case KP_6
: p
+= sprintf((char *)p
, "\x1BOv"); return p
- output
;
749 case KP_7
: p
+= sprintf((char *)p
, "\x1BOw"); return p
- output
;
750 case KP_8
: p
+= sprintf((char *)p
, "\x1BOx"); return p
- output
;
751 case KP_9
: p
+= sprintf((char *)p
, "\x1BOy"); return p
- output
;
755 switch (event
->message
& keyCodeMask
) {
757 p
+= sprintf((char *)p
,
758 s
->term
->app_cursor_keys ?
"\x1BOA" : "\x1B[A");
761 p
+= sprintf((char *)p
,
762 s
->term
->app_cursor_keys ?
"\x1BOB" : "\x1B[B");
765 p
+= sprintf((char *)p
,
766 s
->term
->app_cursor_keys ?
"\x1BOC" : "\x1B[C");
769 p
+= sprintf((char *)p
,
770 s
->term
->app_cursor_keys ?
"\x1BOD" : "\x1B[D");
776 *p
++ = (s
->cfg
.bksp_is_delete ?
0x7f : 0x08);
779 *p
++ = event
->message
& charCodeMask
;
784 void request_paste(void *frontend
)
786 Session
*s
= frontend
;
789 * In the Mac OS, pasting is synchronous: we can read the
790 * clipboard with no difficulty, so request_paste() can just go
793 term_do_paste(s
->term
);
804 void mac_growterm(WindowPtr window
, EventRecord
*event
) {
807 int newrows
, newcols
;
809 DragGrayRgnUPP draghooksave
;
813 s
= (Session
*)GetWRefCon(window
);
815 draghooksave
= LMGetDragHook();
816 growterm_state
.oldmsg
[0] = '\0';
817 growterm_state
.zeromouse
= event
->where
;
818 growterm_state
.zeromouse
.h
-= s
->term
->cols
* s
->font_width
;
819 growterm_state
.zeromouse
.v
-= s
->term
->rows
* s
->font_height
;
820 growterm_state
.s
= s
;
823 BackColor(whiteColor
);
824 ForeColor(blackColor
);
825 TextFont(systemFont
);
829 SetRect(&growterm_state
.msgrect
, 0, 0,
830 StringWidth("\p99999x99999") + 4, fi
.ascent
+ fi
.descent
+ 4);
831 SetPt(&growterm_state
.msgorigin
, 2, fi
.ascent
+ 2);
832 LMSetDragHook(NewDragGrayRgnUPP(mac_growtermdraghook
));
834 SetRect(&limits
, s
->font_width
+ 15, s
->font_height
, SHRT_MAX
, SHRT_MAX
);
835 grow_result
= GrowWindow(window
, event
->where
, &limits
);
837 DisposeDragGrayRgnUPP(LMGetDragHook());
838 LMSetDragHook(draghooksave
);
839 InvalRect(&growterm_state
.msgrect
);
843 if (grow_result
!= 0) {
844 newrows
= HiWord(grow_result
) / s
->font_height
;
845 newcols
= (LoWord(grow_result
) - 15) / s
->font_width
;
846 mac_adjustsize(s
, newrows
, newcols
);
847 term_size(s
->term
, newrows
, newcols
, s
->cfg
.savelines
);
851 static pascal void mac_growtermdraghook(void)
853 Session
*s
= growterm_state
.s
;
857 unsigned char pbuf
[20];
858 int newrows
, newcols
;
861 newrows
= (mouse
.v
- growterm_state
.zeromouse
.v
) / s
->font_height
;
862 if (newrows
< 1) newrows
= 1;
863 newcols
= (mouse
.h
- growterm_state
.zeromouse
.h
) / s
->font_width
;
864 if (newcols
< 1) newcols
= 1;
865 sprintf(buf
, "%dx%d", newcols
, newrows
);
866 if (strcmp(buf
, growterm_state
.oldmsg
) == 0)
868 strcpy(growterm_state
.oldmsg
, buf
);
869 c2pstrcpy(pbuf
, buf
);
872 SetPort(growterm_state
.s
->window
);
873 EraseRect(&growterm_state
.msgrect
);
874 MoveTo(growterm_state
.msgorigin
.h
, growterm_state
.msgorigin
.v
);
879 void mac_closeterm(WindowPtr window
)
881 Session
*s
= (Session
*)GetWRefCon(window
);
883 /* XXX warn on close */
884 HideWindow(s
->window
);
886 s
->next
->prev
= s
->prev
;
887 ldisc_free(s
->ldisc
);
888 s
->back
->free(s
->backhandle
);
890 if (s
->uni_to_font
!= NULL
)
891 DisposeUnicodeToTextInfo(&s
->uni_to_font
);
893 DisposeWindow(s
->window
);
894 DisposePalette(s
->palette
);
898 void mac_activateterm(WindowPtr window
, Boolean active
) {
901 s
= (Session
*)GetWRefCon(window
);
902 s
->term
->has_focus
= active
;
903 term_update(s
->term
);
905 ShowControl(s
->scrollbar
);
908 PmBackColor(DEFAULT_BG
);/* HideControl clears behind the control */
910 BackColor(blackColor
);
911 HideControl(s
->scrollbar
);
916 void mac_updateterm(WindowPtr window
) {
919 s
= (Session
*)GetWRefCon(window
);
923 term_paint(s
->term
, s
,
924 PTOCC((*window
->visRgn
)->rgnBBox
.left
),
925 PTOCR((*window
->visRgn
)->rgnBBox
.top
),
926 PTOCC((*window
->visRgn
)->rgnBBox
.right
),
927 PTOCR((*window
->visRgn
)->rgnBBox
.bottom
), 1);
928 /* Restore default colours in case the Window Manager uses them */
929 if (HAVE_COLOR_QD()) {
930 PmForeColor(DEFAULT_FG
);
931 PmBackColor(DEFAULT_BG
);
933 ForeColor(whiteColor
);
934 BackColor(blackColor
);
936 if (FrontWindow() != window
)
937 EraseRect(&(*s
->scrollbar
)->contrlRect
);
938 UpdateControls(window
, window
->visRgn
);
944 static void mac_drawgrowicon(Session
*s
) {
950 * Stop DrawGrowIcon giving us space for a horizontal scrollbar
951 * See Tech Note TB575 for details.
953 clip
= s
->window
->portRect
;
954 clip
.left
= clip
.right
- 15;
958 DrawGrowIcon(s
->window
);
963 struct do_text_args
{
974 * Call from the terminal emulator to draw a bit of text
976 * x and y are text row and column (zero-based)
978 void do_text(Context ctx
, int x
, int y
, char *text
, int len
,
979 unsigned long attr
, int lattr
) {
982 struct do_text_args a
;
983 RgnHandle textrgn
, saveclip
;
984 char mactextbuf
[1024];
985 UniChar unitextbuf
[1024];
988 ByteCount iread
, olen
;
995 fontwidth
= s
->font_width
;
996 if ((lattr
& LATTR_MODE
) != LATTR_NORM
)
999 /* First check this text is relevant */
1000 a
.textrect
.top
= y
* s
->font_height
;
1001 a
.textrect
.bottom
= (y
+ 1) * s
->font_height
;
1002 a
.textrect
.left
= x
* fontwidth
;
1003 a
.textrect
.right
= (x
+ len
) * fontwidth
;
1004 if (a
.textrect
.right
> s
->term
->cols
* s
->font_width
)
1005 a
.textrect
.right
= s
->term
->cols
* s
->font_width
;
1006 if (!RectInRgn(&a
.textrect
, s
->window
->visRgn
))
1009 /* Unpack Unicode from the mad format we get passed */
1010 for (i
= 0; i
< len
; i
++)
1011 unitextbuf
[i
] = (unsigned char)text
[i
] | (attr
& CSET_MASK
);
1013 if (s
->uni_to_font
!= NULL
) {
1014 err
= ConvertFromUnicodeToText(s
->uni_to_font
, len
* sizeof(UniChar
),
1015 unitextbuf
, kUnicodeUseFallbacksMask
,
1016 0, NULL
, NULL
, NULL
,
1017 1024, &iread
, &olen
, mactextbuf
);
1018 if (err
!= noErr
&& err
!= kTECUsedFallbacksStatus
)
1020 } else if (s
->font_charset
!= CS_NONE
) {
1021 /* XXX this is bogus if wchar_t and UniChar are different sizes. */
1022 unitextptr
= (wchar_t *)unitextbuf
;
1023 olen
= charset_from_unicode(&unitextptr
, &len
, mactextbuf
, 1024,
1024 s
->font_charset
, NULL
, ".", 1);
1029 a
.text
= mactextbuf
;
1033 switch (lattr
& LATTR_MODE
) {
1035 TextSize(s
->cfg
.fontheight
);
1036 a
.numer
= s
->font_stdnumer
;
1037 a
.denom
= s
->font_stddenom
;
1040 TextSize(s
->cfg
.fontheight
);
1041 a
.numer
= s
->font_widenumer
;
1042 a
.denom
= s
->font_widedenom
;
1046 TextSize(s
->cfg
.fontheight
* 2);
1047 a
.numer
= s
->font_bignumer
;
1048 a
.denom
= s
->font_bigdenom
;
1052 TextFont(s
->fontnum
);
1053 if (s
->cfg
.fontisbold
|| (attr
& ATTR_BOLD
) && !s
->cfg
.bold_colour
)
1055 if (attr
& ATTR_UNDER
)
1059 if (HAVE_COLOR_QD())
1061 SpaceExtra(s
->font_boldadjust
<< 16);
1062 CharExtra(s
->font_boldadjust
<< 16);
1067 saveclip
= NewRgn();
1069 ClipRect(&a
.textrect
);
1071 RectRgn(textrgn
, &a
.textrect
);
1072 if (HAVE_COLOR_QD())
1073 DeviceLoop(textrgn
, &do_text_for_device_upp
, (long)&a
, 0);
1075 do_text_for_device(1, 0, NULL
, (long)&a
);
1077 DisposeRgn(saveclip
);
1078 DisposeRgn(textrgn
);
1079 /* Tell the window manager about it in case this isn't an update */
1080 ValidRect(&a
.textrect
);
1083 static pascal void do_text_for_device(short depth
, short devflags
,
1084 GDHandle device
, long cookie
) {
1085 struct do_text_args
*a
;
1086 int bgcolour
, fgcolour
, bright
, reverse
, tmp
;
1088 a
= (struct do_text_args
*)cookie
;
1090 bright
= (a
->attr
& ATTR_BOLD
) && a
->s
->cfg
.bold_colour
;
1091 reverse
= a
->attr
& ATTR_REVERSE
;
1093 if (depth
== 1 && (a
->attr
& TATTR_ACTCURS
))
1096 if (HAVE_COLOR_QD()) {
1098 fgcolour
= ((a
->attr
& ATTR_FGMASK
) >> ATTR_FGSHIFT
) * 2;
1099 bgcolour
= ((a
->attr
& ATTR_BGMASK
) >> ATTR_BGSHIFT
) * 2;
1102 * NB: bold reverse in 2bpp breaks with the usual PuTTY model and
1103 * boldens the background, because that's all we can do.
1105 fgcolour
= bright ? DEFAULT_FG_BOLD
: DEFAULT_FG
;
1106 bgcolour
= DEFAULT_BG
;
1110 fgcolour
= bgcolour
;
1113 if (bright
&& depth
> 2)
1115 if ((a
->attr
& TATTR_ACTCURS
) && depth
> 1) {
1116 fgcolour
= CURSOR_FG
;
1117 bgcolour
= CURSOR_BG
;
1119 PmForeColor(fgcolour
);
1120 PmBackColor(bgcolour
);
1121 } else { /* No Color Quickdraw */
1122 /* XXX This should be done with a _little_ more configurability */
1124 ForeColor(blackColor
);
1125 BackColor(whiteColor
);
1127 ForeColor(whiteColor
);
1128 BackColor(blackColor
);
1132 EraseRect(&a
->textrect
);
1133 switch (a
->lattr
& LATTR_MODE
) {
1136 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
);
1139 MoveTo(a
->textrect
.left
, a
->textrect
.top
+ a
->s
->font_ascent
* 2);
1142 MoveTo(a
->textrect
.left
,
1143 a
->textrect
.top
- a
->s
->font_height
+ a
->s
->font_ascent
* 2);
1146 /* FIXME: Sort out bold width adjustments on Original QuickDraw. */
1147 if (a
->s
->window
->grafProcs
!= NULL
)
1148 InvokeQDTextUPP(a
->len
, a
->text
, a
->numer
, a
->denom
,
1149 a
->s
->window
->grafProcs
->textProc
);
1151 StdText(a
->len
, a
->text
, a
->numer
, a
->denom
);
1153 if (a
->attr
& TATTR_PASCURS
) {
1160 PmForeColor(CURSOR_BG
);
1163 FrameRect(&a
->textrect
);
1167 void do_cursor(Context ctx
, int x
, int y
, char *text
, int len
,
1168 unsigned long attr
, int lattr
)
1171 do_text(ctx
, x
, y
, text
, len
, attr
, lattr
);
1175 * Call from the terminal emulator to get its graphics context.
1176 * Should probably be called start_redraw or something.
1178 void pre_paint(Session
*s
) {
1180 Rect myrect
, tmprect
;
1182 if (HAVE_COLOR_QD()) {
1183 s
->term
->attr_mask
= 0;
1185 myrect
= (*s
->window
->visRgn
)->rgnBBox
;
1186 LocalToGlobal((Point
*)&myrect
.top
);
1187 LocalToGlobal((Point
*)&myrect
.bottom
);
1188 for (gdh
= GetDeviceList();
1190 gdh
= GetNextDevice(gdh
)) {
1191 if (TestDeviceAttribute(gdh
, screenDevice
) &&
1192 TestDeviceAttribute(gdh
, screenActive
) &&
1193 SectRect(&(*gdh
)->gdRect
, &myrect
, &tmprect
)) {
1194 switch ((*(*gdh
)->gdPMap
)->pixelSize
) {
1196 if (s
->cfg
.bold_colour
)
1197 s
->term
->attr_mask
|= ~(ATTR_COLOURS
|
1198 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1201 s
->term
->attr_mask
|= ~ATTR_COLOURS
;
1204 s
->term
->attr_mask
= ~0;
1205 return; /* No point checking more screens. */
1210 s
->term
->attr_mask
= ~(ATTR_COLOURS
|
1211 (s
->cfg
.bold_colour ? ATTR_BOLD
: 0));
1214 Context
get_ctx(void *frontend
) {
1215 Session
*s
= frontend
;
1221 void free_ctx(Context ctx
) {
1226 * Presumably this does something in Windows
1228 void post_paint(Session
*s
) {
1233 * Set the scroll bar position
1235 * total is the line number of the bottom of the working screen
1236 * start is the line number of the top of the display
1237 * page is the length of the displayed page
1239 void set_sbar(void *frontend
, int total
, int start
, int page
) {
1240 Session
*s
= frontend
;
1242 /* We don't redraw until we've set everything up, to avoid glitches */
1243 (*s
->scrollbar
)->contrlMin
= 0;
1244 (*s
->scrollbar
)->contrlMax
= total
- page
;
1245 SetControlValue(s
->scrollbar
, start
);
1247 if (mac_gestalts
.cntlattr
& gestaltControlMgrPresent
)
1248 SetControlViewSize(s
->scrollbar
, page
);
1252 void sys_cursor(void *frontend
, int x
, int y
)
1255 * I think his is meaningless under Mac OS.
1260 * This is still called when mode==BELL_VISUAL, even though the
1261 * visual bell is handled entirely within terminal.c, because we
1262 * may want to perform additional actions on any kind of bell (for
1263 * example, taskbar flashing in Windows).
1265 void beep(void *frontend
, int mode
)
1267 if (mode
!= BELL_VISUAL
)
1270 * XXX We should indicate the relevant window and/or use the
1271 * Notification Manager
1275 int char_width(Context ctx
, int uc
)
1278 * Until we support exciting character-set stuff, assume all chars are
1285 * Set icon string -- a no-op here (Windowshade?)
1287 void set_icon(void *frontend
, char *icon
) {
1288 Session
*s
= frontend
;
1293 * Set the window title
1295 void set_title(void *frontend
, char *title
) {
1296 Session
*s
= frontend
;
1299 c2pstrcpy(mactitle
, title
);
1300 SetWTitle(s
->window
, mactitle
);
1304 * set or clear the "raw mouse message" mode
1306 void set_raw_mouse_mode(void *frontend
, int activate
)
1308 Session
*s
= frontend
;
1310 s
->raw_mouse
= activate
;
1311 /* FIXME: Should call mac_updatetermcursor as appropriate. */
1315 * Resize the window at the emulator's request
1317 void request_resize(void *frontend
, int w
, int h
) {
1318 Session
*s
= frontend
;
1320 term_size(s
->term
, h
, w
, s
->cfg
.savelines
);
1325 * Iconify (actually collapse) the window at the emulator's request.
1327 void set_iconic(void *frontend
, int iconic
)
1329 Session
*s
= frontend
;
1332 if (mac_gestalts
.apprvers
>= 0x0100 &&
1333 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1334 (features
& kWindowCanCollapse
))
1335 CollapseWindow(s
->window
, iconic
);
1339 * Move the window in response to a server-side request.
1341 void move_window(void *frontend
, int x
, int y
)
1343 Session
*s
= frontend
;
1345 MoveWindow(s
->window
, x
, y
, FALSE
);
1349 * Move the window to the top or bottom of the z-order in response
1350 * to a server-side request.
1352 void set_zorder(void *frontend
, int top
)
1354 Session
*s
= frontend
;
1357 * We also change the input focus to point to the topmost window,
1358 * since that's probably what the Human Interface Guidelines would
1362 SelectWindow(s
->window
);
1364 SendBehind(s
->window
, NULL
);
1368 * Refresh the window in response to a server-side request.
1370 void refresh_window(void *frontend
)
1372 Session
*s
= frontend
;
1374 term_invalidate(s
->term
);
1378 * Maximise or restore the window in response to a server-side
1381 void set_zoomed(void *frontend
, int zoomed
)
1383 Session
*s
= frontend
;
1385 ZoomWindow(s
->window
, zoomed ? inZoomOut
: inZoomIn
, FALSE
);
1389 * Report whether the window is iconic, for terminal reports.
1391 int is_iconic(void *frontend
)
1393 Session
*s
= frontend
;
1396 if (mac_gestalts
.apprvers
>= 0x0100 &&
1397 GetWindowFeatures(s
->window
, &features
) == noErr
&&
1398 (features
& kWindowCanCollapse
))
1399 return IsWindowCollapsed(s
->window
);
1404 * Report the window's position, for terminal reports.
1406 void get_window_pos(void *frontend
, int *x
, int *y
)
1408 Session
*s
= frontend
;
1410 *x
= s
->window
->portRect
.left
;
1411 *y
= s
->window
->portRect
.top
;
1415 * Report the window's pixel size, for terminal reports.
1417 void get_window_pixels(void *frontend
, int *x
, int *y
)
1419 Session
*s
= frontend
;
1421 *x
= s
->window
->portRect
.right
- s
->window
->portRect
.left
;
1422 *y
= s
->window
->portRect
.bottom
- s
->window
->portRect
.top
;
1426 * Return the window or icon title.
1428 char *get_window_title(void *frontend
, int icon
)
1430 Session
*s
= frontend
;
1432 static char title
[256];
1434 GetWTitle(s
->window
, ptitle
);
1435 p2cstrcpy(title
, ptitle
);
1440 * real_palette_set(): This does the actual palette-changing work on behalf
1441 * of palette_set(). Does _not_ call ActivatePalette() in case the caller
1442 * is doing a batch of updates.
1444 static void real_palette_set(Session
*s
, int n
, int r
, int g
, int b
)
1448 if (!HAVE_COLOR_QD())
1450 col
.red
= r
* 0x0101;
1451 col
.green
= g
* 0x0101;
1452 col
.blue
= b
* 0x0101;
1453 SetEntryColor(s
->palette
, n
, &col
);
1457 * Set the logical palette. Called by the terminal emulator.
1459 void palette_set(void *frontend
, int n
, int r
, int g
, int b
) {
1460 Session
*s
= frontend
;
1461 static const int first
[21] = {
1462 0, 2, 4, 6, 8, 10, 12, 14,
1463 1, 3, 5, 7, 9, 11, 13, 15,
1467 if (!HAVE_COLOR_QD())
1469 real_palette_set(s
, first
[n
], r
, g
, b
);
1471 real_palette_set(s
, first
[n
]+1, r
, g
, b
);
1472 if (first
[n
] == DEFAULT_BG
)
1474 ActivatePalette(s
->window
);
1478 * Reset to the default palette
1480 void palette_reset(void *frontend
) {
1481 Session
*s
= frontend
;
1482 /* This maps colour indices in cfg to those used in our palette. */
1483 static const int ww
[] = {
1484 6, 7, 8, 9, 10, 11, 12, 13,
1485 14, 15, 16, 17, 18, 19, 20, 21,
1490 if (!HAVE_COLOR_QD())
1493 assert(lenof(ww
) == NCOLOURS
);
1495 for (i
= 0; i
< NCOLOURS
; i
++) {
1496 real_palette_set(s
, i
,
1497 s
->cfg
.colours
[ww
[i
]][0],
1498 s
->cfg
.colours
[ww
[i
]][1],
1499 s
->cfg
.colours
[ww
[i
]][2]);
1502 ActivatePalette(s
->window
);
1503 /* Palette Manager will generate update events as required. */
1507 * Scroll the screen. (`lines' is +ve for scrolling forward, -ve
1510 void do_scroll(void *frontend
, int topline
, int botline
, int lines
) {
1511 Session
*s
= frontend
;
1513 RgnHandle scrollrgn
= NewRgn();
1514 RgnHandle movedupdate
= NewRgn();
1515 RgnHandle update
= NewRgn();
1516 Point g2l
= { 0, 0 };
1521 * Work out the part of the update region that will scrolled by
1525 SetRectRgn(scrollrgn
, 0, (topline
+ lines
) * s
->font_height
,
1526 s
->term
->cols
* s
->font_width
,
1527 (botline
+ 1) * s
->font_height
);
1529 SetRectRgn(scrollrgn
, 0, topline
* s
->font_height
,
1530 s
->term
->cols
* s
->font_width
,
1531 (botline
- lines
+ 1) * s
->font_height
);
1532 CopyRgn(((WindowPeek
)s
->window
)->updateRgn
, movedupdate
);
1533 GlobalToLocal(&g2l
);
1534 OffsetRgn(movedupdate
, g2l
.h
, g2l
.v
); /* Convert to local co-ords. */
1535 SectRgn(scrollrgn
, movedupdate
, movedupdate
); /* Clip scrolled section. */
1536 ValidRgn(movedupdate
);
1537 OffsetRgn(movedupdate
, 0, -lines
* s
->font_height
); /* Scroll it. */
1540 if (HAVE_COLOR_QD())
1541 PmBackColor(DEFAULT_BG
);
1543 BackColor(blackColor
); /* XXX make configurable */
1544 SetRect(&r
, 0, topline
* s
->font_height
,
1545 s
->term
->cols
* s
->font_width
, (botline
+ 1) * s
->font_height
);
1546 ScrollRect(&r
, 0, - lines
* s
->font_height
, update
);
1549 InvalRgn(movedupdate
);
1551 DisposeRgn(scrollrgn
);
1552 DisposeRgn(movedupdate
);
1556 void logevent(void *frontend
, char *str
) {
1558 fprintf(stderr
, "%s\n", str
);
1561 /* Dummy routine, only required in plink. */
1562 void ldisc_update(void *frontend
, int echo
, int edit
)
1567 * Mac PuTTY doesn't support printing yet.
1569 printer_job
*printer_start_job(char *printer
)
1575 void printer_job_data(printer_job
*pj
, void *data
, int len
)
1579 void printer_finish_job(printer_job
*pj
)
1583 void frontend_keypress(void *handle
)
1586 * Keypress termination in non-Close-On-Exit mode is not
1587 * currently supported in PuTTY proper, because the window
1588 * always has a perfectly good Close button anyway. So we do
1595 * Ask whether to wipe a session log file before writing to it.
1596 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
1598 int askappend(void *frontend
, char *filename
)
1601 /* FIXME: not implemented yet. */
1608 * c-file-style: "simon"