void insert_utf8(t_nboon *l, char *data, int size) { t_uint i; t_utf8 c; t_uint width; t_uint pos; i = 0; c = 1; while (c != 0) { c = get_next_char(data, &i); width = get_display_width(c); l->b_curor += width; l->b_curor_end += width; } i = 0; pos = l->b_len - l->b_pos; if (l->b_len != l->b_pos) nb_memmove(&l->buf[l->b_pos + size], &l->buf[l->b_pos], pos); while (data[i] != '\0') { l->buf[l->b_pos++] = data[i++]; l->b_len++; } l->buf[l->b_len] = '\0'; g_refresh_fn(l); }
void MapViewer::refocus_map() { //Get the object ObjectManager& object_manager = ObjectManager::get_instance(); if (map_focus_object == 0) { LOG(INFO) << "MapViewer::refocus_map: No focus."; return; } std::shared_ptr<Sprite> sprite = object_manager.get_object<Sprite>(map_focus_object); // If such an sprite exists, move the map to it if (sprite) { set_display_x(centre_point_in_range( // half-tile offset to take centre of sprite /* point */ float(sprite->get_position().x) + 0.5f, /* length */ float(map->get_width()), /* bound */ get_display_width() )); set_display_y(centre_point_in_range( // half-tile offset to take centre of sprite /* point */ float(sprite->get_position().y) + 0.5f, /* length */ float(map->get_height()), /* bound */ get_display_height() )); } else { LOG(INFO) << "MapViewer::refocus_map: No sprites have focus."; } Engine::text_updater(); }
void move_left_evt(t_nboon *l) { if (l->b_pos > 0) { l->b_curor -= get_display_width(get_prev_char(l->buf, &l->b_pos)); g_refresh_fn(l); } }
void backspace_evt(t_nboon *l) { if (l->b_pos > 0) { l->b_curor -= get_display_width(get_prev_char(l->buf, &l->b_pos)); delete_evt(l); } }
const ray& perspective_camera::generate_ray(ray& out, const unsigned int x, const unsigned int y, const unsigned int sx, const unsigned int sy) { // maximum x is (get_display_width - 1) // maximum y is (get_display_height - 1) assert(x < get_display_width()); assert(y < get_display_height()); out.m_origin = get_eye(); // calculate pixel coordinates by offsetting origin pixel point3 subpixel(m_origin_pixel.x + (m_pixel_pitch * x), m_origin_pixel.y - (m_pixel_pitch * y), -1.0); // z = -1 because we are using the RH coordinate system subpixel.x = subpixel.x + ((m_subpixel_pitch * sx) + (m_subpixel_pitch * 0.5)); subpixel.y = subpixel.y + ((m_subpixel_pitch * sy) + (m_subpixel_pitch * 0.5)); out.m_direction = subpixel - out.m_origin; normalize(out.m_direction, out.m_direction); return out; }
size_t get_str_display_width(const char *str) { size_t ret; t_uint idx; t_utf8 c; int print; ret = 0; idx = 0; c = 1; print = 1; while (c != 0) { c = get_next_char(str, &idx); if (c == 1) print = 0; else if (c == 2) print = 1; else if (print) ret += get_display_width(c); } return (ret); }