xref: /haiku/src/apps/serialconnect/TermView.h (revision 0ce4c23d22fae64d10e5575687490fbdf8ee52b8)
1 /*
2  * Copyright 2012, Adrien Destugues, pulkomandy@gmail.com
3  * Distributed under the terms of the MIT licence.
4  */
5 
6 
7 #include <View.h>
8 
9 extern "C" {
10 	#include <vterm.h>
11 }
12 
13 class TermView: public BView
14 {
15 	public:
16 		TermView();
17 		~TermView();
18 
19 		void AttachedToWindow();
20 		void Draw(BRect updateRect);
21 		void FrameResized(float width, float height);
22 		void GetPreferredSize(float* width, float* height);
23 		void KeyDown(const char* bytes, int32 numBytes);
24 		void MessageReceived(BMessage* message);
25 		void PushBytes(const char* bytes, const size_t length);
26 
27 	private:
28 		VTermRect PixelsToGlyphs(BRect pixels) const;
29 		BRect GlyphsToPixels(const VTermRect& glyphs) const;
30 		BRect GlyphsToPixels(const int width, const int height) const;
31 		void Damage(VTermRect rect);
32 
33 		static int Damage(VTermRect rect, void* user);
34 
35 	private:
36 		VTerm* fTerm;
37 		VTermScreen* fTermScreen;
38 		float fFontWidth;
39 		float fFontHeight;
40 
41 		static const VTermScreenCallbacks sScreenCallbacks;
42 
43 		static const int kDefaultWidth = 80;
44 		static const int kDefaultHeight = 25;
45 		static const int kBorderSpacing = 3;
46 };
47