1 /*
2 Vimpc
3 Copyright (C) 2010 Nathan Sweetman
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 console.cpp - window to accept command mode input
19 */
20
21 #include "console.hpp"
22
23 #include "buffers.hpp"
24 #include "screen.hpp"
25
26 using namespace Ui;
27
ConsoleWindow(Main::Settings const & settings,Ui::Screen & screen,std::string name,Console & console)28 ConsoleWindow::ConsoleWindow(Main::Settings const & settings, Ui::Screen & screen,
29 std::string name, Console & console) :
30 ScrollWindow(screen, name),
31 console_ (console)
32 {
33 console_.AddCallback(Main::Buffer_Add, [this] (Console::BufferType line) { PerformAutoScroll(line); });
34 }
35
~ConsoleWindow()36 ConsoleWindow::~ConsoleWindow()
37 {
38 }
39
40
PerformAutoScroll(Console::BufferType line)41 void ConsoleWindow::PerformAutoScroll(Console::BufferType line)
42 {
43 if ((AutoScroll() == true) && (BufferSize() - 1 <= ScrollLine()))
44 {
45 ScrollTo(console_.Size());
46 }
47 }
48
Clear()49 void ConsoleWindow::Clear()
50 {
51 console_.Clear();
52 ResetScroll();
53 }
54 /* vim: set sw=3 ts=3: */
55