📄 osxwin.m
字号:
}
- (void)alertSheetDidFinishEnding:(id)object
{
int returnCode = [object intValue];
alert_callback(alert_ctx, returnCode); /* transfers ownership of ctx */
/*
* If there's an alert in our queue (either already or because
* the callback just queued it), start it.
*/
if (alert_qhead) {
struct alert_queue *qnext;
alert_callback = alert_qhead->callback;
alert_ctx = alert_qhead->ctx;
[alert_qhead->alert beginSheetModalForWindow:self modalDelegate:self
didEndSelector:@selector(alertSheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
qnext = alert_qhead->next;
sfree(alert_qhead);
alert_qhead = qnext;
if (!qnext)
alert_qtail = NULL;
} else {
alert_ctx = NULL;
}
}
- (void)notifyRemoteExit
{
int exitcode;
if (!exited && (exitcode = back->exitcode(backhandle)) >= 0)
[self endSession:(exitcode == 0)];
}
- (void)endSession:(int)clean
{
exited = TRUE;
if (ldisc) {
ldisc_free(ldisc);
ldisc = NULL;
}
if (back) {
back->free(backhandle);
backhandle = NULL;
back = NULL;
//FIXME: update specials menu;
}
if (cfg.close_on_exit == FORCE_ON ||
(cfg.close_on_exit == AUTO && clean))
[self close];
// FIXME: else show restart menu item
}
- (Terminal *)term
{
return term;
}
@end
int from_backend(void *frontend, int is_stderr, const char *data, int len)
{
SessionWindow *win = (SessionWindow *)frontend;
return [win fromBackend:data len:len isStderr:is_stderr];
}
int from_backend_untrusted(void *frontend, const char *data, int len)
{
SessionWindow *win = (SessionWindow *)frontend;
return [win fromBackendUntrusted:data len:len];
}
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
SessionWindow *win = (SessionWindow *)p->frontend;
Terminal *term = [win term];
return term_get_userpass_input(term, p, in, inlen);
}
void frontend_keypress(void *handle)
{
/* FIXME */
}
void notify_remote_exit(void *frontend)
{
SessionWindow *win = (SessionWindow *)frontend;
[win notifyRemoteExit];
}
void ldisc_update(void *frontend, int echo, int edit)
{
//SessionWindow *win = (SessionWindow *)frontend;
/*
* In a GUI front end, this need do nothing.
*/
}
char *get_ttymode(void *frontend, const char *mode)
{
SessionWindow *win = (SessionWindow *)frontend;
Terminal *term = [win term];
return term_get_ttymode(term, mode);
}
void update_specials_menu(void *frontend)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* This is still called when mode==BELL_VISUAL, even though the
* visual bell is handled entirely within terminal.c, because we
* may want to perform additional actions on any kind of bell (for
* example, taskbar flashing in Windows).
*/
void do_beep(void *frontend, int mode)
{
//SessionWindow *win = (SessionWindow *)frontend;
if (mode != BELL_VISUAL)
NSBeep();
}
int char_width(Context ctx, int uc)
{
/*
* Under X, any fixed-width font really _is_ fixed-width.
* Double-width characters will be dealt with using a separate
* font. For the moment we can simply return 1.
*/
return 1;
}
void palette_set(void *frontend, int n, int r, int g, int b)
{
SessionWindow *win = (SessionWindow *)frontend;
if (n >= 16)
n += 256 - 16;
if (n > NALLCOLOURS)
return;
[win setColour:n r:r/255.0 g:g/255.0 b:b/255.0];
/*
* FIXME: do we need an OS X equivalent of set_window_background?
*/
}
void palette_reset(void *frontend)
{
SessionWindow *win = (SessionWindow *)frontend;
Config *cfg = [win cfg];
/* This maps colour indices in cfg to those used in colours[]. */
static const int ww[] = {
256, 257, 258, 259, 260, 261,
0, 8, 1, 9, 2, 10, 3, 11,
4, 12, 5, 13, 6, 14, 7, 15
};
int i;
for (i = 0; i < NCFGCOLOURS; i++) {
[win setColour:ww[i] r:cfg->colours[i][0]/255.0
g:cfg->colours[i][1]/255.0 b:cfg->colours[i][2]/255.0];
}
for (i = 0; i < NEXTCOLOURS; i++) {
if (i < 216) {
int r = i / 36, g = (i / 6) % 6, b = i % 6;
r = r ? r*40+55 : 0; g = g ? b*40+55 : 0; b = b ? b*40+55 : 0;
[win setColour:i+16 r:r/255.0 g:g/255.0 b:b/255.0];
} else {
int shade = i - 216;
float fshade = (shade * 10 + 8) / 255.0;
[win setColour:i+16 r:fshade g:fshade b:fshade];
}
}
/*
* FIXME: do we need an OS X equivalent of set_window_background?
*/
}
Context get_ctx(void *frontend)
{
SessionWindow *win = (SessionWindow *)frontend;
/*
* Lock the drawing focus on the image inside the TerminalView.
*/
[win drawStartFinish:YES];
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
/*
* Cocoa drawing functions don't take a graphics context: that
* parameter is implicit. Therefore, we'll use the frontend
* handle itself as the context, on the grounds that it's as
* good a thing to use as any.
*/
return frontend;
}
void free_ctx(Context ctx)
{
SessionWindow *win = (SessionWindow *)ctx;
[win drawStartFinish:NO];
}
void do_text(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
SessionWindow *win = (SessionWindow *)ctx;
[win doText:text len:len x:x y:y attr:attr lattr:lattr];
}
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
SessionWindow *win = (SessionWindow *)ctx;
Config *cfg = [win cfg];
int active, passive;
if (attr & TATTR_PASCURS) {
attr &= ~TATTR_PASCURS;
passive = 1;
} else
passive = 0;
if ((attr & TATTR_ACTCURS) && cfg->cursor_type != 0) {
attr &= ~TATTR_ACTCURS;
active = 1;
} else
active = 0;
[win doText:text len:len x:x y:y attr:attr lattr:lattr];
/*
* FIXME: now draw the various cursor types (both passive and
* active underlines and vertical lines, plus passive blocks).
*/
}
/*
* Minimise or restore the window in response to a server-side
* request.
*/
void set_iconic(void *frontend, int iconic)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Move the window in response to a server-side request.
*/
void move_window(void *frontend, int x, int y)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Move the window to the top or bottom of the z-order in response
* to a server-side request.
*/
void set_zorder(void *frontend, int top)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Refresh the window in response to a server-side request.
*/
void refresh_window(void *frontend)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Maximise or restore the window in response to a server-side
* request.
*/
void set_zoomed(void *frontend, int zoomed)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Report whether the window is iconic, for terminal reports.
*/
int is_iconic(void *frontend)
{
//SessionWindow *win = (SessionWindow *)frontend;
return NO; /* FIXME */
}
/*
* Report the window's position, for terminal reports.
*/
void get_window_pos(void *frontend, int *x, int *y)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Report the window's pixel size, for terminal reports.
*/
void get_window_pixels(void *frontend, int *x, int *y)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
/*
* Return the window or icon title.
*/
char *get_window_title(void *frontend, int icon)
{
//SessionWindow *win = (SessionWindow *)frontend;
return NULL; /* FIXME */
}
void set_title(void *frontend, char *title)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void set_icon(void *frontend, char *title)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void set_sbar(void *frontend, int total, int start, int page)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void get_clip(void *frontend, wchar_t ** p, int *len)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void write_clip(void *frontend, wchar_t *data, int *attr, int len, int must_deselect)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void request_paste(void *frontend)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void set_raw_mouse_mode(void *frontend, int activate)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void request_resize(void *frontend, int w, int h)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
}
void sys_cursor(void *frontend, int x, int y)
{
//SessionWindow *win = (SessionWindow *)frontend;
/*
* This is probably meaningless under OS X. FIXME: find out for
* sure.
*/
}
void logevent(void *frontend, const char *string)
{
//SessionWindow *win = (SessionWindow *)frontend;
/* FIXME */
printf("logevent: %s\n", string);
}
int font_dimension(void *frontend, int which)/* 0 for width, 1 for height */
{
//SessionWindow *win = (SessionWindow *)frontend;
return 1; /* FIXME */
}
void set_busy_status(void *frontend, int status)
{
/*
* We need do nothing here: the OS X `application is busy'
* beachball pointer appears _automatically_ when the
* application isn't responding to GUI messages.
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -