Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamOnAir committed Nov 23, 2024
2 parents d9bdbbd + 723488c commit cb18239
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions include/cute_airlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define KMAG "\e[35m"
#define KCYN "\e[36m"
#define KWHT "\e[37m"
#define KHOL "\033[90m%s\033[0m"

#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -63,6 +64,34 @@ void richText(char *text, char *color, unsigned int bold, unsigned int italic, u
printf("\n");
}

void placeholder(char *text, char *output, size_t output_size) {
int ch, index = 0;

// Display the placeholder text in light gray using KHOL
printf(KHOL, text);
fflush(stdout);

// Move cursor back to the beginning of the line to type over the placeholder
printf("\033[1000D"); // Move cursor far left

// Read characters one by one
while ((ch = getchar()) != '\n' && ch != EOF) {
// If the user starts typing, clear the placeholder
if (index == 0) {
// Clear the placeholder by overwriting with spaces
printf("\033[1000D\033[0K"); // Move to start of line and clear it
fflush(stdout);
}

// Add character to the output buffer
if (index < output_size - 1) {
output[index++] = ch;
}
}
output[index] = '\0'; // Null-terminate the input string
printf(KNRM);
}

// ------------------------------------
// Window
// ------------------------------------
Expand Down

0 comments on commit cb18239

Please sign in to comment.