fix #43 added a config interface to change the newline character expected
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user