aleitner commented on code in PR #383:
URL: https://github.com/apache/guacamole-server/pull/383#discussion_r902833372
##########
src/terminal/terminal.c:
##########
@@ -335,6 +335,88 @@ guac_terminal_options* guac_terminal_options_create(
return options;
}
+/**
+ * Calculate the available height and width in characters for text display in
+ * the terminal and store the results in the pointer arguments.
+ *
+ * @param terminal
+ * The terminal provides character width and height for calculations.
+ *
+ * @param height
+ * The outer height of the terminal, in pixels.
+ *
+ * @param width
+ * The outer width of the terminal, in pixels.
+ *
+ * @param rows
+ * Calculated height of the terminal for text display, in characters.
+ *
+ * @param columns
+ * Calculated width of the terminal for text display, in characters.
+ *
+ */
+static void calculate_rows_and_columns(guac_terminal* term,
+ int height, int width, int *rows, int *columns) {
+
+ int margin = term->display->margin;
+ int char_width = term->display->char_width;
+ int char_height = term->display->char_height;
+
+ /* Calculate available display area */
+ int available_width = width - GUAC_TERMINAL_SCROLLBAR_WIDTH - 2 * margin;
+ if (available_width < 0)
+ available_width = 0;
+
+ int available_height = height - 2 * margin;
+ if (available_height < 0)
+ available_height = 0;
+
+ /* Calculate dimensions */
+ *rows = available_height / char_height;
+ *columns = available_width / char_width;
+
+ /* Keep height within predefined maximum */
+ if (*rows > GUAC_TERMINAL_MAX_ROWS) {
+ *rows = GUAC_TERMINAL_MAX_ROWS;
+ }
+
+ /* Keep width within predefined maximum */
+ if (*columns > GUAC_TERMINAL_MAX_COLUMNS) {
+ *columns = GUAC_TERMINAL_MAX_COLUMNS;
+ }
+}
+
+/**
+ * Calculate the available height and width in pixels of the terminal for text
+ * display in the terminal and store the results in the pointer arguments.
+ *
+ * @param terminal
+ * The terminal provides character width and height for calculations.
+ *
+ * @param rows
+ * The available height of the terminal for text display, in characters.
+ *
+ * @param columns
+ * The available width of the terminal for text display, in characters.
+ *
+ * @param height
+ * Calculated available height of the terminal for text display, in pixels.
+ *
+ * @param width
+ * Calculated available width of the terminal for text display, in pixels.
Review Comment:
done
##########
src/terminal/terminal.c:
##########
@@ -335,6 +335,88 @@ guac_terminal_options* guac_terminal_options_create(
return options;
}
+/**
+ * Calculate the available height and width in characters for text display in
+ * the terminal and store the results in the pointer arguments.
+ *
+ * @param terminal
+ * The terminal provides character width and height for calculations.
+ *
+ * @param height
+ * The outer height of the terminal, in pixels.
+ *
+ * @param width
+ * The outer width of the terminal, in pixels.
+ *
+ * @param rows
+ * Calculated height of the terminal for text display, in characters.
+ *
+ * @param columns
+ * Calculated width of the terminal for text display, in characters.
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]