vfs: check userland buffers before reading them.
[haiku.git] / src / apps / serialconnect / TermView.h
blobc43250723f62c7ac1f9aa65c5d2501adf201cf2a
1 /*
2 * Copyright 2012-2015, Adrien Destugues, pulkomandy@gmail.com
3 * Distributed under the terms of the MIT licence.
4 */
7 #include <String.h>
8 #include <View.h>
10 extern "C" {
11 #include <vterm.h>
15 class TermView: public BView
17 public:
18 TermView();
19 TermView(BRect bounds);
20 ~TermView();
22 void AttachedToWindow();
23 void Draw(BRect updateRect);
24 void FrameResized(float width, float height);
25 void GetPreferredSize(float* width, float* height);
26 void KeyDown(const char* bytes, int32 numBytes);
27 void MessageReceived(BMessage* message);
28 void SetLineTerminator(BString bytes);
30 void PushBytes(const char* bytes, const size_t length);
32 private:
33 void _Init();
35 VTermRect _PixelsToGlyphs(BRect pixels) const;
36 BRect _GlyphsToPixels(const VTermRect& glyphs) const;
37 BRect _GlyphsToPixels(const int width, const int height)
38 const;
39 void _GetCell(VTermPos pos, VTermScreenCell& cell);
41 void _Damage(VTermRect rect);
42 void _MoveCursor(VTermPos pos, VTermPos oldPos,
43 int visible);
44 void _PushLine(int cols, const VTermScreenCell* cells);
46 static int _Damage(VTermRect rect, void* user);
47 static int _MoveCursor(VTermPos pos, VTermPos oldPos,
48 int visible, void* user);
49 static int _PushLine(int cols, const VTermScreenCell* cells,
50 void* user);
51 static int _PopLine(int cols, const VTermScreenCell* cells,
52 void* user);
54 private:
55 VTerm* fTerm;
56 VTermScreen* fTermScreen;
57 BList fScrollBuffer;
58 int fFontWidth;
59 int fFontHeight;
61 BString fLineTerminator;
63 static const VTermScreenCallbacks sScreenCallbacks;
65 static const int kDefaultWidth = 80;
66 static const int kDefaultHeight = 25;
67 static const int kBorderSpacing = 3;
68 static const int kScrollBackSize = 1000;