1 // Copyright (c) 2015 Ryan Prichard
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 #ifndef LARGE_CONSOLE_READ_H
22 #define LARGE_CONSOLE_READ_H
29 #include "SmallRect.h"
30 #include "../shared/DebugClient.h"
31 #include "../shared/WinptyAssert.h"
33 class Win32ConsoleBuffer;
35 class LargeConsoleReadBuffer {
37 LargeConsoleReadBuffer();
38 const SmallRect &rect() const { return m_rect; }
39 const CHAR_INFO *lineData(int line) const {
40 validateLineNumber(line);
41 return &m_data[(line - m_rect.Top) * m_rectWidth];
45 CHAR_INFO *lineDataMut(int line) {
46 validateLineNumber(line);
47 return &m_data[(line - m_rect.Top) * m_rectWidth];
50 void validateLineNumber(int line) const {
51 if (line < m_rect.Top || line > m_rect.Bottom) {
52 trace("Fatal error: LargeConsoleReadBuffer: invalid line %d for "
53 "read rect %s", line, m_rect.toString().c_str());
60 std::vector<CHAR_INFO> m_data;
62 friend void largeConsoleRead(LargeConsoleReadBuffer &out,
63 Win32ConsoleBuffer &buffer,
64 const SmallRect &readArea,
68 #endif // LARGE_CONSOLE_READ_H