From a8443598b820f5d0302c2663ef3424571d9073ed Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Fri, 8 May 2009 20:58:19 +0000 Subject: [PATCH] Updates to the gui app to fix command entering Additional flags for the build process to get the gui app compiled properly across operating systems Parsing ready for event scripts git-svn-id: file:///srv/svn/ircclient/trunk@13 a9804ffe-773b-11dd-bd7c-89c3ef1d2733 --- CMakeLists.txt | 8 +++++++- guiapp/chatwindow.ui | 31 +++++++++++++++++++------------ guiapp/messagehandler.cpp | 14 +++++++------- mirc/includes/parser.h | 23 +++++++++++++++++++++-- mirc/src/parser.cpp | 13 +++++++++++-- mirc/test.mrc | 10 +++++++++- 6 files changed, 74 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b223a..454fd84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,14 @@ add_subdirectory(src) add_subdirectory(mirc) add_subdirectory(testapp) if (WITH_GUI) + if (WIN32) + set (GUI_TYPE WIN32) + endif() + if (APPLE) + set (GUI_TYPE MACOSX_BUNDLE) + endif() set (QT_DONT_USE_QTGUI FALSE) include (${QT_USE_FILE}) set (LIBS ${QT_LIBRARIES}) add_subdirectory(guiapp) -endif() \ No newline at end of file +endif() diff --git a/guiapp/chatwindow.ui b/guiapp/chatwindow.ui index d45828d..4d70954 100644 --- a/guiapp/chatwindow.ui +++ b/guiapp/chatwindow.ui @@ -1,7 +1,8 @@ - + + ChatWindow - - + + 0 0 @@ -9,25 +10,31 @@ 300 - + - + - - + + + + Monospace + + + - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> +</style></head><body style=" font-family:'Monospace'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> - + diff --git a/guiapp/messagehandler.cpp b/guiapp/messagehandler.cpp index 22adb5f..c8601ac 100644 --- a/guiapp/messagehandler.cpp +++ b/guiapp/messagehandler.cpp @@ -10,7 +10,7 @@ MessageHandler::MessageHandler( IRCClient *irc, QWidget *parent ) : QTabWidget( connect( irc, SIGNAL( sentRAW( QString ) ), this, SLOT( sentRAW( QString ) ) ); connect( irc, SIGNAL( rcvdRAW( QString ) ), this, SLOT( rcvdRAW( QString ) ) ); this->setTabPosition( QTabWidget::South ); - _addWindow( "status", "", true ); + _addWindow( "status", "say", true ); DCCPortMin = 1024; DCCPortMax = 5000; @@ -66,7 +66,7 @@ void MessageHandler::messageRcvd( QString type, QString src, QString dest, QStri // Handle special messages first if( type == "JOIN" ) { - _addWindow( text, "msg " + text, true ); + _addWindow( text, "say", true ); } if( !dest.isEmpty() && dest.startsWith( '#' ) ) { @@ -89,19 +89,19 @@ void MessageHandler::messageRcvd( QString type, QString src, QString dest, QStri } //emit dispatchMessage( window, src, message ); - _addWindow( window, "msg " + window ); + _addWindow( window, "say" ); windows[window]->message( source, message ); } void MessageHandler::messageSentDCC( QString nickName, QString text ) { QString window = nickName.prepend( "=" ); - _addWindow( window, "msg " + window ); + _addWindow( window, "say" ); windows[window]->message( irc->getNickName(), text ); } void MessageHandler::messageRcvdDCC( QString nickName, QString text ) { QString window = "=" + nickName; - _addWindow( window, "msg " + window ); + _addWindow( window, "say" ); windows[window]->message( nickName, text ); } @@ -148,7 +148,7 @@ void MessageHandler::connectedDCCChat( QString nickName ) { connect( dcc, SIGNAL( rcvdText( QString, QString ) ), this, SLOT( messageRcvdDCC( QString, QString ) ) ); connect( dcc, SIGNAL( sentText( QString, QString ) ), this, SLOT( messageSentDCC( QString, QString ) ) ); QString window = nickName.prepend( "=" ); - _addWindow( window, "msg " + window ); + _addWindow( window, "say" ); windows[window]->echo( "DCC Chat Connected" ); } @@ -218,7 +218,7 @@ void MessageHandler::alias_msg(QStringList args) { } } void MessageHandler::alias_nick(QStringList args) { - if( args.count() > 1 ) { + if( args.count() > 0 ) { irc->nick( args[0] ); } this->scriptManager->return_value(irc->getNickName()); diff --git a/mirc/includes/parser.h b/mirc/includes/parser.h index 70819d0..d14ef3d 100644 --- a/mirc/includes/parser.h +++ b/mirc/includes/parser.h @@ -58,9 +58,10 @@ private: QStringList current_value; QStack stack; QString _alias; + mirc_engine_stage stage; + bool fetch; public: - mirc_engine_stage stage; mirc_alias script; mirc_aliases aliases; mirc_variables vars; @@ -69,9 +70,11 @@ public: mirc_script_engine(MIRCScriptManager *m); void set_stage(mirc_engine_stage _stage); + void set_fetch(bool _fetch); void handle_alias_definition(char const* str, char const* end); void handle_alias_definition_local(char const* str, char const* end); + void handle_event_definition(char const* str, char const* end); void close_alias(char const*, char const*); void store_code(char const* str, char const* end); void code_line(char const* str, char const* end); @@ -109,6 +112,8 @@ struct mirc_script : public grammar { alias_action, alias_function, alias_definition, + event_option, + event_definition, code_line, code_block, comment; @@ -118,6 +123,7 @@ struct mirc_script : public grammar { typedef function< void(const char*, const char*) > s_action; s_action a_def ( bind( &mirc_script_engine::handle_alias_definition, self.actions, _1, _2 ) ); s_action l_def ( bind( &mirc_script_engine::handle_alias_definition_local, self.actions, _1, _2 ) ); + s_action e_def ( bind( &mirc_script_engine::handle_event_definition, self.actions, _1, _2 ) ); s_action a_close ( bind( &mirc_script_engine::close_alias, self.actions, _1, _2 ) ); s_action a_set ( bind( &mirc_script_engine::set_alias, self.actions, _1, _2 ) ); s_action a_call ( bind( &mirc_script_engine::call_alias, self.actions, _1, _2 ) ); @@ -134,6 +140,7 @@ struct mirc_script : public grammar { script = *( alias_definition[a_close] + | event_definition | code_block ) >> end_p ; @@ -195,12 +202,24 @@ struct mirc_script : public grammar { >> *space >> !eol_p[c_line] >> code_block ; + event_option + = (+(graph_p - ch_p(':'))) + ; + event_definition + = str_p("on") >> *space + >> ( //event_option >> ch_p(':') >> event_option /* level:EVENT */ + //>> *(ch_p(':') >> event_option) >> ch_p(':') /* options */ + +(event_option[v_append][e_append] >> ch_p(':')) + )[e_def] + >> code_block + ; code_line = *space - >> ( comment[c_line] + >> ( comment[c_line] | ( assignment /* Must come first to avoid "var" being caught as an action */ | alias_action + | eol_p[c_line] )[s_code] )[c_stack] >> !eol_p[c_line] diff --git a/mirc/src/parser.cpp b/mirc/src/parser.cpp index a4e9d3b..cade9f9 100644 --- a/mirc/src/parser.cpp +++ b/mirc/src/parser.cpp @@ -5,6 +5,7 @@ mirc_script_engine::mirc_script_engine(MIRCScriptManager *m) : script() { manager = m; set_stage(PARSE); + set_fetch(true); current_alias = aliases.end(); current_variable = vars.end(); } @@ -13,6 +14,9 @@ void mirc_script_engine::set_stage(mirc_engine_stage _stage) { this->stage = _stage; this->line = 1; } +void mirc_script_engine::set_fetch(bool _fetch) { + this->fetch = _fetch; +} void mirc_script_engine::handle_alias_definition(char const* str, char const* end) { if (stage != PARSE) return; @@ -36,6 +40,11 @@ void mirc_script_engine::close_alias(char const*, char const*) { current_alias = aliases.end(); } } +void mirc_script_engine::handle_event_definition(char const* str, char const* end) { + if (stage != PARSE) return; + string s(str, end); + qDebug() << "EVENT DEFINITION" << s.c_str(); +} void mirc_script_engine::store_code(char const* str, char const* end) { if (stage != PARSE) return; @@ -63,7 +72,7 @@ void mirc_script_engine::call_alias(char const* str, char const* end) { stack.pop(); } void mirc_script_engine::return_alias(char const* str, char const* end) { - if (stage != EXECUTE) return; + if (stage != EXECUTE || !fetch) return; string s(str, end); manager->call_alias(_alias, stack.top()); stack.pop(); @@ -88,7 +97,7 @@ void mirc_script_engine::assign_variable(char const* str, char const* end) { } } void mirc_script_engine::fetch_variable(char const*, char const*) { - if (stage != EXECUTE) return; + if (stage != EXECUTE || !fetch) return; if (!current_value.isEmpty()) { QString var = current_value.last(); diff --git a/mirc/test.mrc b/mirc/test.mrc index 5f68825..159a3df 100644 --- a/mirc/test.mrc +++ b/mirc/test.mrc @@ -4,6 +4,9 @@ echo TEST Code line match [ 2 = $line ] echo TEST Code line match [ 4 = $line ] set name Correl %first = Correl + + + %middle = Joseph %name = %first $& %middle Roush @@ -22,6 +25,11 @@ alias -l getversion { } alias -l showversion { echo You're testing Mercenary $getversion - echo TEST Code line match [ 23 = $line ] + echo TEST Code line match [ 25 = $line ] +} +on *:TEXT:something:echo hey I got a message + +on *:QUIT:{ + echo Quitting! } dostuff