teditor
1.8.0@@fee5e94
Terminal based editor written in C++
|
Go to the documentation of this file.
10 #include <unordered_map>
21 typedef std::unordered_map<std::string, std::string>
OptionMap;
25 Editor(
const std::vector<FileInfo>& _files);
27 void setTitle(
const std::string& ti);
30 Buffer&
getBuff(
const std::string& name,
bool noUndoRedo,
bool& newOne);
37 Choices* choices=
nullptr,
const std::string& defVal=std::string());
40 void load(
const std::string& file,
int line);
41 void runCmd(
const std::string& cmd);
47 const char* str,
int len);
49 const char* fmt, ...);
63 int buffSize()
const {
return (
int)buffs.size(); }
66 bool switchToIt=
false);
84 bool quitEventLoop, quitPromptLoop, cancelPromptLoop, cmdMsgBarActive;
87 std::vector<FileInfo> files;
88 struct timeval timeout;
99 void writeLiteral(
const char* fmt, ...);
102 void clearBackBuff();
103 void sendCell(
int x,
int y,
const Cell& c) { backbuff.
at(x, y) = c; }
104 void writef(
const char* fmt, ...);
108 const AttrColor& getColor(
const std::string& name)
const;
109 int cmBarHeight()
const;
110 void deleteBuffer(
int idx);
112 void checkForModifiedBuffer(Buffer* mlb);
Definition: cell_buffer.h:13
void attachBuffs(Buffers *bs)
attach buffers list to this window. This list should be shared with all the other windows being displ...
Definition: window.cpp:13
void setChoiceIdx(int idx)
Definition: cmd_msg_bar.h:27
std::unordered_map< std::string, std::string > OptionMap
Definition: editor.h:19
void store() const
Definition: utils.cpp:276
int getOptLoc() const
Definition: cmd_msg_bar.h:72
virtual void load(const std::string &file, int line=0)
Definition: buffer.cpp:333
void decrementCurrBuff()
Definition: window.cpp:23
TrieStatus
Definition: key_cmd_map.h:7
bool splitVertically()
Definition: editor.h:73
Window & getWindow()
Definition: editor.h:31
Strings fileHistoryToString() const
Definition: editor.h:69
bool isRO() const
Definition: buffer.h:203
CmdMsgBar & getCmBar()
Definition: editor.h:34
TrieStatus traverse(const std::string &currKey)
Definition: key_cmd_map.cpp:18
key_t getKey() const
Definition: editor.cpp:509
void clear(AttrColor fg, AttrColor bg)
Definition: cell_buffer.cpp:40
void incrementCurrBuff()
Definition: editor.h:57
void writeChar(uint32_t c, int x, int y)
Definition: editor.cpp:359
void incrementCurrWin()
Definition: window.cpp:82
void clearAll()
Definition: window.cpp:150
void requestCancelPromptLoop()
Definition: editor.h:56
void setClipboard(const std::string &in)
Definition: editor.cpp:84
void createReadOnlyBuff(const std::string &name, const std::string &contents, bool switchToIt=false)
Definition: editor.cpp:129
@ Event_Key
Definition: terminal.h:32
void decrementCurrBuff()
Definition: editor.h:58
MetaKey mk
Definition: terminal.h:48
void requestQuitEventLoop()
Definition: editor.h:54
Chr ch
Definition: cell_buffer.h:14
const std::string clipboard() const
Definition: editor.cpp:68
uint32_t Chr
Definition: cell_buffer.h:10
#define CMBAR_MSG(ed, fmt,...)
Definition: logger.h:52
int sendStringf(int x, int y, const AttrColor &fg, const AttrColor &bg, const char *fmt,...)
Definition: editor.cpp:302
int buffSize() const
Definition: editor.h:63
const Window & getWindow() const
Definition: editor.h:32
const Strings & get() const
Definition: utils.h:136
void clearAllWindows()
Definition: editor.h:74
Definition: key_cmd_map.h:19
void puts(const char *data, size_t len)
append data at the end of the current buffer contents
Definition: terminal.cpp:62
Definition: cmd_msg_bar.h:50
const Point & getPoint() const
Definition: buffer.h:165
void clearChoices()
Definition: cmd_msg_bar.cpp:141
Strings buffNamesToString() const
Definition: editor.h:70
T y
Definition: pos2d.h:16
void resetTraversal()
Definition: key_cmd_map.h:26
int currBuffId() const
Definition: editor.h:62
Definition: cmd_msg_bar.h:15
void incrementCurrWin()
Definition: editor.h:75
bool promptYesNo(const std::string &msg)
Definition: editor.cpp:390
std::vector< std::string > Strings
Definition: utils.h:42
std::string promptEnum(const std::string &msg, OptionMap &opts)
Definition: editor.cpp:395
bool isModified() const
Definition: buffer.h:204
void switchToBuff(const std::string &name)
Definition: editor.cpp:169
int sendChar(int x, int y, const AttrColor &fg, const AttrColor &bg, char c)
Definition: editor.cpp:295
bool isUnderline() const
Definition: colors.h:70
static std::vector< KeyCmdPair > All
Definition: editor.cpp:26
@ Func_Italic
Definition: terminal.h:21
int char2unicode(uint32_t *out, const char *c)
Definition: utf8.cpp:23
static const int UndefinedSequence
Definition: terminal.h:95
int currBuffId() const
Definition: window.h:55
@ TS_NULL
Definition: key_cmd_map.h:8
bool splitVertically()
split the window into 2 vertical parts
Definition: window.cpp:129
const Buffer & getBuff() const
Definition: editor.h:29
void unselectCmBar()
Definition: editor.h:68
uint32_t key_t
Definition: keys.h:9
void clear() override
Definition: cmd_msg_bar.cpp:134
void dos2unix(std::string &in)
Definition: utils.cpp:249
void setMinLoc(int loc)
Definition: cmd_msg_bar.h:61
void resize(int w, int h)
Definition: cell_buffer.cpp:47
~Editor()
Definition: editor.cpp:56
void insert(char c) override
Definition: cmd_msg_bar.cpp:108
const std::string getCmd() const
Definition: key_cmd_map.cpp:26
Window & getWindow()
Definition: window.h:79
KeyCmdMap & getKeyCmdMap()
Definition: buffer.h:294
Buffer * push_back(const std::string &name, bool noUndoRedo=false)
Definition: buffer.cpp:834
bool usingChoices() const
Definition: cmd_msg_bar.h:66
void add(const std::string &file, int line)
Definition: file_utils.cpp:367
const Cell & at(int x, int y) const
Definition: cell_buffer.h:32
int getInt() const
Definition: option.h:44
Buffer & getBuff()
Definition: editor.h:28
#define ASSERT(check, fmt,...)
Macro to assert with runtime_error exception if the check fails.
Definition: utils.h:35
void flush()
Definition: terminal.cpp:71
void killOtherBuffs()
Definition: editor.cpp:191
int sendString(int x, int y, const AttrColor &fg, const AttrColor &bg, const char *str, int len)
Definition: editor.cpp:282
@ Event_Resize
Definition: terminal.h:33
void draw(Editor &ed, bool cmdMsgBarActive)
Definition: window.cpp:92
unsigned w() const
Definition: cell_buffer.h:34
int width() const
Definition: cell_buffer.cpp:29
int unicode2char(char *out, uint32_t c)
Definition: utf8.cpp:37
bool isAbs(const std::string &file)
Definition: file_utils.cpp:116
const Command & getCmd(const std::string &cmd)
Helper to return the command of interest.
Definition: command.cpp:23
Buffer & getBuff()
Definition: window.cpp:15
void makeReadOnly()
Definition: buffer.cpp:345
void runCmd(const std::string &cmd)
Definition: editor.cpp:119
bool isBold() const
Definition: colors.h:69
const std::string & bufferName() const
Definition: buffer.h:200
void killCurrBuff()
Definition: editor.cpp:180
#define DEBUG(fmt,...)
Definition: logger.h:73
void add(char key, const std::string &cmd)
Definition: key_cmd_map.cpp:6
void resize(int cmBarHt)
Definition: window.cpp:59
@ Func_ClearScreen
Definition: terminal.h:18
void setTitle(const std::string &ti)
Definition: editor.cpp:63
bool isItalic() const
Definition: colors.h:71
std::string getFinalChoice() const
Definition: cmd_msg_bar.cpp:82
unsigned h() const
Definition: cell_buffer.h:35
void load(const std::string &file, int line)
Definition: editor.cpp:151
void refresh()
Definition: editor.h:76
Window & getCmBarWindow()
Definition: editor.h:33
static ModePtr createMode(const std::string &mode)
Helper to create mode object of the named mode.
Definition: core/mode.cpp:48
void run()
Definition: editor.cpp:212
std::string rel2abs(const std::string &pwd, const std::string &rel)
Definition: file_utils.cpp:118
@ Func_Sgr0
Definition: terminal.h:19
Editor(const std::vector< FileInfo > &_files)
Definition: editor.cpp:35
void setChoices(Choices *ch)
Definition: cmd_msg_bar.h:64
void selectCmBar()
Definition: editor.h:67
color_t color() const
Definition: colors.h:72
Definition: cell_buffer.h:27
void writeCursor(int x, int y)
Definition: editor.cpp:355
Definition: editor.cpp:25
@ Func_Bold
Definition: terminal.h:22
void saveBuffer(Buffer &buf)
Definition: editor.cpp:92
Class to define an option used in the editor.
Definition: option.h:14
Definition: file_utils.h:99
void requestQuitPromptLoop()
Definition: editor.h:55
void gotoLine(int lineNum, const Point &dim)
Definition: buffer.cpp:797
#define ULTRA_DEBUG(fmt,...)
Definition: logger.h:74
Strings namesList() const
Definition: buffer.cpp:853
void setColors(AttrColor fg, AttrColor bg)
Definition: editor.cpp:367
virtual void insert(char c)
Definition: buffer.cpp:25
static Option & get(const std::string &n)
Definition: option.cpp:40
const AttrColor & get(const std::string &name) const
Definition: colors.cpp:67
static Terminal & getInstance()
Definition: terminal.cpp:57
@ Func_Underline
Definition: terminal.h:20
const AttrColor & getColor(const std::string &name) const
Definition: buffer.cpp:303
void setCurrBuff(int i)
Definition: window.h:56
std::string format(const char *fmt, va_list &vl)
Definition: utils.cpp:22
virtual bool save(const std::string &fName="")
Definition: buffer.cpp:638
void createScratchBuff(bool switchToIt=false)
Definition: editor.cpp:124
std::string getpwd()
Definition: file_utils.cpp:107
@ TS_LEAF
Definition: key_cmd_map.h:10
std::string prompt(const std::string &msg, KeyCmdMap *kcMap=nullptr, Choices *choices=nullptr, const std::string &defVal=std::string())
Definition: editor.cpp:413
#define CMBAR(ed, fmt,...)
Definition: logger.h:49
Buffer & getMessagesBuff()
Definition: editor.cpp:329
void incrementCurrBuff()
Definition: window.cpp:18
void erase(int idx)
Definition: buffer.cpp:846
const std::string & getFileName() const
Definition: buffer.h:201