static void display_all(struct termios *mode, int fd, const char *device_name) { int i; tcflag_t *bitsp; unsigned long mask; enum mode_type prev_type = control; display_speed(mode, 1); #ifdef TIOCGWINSZ display_window_size(1, fd, device_name); #endif #ifdef HAVE_C_LINE wrapf("line = %d;", mode->c_line); #endif putchar('\n'); current_col = 0; for (i = 0; control_info[i].name != stty_min; ++i) { /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP if (control_info[i].name == stty_swtch) continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 && (control_info[i].name == stty_eof || control_info[i].name == stty_eol)) continue; #endif wrapf("%s = %s;", control_info[i].name, visible(mode->c_cc[control_info[i].offset])); } #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0) #endif wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); if (current_col != 0) putchar('\n'); current_col = 0; for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; if (mode_info[i].type != prev_type) { putchar('\n'); current_col = 0; prev_type = mode_info[i].type; } bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) wrapf("%s", mode_info[i].name); else if (mode_info[i].flags & REV) wrapf("-%s", mode_info[i].name); } putchar('\n'); current_col = 0; }
static void do_display(const struct termios *mode, const int all) { int i; tcflag_t *bitsp; unsigned long mask; int prev_type = control; display_speed(mode, 1); if (all) display_window_size(1); #ifdef HAVE_C_LINE wrapf("line = %d;\n", mode->c_line); #else wrapf("\n"); #endif for (i = 0; control_info[i].name != stty_min; ++i) { /* If swtch is the same as susp, don't print both */ #if VSWTCH == VSUSP if (control_info[i].name == stty_swtch) continue; #endif /* If eof uses the same slot as min, only print whichever applies */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 && (control_info[i].name == stty_eof || control_info[i].name == stty_eol)) continue; #endif wrapf("%s = %s;", control_info[i].name, visible(mode->c_cc[control_info[i].offset])); } #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0) #endif wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); if (current_col) wrapf("\n"); for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; if (mode_info[i].type != prev_type) { /* wrapf("\n"); */ if (current_col) wrapf("\n"); prev_type = mode_info[i].type; } bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) { if (all || (mode_info[i].flags & SANE_UNSET)) wrapf("%s", mode_info[i].name); } else { if ((all && mode_info[i].flags & REV) || (!all && (mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV))) wrapf("-%s", mode_info[i].name); } } if (current_col) wrapf("\n"); }
static void display_speed(struct termios *mode, int fancy) { if (cfgetispeed(mode) == 0 || cfgetispeed(mode) == cfgetospeed(mode)) wrapf(fancy ? "speed %lu baud;" : "%lu\n", baud_to_value(cfgetospeed(mode))); else wrapf(fancy ? "ispeed %lu baud; ospeed %lu baud;" : "%lu %lu\n", baud_to_value(cfgetispeed(mode)), baud_to_value(cfgetospeed(mode))); if (!fancy) current_col = 0; }
static void display_window_size(int fancy) { const char *fmt_str = "%s\0%s: no size information for this device"; unsigned width, height; if (get_terminal_width_height(STDIN_FILENO, &width, &height)) { if ((errno != EINVAL) || ((fmt_str += 2), !fancy)) { perror_on_device(fmt_str); } } else { wrapf(fancy ? "rows %u; columns %u;" : "%u %u\n", height, width); } }
static void display_speed(const struct termios *mode, int fancy) { //01234567 8 9 const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; unsigned long ispeed, ospeed; ospeed = ispeed = cfgetispeed(mode); if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) { ispeed = ospeed; /* in case ispeed was 0 */ //0123 4 5 6 7 8 9 fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; } if (fancy) fmt_str += 9; wrapf(fmt_str, tty_baud_to_value(ispeed), tty_baud_to_value(ospeed)); }
void move_polygon(FPOINT *points, int size, FPOINT *centroid, VECTOR2D velocity, float *angle, float rotation, FRECT *bounding_box) { FPOINT orig_centroid = *centroid; float offset_x, offset_y; float min_x, max_x, min_y, max_y; int p; centroid->x += velocity.x; centroid->y += velocity.y; offset_x = centroid->x - orig_centroid.x; offset_y = centroid->y - orig_centroid.y; if (angle != NULL) *angle = wrapf(*angle + rotation, FULL_DEG); if (points != NULL && size > 0) { max_x = min_x = centroid->x; max_y = min_y = centroid->y; for (p=0; p<size; p++) { points[p].x += offset_x; points[p].y += offset_y; point2_rotate(&points[p], to_radians(rotation), centroid->x, centroid->y); if (bounding_box != NULL) { if (points[p].x < min_x) min_x = points[p].x; else if (points[p].x > max_x) max_x = points[p].x; if (points[p].y < min_y) min_y = points[p].y; else if (points[p].y > max_y) max_y = points[p].y; } } if (bounding_box != NULL) { bounding_box->x = min_x; bounding_box->w = max_x - min_x; bounding_box->y = min_y; bounding_box->h = max_y - min_y; } } }
static void display_window_size(int fancy, int fd, const char *device_name) { struct winsize win; if (get_win_size(fd, &win)) { if (errno != EINVAL) perror_msg_and_die("%s", device_name); if (!fancy) perror_msg_and_die("%s: no size information for this device", device_name); } else { wrapf(fancy ? "rows %d; columns %d;" : "%d %d\n", win.ws_row, win.ws_col); if (!fancy) current_col = 0; } }
static void do_display(const struct termios *mode, int all) { int i; tcflag_t *bitsp; unsigned long mask; int prev_type = control; display_speed(mode, 1); if (all) display_window_size(1); #ifdef __linux__ wrapf("line = %u;\n", mode->c_line); #else newline(); #endif for (i = 0; i != CIDX_min; ++i) { char ch; /* If swtch is the same as susp, don't print both */ #if VSWTCH == VSUSP if (i == CIDX_swtch) continue; #endif /* If eof uses the same slot as min, only print whichever applies */ #if VEOF == VMIN if (!(mode->c_lflag & ICANON) && (i == CIDX_eof || i == CIDX_eol) ) { continue; } #endif ch = mode->c_cc[control_info[i].offset]; if (ch == _POSIX_VDISABLE) strcpy(G.buf, "<undef>"); else visible(ch, G.buf, 0); wrapf("%s = %s;", nth_string(control_name, i), G.buf); } #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0) #endif wrapf("min = %u; time = %u;", mode->c_cc[VMIN], mode->c_cc[VTIME]); newline(); for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; if (mode_info[i].type != prev_type) { newline(); prev_type = mode_info[i].type; } bitsp = get_ptr_to_tcflag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) { if (all || (mode_info[i].flags & SANE_UNSET)) wrapf("-%s"+1, nth_string(mode_name, i)); } else { if ((all && mode_info[i].flags & REV) || (!all && (mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)) ) { wrapf("-%s", nth_string(mode_name, i)); } } } newline(); }
static void newline(void) { if (G.current_col != 0) wrapf("\n"); }
static void display_changed(struct termios *mode) { int i; int empty_line; tcflag_t *bitsp; unsigned long mask; enum mode_type prev_type = control; display_speed(mode, 1); #ifdef HAVE_C_LINE wrapf("line = %d;", mode->c_line); #endif putchar('\n'); current_col = 0; empty_line = 1; for (i = 0; control_info[i].name != stty_min; ++i) { if (mode->c_cc[control_info[i].offset] == control_info[i].saneval) continue; /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP if (control_info[i].name == stty_swtch) continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 && (control_info[i].name == stty_eof || control_info[i].name == stty_eol)) continue; #endif empty_line = 0; wrapf("%s = %s;", control_info[i].name, visible(mode->c_cc[control_info[i].offset])); } if ((mode->c_lflag & ICANON) == 0) { wrapf("min = %d; time = %d;\n", (int) mode->c_cc[VMIN], (int) mode->c_cc[VTIME]); } else if (empty_line == 0) putchar('\n'); current_col = 0; empty_line = 1; for (i = 0; i < NUM_mode_info; ++i) { if (mode_info[i].flags & OMIT) continue; if (mode_info[i].type != prev_type) { if (empty_line == 0) { putchar('\n'); current_col = 0; empty_line = 1; } prev_type = mode_info[i].type; } bitsp = mode_type_flag(mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) { if (mode_info[i].flags & SANE_UNSET) { wrapf("%s", mode_info[i].name); empty_line = 0; } } else if ((mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)) { wrapf("-%s", mode_info[i].name); empty_line = 0; } } if (empty_line == 0) putchar('\n'); current_col = 0; }