+/* Re-calculates the page width and length based on settings,
+ margins, and, if "auto" is set, the size of the user's
+ terminal window or GUI output window. */
+static bool
+update_page_size (struct outp_driver *this, bool issue_error)
+{
+ struct ascii_driver_ext *x = this->ext;
+ int margins = x->top_margin + x->bottom_margin + 1 + (x->headers ? 3 : 0);
+
+ if (x->auto_width)
+ this->width = settings_get_viewwidth ();
+ if (x->auto_length)
+ x->page_length = settings_get_viewlength ();
+
+ this->length = x->page_length - margins;
+
+ if (this->width < 59 || this->length < 15)
+ {
+ if (issue_error)
+ error (0, 0,
+ _("ascii: page excluding margins and headers "
+ "must be at least 59 characters wide by 15 lines long, but "
+ "as configured is only %d characters by %d lines"),
+ this->width, this->length);
+ if (this->width < 59)
+ this->width = 59;
+ if (this->length < 15)
+ {
+ this->length = 15;
+ x->page_length = this->length + margins;
+ }
+ return false;
+ }
+
+ return true;
+}
+