fix #43 added a config interface to change the newline character expected

This commit is contained in:
prozessorkern
2020-03-27 18:34:43 +01:00
parent c2e4324236
commit 3b99ad2a56
5 changed files with 79 additions and 17 deletions

View File

@@ -94,6 +94,7 @@ shellmatta_retCode_t shellmatta_doInit(
inst->hereStartIdx = 0u;
inst->hereDelimiterIdx = 0u;
inst->hereLength = 0u;
inst->delimiter = '\r';
inst->mode = SHELLMATTA_MODE_INSERT;
inst->cmdList = &(inst->helpCmd);
inst->continuousCmd = NULL;
@@ -322,10 +323,14 @@ shellmatta_retCode_t shellmatta_removeCmd(shellmatta_handle_t handle, shellmatta
* @param[in] handle shellmatta instance handle
* @param[in] mode insert mode of the shellmatta type #shellmatta_mode_t
* @param[in] echoEnabled true: echo received chars to the output
* @param[in] delimiter delimiter used to detect the end of a cmd (default \r)
* @return errorcode #SHELLMATTA_OK
* #SHELLMATTA_USE_FAULT (param err)
*/
shellmatta_retCode_t shellmatta_configure(shellmatta_handle_t handle, shellmatta_mode_t mode, bool echoEnabled)
shellmatta_retCode_t shellmatta_configure( shellmatta_handle_t handle,
shellmatta_mode_t mode,
bool echoEnabled,
char delimiter)
{
shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
shellmatta_retCode_t ret = SHELLMATTA_OK;
@@ -337,6 +342,7 @@ shellmatta_retCode_t shellmatta_configure(shellmatta_handle_t handle, shellmatta
{
inst->mode = mode;
inst->echoEnabled = echoEnabled;
inst->delimiter = delimiter;
}
else
{
@@ -394,14 +400,8 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
{
escape_handleSequence(inst, *data);
}
/** -# ignore newline as first character (to be compatible to
* terminals sending newline after return */
else if((0u == inst->inputCount) && ('\n' == *data))
{
/* do nothing */
}
/** -# handle return as start of processing the command */
else if ('\r' == *data)
/** -# handle delimiter as start of processing the command */
else if (inst->delimiter == *data)
{
if(0u == inst->hereLength)
{
@@ -574,6 +574,12 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
}
}
}
/** -# ignore newline as first character (to be compatible to
* terminals sending newline after return */
else if((0u == inst->inputCount) && ('\n' == *data))
{
/* do nothing */
}
/** -# check for tabulator key - auto complete */
else if('\t' == *data)
{