Skip to content

Commit bd423f0

Browse files
Update input.h
1 parent fe21096 commit bd423f0

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

code/logic/fossil/io/input.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,48 @@ int fossil_io_validate_sanitize_string(const char *input, char *output, size_t o
145145
*/
146146
int fossil_io_validate_read_secure_line(char *buffer, size_t buffer_size);
147147

148+
/**
149+
* Displays a menu of choices and returns the selected choice.
150+
*
151+
* @param prompt The prompt message before displaying the menu.
152+
* @param choices Array of strings representing the choices.
153+
* @param num_choices The number of choices.
154+
* @return The index of the selected choice.
155+
*/
156+
int fossil_io_display_menu(const char *prompt, const char *choices[], int num_choices);
157+
158+
/**
159+
* Reads a password from the user with masked input (e.g., asterisks).
160+
*
161+
* @param buffer The buffer to store the password.
162+
* @param size The maximum size of the buffer.
163+
* @return 1 if password was successfully read, 0 otherwise.
164+
*/
165+
int fossil_io_read_password(char *buffer, size_t size);
166+
167+
/**
168+
* Reads multiline input from the user, allowing the user to press Enter to add new lines.
169+
*
170+
* @param buffer The buffer to store the input.
171+
* @param size The maximum size of the buffer.
172+
* @return 1 if the input was successfully received, 0 otherwise.
173+
*/
174+
int fossil_io_read_multiline_input(char *buffer, size_t size);
175+
176+
/**
177+
* Reads a single character from the user without echoing to the screen.
178+
*
179+
* @return The character entered by the user.
180+
*/
181+
char fossil_io_getch(void);
182+
183+
/**
184+
* Displays a simple progress bar.
185+
*
186+
* @param progress The current progress (0-100).
187+
*/
188+
void fossil_io_show_progress(int progress);
189+
148190
#ifdef __cplusplus
149191
}
150192

@@ -320,6 +362,26 @@ namespace fossil {
320362
return fossil_io_validate_read_secure_line(buffer, buffer_size);
321363
}
322364

365+
/**
366+
* @brief Override the output stream operator to display Input object details.
367+
*
368+
* @param os The output stream where data will be printed.
369+
* @param input The Input object to display.
370+
* @return The modified output stream.
371+
*/
372+
friend std::ostream& operator<<(std::ostream& os, const Input& input) {
373+
// Example of what to output: printing the state or some meaningful data
374+
os << "Input Stream Details:\n";
375+
os << " - Max Buffer Size: " << input.max_buffer_size << "\n";
376+
os << " - Input Stream: " << (input.stream ? "Valid Stream" : "Invalid Stream") << "\n";
377+
378+
// Return the output stream
379+
return os;
380+
}
381+
382+
private:
383+
size_t max_buffer_size; // Example private member
384+
FILE* stream; // Example stream (pointer to the input stream, like stdin)
323385
};
324386

325387
}

0 commit comments

Comments
 (0)