teditor
1.8.0@@fee5e94
Terminal based editor written in C++
|
Go to the documentation of this file.
4 #include <unordered_map>
18 typedef Mode* (*ModeCreator)();
34 Mode(
const std::string& n,
const std::string& w): name_(n), word_(w) {}
40 virtual const std::string&
name()
const {
return name_; }
43 virtual const std::string&
word()
const {
return word_; }
56 const Buffer& b,
bool isHighlighted) = 0;
92 #define REGISTER_MODE(Name, NameStr) \
93 Mode::Registrar mode ## Name(NameStr, Name::create, Name::modeCheck)
LedgerMode()
Definition: extensions/ledger/mode.cpp:13
ReadOnlyMode(const std::string &n="ro", const std::string &w="abcdefghijklmnopqrstuvwxyzABCDEGGHIJKLMNO" "PQRSTUVWXYZ0123456789_")
Definition: readonly.cpp:13
Strings allModeNames()
Definition: core/mode.cpp:16
static bool modeCheck(const std::string &file)
Definition: extensions/grep/mode.cpp:32
static bool modeCheck(const std::string &file)
Definition: extensions/cpp/mode.cpp:36
Definition: extensions/todo/mode.cpp:27
void addCmd(const std::string &c)
Definition: extensions/calc/mode.cpp:22
void store() const
Definition: utils.cpp:276
Definition: extensions/grep/mode.cpp:8
virtual int indent(Buffer &buf, int line)=0
TextMode(const std::string &n="text", const std::string &w="abcdefghijklmnopqrstuvwxyzABCDEGGHIJKLMNOPQRS" "TUVWXYZ0123456789_")
Definition: text.cpp:10
REGISTER_MODE(CppMode, "c++")
virtual const std::string & name() const
Definition: core/mode.h:40
Strings cmdNames() const
Definition: extensions/watch/mode.cpp:17
static Mode * create()
Definition: extensions/ledger/mode.cpp:39
std::unordered_map< std::string, Num64 > VarMap
Definition: extensions/calc/mode.h:9
static bool modeCheck(const std::string &file)
Definition: extensions/calc/mode.cpp:37
REGISTER_MODE(GrepMode, "grep")
static Mode * create()
Definition: extensions/cpp/mode.cpp:34
std::unordered_map< std::string, InferMode > ModeInferMap
Definition: core/mode.h:23
Mode *(* ModeCreator)()
Definition: core/mode.h:18
static std::string inferMode(const std::string &file, bool isDir)
Helper to infer mode name from the file.
Definition: core/mode.cpp:40
int length() const
Definition: buffer.h:92
Definition: extensions/calc/mode.cpp:27
LedgerShowMode()
Definition: extensions/ledger/mode.cpp:34
Definition: key_cmd_map.h:19
CmdStatus check_output(const std::string &cmd)
Definition: utils.cpp:110
ModeCreatorMap & modes()
Definition: core/mode.cpp:6
DirMode()
Definition: extensions/dir/mode.cpp:11
static Mode * create()
Definition: extensions/todo/mode.cpp:15
std::shared_ptr< Mode > ModePtr
Definition: core/mode.h:19
Strings allCmdNames(CmdFilterOp filterOp)
Accessor function to the list of command names.
Definition: command.cpp:30
bool isDir(const std::string &f)
Definition: file_utils.cpp:34
REGISTER_MODE(WatchMode, "watch")
static bool modeCheck(const std::string &file)
Definition: extensions/todo/mode.cpp:35
const std::string & get() const
Definition: line.h:51
void getColorFor(AttrColor &fg, AttrColor &bg, int lineNum, int pos, const Buffer &b, bool isHighlighted)
Definition: extensions/dir/mode.cpp:16
Mode(const std::string &n, const std::string &w)
ctor
Definition: core/mode.h:34
Line & at(int idx)
Definition: buffer.h:98
std::vector< std::string > Strings
Definition: utils.h:42
Ken-Thompson NFA as described here: https://swtch.com/~rsc/regexp/regexp1.html but adjusted to work w...
Definition: nfa.h:23
TodoMode()
Definition: extensions/todo/mode.cpp:13
TodoShowMode()
Definition: extensions/todo/mode.cpp:29
int indent(Buffer &buf, int line)
Definition: extensions/cpp/mode.cpp:16
~CalcMode()
Definition: extensions/calc/mode.cpp:34
GrepMode()
Definition: extensions/grep/mode.cpp:10
static Mode * create()
Definition: extensions/dir/mode.cpp:32
Strings cmdNames() const
Definition: extensions/ledger/mode.cpp:15
virtual Strings cmdNames() const
Definition: core/mode.cpp:25
bool(* InferMode)(const std::string &)
Definition: core/mode.h:22
virtual void getColorFor(AttrColor &fg, AttrColor &bg, int lineNum, int pos, const Buffer &b, bool isHighlighted)=0
static const size_t NoMatch
Definition: nfa.h:93
Definition: extensions/dir/mode.cpp:9
static bool modeCheck(const std::string &file)
Definition: extensions/ledger/mode.cpp:40
virtual const std::string & word() const
Definition: core/mode.h:43
REGISTER_MODE(LedgerMode, "ledger")
#define ASSERT(check, fmt,...)
Macro to assert with runtime_error exception if the check fails.
Definition: utils.h:35
void start(Buffer *buf, const std::string &cmd, int sleepLenMs=0)
Definition: extensions/watch/mode.cpp:35
void add(const std::string &elem)
Definition: utils.cpp:285
Definition: extensions/todo/mode.cpp:11
CppMode()
Definition: extensions/cpp/mode.cpp:11
KeyCmdMap & getKeyCmdMap()
Definition: readonly.h:17
virtual ~Mode()
Definition: core/mode.h:37
void getColorFor(AttrColor &fg, AttrColor &bg, int lineNum, int pos, const Buffer &b, bool isHighlighted)
Definition: extensions/grep/mode.cpp:15
CalcMode()
Definition: extensions/calc/mode.cpp:29
static Mode * create()
Definition: extensions/calc/mode.cpp:36
Definition: core/mode.h:76
Definition: core/mode.h:27
REGISTER_MODE(DirMode, "dir")
Definition: extensions/ledger/mode.cpp:11
Registrar(const std::string &mode, ModeCreator fptr, InferMode iptr)
Definition: core/mode.cpp:31
static bool modeCheck(const std::string &file)
Definition: extensions/todo/mode.cpp:17
Container to store history (files-visited or command-history, etc)
Definition: utils.h:115
void stop()
Definition: extensions/watch/mode.cpp:44
static ModePtr createMode(const std::string &mode)
Helper to create mode object of the named mode.
Definition: core/mode.cpp:48
static bool modeCheck(const std::string &file)
Definition: extensions/dir/mode.cpp:34
static Mode * create()
Definition: extensions/grep/mode.cpp:30
REGISTER_MODE(TodoMode, "todo")
Definition: extensions/ledger/mode.cpp:32
static Mode * create()
Definition: extensions/todo/mode.cpp:34
virtual ColorMap & getColorMap()=0
size_t find(const std::string &str, size_t start=0, size_t end=0)
String match function.
Definition: nfa.cpp:64
virtual KeyCmdMap & getKeyCmdMap()=0
static Mode * create()
Definition: extensions/ledger/mode.cpp:21
Class to define an option used in the editor.
Definition: option.h:14
VarMap & vars()
Definition: extensions/calc/mode.cpp:11
virtual void insert(char c)
Definition: buffer.cpp:25
static Option & get(const std::string &n)
Definition: option.cpp:40
Definition: extensions/cpp/mode.cpp:9
REGISTER_MODE(CalcMode, "calc")
ModeInferMap & infers()
Definition: core/mode.cpp:11
std::string format(const char *fmt, va_list &vl)
Definition: utils.cpp:22
static bool modeCheck(const std::string &file)
Definition: extensions/ledger/mode.cpp:23
std::unordered_map< std::string, ModeCreator > ModeCreatorMap
Definition: core/mode.h:20
History & cmds()
Definition: extensions/calc/mode.cpp:16
virtual void clear()
Definition: buffer.cpp:173
ColorMap & getColorMap()
Definition: readonly.h:18
Definition: readonly.h:11
std::string currentTimeToStr()
Definition: time_utils.cpp:46
WatchMode()
Definition: extensions/watch/mode.cpp:9