File: wxTerminalOptions.h

package info (click to toggle)
codelite 14.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (91 lines) | stat: -rw-r--r-- 2,695 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef WXTERMINALOPTIONS_H
#define WXTERMINALOPTIONS_H

#include <wx/string.h>
#include "JSON.h"

enum eTerminalOptions {
    kPrintTTY = (1 << 0),
    kPause = (1 << 1),
};

class wxTerminalOptions
{
    size_t m_flags = 0;
    wxString m_workingDirectory;
    wxString m_title;
    wxString m_command;
    wxString m_logfile;
    wxString m_ttyfile;
    // seriliazable fields
    wxFont m_font;
    wxColour m_bgColour;
    wxColour m_textColour;
    wxArrayString m_history;

protected:
    void EnableFlag(bool b, eTerminalOptions flag)
    {
        if(b) {
            m_flags |= flag;
        } else {
            m_flags &= ~flag;
        }
    }

public:
    wxTerminalOptions();
    ~wxTerminalOptions();

    static wxTerminalOptions& Get();
    wxTerminalOptions& Load();
    wxTerminalOptions& Save();

    wxTerminalOptions& SetFlags(size_t flags)
    {
        this->m_flags = flags;
        return *this;
    }

    void SetTtyfile(const wxString& ttyfile) { this->m_ttyfile = ttyfile; }
    const wxString& GetTtyfile() const { return m_ttyfile; }

    void SetBgColour(const wxColour& bgColour) { this->m_bgColour = bgColour; }
    void SetFont(const wxFont& font) { this->m_font = font; }
    void SetTextColour(const wxColour& textColour) { this->m_textColour = textColour; }
    const wxColour& GetBgColour() const { return m_bgColour; }
    const wxFont& GetFont() const { return m_font; }
    const wxColour& GetTextColour() const { return m_textColour; }
    wxTerminalOptions& SetWorkingDirectory(const wxString& workingDirectory)
    {
        this->m_workingDirectory = workingDirectory;
        return *this;
    }

    void FromJSON(const JSONItem& json);
    JSONItem ToJSON() const;

    size_t GetFlags() const { return m_flags; }
    const wxString& GetWorkingDirectory() const { return m_workingDirectory; }

    void SetPrintTTY(bool b) { EnableFlag(b, kPrintTTY); }
    bool IsPrintTTY() const { return m_flags & kPrintTTY; }

    void SetWaitOnExit(bool b) { EnableFlag(b, kPause); }
    bool IsWaitOnExit() const { return m_flags & kPause; }

    void SetTitle(const wxString& title) { this->m_title = title; }
    const wxString& GetTitle() const { return m_title; }

    void SetCommand(const wxString& command) { this->m_command = command; }
    const wxString& GetCommand() const { return m_command; }
    void SetCommandFromFile(const wxString& command);

    void SetLogfile(const wxString& logfile) { this->m_logfile = logfile; }
    const wxString& GetLogfile() const { return m_logfile; }
    
    void SetHistory(const wxArrayString& history) ;
    const wxArrayString& GetHistory() const { return m_history; }
};

#endif // WXTERMINALOPTIONS_H