* application output, a smaller terminal should help.
* The terminal window may eventually be dynamically resizable but it
* currently is not, for simplicity and performance.
+ * -1 Means that unless specified by the user, the window should be made to
+ * fit the parent window's dimensions automatically.
*/
#if (CONDENSE_X == true)
-#define TEXT_WIDTH 176
+#define TEXT_WIDTH -1
#else
-#define TEXT_WIDTH 137
+#define TEXT_WIDTH -1
#endif
#if (EXPAND_Y == true)
-#define TEXT_HEIGHT 40
+#define TEXT_HEIGHT -1
#else
-#define TEXT_HEIGHT 57
+#define TEXT_HEIGHT -1
#endif
/* Close to 1920x1080 with 2x2 zoom.
if (!color_set)
cfg_color = (cfg_mono ? DEFAULT_MONOCOLOR : DEFAULT_COLOR);
+ if ((screen = screen_init()) == NULL)
+ err(EXIT_FAILURE, "screen_init()");
+
winsize.ws_row = cfg_text_height;
winsize.ws_col = cfg_text_width;
/* XXX Should we set these? */
#endif
ttys = tty_shell(envp, &winsize, command);
- if ((screen = screen_init()) == NULL)
- err(EXIT_FAILURE, "screen_init()");
if ((state = state_init(ttys->ptyfd)) == NULL)
err(EXIT_FAILURE, "state_init()");
font_init(state, screen);
screen_init(void)
{
screen_t *s;
+ XWindowAttributes wattr;
int depth, width, height;
if ((s = malloc(sizeof(screen_t))) == NULL) {
s->visual = s->vinfo.visual;
depth = s->vinfo.depth;
+ /*
+ * If cfg_text_width or cfg_text_height are -1 set them to a large
+ * size but that likely fit in the visual port.
+ */
+ if (XGetWindowAttributes(s->dpy, s->parentwin, &wattr) == 0)
+ err(EXIT_FAILURE, "XGetWindowAttributes()");
+ if (cfg_text_width == -1)
+ cfg_text_width = ((wattr.width - wattr.border_width) /
+ (FONT_WIDTH * (cfg_condensed ? 1.5 : 2)) - 6);
+ if (cfg_text_height == -1)
+ cfg_text_height = (wattr.height /
+ ((FONT_HEIGHT + cfg_leading) * 2) - 3);
+
/* Font rendered with 2x/1.5x software zoom */
if (cfg_condensed)
width = ((int)((cfg_text_width * FONT_WIDTH) * 1.5)) + 1;
st->cursor_mode = CMODE_BLOCK;
if (cfg_cursorblink)
st->cursor_blink = true;
- st->cursor_bright = true; /* XXX */
+ st->cursor_bright = cfg_cursorbright;
break;
case 2:
st->cursor_mode = CMODE_BLOCK;