ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/dclient/src/frontend/client/widgets/query_widget.cpp
Revision: 1.3
Committed: Mon Oct 18 14:11:50 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.2: +3 -1 lines
Log Message:
check and log but do not die when ncurses stuff fails

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include "dclient/widgets/query.h"
2    
3     #include "deliantra/data/counters.h"
4     #include "deliantra/data/map.h"
5     #include "deliantra/data/statistics.h"
6    
7     #include <ndk++/pen.hh>
8    
9 sf-pippijn 1.3 #include <ncurses/assert.hh>
10    
11 sf-pippijn 1.1 query_widget::query_widget (ndk::panel *parent)
12     : frame ("", parent)
13     {
14     }
15    
16     void
17     query_widget::update (string_vector &&query)
18     {
19     this->query = query;
20    
21     std::string::size_type maxlen = 0;
22 sf-pippijn 1.2 foreach (std::string const &line, query)
23 sf-pippijn 1.1 maxlen = std::max (maxlen, line.size ());
24    
25     resize (maxlen + 2, query.size () + 4);
26     }
27    
28     void
29     query_widget::draw ()
30     {
31     frame::draw ();
32    
33     ndk::pen pen (*this);
34     int col = 0;
35 sf-pippijn 1.2 foreach (std::string const &line, query)
36 sf-pippijn 1.1 {
37 sf-pippijn 1.3 return_unless (pen.move (1, ++col));
38 sf-pippijn 1.1 pen.write (line);
39     }
40     }