📄 window_set.c
字号:
register int i; (void)win_get_kbd_mask(win->fd, &mask); for(i=1; attrs[i]; i++) unset_mask_bit(&mask, attrs[i], win->fd); (void)win_set_kbd_mask(win->fd, &mask); } break; case WIN_PICK_INPUT_MASK: (void)win_set_pick_mask(win->fd, (struct inputmask *)attrs[1]); break; case WIN_CONSUME_PICK_EVENT: { struct inputmask mask; (void)win_get_pick_mask(win->fd, &mask); set_mask_bit(&mask, attrs[1], win->fd); (void)win_set_pick_mask(win->fd, &mask); } break; case WIN_IGNORE_PICK_EVENT: { struct inputmask mask; (void)win_get_pick_mask(win->fd, &mask); unset_mask_bit(&mask, attrs[1], win->fd); (void)win_set_pick_mask(win->fd, &mask); } break; case WIN_CONSUME_PICK_EVENTS: { struct inputmask mask; register int i; (void)win_get_pick_mask(win->fd, &mask); for(i=1; attrs[i]; i++) set_mask_bit(&mask, attrs[i], win->fd); (void)win_set_pick_mask(win->fd, &mask); } break; case WIN_IGNORE_PICK_EVENTS: { struct inputmask mask; register int i; (void)win_get_pick_mask(win->fd, &mask); for(i=1; attrs[i]; i++) unset_mask_bit(&mask, attrs[i], win->fd); (void)win_set_pick_mask(win->fd, &mask); } break; case WIN_ERROR_MSG: /* Ignore this attr during set */ break; /* * There is abug dealing with nested calls to window_set() * from an object set_proc. * Note: This is a fix for frame_set() that allows frame_set() * to set the TOP_MARGIN */ case WIN_TOP_MARGIN: win->top_margin = (int)attrs[1]; break; case WIN_FONT: /* These attrs have been prescanned */ case WIN_BOTTOM_MARGIN: case WIN_LEFT_MARGIN: case WIN_RIGHT_MARGIN: case WIN_ROW_HEIGHT: case WIN_COLUMN_WIDTH: case WIN_ROW_GAP: case WIN_COLUMN_GAP: case WIN_SHOW_UPDATES: case WIN_COMPATIBILITY: case WIN_COMPATIBILITY_INFO: break; case ATTR_LIST: /* This only occurs when a pkg_set wants to do inline */ /* substitution. Don''t defer the set. */ if (attrs[1]) (void)window_set_avlist(win, (Window_attribute *) (LINT_CAST(attrs[1]))); break; case WIN_ALARM: win_alarm((Win_alarm *) (LINT_CAST(attrs[1])), win->fd, win->pixwin); break; default: if (ATTR_PKG_WIN == ATTR_PKG(attrs[0])) (void)fprintf(stderr, "window_set: Window attribute not allowed.\n%s\n", attr_sprint((char *)NULL, (unsigned)attrs[0])); break; } } /* This unlock may operate on a different fd then the original lock * This is supposed to work. See compatibility_info attr. */ if (win->fd >= 0) (void)win_unlockdata(win->fd); if (adjusted && win->layout_proc) (win->layout_proc)(win->object, win->object, WIN_ADJUSTED); if (allow_registration && do_registration && win->well_behaved) { if (win->registered) (void)win_unregister(old_object); (void)win_register(win->object, win->pixwin, event_proc, destroy_proc, (unsigned)notify_flags); win->registered = TRUE; } else if (win->well_behaved) { if (event_proc != window_default_event_func) (void)notify_set_event_func(win->object, event_proc, NOTIFY_SAFE); if (destroy_proc != window_default_destroy_func) (void)notify_set_destroy_func((Notify_client)(LINT_CAST(win->object)), destroy_proc); } return TRUE;}intwindow_read_event(window, event)Window window;struct inputevent *event;{ return input_readevent(window_fd(window), event);}voidwindow_bell(window)Window window;{ struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 100000; /* 1/10 second */ (void)win_bell(window_fd(window), tv, (struct pixwin *)(LINT_CAST(window_get(window, WIN_PIXWIN))));}/* convert any row or column unit attribute values * in avlist to pixel units, using the window's row, column * parameters. */Pkg_private voidwindow_rc_units_to_pixels(client_win, avlist) Window client_win; Window_attribute avlist[];{ register struct window *win; win = client_to_win(client_win); if (!win) return; attr_rc_units_to_pixels((char **)(LINT_CAST(avlist)), actual_column_width(win), actual_row_height(win), win->left_margin, win->top_margin, win->column_gap, win->row_gap);}Pkg_private voidwindow_scan_and_convert_to_pixels(win, avlist) register struct window *win; Window_attribute avlist[];{ register Window_attribute *attrs; for (attrs = avlist; *attrs; attrs = window_attr_next(attrs)) { switch (attrs[0]) { struct pixfont *pw_pfsysopen(); case WIN_FONT: win->font = (struct pixfont *)attrs[1]; if (!win->font) win->font = pw_pfsysopen(); break; case WIN_TOP_MARGIN: win->top_margin = (int)attrs[1]; break; case WIN_BOTTOM_MARGIN: win->bottom_margin = (int)attrs[1]; break; case WIN_LEFT_MARGIN: win->left_margin = (int)attrs[1]; break; case WIN_RIGHT_MARGIN: win->right_margin = (int)attrs[1]; break; case WIN_ROW_HEIGHT: win->row_height = (int)attrs[1]; break; case WIN_COLUMN_WIDTH: win->column_width = (int)attrs[1]; break; case WIN_ROW_GAP: win->row_gap = (int)attrs[1]; break; case WIN_COLUMN_GAP: win->column_gap = (int)attrs[1]; break; case WIN_COMPATIBILITY_INFO: win->fd = (int)attrs[1]; win->pixwin = (struct pixwin *)attrs[2]; /* FALL THRU */ case WIN_COMPATIBILITY: win->well_behaved = FALSE; break; case WIN_SHOW_UPDATES: win->show_updates = (int)attrs[1]; break; } } window_rc_units_to_pixels(win->object, avlist);}/* * This routine converts a client handle into a pointer to a window struct. * The only call to this routine should be in the macro client_to_win(). */Pkg_private Windowwin_from_client(client) register Window client;{ register Window_slot *wp = win_clients; /* Clear the cache (Not sure this feature is used anywhere) */ if (client == NULL || next_window_slot == NULL) return win_last_client = win_last_window = NULL; next_window_slot->client = client; /* Guarantee that search terminates */ while (wp->client != client) wp++; /* Search the assoc table */ if (wp == next_window_slot) return NULL; /* Search failed */ win_last_client = client; /* Search successed, set cache */ win_last_window = (Window)wp->window; return win_last_window;}#define MAX_CLIENTS getdtablesize()Pkg_private caddr_twin_set_client(win, client, create) struct window *win; caddr_t client; int/*bool*/ create;{ register Window_slot *wp; if (!win_clients) { /* Malloc, instead of Bss */ win_clients = (Window_slot *)malloc(MAX_CLIENTS * sizeof(*win_clients)); if (!win_clients) { return 0; } next_window_slot = win_clients; /* Initialize slot ptr */ } wp = win_clients; if (create) { /* Find first empty slot */ next_window_slot->client = NULL; while (wp->client) wp++; if (wp == next_window_slot) next_window_slot++; } else { /* Look for existing entry */ next_window_slot->window = win; while (wp->window != win) wp++; if (wp == next_window_slot) return NULL;/* Search Failed */ } wp->client = win->object = win_last_client = client; wp->window = client ? win : 0; win_last_window = (Window)wp->window; return win->object;}Private voidset_mask_bit(mask, value, fd) register Inputmask *mask; Window_input_event value; int fd;{ int i; switch (value) { case WIN_NO_EVENTS: (void)input_imnull(mask); break; case WIN_MOUSE_BUTTONS: win_setinputcodebit(mask, MS_LEFT); win_setinputcodebit(mask, MS_MIDDLE); win_setinputcodebit(mask, MS_RIGHT); mask->im_flags |= IM_NEGEVENT; break; case WIN_LEFT_KEYS: for(i = 1; i < 16; i++) win_setinputcodebit(mask, KEY_LEFT(i)); break; case WIN_TOP_KEYS: for(i = 1; i < 16; i++) win_setinputcodebit(mask, KEY_TOP(i)); break; case WIN_RIGHT_KEYS: for(i = 1; i < 16; i++) win_setinputcodebit(mask, KEY_RIGHT(i)); break; case WIN_BOTTOM_KEYS: for(i = 1; i < 16; i++) win_setinputcodebit(mask, KEY_BOTTOM(i)); break; case WIN_ASCII_EVENTS: mask->im_flags |= IM_ASCII; mask->im_flags |= IM_META; break; case WIN_UP_ASCII_EVENTS: mask->im_flags |= IM_NEGASCII; mask->im_flags |= IM_NEGMETA; break; case WIN_EUC_EVENTS: mask->im_flags |= IM_EUC; mask->im_flags |= IM_META; break; case WIN_UP_EUC_EVENTS: mask->im_flags |= IM_NEGEUC; mask->im_flags |= IM_NEGMETA; break; case WIN_UP_EVENTS: mask->im_flags |= IM_NEGEVENT; break; case WIN_IN_TRANSIT_EVENTS: mask->im_flags |= IM_INTRANSIT; break; case WIN_SUNVIEW_FUNCTION_KEYS: win_keymap_set_smask_class(fd, KEYMAP_FUNCT_KEYS); break; case WIN_EDIT_KEYS: win_keymap_set_smask_class(fd, KEYMAP_EDIT_KEYS); break; case WIN_MOTION_KEYS: win_keymap_set_smask_class(fd, KEYMAP_MOTION_KEYS); break; case WIN_TEXT_KEYS: win_keymap_set_smask_class(fd, KEYMAP_TEXT_KEYS); break; default: if (isworkstationdevid((int) value)) win_setinputcodebit(mask, (int)value); else { win_keymap_set_smask(fd, (u_short) value); win_keymap_set_imask_from_std_bind(mask, (u_short)value); } break; } }Private voidunset_mask_bit(mask, value, fd) register Inputmask *mask; Window_input_event value; int fd;{ switch (value) { case WIN_NO_EVENTS: (void)input_imnull(mask); break; case WIN_MOUSE_BUTTONS: win_unsetinputcodebit(mask, MS_LEFT); win_unsetinputcodebit(mask, MS_MIDDLE); win_unsetinputcodebit(mask, MS_RIGHT); mask->im_flags &= ~IM_NEGEVENT; break; case WIN_ASCII_EVENTS: mask->im_flags &= ~IM_ASCII; mask->im_flags &= ~IM_META; break; case WIN_UP_ASCII_EVENTS: mask->im_flags &= ~IM_NEGASCII; mask->im_flags &= ~IM_NEGMETA; break; case WIN_EUC_EVENTS: mask->im_flags &= ~IM_EUC; mask->im_flags &= ~IM_META; break; case WIN_UP_EUC_EVENTS: mask->im_flags &= ~IM_NEGEUC; mask->im_flags &= ~IM_NEGMETA; break; case WIN_UP_EVENTS: mask->im_flags &= ~IM_NEGEVENT; break; case WIN_IN_TRANSIT_EVENTS: mask->im_flags &= ~IM_INTRANSIT; break; default: if (isworkstationdevid((int) value)) win_unsetinputcodebit(mask, (int)value); else win_keymap_unset_smask(fd, (u_short) value); break; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -