Misc cleanups.
[tagua/yd.git] / src / console_p.h
blob879e6cb92bbaa79eab6ec910c47187770a7e3cdd
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef CONSOLE_P_H
12 #define CONSOLE_P_H
14 #include "highlighter.h"
15 #include "hline.h"
16 #include "luaapi/luahl.h"
17 #include <QTextCharFormat>
18 class QTextEdit;
20 //BEGIN ConsoleOutput ---------------------------------------
22 /**
23 * An utility class to perform a simple output operation
24 * on a QTextEdit with RAII.
26 class ConsoleOutput {
27 QTextEdit* m_edit;
28 int m_old_val;
29 bool m_scroll_to;
30 public:
31 ConsoleOutput(QTextEdit* edit, bool force_scroll = false);
33 virtual ~ConsoleOutput();
35 virtual void operator()(const QString& text);
38 class ConsoleHighlighter {
39 std::vector<Highlighter::Pattern> m_patterns;
40 QTextEdit* m_display;
41 QTextCharFormat m_basic_format;
42 public:
43 ConsoleHighlighter();
45 void setDisplay(QTextEdit* display);
47 void operator()(const QString& text, ConsoleOutput& output);
50 class LuaConsoleHighlighter {
51 QTextEdit* m_display;
52 LuaApi::Api m_api;
53 class Executor : public HLineExecutor {
54 QTextEdit* m_display;
55 ConsoleOutput& m_output;
56 public:
57 Executor(QTextEdit* display, ConsoleOutput& output);
58 virtual ~Executor();
59 virtual void writeChunk(const QString& text);
60 virtual void setFormat(const QTextCharFormat& format);
62 public:
63 LuaConsoleHighlighter();
64 void setDisplay(QTextEdit* display);
65 void operator()(const QString& text, ConsoleOutput& output);
69 #endif // CONSOLE_P_H