The function uses the following control sequences: + * + *
By combining these control sequences in a single \c printf statement, + * the function achieves the effect of clearing the terminal screen. + * + * @since 0.1.0 + */ +void clrscr() { + printf("%s0m%s1J%s1;1f", __prefix, __prefix, __prefix); +} + +/** + * @brief Pushes a character back onto the input stream. + * This function pushes a character back onto the input stream. + * It takes an integer parameter \c __c, representing the character to be pushed back. + * + * @param __c The character to be pushed back. + * + * @return Returns the pushed-back character on success, or `EOF` on failure. + * + * @since 0.1.0 + * @see #getch() + * @see #getche() + */ +const int ungetch(const int __c) { + return ungetc(__c, stdin); +} + +/** + * @brief Reads a single character from the standard input without echoing it. + * This function reads a single character from the standard input without echoing it. + * + * @return Returns the character read from the standard input. + * + * @since 0.1.0 + * @see #getche() + * @see #ungetch(int) + */ +const int getch() { + return __getch(0); /* 0 means no echo */ +} + +/** + * @brief Reads a single character from the standard input and then echoing it. + * This function reads a single character from the standard input and then echoing it. + * + * @return Returns the character read from the standard input. + * + * @since 0.1.0 + * @see #getch() + * @see #ungetch(int) + */ +const int getche() { + return __getch(1); /* non-zero means with echo */ +} + +/** + * @brief Retrieves the current X-coordinate of the cursor on the terminal screen. + * This function retrieves the current X-coordinate of the cursor on the terminal screen. + * + * @return Returns the X-coordinate of the cursor. + * + * @since 0.1.0 + */ +const int wherex() { + int __x = 0, __y = 0; + __whereis_xy(&__x, &__y); + + return __x; /* only return the X-coordinate */ +} + +/** + * @brief Retrieves the current Y-coordinate of the cursor on the terminal screen. + * This function retrieves the current Y-coordinate of the cursor on the terminal screen. + * + * @return Returns the Y-coordinate of the cursor. + * + * @since 0.1.0 + */ +const int wherey() { + int __x = 0, __y = 0; + __whereis_xy(&__x, &__y); + + return __y; /* only return the Y-coordinate */ +} + +/** + * @brief Writes a character to the standard output. + * This function writes a character to the standard output. + * It takes an integer parameter \c __chr, representing the character to be written. + * + * @param __chr The character to be written. + * + * @return Returns the written character as an integer. + * + * @since 0.1.0 + */ +const int putch(const int __chr) { + printf("%c", __chr); + return __chr; +} + +#endif /* CONIO_LT_H_ */