File: lf_code_editor.h

package info (click to toggle)
mysql-workbench 5.2.40%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 53,880 kB
  • sloc: cpp: 419,850; yacc: 74,784; xml: 54,510; python: 31,455; sh: 9,423; ansic: 4,736; makefile: 2,442; php: 529; java: 237
file content (67 lines) | stat: -rw-r--r-- 2,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __LF_CODE_EDITOR_H__
#define __LF_CODE_EDITOR_H__

#include "mforms/code_editor.h"
#include "lf_view.h"

#include "Scintilla.h"
#define PLAT_GTK 2
#define GTK
#include "ScintillaWidget.h"

namespace mforms
{
namespace gtk
{

typedef std::map<std::string, int>  StyleNameMap;

class CodeEditorImpl : public ViewImpl
{
  public:
    CodeEditorImpl(CodeEditor* self);
    virtual ~CodeEditorImpl();
    static void init();

    virtual Gtk::Widget *get_outer() const;

    void notify(SCNotification *event);

  private:
    // private data
    GtkWidget         *_sci_gtk_widget;
    Gtk::Widget       *_sci_gtkmm_widget;
    ScintillaObject   *_sci;
    CodeEditor        *_owner;

    typedef std::map<int, std::map<int, std::string> > StyleMap;

    void load_language_settings(const std::string& language, StyleMap &sm);
    void language_setup(const std::string& language);
    void setup_marker(const int marker_id, const char* icon_path, int background);

    void setup_editor(const bool use_tabs, const int indentation, const std::string& lang);
    sptr_t send_editor(unsigned int msg, uptr_t uparam = 0, sptr_t sparam = 0)
    {
      return scintilla_send_message(_sci, msg, uparam, sparam);
    }

    static bool create(CodeEditor* self);
    static void set_text(CodeEditor* self, const std::string& text);
    static const std::string get_text(CodeEditor* self, bool selection_only);
    static void get_selection(CodeEditor* self, int &start, int &length);
    static void set_selection(CodeEditor* self, int start, int length);
    static bool get_range_of_line(CodeEditor* self, int line, int &start, int &length);
    static void set_language(CodeEditor* self, SyntaxHighlighterLanguage language);
    static void set_read_only(CodeEditor* self, bool flag);
    static void show_markup(CodeEditor* self, LineMarkup markup, int line);
    static void remove_markup(CodeEditor* self, LineMarkup markup, int line);
    static int line_count(CodeEditor* self);
    static void set_font(CodeEditor* self, const std::string &fontDescription);
    static void show_gutter(CodeEditor* self, bool on);
};

}//end of namespace gtk
}//end of namespace mforms

#endif