}
}
-int set_terminal_cursor_position(int fd, unsigned int row, unsigned int column) {
- int r;
- char cursor_position[STRLEN("\x1B[") + DECIMAL_STR_MAX(int) * 2 + STRLEN(";H") + 1];
-
+int terminal_set_cursor_position(int fd, unsigned row, unsigned column) {
assert(fd >= 0);
+ char cursor_position[STRLEN("\x1B[" ";" "H") + DECIMAL_STR_MAX(unsigned) * 2 + 1];
xsprintf(cursor_position, "\x1B[%u;%uH", row, column);
- r = loop_write(fd, cursor_position, SIZE_MAX);
- if (r < 0)
- return log_warning_errno(r, "Failed to set cursor position, ignoring: %m");
-
- return 0;
+ return loop_write(fd, cursor_position, SIZE_MAX);
}
int terminal_reset_ansi_seq(int fd) {
int reset_terminal_fd(int fd, bool switch_to_text);
int reset_terminal(const char *name);
-int set_terminal_cursor_position(int fd, unsigned int row, unsigned int column);
int terminal_reset_ansi_seq(int fd);
+int terminal_set_cursor_position(int fd, unsigned row, unsigned column);
+
int open_terminal(const char *name, int mode);
/* Flags for tweaking the way we become the controlling process of a terminal. */
if (r < 0)
log_warning_errno(r, "Failed to clear terminal, ignoring: %m");
- r = set_terminal_cursor_position(fd, 2, 4);
+ r = terminal_set_cursor_position(fd, 2, 4);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
qr_code_start_row = w.ws_row * 3U / 5U;
qr_code_start_column = w.ws_col * 3U / 4U;
- r = set_terminal_cursor_position(fd, 4, 4);
+ r = terminal_set_cursor_position(fd, 4, 4);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
if (r < 0)
log_warning_errno(r, "QR code could not be printed, ignoring: %m");
- r = set_terminal_cursor_position(fd, w.ws_row - 1, w.ws_col * 2U / 5U);
+ r = terminal_set_cursor_position(fd, w.ws_row - 1, w.ws_col * 2U / 5U);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
if (fd < 0)
return (void)log_debug_errno(errno, "Failed to get file descriptor from the file stream: %m");
- r = set_terminal_cursor_position(fd, row, column);
+ r = terminal_set_cursor_position(fd, row, column);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
fputs(UNICODE_FULL_BLOCK, output);
fputs(ANSI_NORMAL "\n", output);
- r = set_terminal_cursor_position(fd, row + 1, column);
+ r = terminal_set_cursor_position(fd, row + 1, column);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
}
if (fd < 0)
return (void)log_debug_errno(errno, "Failed to get file descriptor from the file stream: %m");
- r = set_terminal_cursor_position(fd, row + move_down, column);
+ r = terminal_set_cursor_position(fd, row + move_down, column);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
for (unsigned x = 0; x < 4; x++)
fputs(UNICODE_FULL_BLOCK, output);
- r = set_terminal_cursor_position(fd, row + move_down, column);
+ r = terminal_set_cursor_position(fd, row + move_down, column);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");
move_down += 1;
row = tty_height - (qr_code_height / 2 ) - 1;
if (header) {
- r = set_terminal_cursor_position(fd, row - 2, tty_width - qr_code_width - 2);
+ r = terminal_set_cursor_position(fd, row - 2, tty_width - qr_code_width - 2);
if (r < 0)
log_warning_errno(r, "Failed to move terminal cursor position, ignoring: %m");