xref: /haiku/src/apps/terminal/TermParse.h (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
1 /*
2  * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
3  * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files or portions
7  * thereof (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so, subject
11  * to the following conditions:
12  *
13  *  * Redistributions of source code must retain the above copyright notice,
14  *    this list of conditions and the following disclaimer.
15  *
16  *  * Redistributions in binary form must reproduce the above copyright notice
17  *    in the  binary, as well as this list of conditions and the following
18  *    disclaimer in the documentation and/or other materials provided with
19  *    the distribution.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27  * THE SOFTWARE.
28  *
29  */
30 
31 #ifndef TERMPARSE_H
32 #define TERMPARSE_H
33 
34 #include <kernel/OS.h>
35 #include <MessageRunner.h>
36 #include "TermConst.h"
37 
38 class TermView;
39 class CodeConv;
40 class TermWindow;
41 
42 //PtyReader buffer size.
43 #define READ_BUF_SIZE 2048
44 
45 class TermParse : public BHandler
46 {
47 public:
48   TermParse (void);
49   ~TermParse (void);
50 
51   // Initialize TermParse and PtyReader thread.
52   status_t InitTermParse (TermView *inViewObj, CodeConv *inConvObj);
53   thread_id InitPtyReader (TermWindow *inWinObj);
54 
55   // Delete TermParse and PtyReader thread.
56   status_t AbortTermParse (void);
57   status_t AbortPtyReader (void);
58 
59 
60 private:
61   //
62   // Hook Functions.
63   //
64 
65 
66   // Escape Sequance parse thread.
67   static int32 EscParse (void *);
68 
69   // Pty device reader thread.
70   static int32 PtyReader (void *);
71 
72   // Reading ReadBuf at one Char.
73   uchar GetReaderBuf (void);
74 
75   TermView *fViewObj;
76   TermWindow *fWinObj;
77   CodeConv *fConvObj;
78 
79   thread_id fParseThread;
80   sem_id fParseSem;
81 
82   thread_id fReaderThread;
83   sem_id fReaderSem;
84   sem_id fReaderLocker;
85 
86   BMessageRunner *fCursorUpdate;
87 
88   uint fParser_p;	/* EscParse reading buffer pointer */
89   int fLockFlag;	/* PtyReader lock flag */
90 
91   bool fQuitting;
92 
93   uchar fReadBuf[READ_BUF_SIZE]; /* Reading buffer */
94 
95 };
96 
97 #endif // TERMPARSE_H
98