fix #15 added an api to control mode and echo + fixed the implementation and added tests
This commit is contained in:
@@ -162,6 +162,7 @@ void utils_forwardCursor(shellmatta_instance_t *inst, uint32_t length)
|
||||
* @param[in] inst pointer to shellmatta instance
|
||||
* @param[in] data pointer to the data to be inserted
|
||||
* @param[in] length length of the data to be inserted
|
||||
* @todo this function shall check buffer overflows
|
||||
*/
|
||||
void utils_insertChars( shellmatta_instance_t *inst,
|
||||
char *data,
|
||||
@@ -192,16 +193,20 @@ void utils_insertChars( shellmatta_instance_t *inst,
|
||||
&(inst->buffer[inst->cursor + length]),
|
||||
inst->inputCount - inst->cursor);
|
||||
utils_restoreCursorPos(inst);
|
||||
inst->cursor += length;
|
||||
inst->inputCount += length;
|
||||
}
|
||||
/** -# just overwrite/append the chars */
|
||||
/** -# overwrite - if the cursor reaches the end of the input it is pushed further */
|
||||
else
|
||||
{
|
||||
memcpy(&(inst->buffer[inst->cursor]), data, length);
|
||||
utils_writeEcho(inst, data, length);
|
||||
inst->cursor += length;
|
||||
if(inst->cursor > inst->inputCount)
|
||||
{
|
||||
inst->inputCount = inst->cursor;
|
||||
}
|
||||
}
|
||||
|
||||
inst->inputCount += length;
|
||||
inst->cursor += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user