754 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
755 |
bufferedCommands[socket] += "\r\n"; |
bufferedCommands[socket] += "\r\n"; |
756 |
return true; //Complete command was read |
return true; //Complete command was read |
757 |
} |
} else if (c == 2) { // custom ASCII code usage for moving cursor left (LSCP shell) |
758 |
// backspace character - should only happen with shell |
if (iter->iCursorOffset + bufferedCommands[socket].size() > 0) |
759 |
if (c == '\b') { |
iter->iCursorOffset--; |
760 |
if (!bufferedCommands[socket].empty()) { |
} else if (c == 3) { // custom ASCII code usage for moving cursor right (LSCP shell) |
761 |
bufferedCommands[socket] = bufferedCommands[socket].substr( |
if (iter->iCursorOffset < 0) iter->iCursorOffset++; |
762 |
0, bufferedCommands[socket].length() - 1 |
} else { |
763 |
); |
size_t cursorPos = bufferedCommands[socket].size() + iter->iCursorOffset; |
764 |
|
// backspace character - should only happen with shell |
765 |
|
if (c == '\b') { |
766 |
|
if (!bufferedCommands[socket].empty() && cursorPos > 0) |
767 |
|
bufferedCommands[socket].erase(cursorPos - 1, 1); |
768 |
|
} else { // append (or insert) new character (at current cursor position) ... |
769 |
|
if (cursorPos >= 0) |
770 |
|
bufferedCommands[socket].insert(cursorPos, String(1,c)); // insert |
771 |
|
else |
772 |
|
bufferedCommands[socket] += c; // append |
773 |
} |
} |
774 |
} else bufferedCommands[socket] += c; |
} |
775 |
// only if the other side is the LSCP shell application: |
// only if the other side is the LSCP shell application: |
776 |
// check the current (incomplete) command line for syntax errors, |
// check the current (incomplete) command line for syntax errors, |
777 |
// possible completions and report everything back to the shell |
// possible completions and report everything back to the shell |