git-svn-id: svn://db.shs.com.ru/pip@263 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
50
main.cpp
50
main.cpp
@@ -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;
|
|
||||||
//ba << PIChar(key.key).toConcole1Byte();
|
|
||||||
//piCout << key.key;
|
|
||||||
ba = PIString(PIChar(key.key)).toUTF8();
|
|
||||||
term->write(ba);
|
|
||||||
}
|
}
|
||||||
EVENT_HANDLER1(void, keyEv, PIKbdListener::KeyEvent, k) {
|
void resizeEvent(int w, int h) {
|
||||||
piCoutObj << k.key;
|
if (!term) return;
|
||||||
if (k.key == -20) {
|
term->resize(w, h);
|
||||||
PIKbdListener::exiting = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (k.key == 's') {
|
PITerminal * term;
|
||||||
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;
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user