FACT++  1.0
void WindowLog::Display ( bool  empty = false)

Display backlog.

Display the backlog. If fWindow is NULL then it is flushed to cout otherwise to the window (including the colors and attributes)

Access to cout, the backlog and the window is encapsulated in mutices.

Definition at line 46 of file WindowLog.cc.

References i.

Referenced by Console::EventHook(), Main::execute(), Shell::HandleResize(), Console::Lock(), Shell::Process(), Shell::Resize(), Console::Run(), SetWindow(), Console::Startup(), Console::~Console(), and ConsoleStream::~ConsoleStream().

47 {
48  if (!fWindow)
49  {
50  fMuxBacklog.lock();
51  fMuxCout.lock();
52 
53  cout.write(fBacklog.data(), fBacklog.size());
54  cout.flush();
55 
56  if (empty)
57  fBacklog.clear();
58 
59  fMuxCout.unlock();
60  fMuxBacklog.unlock();
61  return;
62  }
63 
64  const int w = getmaxx(fWindow);
65 
66  fMuxBacklog.lock();
67  fMuxWindow.lock();
68  //vector<char>::iterator p0 = fBacklog.begin();
69 
70  int lines = 0;
71  int x = 0;
72 
73  for (unsigned int i=0; i<fBacklog.size(); i++)
74  {
75  if (fAttributes.find(i)!=fAttributes.end())
76  fAttributes[i]==-1 ? wattrset(fWindow, 0) : wattron(fWindow, fAttributes[i]);
77 
78  if (fBacklog[i]=='\n')
79  {
80  // The attribute is added to the backlog in WriteBuffer
81  //wattrset(fWindow, 0);
82  lines += x/w + 1;
83  x=0;
84  }
85  wprintw(fWindow, "%c", fBacklog[i]);
86  x++;
87  }
88 
89  if (empty)
90  fBacklog.clear();
91 
92  fMuxWindow.unlock();
93  fMuxBacklog.unlock();
94 
95  lines += x/w;
96 }
std::vector< char > fBacklog
Pointer to an ncurses Window.
Definition: WindowLog.h:65
std::mutex fMuxCout
Mutex securing file access.
Definition: WindowLog.h:75
int i
Definition: db_dim_client.c:21
WINDOW * fWindow
Pointer to end of buffer.
Definition: WindowLog.h:63
std::map< int, int > fAttributes
Backlog storage.
Definition: WindowLog.h:66
std::mutex fMuxBacklog
Switch to toggle storage in the backlog on or off.
Definition: WindowLog.h:73
std::mutex fMuxWindow
Mutex securing output to cout.
Definition: WindowLog.h:76

+ Here is the caller graph for this function: