git-svn-id: svn://db.shs.com.ru/pip@263 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-09-14 08:37:00 +00:00
parent 047c58f342
commit bf3b01b4f3
4 changed files with 29 additions and 38 deletions

View File

@@ -10,8 +10,8 @@
#include "piserial.h" #include "piserial.h"
PIScreen screen;
PIConnection conn; PIConnection conn;
TilePICout cout_tile;
const char conn_config[] = const char conn_config[] =
@@ -19,7 +19,12 @@ const char conn_config[] =
device.test = ser://COM54:115200 #s\n\ device.test = ser://COM54:115200 #s\n\
device.test.disconnectTimeout = 3.00000000 #f\n\ device.test.disconnectTimeout = 3.00000000 #f\n\
[]\n"; []\n";
class TileTerminal: public PIScreenTile {
public:
TileTerminal(PITerminal * t) {
focus_flags = PIScreenTypes::CanHasFocus;
term = t;
}
private: private:
void drawEvent(PIScreenDrawer * d) { void drawEvent(PIScreenDrawer * d) {
//piCout << "draw" << visible; //piCout << "draw" << visible;
@@ -28,38 +33,20 @@ private:
d->fillRect(x_, y_, x_ + width_, y_ + height_, c); d->fillRect(x_, y_, x_ + width_, y_ + height_, c);
} }
bool keyEvent(PIKbdListener::KeyEvent key) { bool keyEvent(PIKbdListener::KeyEvent key) {
//piCout << "key";
//return false; //return false;
if (key.key == '~') {
cout_tile.content.clear();
return true;
}
if (!term) return false; if (!term) return false;
if (PITerminal::isSpecialKey(key.key)) term->write((PIKbdListener::SpecialKey)key.key, key.modifiers); term->write(key);
else { }
PIByteArray ba; void resizeEvent(int w, int h) {
//ba << PIChar(key.key).toConcole1Byte(); if (!term) return;
//piCout << key.key; term->resize(w, h);
ba = PIString(PIChar(key.key)).toUTF8(); }
term->write(ba); PITerminal * term;
} };
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;
}
};
int main (int argc, char * argv[]) { int main (int argc, char * argv[]) {
/*const char cs[] = "this is text\e"; /*const char cs[] = "this is text\e";
@@ -75,7 +62,7 @@ int main (int argc, char * argv[]) {
TileTerminal tt(&term); TileTerminal tt(&term);
if (screen) { if (screen) {
screen->rootTile()->addTile(&tt); screen->rootTile()->addTile(&tt);
screen->rootTile()->addTile(new TilePICout()); screen->rootTile()->addTile(&cout_tile);
screen->enableExitCapture(); screen->enableExitCapture();
} }
tt.setFocus(); tt.setFocus();
@@ -102,6 +89,7 @@ int main (int argc, char * argv[]) {
} }
if (screen) { if (screen) {
screen->rootTile()->takeTile(&tt); screen->rootTile()->takeTile(&tt);
screen->rootTile()->takeTile(&cout_tile);
delete screen; delete screen;
} }
return 0; return 0;

View File

@@ -25,9 +25,13 @@
#else #else
# include "piprocess.h" # include "piprocess.h"
# include <csignal> # include <csignal>
# include <pty.h>
# include <fcntl.h> # include <fcntl.h>
# include <sys/ioctl.h> # include <sys/ioctl.h>
# if defined(QNX) || defined(BLACKBERRY)
# include <unix.h>
# else
# include <pty.h>
# endif
#endif #endif
@@ -75,7 +79,6 @@ PRIVATE_DEFINITION_START(PITerminal)
bool is_esc_seq, last_read; bool is_esc_seq, last_read;
PIMap<int, bool> DEC; PIMap<int, bool> DEC;
PIVector<PIVector<PIScreenTypes::Cell> > cells_save; PIVector<PIVector<PIScreenTypes::Cell> > cells_save;
termios desc;
#endif #endif
PRIVATE_DEFINITION_END(PITerminal) PRIVATE_DEFINITION_END(PITerminal)

View File

@@ -36,7 +36,7 @@
# ifdef BLACKBERRY # ifdef BLACKBERRY
# include <complex> # include <complex>
# else # else
# include <complex.h> # include <complex>
# endif # endif
#else #else
# include <complex> # include <complex>

View File

@@ -137,7 +137,7 @@ bool PIThread::start(int timer_delay) {
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
if (ret == 0) { if (ret == 0) {
# ifdef MAC_OS # ifdef MAC_OS
pthread_threadid_np(thread, (__uint64_t*)&tid) pthread_threadid_np(thread, (__uint64_t*)&tid_)
# else # else
tid_ = thread; tid_ = thread;
# endif # endif
@@ -173,7 +173,7 @@ bool PIThread::startOnce() {
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
if (ret == 0) { if (ret == 0) {
# ifdef MAC_OS # ifdef MAC_OS
pthread_threadid_np(thread, (__uint64_t*)&tid) pthread_threadid_np(thread, (__uint64_t*)&tid_)
# else # else
tid_ = thread; tid_ = thread;
# endif # endif