void screen_char (zchar c) { int width; if (discarding) return; if (c == ZC_INDENT && cwp->x_cursor != cwp->left + 1) c = ' '; if (units_left () < (width = os_char_width (c))) { if (!enable_wrapping) { cwp->x_cursor = cwp->x_size - cwp->right; return; } screen_new_line (); } os_display_char (c); cwp->x_cursor += width; }/* screen_char */
int GlkInterface::os_string_width(const zchar *s) { int width = 0; zchar c; while ((c = *s++) != 0) if (c == ZC_NEW_STYLE || c == ZC_NEW_FONT) s++; else width += os_char_width(c); return width; }
static void pad_status_line (int column) { int spaces; flush_buffer (); spaces = units_left () / os_char_width (' ') - column; /* while (spaces--) */ /* Justin Wesley's fix for narrow displays (Agenda PDA) */ while (spaces-- > 0) screen_char (' '); }/* pad_status_line */
/* * os_string_width * * Calculate the length of a word in screen units. Apart from letters, * the word may contain special codes: * * NEW_STYLE - next character is a new text style * NEW_FONT - next character is a new font * */ int os_string_width (const zchar *s) { int width = 0; zchar c; while ((c = *s++) != 0) { if (c == ZC_NEW_STYLE || c == ZC_NEW_FONT) { s++; /* No effect */ } else width += os_char_width(c); } return width; }/* os_string_width */