From bf3b01b4f34d2fa032226108a04c12a06735d490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Wed, 14 Sep 2016 08:37:00 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@263 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 54 +++++++++++++++----------------------- src/console/piterminal.cpp | 7 +++-- src/math/pimathbase.h | 2 +- src/thread/pithread.cpp | 4 +-- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/main.cpp b/main.cpp index a3deb4e8..82be5c80 100644 --- a/main.cpp +++ b/main.cpp @@ -10,8 +10,8 @@ #include "piserial.h" -PIScreen screen; PIConnection conn; +TilePICout cout_tile; const char conn_config[] = @@ -19,7 +19,12 @@ const char conn_config[] = device.test = ser://COM54:115200 #s\n\ device.test.disconnectTimeout = 3.00000000 #f\n\ []\n"; - +class TileTerminal: public PIScreenTile { +public: + TileTerminal(PITerminal * t) { + focus_flags = PIScreenTypes::CanHasFocus; + term = t; + } private: void drawEvent(PIScreenDrawer * d) { //piCout << "draw" << visible; @@ -28,38 +33,20 @@ private: d->fillRect(x_, y_, x_ + width_, y_ + height_, c); } bool keyEvent(PIKbdListener::KeyEvent key) { - //piCout << "key"; //return false; + if (key.key == '~') { + cout_tile.content.clear(); + return true; + } if (!term) return false; - if (PITerminal::isSpecialKey(key.key)) term->write((PIKbdListener::SpecialKey)key.key, key.modifiers); - else { - PIByteArray ba; - //ba << PIChar(key.key).toConcole1Byte(); - //piCout << key.key; - ba = PIString(PIChar(key.key)).toUTF8(); - term->write(ba); - } - EVENT_HANDLER1(void, keyEv, PIKbdListener::KeyEvent, k) { - piCoutObj << k.key; - if (k.key == -20) { - PIKbdListener::exiting = true; - - } - if (k.key == 's') { - PISerial * ser = (PISerial *)conn.deviceByName("test"); - if (ser) { - PIByteArray ba; - ba << uchar(31) << uchar(230) << uchar(0xd) << uchar(0xa); - piCoutObj << "send"; - ser->writeThreaded(ba); - } - } - } - - EVENT_HANDLER2(void, recv, const PIString &, from, const PIByteArray &, data) { - piCoutObj << from << PIString(data) << PICoutManipulators::Hex << data; - } - }; + term->write(key); + } + void resizeEvent(int w, int h) { + if (!term) return; + term->resize(w, h); + } + PITerminal * term; +}; int main (int argc, char * argv[]) { /*const char cs[] = "this is text\e"; @@ -75,7 +62,7 @@ int main (int argc, char * argv[]) { TileTerminal tt(&term); if (screen) { screen->rootTile()->addTile(&tt); - screen->rootTile()->addTile(new TilePICout()); + screen->rootTile()->addTile(&cout_tile); screen->enableExitCapture(); } tt.setFocus(); @@ -102,6 +89,7 @@ int main (int argc, char * argv[]) { } if (screen) { screen->rootTile()->takeTile(&tt); + screen->rootTile()->takeTile(&cout_tile); delete screen; } return 0; diff --git a/src/console/piterminal.cpp b/src/console/piterminal.cpp index 70092c94..d09d59f0 100644 --- a/src/console/piterminal.cpp +++ b/src/console/piterminal.cpp @@ -25,9 +25,13 @@ #else # include "piprocess.h" # include -# include # include # include +# if defined(QNX) || defined(BLACKBERRY) +# include +# else +# include +# endif #endif @@ -75,7 +79,6 @@ PRIVATE_DEFINITION_START(PITerminal) bool is_esc_seq, last_read; PIMap DEC; PIVector > cells_save; - termios desc; #endif PRIVATE_DEFINITION_END(PITerminal) diff --git a/src/math/pimathbase.h b/src/math/pimathbase.h index 2010b65d..6361baef 100644 --- a/src/math/pimathbase.h +++ b/src/math/pimathbase.h @@ -36,7 +36,7 @@ # ifdef BLACKBERRY # include # else -# include +# include # endif #else # include diff --git a/src/thread/pithread.cpp b/src/thread/pithread.cpp index 2355fcc2..d2774e0d 100755 --- a/src/thread/pithread.cpp +++ b/src/thread/pithread.cpp @@ -137,7 +137,7 @@ bool PIThread::start(int timer_delay) { pthread_attr_destroy(&attr); if (ret == 0) { # ifdef MAC_OS - pthread_threadid_np(thread, (__uint64_t*)&tid) + pthread_threadid_np(thread, (__uint64_t*)&tid_) # else tid_ = thread; # endif @@ -173,7 +173,7 @@ bool PIThread::startOnce() { pthread_attr_destroy(&attr); if (ret == 0) { # ifdef MAC_OS - pthread_threadid_np(thread, (__uint64_t*)&tid) + pthread_threadid_np(thread, (__uint64_t*)&tid_) # else tid_ = thread; # endif