| 1 | // @file ScintillaDocument.h |
| 2 | // Wrapper for Scintilla document object so it can be manipulated independently. |
| 3 | // Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware |
| 4 | |
| 5 | #ifndef SCINTILLADOCUMENT_H |
| 6 | #define SCINTILLADOCUMENT_H |
| 7 | |
| 8 | #include <QObject> |
| 9 | |
| 10 | class WatcherHelper; |
| 11 | |
| 12 | #ifndef EXPORT_IMPORT_API |
| 13 | #ifdef WIN32 |
| 14 | #ifdef MAKING_LIBRARY |
| 15 | #define EXPORT_IMPORT_API __declspec(dllexport) |
| 16 | #else |
| 17 | // Defining dllimport upsets moc |
| 18 | #define EXPORT_IMPORT_API __declspec(dllimport) |
| 19 | //#define EXPORT_IMPORT_API |
| 20 | #endif |
| 21 | #else |
| 22 | #define EXPORT_IMPORT_API |
| 23 | #endif |
| 24 | #endif |
| 25 | |
| 26 | class EXPORT_IMPORT_API ScintillaDocument : public QObject |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | |
| 30 | void *pdoc; |
| 31 | WatcherHelper *docWatcher; |
| 32 | |
| 33 | public: |
| 34 | explicit ScintillaDocument(QObject *parent = 0, void *pdoc_=0); |
| 35 | virtual ~ScintillaDocument(); |
| 36 | void *pointer(); |
| 37 | |
| 38 | int line_from_position(int pos); |
| 39 | bool is_cr_lf(int pos); |
| 40 | bool delete_chars(int pos, int len); |
| 41 | int undo(); |
| 42 | int redo(); |
| 43 | bool can_undo(); |
| 44 | bool can_redo(); |
| 45 | void delete_undo_history(); |
| 46 | bool set_undo_collection(bool collect_undo); |
| 47 | bool is_collecting_undo(); |
| 48 | void begin_undo_action(); |
| 49 | void end_undo_action(); |
| 50 | void set_save_point(); |
| 51 | bool is_save_point(); |
| 52 | void set_read_only(bool read_only); |
| 53 | bool is_read_only(); |
| 54 | void insert_string(int position, QByteArray &str); |
| 55 | QByteArray get_char_range(int position, int length); |
| 56 | char style_at(int position); |
| 57 | int line_start(int lineno); |
| 58 | int line_end(int lineno); |
| 59 | int line_end_position(int pos); |
| 60 | int length(); |
| 61 | int lines_total(); |
| 62 | void start_styling(int position); |
| 63 | bool set_style_for(int length, char style); |
| 64 | int get_end_styled(); |
| 65 | void ensure_styled_to(int position); |
| 66 | void set_current_indicator(int indic); |
| 67 | void decoration_fill_range(int position, int value, int fillLength); |
| 68 | int decorations_value_at(int indic, int position); |
| 69 | int decorations_start(int indic, int position); |
| 70 | int decorations_end(int indic, int position); |
| 71 | int get_code_page(); |
| 72 | void set_code_page(int code_page); |
| 73 | int get_eol_mode(); |
| 74 | void set_eol_mode(int eol_mode); |
| 75 | int move_position_outside_char(int pos, int move_dir, bool check_line_end); |
| 76 | |
| 77 | int get_character(int pos); // Calls GetCharacterAndWidth(pos, NULL) |
| 78 | |
| 79 | signals: |
| 80 | void modify_attempt(); |
| 81 | void save_point(bool atSavePoint); |
| 82 | void modified(int position, int modification_type, const QByteArray &text, int length, |
| 83 | int linesAdded, int line, int foldLevelNow, int foldLevelPrev); |
| 84 | void style_needed(int pos); |
| 85 | void lexer_changed(); |
| 86 | void error_occurred(int status); |
| 87 | |
| 88 | friend class ::WatcherHelper; |
| 89 | }; |
| 90 | |
| 91 | #endif /* SCINTILLADOCUMENT_H */ |
| 92 | |