teditor  1.8.0@@fee5e94
Terminal based editor written in C++
readonly.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "core/mode.h"
4 #include "core/key_cmd_map.h"
5 #include "core/colors.h"
6 
7 namespace teditor {
8 namespace readonly {
9 
11 class ReadOnlyMode: public Mode {
12 public:
13  ReadOnlyMode(const std::string& n="ro",
14  const std::string& w="abcdefghijklmnopqrstuvwxyzABCDEGGHIJKLMNO"
15  "PQRSTUVWXYZ0123456789_");
16  int indent(Buffer& buf, int line) { return 0; }
17  KeyCmdMap& getKeyCmdMap() { return kcMap; }
18  ColorMap& getColorMap() { return cMap; }
19  void getColorFor(AttrColor& fg, AttrColor& bg, int lineNum, int pos,
20  const Buffer& b, bool isHighlighted);
21 
22  static Mode* create() { return new ReadOnlyMode; }
23 
24  static bool modeCheck(const std::string& file);
25 
26 private:
27  KeyCmdMap kcMap;
28  ColorMap cMap;
29 
30  struct Keys { static std::vector<KeyCmdPair> All; };
31  struct Colors { static std::vector<NameColorPair> All; };
32 };
33 
34 }; // end namespace readonly
35 }; // end namespace teditor
teditor::readonly::ReadOnlyMode::ReadOnlyMode
ReadOnlyMode(const std::string &n="ro", const std::string &w="abcdefghijklmnopqrstuvwxyzABCDEGGHIJKLMNO" "PQRSTUVWXYZ0123456789_")
Definition: readonly.cpp:13
teditor::readonly::ReadOnlyMode::modeCheck
static bool modeCheck(const std::string &file)
Definition: readonly.cpp:9
key_cmd_map.h
teditor::ColorMap
Definition: colors.h:87
teditor::KeyCmdMap
Definition: key_cmd_map.h:19
teditor::KeyCmdMap::resetTraversal
void resetTraversal()
Definition: key_cmd_map.h:26
teditor::readonly::ReadOnlyMode::getColorFor
void getColorFor(AttrColor &fg, AttrColor &bg, int lineNum, int pos, const Buffer &b, bool isHighlighted)
Definition: readonly.cpp:20
teditor::AttrColor
Definition: colors.h:56
utils.h
teditor::isReadOnly
bool isReadOnly(const char *f)
Definition: file_utils.cpp:52
file_utils.h
teditor::readonly::ReadOnlyMode::indent
int indent(Buffer &buf, int line)
Definition: readonly.h:16
teditor::readonly::ReadOnlyMode::getKeyCmdMap
KeyCmdMap & getKeyCmdMap()
Definition: readonly.h:17
teditor::readonly::REGISTER_MODE
REGISTER_MODE(ReadOnlyMode, "ro")
teditor::readonly::ReadOnlyMode::create
static Mode * create()
Definition: readonly.h:22
teditor::Mode
Definition: core/mode.h:27
colors.h
mode.h
teditor::ColorMap::get
const AttrColor & get(const std::string &name) const
Definition: colors.cpp:67
readonly.h
teditor::Buffer
Definition: buffer.h:25
teditor
Definition: any.hpp:10
teditor::readonly::ReadOnlyMode::getColorMap
ColorMap & getColorMap()
Definition: readonly.h:18
teditor::readonly::ReadOnlyMode
Definition: readonly.h:11