OSDN Git Service

console/console_monitor.hpp: 完成!
authorMyun2 <myun2@nwhite.info>
Sat, 8 Jan 2011 18:52:24 +0000 (03:52 +0900)
committerMyun2 <myun2@nwhite.info>
Sat, 8 Jan 2011 18:52:24 +0000 (03:52 +0900)
roast/include/roast/console/console_monitor.hpp
roast/include/roast/console/windows_console.hpp

index bbee5c0..3857937 100644 (file)
@@ -17,6 +17,9 @@ namespace roast
        {
                struct into{
                        ::std::string name;
+
+                       into(const ::std::string &s):name(s){}
+                       into(const char* s):name(s){}
                };
 
                struct out{};
@@ -25,13 +28,34 @@ namespace roast
        class debug_console_monitor
        {
        private:
-               ::std::stack<::std::string> m_stack;
-               typedef ::std::stack<::std::string>::iterator _StackIterator;
+               ::std::list<::std::string> m_stack;
+               typedef ::std::list<::std::string>::iterator _StackIterator;
        public:
                debug_console_monitor()
                {
+                       update_screen();
+               }
+
+               void update_stackframe()
+               {
+                       using namespace console;
+                       set_cursol(0,3);
+                       //for(size_t i=0; i<m_stack.size(); i++)
+                       int i=0;
+                       for(_StackIterator it=m_stack.begin(); it != m_stack.end(); it++, i++)
+                       {
+                               putchar_repeat(' ',i*2);
+                               printf("%s\n", it->c_str());
+                       }
+                       getc(stdin);
+               }
+
+               void update_screen()
+               {
                        using namespace console;
 
+                       clear_screen();
+
                        set_cursol(0,0);
                        repeat_to_screen_max('*',2);
                //      printf("\n*");
@@ -42,23 +66,20 @@ namespace roast
                        set_cursol(0,console::screen_height - 4);
                        repeat_to_screen_max('-');
                        printf("> ");
+
+                       update_stackframe();
                }
 
-               void update_stackframe()
+               void operator << (const debug::into& in)
                {
-                       using namespace console;
-                       set_cursol(0,3);
-                       //for(size_t i=0; i<m_stack.size(); i++)
-                       for(_StackIterator it=m_stack.begin(); it != m_stack.end(); it++)
-                       {
-                               printf("%s\n", it->c_str());
-                       }
+                       m_stack.push_back(in.name);
+                       update_screen();
                }
 
-               void operator << (const debug::into& in)
+               void operator << (const debug::out& out)
                {
-                       m_stack.push(in);
-                       update_stackframe();
+                       m_stack.pop_back();
+                       update_screen();
                }
        };
 }
index 961f863..08d9da3 100644 (file)
@@ -16,6 +16,7 @@ namespace roast
                void clear(){
                        ::system("cls");
                }
+               void clear_screen(){ clear(); }
 
                ///////////////////////////////////