mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/code] Handle carriage returns in the input text
This commit is contained in:
@@ -15,17 +15,11 @@ mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
|
||||
prompt = mp_obj_str_get_str(args[0]);
|
||||
}
|
||||
|
||||
// 2 - Perform the HAL input command
|
||||
// 2 - Perform the HAL input command. This logs the prompt and the result
|
||||
const char * result = mp_hal_input(prompt);
|
||||
|
||||
// 3 - Log the prompt, result and flush a new line
|
||||
// 3 - Return the input
|
||||
mp_obj_t resultStr = mp_obj_new_str(result, strlen(result));
|
||||
if (n_args == 1) {
|
||||
mp_obj_print(args[0], PRINT_STR);
|
||||
}
|
||||
mp_obj_print(resultStr, PRINT_STR);
|
||||
mp_print_str(MP_PYTHON_PRINTER, "\n");
|
||||
|
||||
return resultStr;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
|
||||
|
||||
Reference in New Issue
Block a user