[b0c416c] | 1 | /* cavernlog.h |
---|
[6bec10c] | 2 | * Run cavern inside an Aven window |
---|
| 3 | * |
---|
[0415bac] | 4 | * Copyright (C) 2005,2006,2010,2015,2016 Olly Betts |
---|
[6bec10c] | 5 | * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef SURVEX_CAVERNLOG_H |
---|
| 22 | #define SURVEX_CAVERNLOG_H |
---|
| 23 | |
---|
| 24 | #include "wx.h" |
---|
| 25 | #include <wx/html/htmlwin.h> |
---|
[15ba0b5] | 26 | #include <wx/process.h> |
---|
[6bec10c] | 27 | |
---|
[0e81a88] | 28 | #include <string> |
---|
| 29 | |
---|
[15ba0b5] | 30 | // We probably want to use a thread if we can - that way we can use a blocking |
---|
| 31 | // read from cavern rather than busy-waiting via idle events. |
---|
[fc626ae] | 32 | #ifdef wxUSE_THREADS |
---|
[0415bac] | 33 | # define CAVERNLOG_USE_THREADS |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 37 | class CavernThread; |
---|
| 38 | #endif |
---|
[fb5887c] | 39 | class MainFrm; |
---|
| 40 | |
---|
[6bec10c] | 41 | class CavernLogWindow : public wxHtmlWindow { |
---|
[0415bac] | 42 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 43 | friend class CavernThread; |
---|
| 44 | #endif |
---|
| 45 | |
---|
[fb5887c] | 46 | wxString filename; |
---|
| 47 | |
---|
| 48 | MainFrm * mainfrm; |
---|
| 49 | |
---|
[15ba0b5] | 50 | wxProcess * cavern_out; |
---|
[8991d7f] | 51 | wxString cur; |
---|
[f207751] | 52 | wxString source_line; |
---|
| 53 | const wxChar * highlight; |
---|
[8991d7f] | 54 | int link_count; |
---|
| 55 | unsigned char buf[1024]; |
---|
| 56 | unsigned char * end; |
---|
| 57 | |
---|
[d7b53e3] | 58 | bool init_done; |
---|
| 59 | |
---|
| 60 | wxString survey; |
---|
| 61 | |
---|
[0e81a88] | 62 | std::string log_txt; |
---|
| 63 | |
---|
[0415bac] | 64 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 65 | void stop_thread(); |
---|
| 66 | |
---|
| 67 | CavernThread * thread; |
---|
| 68 | |
---|
| 69 | wxCriticalSection thread_lock; |
---|
| 70 | #endif |
---|
| 71 | |
---|
[6bec10c] | 72 | public: |
---|
[d7b53e3] | 73 | CavernLogWindow(MainFrm * mainfrm_, const wxString & survey_, wxWindow * parent); |
---|
[6bec10c] | 74 | |
---|
[8991d7f] | 75 | ~CavernLogWindow(); |
---|
| 76 | |
---|
| 77 | /** Start to process survey data in file. */ |
---|
| 78 | void process(const wxString &file); |
---|
[6bec10c] | 79 | |
---|
| 80 | virtual void OnLinkClicked(const wxHtmlLinkInfo &link); |
---|
[fb5887c] | 81 | |
---|
[81e1aa4] | 82 | void OnReprocess(wxCommandEvent &); |
---|
[fb5887c] | 83 | |
---|
[0e81a88] | 84 | void OnSave(wxCommandEvent &); |
---|
| 85 | |
---|
[fb5887c] | 86 | void OnOK(wxCommandEvent &); |
---|
| 87 | |
---|
[fc626ae] | 88 | void OnCavernOutput(wxCommandEvent & e); |
---|
| 89 | |
---|
[15ba0b5] | 90 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 91 | void OnClose(wxCloseEvent &); |
---|
| 92 | #else |
---|
[8991d7f] | 93 | void OnIdle(wxIdleEvent &); |
---|
[fc626ae] | 94 | #endif |
---|
[8991d7f] | 95 | |
---|
[15ba0b5] | 96 | void OnEndProcess(wxProcessEvent & e); |
---|
| 97 | |
---|
[fb5887c] | 98 | DECLARE_EVENT_TABLE() |
---|
[6bec10c] | 99 | }; |
---|
| 100 | |
---|
[549eb37] | 101 | wxString escape_for_shell(wxString s, bool protect_dash = false); |
---|
| 102 | wxString get_command_path(const wxChar * command_name); |
---|
| 103 | |
---|
[6bec10c] | 104 | #endif |
---|