[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kcwsh] /: add a way to transfer history as output
From: Patrick Spendrin <ps_ml () gmx ! de>
Date: 2014-06-30 21:14:37
Message-ID: E1X1iuL-0005t9-BJ () scm ! kde ! org
[Download RAW message or body]
Git commit 90c5130b6988a5adcc7bb45347f7da32e01c9fc3 by Patrick Spendrin.
Committed on 30/06/2014 at 20:47.
Pushed by sengels into branch 'master'.
add a way to transfer history as output
M +7 -0 outputreader.cpp
M +1 -0 outputreader.h
M +31 -0 outputwriter.cpp
M +5 -0 outputwriter.h
http://commits.kde.org/kcwsh/90c5130b6988a5adcc7bb45347f7da32e01c9fc3
diff --git a/outputreader.cpp b/outputreader.cpp
index 52e80f4..4e6726d 100644
--- a/outputreader.cpp
+++ b/outputreader.cpp
@@ -355,6 +355,13 @@ void OutputReader::init() {
}
wss.str(L"");
+ wss << L"kcwsh-outputHistory-" << dwProcessId;
+ if(m_outputHistory.create(wss.str().c_str(), m_bufferSize.data()->X * \
m_bufferSize.data()->Y) != 0) { + KcwDebug() << "failed to create \
outputHistory shared memory:" << wss.str(); + return;
+ }
+
+ wss.str(L"");
wss << L"kcwsh-title-" << dwProcessId;
// this is the maximum size (64KB)
if(m_title.create(wss.str().c_str(), 4096) != 0) {
diff --git a/outputreader.h b/outputreader.h
index bb3d778..519abad 100644
--- a/outputreader.h
+++ b/outputreader.h
@@ -54,6 +54,7 @@ class OutputReader : public KcwEventLoop {
DWORD dwmsEventTime);
bool minimizeConsoleFont();
KcwSharedMemory<CHAR_INFO> m_output;
+ KcwSharedMemory<CHAR_INFO> m_outputHistory;
KcwSharedMemory<COORD> m_bufferSize;
KcwSharedMemory<COORD> m_cursorPosition;
KcwSharedMemory<WCHAR> m_title;
diff --git a/outputwriter.cpp b/outputwriter.cpp
index 486f781..7679e17 100644
--- a/outputwriter.cpp
+++ b/outputwriter.cpp
@@ -129,6 +129,30 @@ WORD OutputWriter::attributesAt(COORD c) const {
return ci.Attributes;
}
+WCHAR OutputWriter::historyAt(COORD c) const {
+ CHAR_INFO ci;
+ COORD bufSize;
+
+ KcwAutoMutex a(m_mutex);
+ a.lock();
+
+ memcpy(&bufSize, m_bufferSize.data(), sizeof(COORD));
+ memcpy(&ci, m_outputHistory.data() + (bufSize.X * c.X + c.Y), \
sizeof(CHAR_INFO)); + return ci.Char.UnicodeChar;
+}
+
+WORD OutputWriter::historyAttributesAt(COORD c) const {
+ CHAR_INFO ci;
+ COORD bufSize;
+
+ KcwAutoMutex a(m_mutex);
+ a.lock();
+
+ memcpy(&bufSize, m_bufferSize.data(), sizeof(COORD));
+ memcpy(&ci, m_outputHistory.data() + (bufSize.X * c.X + c.Y), \
sizeof(CHAR_INFO)); + return ci.Attributes;
+}
+
COORD OutputWriter::scrolledDistance(bool reset) const {
COORD c;
ZeroMemory(&c, sizeof(COORD));
@@ -257,6 +281,13 @@ void OutputWriter::init() {
}
wss.str(L"");
+ wss << L"kcwsh-outputHistory-" << m_process->pid();
+ if(m_outputHistory.open(wss.str().c_str()) != 0) {
+ KcwDebug() << "failed to open outputHistory shared memory:" << wss.str();
+ return;
+ }
+
+ wss.str(L"");
wss << L"kcwsh-title-" << m_process->pid();
if(m_title.open(wss.str().c_str()) != 0) {
KcwDebug() << "failed to open title shared memory:" << wss.str();
diff --git a/outputwriter.h b/outputwriter.h
index dccea1f..947b638 100644
--- a/outputwriter.h
+++ b/outputwriter.h
@@ -63,9 +63,13 @@ class KCWSH_EXPORT OutputWriter : public KcwThread {
WCHAR at(COORD c) const;
WORD attributesAt(COORD c) const;
+ WCHAR historyAt(COORD c) const;
+ WORD historyAttributesAt(COORD c) const;
+
int foregroundPid() const;
protected:
KcwSharedMemory<CHAR_INFO> m_output;
+ KcwSharedMemory<CHAR_INFO> m_outputHistory;
KcwSharedMemory<COORD> m_bufferSize;
KcwSharedMemory<COORD> m_cursorPosition;
KcwSharedMemory<COORD> m_scrolledDistance;
@@ -82,6 +86,7 @@ class KCWSH_EXPORT OutputWriter : public KcwThread {
KcwNotifier m_titleChangeRequested;
KcwNotifier m_titleChanged;
+ CHAR_INFO *m_historyBuffer;
HANDLE m_mutex;
KcwProcess* m_process;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic