From: Foster B. <fos...@us...> - 2006-01-24 19:39:12
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/begin/sources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12473/adobe-source/adobe/test/begin/sources Modified Files: express_viewer.cpp report_exception.cpp Log Message: moved win/ directories to win32/ to anticipate a possible widgets port for WPF; added a 'mini-sheet' to Eve so you can save UI state information (what tab is currently selected) without mucking up your Adam model; started the modal_dialog_interface, an API that'll be used to direct a modal dialog interaction between the user and the application (it's still in its infancy); other misc bug fixes Index: report_exception.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/begin/sources/report_exception.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** report_exception.cpp 6 Jan 2006 18:03:02 -0000 1.2 --- report_exception.cpp 24 Jan 2006 19:38:50 -0000 1.3 *************** *** 7,73 **** /****************************************************************************************************/ ! #include "report_exception.hpp" ! ! #include <cassert> ! ! #ifndef NDEBUG ! #include <iostream> ! #endif ! ! /****************************************************************************************************/ ! ! namespace { ! ! /****************************************************************************************************/ ! ! inline adobe::report_exception_proc_t& report_exception_proc() ! { ! static adobe::report_exception_proc_t report_exception_proc_s; ! ! return report_exception_proc_s; ! } ! ! /****************************************************************************************************/ ! ! } // namespace ! ! /****************************************************************************************************/ ! ! namespace adobe { ! ! /****************************************************************************************************/ ! ! namespace implementation { ! ! /****************************************************************************************************/ ! ! void report_exception(const std::string& error_message) ! { ! if (report_exception_proc()) ! { ! report_exception_proc()(error_message); ! } ! #ifndef NDEBUG ! else ! { ! std::cerr << error_message << std::endl; ! } ! #endif ! } ! ! /****************************************************************************************************/ ! ! } // namespace implementation ! ! /****************************************************************************************************/ ! ! void set_report_exception_callback(boost::function<void (const std::string& msg)> proc) ! { ! report_exception_proc() = proc; ! } ! ! /****************************************************************************************************/ ! ! } // namespace adobe ! ! /****************************************************************************************************/ --- 7,9 ---- /****************************************************************************************************/ ! // This file intentionally left blank Index: express_viewer.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/begin/sources/express_viewer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** express_viewer.cpp 6 Jan 2006 18:03:02 -0000 1.8 --- express_viewer.cpp 24 Jan 2006 19:38:50 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- #include <adobe/future/file_slurp.hpp> + #include <adobe/future/modal_dialog_interface.hpp> #include <adobe/adam_evaluate.hpp> *************** *** 43,46 **** --- 44,48 ---- #include <adobe/dictionary.hpp> #include <adobe/config.hpp> + #include <adobe/future/widgets/headers/ui_core.hpp> #include <boost/version.hpp> *************** *** 156,162 **** bfs::ifstream eve_view_stream( editor_eve ); static adobe::auto_ptr<eve_client::eve_client_holder> editor_view_s( ! eve_client::make_view( adobe::line_position_t::ident_pair_t(adobe::name_t(editor_eve.string().c_str()), boost::any(&eve_view_stream)), eve_view_stream, editor_sheet_s, --- 158,166 ---- bfs::ifstream eve_view_stream( editor_eve ); + line_position_t::getline_proc_t getline_proc(new line_position_t::getline_proc_impl_t(boost::bind(&application_t::format_stream_error, boost::ref(*this), _1, _2))); + static adobe::auto_ptr<eve_client::eve_client_holder> editor_view_s( ! eve_client::make_view( adobe::name_t(editor_eve.string().c_str()), getline_proc, eve_view_stream, editor_sheet_s, *************** *** 184,195 **** // editor_sheet_s.update(); ! editor_view_s->eve_m->evaluate(adobe::eve_t::evaluate_nested); editor_view_s->show_window_m(); // ! // set the error reporting callback // ! set_report_exception_callback(boost::bind(&application_t::display_error, boost::ref(*this), _1)); _initialized = true; --- 188,199 ---- // editor_sheet_s.update(); ! editor_view_s->eve_m.evaluate(adobe::eve_t::evaluate_nested); editor_view_s->show_window_m(); // ! // set the ui_core error reporting callback // ! set_ui_core_error_handler(boost::bind(&application_t::display_error, boost::ref(*this), _1)); _initialized = true; *************** *** 431,438 **** // std::stringstream stream( _eve_file_m.as_string() ); ! try { ! _holder_m->push_back( stream, adobe::line_position_t::ident_pair_t(adobe::name_t(_eve_file_m.file_name()), boost::any(&stream)), _dialog_size_m ); } catch(const adobe::stream_error_t&) --- 435,443 ---- // std::stringstream stream( _eve_file_m.as_string() ); ! line_position_t::getline_proc_t getline_proc(new line_position_t::getline_proc_impl_t(boost::bind(&application_t::format_stream_error, boost::ref(*this), _1, _2))); ! try { ! _holder_m->push_back( stream, adobe::name_t(_eve_file_m.file_name()), getline_proc, _dialog_size_m ); } catch(const adobe::stream_error_t&) *************** *** 450,453 **** --- 455,488 ---- /****************************************************************************************************/ + const adobe::file_buffer_t& application_t::_file_lookup(adobe::name_t file_path) + { + boost::filesystem::path test_path(file_path.get(), boost::filesystem::native); + + if (_adam_file_m.get_path() == test_path) + return _adam_file_m; + else if (_eve_file_m.get_path() == test_path) + return _eve_file_m; + + throw std::runtime_error("No filename with that path, sorry"); + } + + /****************************************************************************************************/ + + std::string application_t::format_stream_error(adobe::name_t file_name, std::streampos line_start_position) + { + const adobe::file_buffer_t& file(_file_lookup(file_name)); + + std::string contents(file.as_string()); + + std::string::size_type cr_pos(contents.find("\r", line_start_position)); + std::string::size_type lf_pos(contents.find("\n", line_start_position)); + + std::string::size_type newline_pos(std::min(cr_pos, lf_pos)); + + return contents.substr(line_start_position, newline_pos - line_start_position); + } + + /****************************************************************************************************/ + void application_t::load_sheet() { *************** *** 484,491 **** // std::stringstream stream( _adam_file_m.as_string() ); try { ! adobe::parse( stream, adobe::line_position_t(adobe::line_position_t::ident_pair_t(adobe::name_t(_adam_file_m.file_name()), boost::any(&stream))), bind_to_sheet( *_sheet_m ) ); } catch(const adobe::stream_error_t&) --- 519,527 ---- // std::stringstream stream( _adam_file_m.as_string() ); + line_position_t::getline_proc_t getline_proc(new line_position_t::getline_proc_impl_t(boost::bind(&application_t::format_stream_error, boost::ref(*this), _1, _2))); try { ! adobe::parse( stream, adobe::line_position_t(adobe::name_t(_adam_file_m.file_name()), getline_proc), bind_to_sheet( *_sheet_m ) ); } catch(const adobe::stream_error_t&) *************** *** 526,530 **** void application_t::serialize_connections() { ! #ifdef ADOBE_SERIALIZATION if ( !_holder_m || !_editor_sheet_m ) return; --- 562,566 ---- void application_t::serialize_connections() { ! #if !defined(NDEBUG) && defined(ADOBE_SERIALIZATION) if ( !_holder_m || !_editor_sheet_m ) return; *************** *** 549,552 **** --- 585,606 ---- /****************************************************************************************************/ + void application_t::run_current_as_modal() + { + std::stringstream adam_stream( _adam_file_m.as_string() ); + std::stringstream eve_stream( _eve_file_m.as_string() ); + adobe::dictionary_t input; + adobe::record_info_t record; + adobe::dictionary_t display_state; + adobe::dialog_result_t result = + handle_dialog( input, + record, + display_state, + adobe::dialog_display_s, + eve_stream, + adam_stream); + } + + /****************************************************************************************************/ + void application_t::set_eve_file( const bfs::path& file_name ) { |