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 GetPreferredSize(float* width, float* height); 22 void KeyDown(const char* bytes, int32 numBytes); 23 void PushBytes(const char* bytes, const size_t length); 24 25 private: 26 VTermRect PixelsToGlyphs(BRect pixels) const; 27 BRect GlyphsToPixels(const VTermRect& glyphs) const; 28 BRect GlyphsToPixels(const int width, const int height) const; 29 void Damage(VTermRect rect); 30 31 static int Damage(VTermRect rect, void* user); 32 33 private: 34 VTerm* fTerm; 35 VTermScreen* fTermScreen; 36 float fFontWidth; 37 float fFontHeight; 38 39 static const VTermScreenCallbacks sScreenCallbacks; 40 41 static const int kDefaultWidth = 80; 42 static const int kDefaultHeight = 25; 43 static const int kBorderSpacing = 3; 44 }; 45