mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
46 lines
944 B
C++
46 lines
944 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "Module/Terminal.h"
|
|
#include "Module/CircularBuffer.h"
|
|
#include "Module/Runner.h"
|
|
|
|
class CommandShell {
|
|
public:
|
|
CommandShell(Runner *runner);
|
|
|
|
void setTerm(Terminal *term);
|
|
Terminal *term();
|
|
|
|
void showGreetings(bool = true);
|
|
void showFarewell(bool = true);
|
|
|
|
void clearHistory();
|
|
void addHistory(const char *);
|
|
bool getHistoryInput(String &);
|
|
void setEditLine(const String &);
|
|
bool active();
|
|
void loop();
|
|
|
|
private:
|
|
size_t printGreetings(Print *);
|
|
size_t printFarewell(Print *);
|
|
size_t printPrompt(Print *);
|
|
|
|
void onOpen(Print *out);
|
|
void onClose(Print *out);
|
|
void onData(const char *);
|
|
void onHistory(Print *out);
|
|
bool getLastInput(String &);
|
|
|
|
private:
|
|
CircularBuffer<String, 4> _history;
|
|
Terminal *_term;
|
|
Runner *_runner;
|
|
String _path;
|
|
bool _active;
|
|
bool _greetings;
|
|
bool _farewell;
|
|
};
|