From kde-commits Mon Jun 30 21:14:37 2014 From: Patrick Spendrin Date: Mon, 30 Jun 2014 21:14:37 +0000 To: kde-commits Subject: [kcwsh] /: add a way to transfer history as output Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=140416288615600 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) !=3D 0) { + KcwDebug() << "failed to create outputHistory shared memory:" << w= ss.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) !=3D 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 m_output; + KcwSharedMemory m_outputHistory; KcwSharedMemory m_bufferSize; KcwSharedMemory m_cursorPosition; KcwSharedMemory 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(C= HAR_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(C= HAR_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()) !=3D 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()) !=3D 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 m_output; + KcwSharedMemory m_outputHistory; KcwSharedMemory m_bufferSize; KcwSharedMemory m_cursorPosition; KcwSharedMemory 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;