View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001547 | Wishes | Editor | public | 2010-10-14 07:13 | 2011-08-06 17:07 |
Reporter | sonar | Assigned To | DrKnS | ||
Priority | normal | Severity | feature | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 2.0 | ||||
Fixed in Version | 3.0 | ||||
Summary | 0001547: Добавить в Far поддержку отображения rgb цветов и стилей форматирования в редакторе (truemod) | ||||
Description | В прикрепленном патче для far 1691 реализуется поддержка отображения rgb цветов и стилей форматирования в редакторе. Работу можно увидеть на связке colorer 1.0.2.10 + ConEmu + far с данным патчем. Я понимаю, что сразу патч не подойдет, что то скорее всего не устроит. Ожидаю предложений от far-team по доделкам, которые нужны перед включением данной возможности (если конечно сама идея будет принята) | ||||
Tags | No tags attached. | ||||
Build | 2118 | ||||
|
far2truemod.patch (25,025 bytes)
Index: ConsoleAnnotation.h =================================================================== --- ConsoleAnnotation.h (revision 0) +++ ConsoleAnnotation.h (revision 0) @@ -0,0 +1,149 @@ +#pragma once +/* + * v0.1 color&border styles + * v0.2 interface formal description, unified with ConEmu + */ + +/** + * Extended console AnnotationInfo (aka truemod) interprocess interactions agreements: + * + * - Shared buffer is always created by a Host (console manager) process. + * + * - Hosted (child) process should check for Share Name availability and + * rollback to basic console behaviour in case Share Name is not available. + * + * - It is responsibility of a Host process to ensure Share is created before + * child process is actually requires it + * + * - It is responsibility of a Host process to detect and create additional + * shares in case child process creates extra consoles on its own. + * + */ + +/** + * Share name to search for + * Two replacements: + * %d sizeof(AnnotationInfo) - compatibility/versioning field. + * %d console window handle + */ +#define AnnotationShareNameA "Console_annotationInfo_%x_%x" +#define AnnotationShareName L"Console_annotationInfo_%x_%x" + +/** + * Header structure, located at offset <0> within shared annotation buffer. + */ +struct AnnotationHeader +{ + /** + * Size of this header. annotation buffer at offset <struct_size> + * contains <AnnotationInfo> structures, one after another + */ + int struct_size; + /** + * Number of allocated <AnnotationInfo> elements within shared buffer. + * Clients should not access buffer outside of this size. + */ + int bufferSize; + /** + * Real console is in update phase (text and attributes). + * Clients must set this field to TRUE before WriteConsoleOutput and + * writing to annotation buffer. + * When modifications are completes - clients must + * increment modifiedCounter and set this field to FALSE. + */ + int locked; + /** + * Flush counter of annotation buffer. + * Clients must increment this value, when it completes buffer modification. + * Host may use it to understand when to update annotation buffer. + */ + unsigned int flushCounter; +}; + +/** + * Annotation Information for each character on the screen. + * + */ +struct AnnotationInfo +{ + AnnotationInfo() + { + for (int i = 0; i < sizeof(raw)/sizeof(raw[0]); i++) + raw[i] = 0; + } + union{ + struct{ + /** + * Background color + */ + unsigned int bk_color :24; + /** + * Foreground color + */ + unsigned int fg_color :24; + /** + * Validity indicators; + */ + int bk_valid :1; + int fg_valid :1; + + /** + * Custom border over the character position. + * + * bit 0 - left, bit 1 - top, bit 2 - right, bit 3 - bottom + */ + int border_visible :4; + /** + * When border within character has angles (f.e. left+top), + * console server may choose to draw it in some nice way (rounded, etc) + * + * 0 - no border, 1 - 1 pixel + */ + unsigned int border_style :8; + unsigned int border_color :24; + + /** + * Extra character style attributes. See AI_STYLE_* defines + */ + unsigned int style :16; + + #define AI_STYLE_BOLD 1 + #define AI_STYLE_ITALIC 2 + #define AI_STYLE_UNDERLINE 4 + #define AI_STYLE_STRIKEOUT 8 + #define AI_STYLE_SUPERSCRIPT 16 + #define AI_STYLE_SUBSCRIPT 32 + #define AI_STYLE_SHADOW 64 + #define AI_STYLE_SMALL_CAPS 128 + #define AI_STYLE_ALL_CAPS 256 + + }; + int raw[8]; + }; +}; +/* +Copyright (c) 2010 Igor Russkih +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ \ No newline at end of file Index: edit.cpp =================================================================== --- edit.cpp (revision 5120) +++ edit.cpp (working copy) @@ -2754,15 +2754,28 @@ // ����������� �������, ���� ��� ��� ���������� if (Length > 0) { - ScrBuf.ApplyColor( - Start, - Y1, - Start+Length-1, - Y1, - Attr, - // �� ����������� �������� - SelColor >= COL_FIRSTPALETTECOLOR ? Palette[SelColor-COL_FIRSTPALETTECOLOR] : SelColor - ); + if (Attr == COLOR_ITEM_ANNOTATION_INDICATOR) + { + ScrBuf.ApplyAnnotation( + Start, + Y1, + Start+Length-1, + Y1, + &CurItem->annotationInfo, + // �� ����������� �������� + SelColor >= COL_FIRSTPALETTECOLOR ? Palette[SelColor-COL_FIRSTPALETTECOLOR] : SelColor + ); + }else{ + ScrBuf.ApplyColor( + Start, + Y1, + Start+Length-1, + Y1, + Attr, + // �� ����������� �������� + SelColor >= COL_FIRSTPALETTECOLOR ? Palette[SelColor-COL_FIRSTPALETTECOLOR] : SelColor + ); + } } } } Index: edit.hpp =================================================================== --- edit.hpp (revision 5120) +++ edit.hpp (working copy) @@ -36,6 +36,7 @@ #include "scrobj.hpp" #include "colors.hpp" #include "bitflags.hpp" +#include "scrbufAnnotate.hpp" // ������ ���� (����� 0xFF) ������ ������� ScreenObject!!! enum FLAGS_CLASS_EDITLINE @@ -59,11 +60,15 @@ FEDITLINE_PARENT_EDITOR = 0x00400000, // "�����" ���� �������� }; +// Fck! Bit 'C' should be instead of 'D', since 0x10000 is cleared by FAR! +#define COLOR_ITEM_ANNOTATION_INDICATOR 0xDEACBEAF + struct ColorItem { int StartPos; int EndPos; int Color; + AnnotationInfo annotationInfo; }; enum SetCPFlags Index: editor.cpp =================================================================== --- editor.cpp (revision 5120) +++ editor.cpp (working copy) @@ -5744,6 +5744,41 @@ break; } + case ECTL_ADDANNOTATION: + { + if (Param) + { + EditorAnnotation *col=(EditorAnnotation*)Param; + _ECTLLOG(SysLog(L"EditorAnnotation{")); + _ECTLLOG(SysLog(L" StringNumber=%d",col->StringNumber)); + _ECTLLOG(SysLog(L" StartPos =%d",col->StartPos)); + _ECTLLOG(SysLog(L" EndPos =%d",col->EndPos)); + //_ECTLLOG(SysLog(L" Color =%d (0x%08X)",col->Color,col->Color)); + _ECTLLOG(SysLog(L"}")); + + ColorItem newcol; + newcol.StartPos = col->StartPos+(col->StartPos!=-1?X1:0); + newcol.EndPos = col->EndPos+X1; + newcol.Color = COLOR_ITEM_ANNOTATION_INDICATOR; + memcpy(newcol.annotationInfo.raw, col->annotation_raw, sizeof(AnnotationInfo)); + + Edit *CurPtr=GetStringByNumber(col->StringNumber); + + if (CurPtr==NULL) + { + _ECTLLOG(SysLog(L"GetStringByNumber(%d) return NULL",col->StringNumber)); + return FALSE; + } + + if (newcol.StartPos == -1) + return(CurPtr->DeleteColor(newcol.StartPos)); + + CurPtr->AddColor(&newcol); + return TRUE; + } + + break; + } // TODO: ���� DI_MEMOEDIT �� ����� ���� ��������, �� ������ �������� � FileEditor::EditorControl(), � ������� - ����� ����� case ECTL_GETCOLOR: { Index: far2.VS2008.vcproj =================================================================== --- far2.VS2008.vcproj (revision 5120) +++ far2.VS2008.vcproj (working copy) @@ -1164,6 +1164,10 @@ > </File> <File + RelativePath="scrbufAnnotate.cpp" + > + </File> + <File RelativePath="scrobj.cpp" > </File> Index: interf.cpp =================================================================== --- interf.cpp (revision 5120) +++ interf.cpp (working copy) @@ -911,6 +911,11 @@ ScrBuf.Read(X1,Y1,X2,Y2,(CHAR_INFO *)Dest,DestSize); } +void GetTextAn(int X1,int Y1,int X2,int Y2,void *Dest,int DestSize) +{ + ScrBuf.ReadAn(X1,Y1,X2,Y2,(AnnotationInfo *)Dest,DestSize); +} + void PutText(int X1,int Y1,int X2,int Y2,const void *Src) { int Width=X2-X1+1; @@ -921,6 +926,16 @@ ScrBuf.Write(X1,Y,SrcPtr,Width); } +void PutTextAn(int X1,int Y1,int X2,int Y2,const void *Src) +{ + int Width=X2-X1+1; + int Y; + AnnotationInfo *SrcPtr=(AnnotationInfo*)Src; + + for (Y=Y1; Y<=Y2; ++Y,SrcPtr+=Width) + ScrBuf.WriteAn(X1,Y,SrcPtr,Width); +} + void BoxText(wchar_t Chr) { wchar_t Str[]={Chr,L'\0'}; @@ -1362,3 +1377,8 @@ } return Result; } + +bool IsTrueMode() +{ + return ScrBuf.AiActive(); +} \ No newline at end of file Index: interf.hpp =================================================================== --- interf.hpp (revision 5120) +++ interf.hpp (working copy) @@ -147,7 +147,9 @@ void mprintf(const WCHAR *fmt,...); void vmprintf(const WCHAR *fmt,...); void PutText(int X1,int Y1,int X2,int Y2,const void *Src); +void PutTextAn(int X1,int Y1,int X2,int Y2,const void *Src); void GetText(int X1,int Y1,int X2,int Y2,void *Dest,int DestSize); +void GetTextAn(int X1,int Y1,int X2,int Y2,void *Dest,int DestSize); void BoxText(wchar_t Chr); void BoxText(const wchar_t *Str,int IsVert=0); @@ -184,3 +186,5 @@ #define RemoveHighlights(Str) RemoveChar(Str,L'&') bool IsFullscreen(); + +bool IsTrueMode(); Index: makefile_vc =================================================================== --- makefile_vc (revision 5120) +++ makefile_vc (working copy) @@ -205,6 +205,7 @@ "$(INTDIR)\savescr.obj" \ "$(INTDIR)\scantree.obj" \ "$(INTDIR)\scrbuf.obj" \ + "$(INTDIR)\scrbufAnnotate.obj" \ "$(INTDIR)\scrobj.obj" \ "$(INTDIR)\scrsaver.obj" \ "$(INTDIR)\setattr.obj" \ Index: plugin.hpp =================================================================== --- plugin.hpp (revision 5120) +++ plugin.hpp (working copy) @@ -1503,6 +1503,7 @@ #ifdef FAR_USE_INTERNALS ECTL_SERVICEREGION, #endif // END FAR_USE_INTERNALS + ECTL_ADDANNOTATION=100, }; enum EDITOR_SETPARAMETER_TYPES @@ -1695,6 +1696,14 @@ int Color; }; +struct EditorAnnotation +{ + int StringNumber; + int StartPos; + int EndPos; + int annotation_raw[8]; +}; + struct EditorSaveFile { const wchar_t *FileName; Index: savescr.cpp =================================================================== --- savescr.cpp (revision 5120) +++ savescr.cpp (working copy) @@ -71,6 +71,8 @@ _OT(SysLog(L"[%p] SaveScreen::~SaveScreen()", this)); RestoreArea(); delete[] ScreenBuf; + if (ScreenBufAn) + delete[] ScreenBufAn; } @@ -81,6 +83,12 @@ delete[] ScreenBuf; ScreenBuf=nullptr; + + if (!ScreenBufAn) + return; + + delete[] ScreenBufAn; + ScreenBufAn=nullptr; } @@ -90,6 +98,8 @@ return; PutText(X1,Y1,X2,Y2,ScreenBuf); + if (ScreenBufAn) + PutTextAn(X1,Y1,X2,Y2,ScreenBufAn); if (RestoreCursor) { @@ -111,6 +121,17 @@ return; GetText(X1,Y1,X2,Y2,ScreenBuf,ScreenBufCharCount()*sizeof(CHAR_INFO)); + + if (IsTrueMode()) + { + ScreenBufAn=new AnnotationInfo[ScreenBufCharCount()]; + + if (ScreenBufAn) + GetTextAn(X1,Y1,X2,Y2,ScreenBufAn,ScreenBufCharCount()*sizeof(AnnotationInfo)); + } + else + ScreenBufAn=NULL; + GetCursorPos(CurPosX,CurPosY); GetCursorType(CurVisible,CurSize); } @@ -121,6 +142,8 @@ return; GetText(X1,Y1,X2,Y2,ScreenBuf,ScreenBufCharCount()*sizeof(CHAR_INFO)); + if (ScreenBufAn) + GetTextAn(X1,Y1,X2,Y2,ScreenBufAn,ScreenBufCharCount()*sizeof(AnnotationInfo)); GetCursorPos(CurPosX,CurPosY); GetCursorType(CurVisible,CurSize); } Index: savescr.hpp =================================================================== --- savescr.hpp (revision 5120) +++ savescr.hpp (working copy) @@ -32,12 +32,14 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include"ConsoleAnnotation.h" class SaveScreen { friend class Grabber; private: PCHAR_INFO ScreenBuf; + AnnotationInfo *ScreenBufAn; SHORT CurPosX,CurPosY; bool CurVisible; DWORD CurSize; Index: scrbuf.cpp =================================================================== --- scrbuf.cpp (revision 5120) +++ scrbuf.cpp (working copy) @@ -103,6 +103,11 @@ BufY=Y; } +bool ScreenBuf::AiActive() +{ + return ai.active(); +} + /* ���������� ����������� ������ �������� �� �������. */ void ScreenBuf::FillBuf() @@ -117,6 +122,11 @@ Console.GetCursorPosition(CursorPosition); CurX=CursorPosition.X; CurY=CursorPosition.Y; + + if (!ai.active()) return; + AnnotationInfo *ai_ptr = ai.at(0); + memset(ai_ptr, 0, sizeof(AnnotationInfo) * ai.header->bufferSize); + } /* ������� Text � ��������� ����� @@ -145,6 +155,10 @@ SetVidChar(PtrBuf[i],Text[i].Char.UnicodeChar); PtrBuf[i].Attributes=Text[i].Attributes; } + AnnotationInfo *ai_ptr = ai.at(Y*BufX + X); + AnnotationInfo *ai_ptr_e = ai.at(Y*BufX + X + TextLength); + if (ai_ptr && ai_ptr_e) + memset(ai_ptr, 0, sizeof(AnnotationInfo) * TextLength); SBFlags.Clear(SBFLAGS_FLUSHED); #ifdef DIRECT_SCREEN_OUT @@ -157,7 +171,41 @@ #endif } +void ScreenBuf::WriteAn(int X,int Y,const AnnotationInfo *Text,int TextLength) +{ + CriticalSectionLock Lock(CS); + if (!ai.active()) return; + + if (X<0) + { + Text-=X; + TextLength=Max(0,TextLength+X); + X=0; + } + + if (X>=BufX || Y>=BufY || !TextLength || Y<0) + return; + + if (X+TextLength >= BufX) + TextLength=BufX-X; //?? + + AnnotationInfo *ai_ptr = ai.at(Y*BufX + X); + AnnotationInfo *ai_ptr_e = ai.at(Y*BufX + X + TextLength); + if (ai_ptr && ai_ptr_e) + memcpy(ai_ptr, Text, sizeof(AnnotationInfo) * TextLength); + + SBFlags.Clear(SBFLAGS_FLUSHED); +#ifdef DIRECT_SCREEN_OUT + Flush(); +#elif defined(DIRECT_RT) + + if (DirectRT) + Flush(); + +#endif +} + /* ����� ���� �� ����������� ������. */ void ScreenBuf::Read(int X1,int Y1,int X2,int Y2,CHAR_INFO *Text,int MaxTextLength) @@ -171,6 +219,23 @@ memcpy(Text+Idx,Buf+(Y1+I)*BufX+X1,Min((int)sizeof(CHAR_INFO)*Width,(int)MaxTextLength)); } +void ScreenBuf::ReadAn(int X1,int Y1,int X2,int Y2,AnnotationInfo *annotation,int MaxTextLength) +{ + CriticalSectionLock Lock(CS); + int Width=X2-X1+1; + int Height=Y2-Y1+1; + int I, Idx; + + if (!ai.active()) return; + + for (Idx=I=0; I < Height; I++, Idx+=Width) + { + AnnotationInfo *ai_ptr = ai.at((Y1+I)*BufX+X1); + AnnotationInfo *ai_ptr1 = annotation+Idx; + memcpy( ai_ptr1->raw,ai_ptr->raw, Min((int)sizeof(AnnotationInfo)*Width,(int)MaxTextLength)); + } +} + /* ������� ������� ������ ��������� � ������������ � ������ (� �������� ��������� �� "�������" ����) */ @@ -189,6 +254,7 @@ { if (!(PtrBuf->Attributes&=~ColorMask)) PtrBuf->Attributes=0x08; + // TODO: rgb darkening? } } @@ -223,7 +289,12 @@ CHAR_INFO *PtrBuf=Buf+(Y1+I)*BufX+X1; for (J=0; J < Width; J++, ++PtrBuf) + { PtrBuf->Attributes=Color; + } + AnnotationInfo *ai_ptr = ai.at((Y1+I)*BufX + X1); + if (ai_ptr) + memset(ai_ptr->raw, 0, sizeof(AnnotationInfo)*Width); //Buf[K+J].Attributes=Color; } @@ -257,7 +328,12 @@ for (int J = 0; J < X2-X1+1; J++, ++PtrBuf) if (PtrBuf->Attributes != ExceptColor) + { PtrBuf->Attributes = Color; + } + AnnotationInfo *ai_ptr = ai.at((Y1+I)*BufX + X1); + if (ai_ptr) + memset(ai_ptr->raw, 0, sizeof(AnnotationInfo) * (X2-X1+1) ); } #ifdef DIRECT_SCREEN_OUT @@ -271,6 +347,41 @@ } } +void ScreenBuf::ApplyAnnotation(int X1,int Y1,int X2,int Y2,AnnotationInfo *annotation,WORD ExceptColor) +{ + CriticalSectionLock Lock(CS); + int Width=X2-X1+1; + int Height=Y2-Y1+1; + int I, J; + + if (!ai.active()) return; + + for (I=0; I < Height; I++) + { + CHAR_INFO *PtrBuf = Buf+(Y1+I)*BufX+X1; + AnnotationInfo *ai_ptr = ai.at((Y1+I)*BufX + X1); + + for (J=0; J < Width; J++, ++ai_ptr, ++PtrBuf) + { + if (PtrBuf->Attributes != ExceptColor) + { + memcpy(ai_ptr->raw, annotation->raw, sizeof(AnnotationInfo)); + } + } + } + +#ifdef DIRECT_SCREEN_OUT + Flush(); +#elif defined(DIRECT_RT) + + if (DirectRT) + Flush(); + +#endif + +} + + /* �������� ����������� �������� Ch � ������ Color */ void ScreenBuf::FillRect(int X1,int Y1,int X2,int Y2,WCHAR Ch,WORD Color) @@ -287,6 +398,10 @@ { for (PtrBuf=Buf+(Y1+I)*BufX+X1, J=0; J < Width; J++, ++PtrBuf) *PtrBuf=CI; + AnnotationInfo *ai_ptr = ai.at((Y1+I)*BufX + X1); + if (ai_ptr && ai.at((Y1+I)*BufX + X1 + Width)) + memset(ai_ptr, 0, sizeof(AnnotationInfo) * Width); + } SBFlags.Clear(SBFLAGS_FLUSHED); @@ -308,6 +423,10 @@ if (!LockCount) { + + if (ai.active()) + ai.header->flushCounter++; + if (CtrlObject && (CtrlObject->Macro.IsRecording() || CtrlObject->Macro.IsExecuting())) { MacroChar=Buf[0]; Index: scrbuf.hpp =================================================================== --- scrbuf.hpp (revision 5120) +++ scrbuf.hpp (working copy) @@ -35,6 +35,7 @@ #include "bitflags.hpp" #include "CriticalSections.hpp" +#include "scrbufAnnotate.hpp" class ScreenBuf { @@ -43,6 +44,7 @@ CHAR_INFO *Buf; CHAR_INFO *Shadow; + ScrBufAnnotationInfo ai; CHAR_INFO MacroChar; bool MacroCharUsed; CHAR_INFO ElevationChar; @@ -76,17 +78,22 @@ public: void FillBuf(); void Read(int X1,int Y1,int X2,int Y2,CHAR_INFO *Text,int MaxTextLength); + void ReadAn(int X1,int Y1,int X2,int Y2,AnnotationInfo *annotation,int MaxTextLength); void Write(int X,int Y,const CHAR_INFO *Text,int TextLength); + void WriteAn(int X,int Y,const AnnotationInfo *Text,int TextLength); void RestoreMacroChar(); void RestoreElevationChar(); void ApplyColorMask(int X1,int Y1,int X2,int Y2,WORD ColorMask); void ApplyColor(int X1,int Y1,int X2,int Y2,WORD Color); void ApplyColor(int X1,int Y1,int X2,int Y2,int Color,WORD ExceptColor); + void ApplyAnnotation(int X1,int Y1,int X2,int Y2,AnnotationInfo *annotation,WORD ExceptColor); void FillRect(int X1,int Y1,int X2,int Y2,WCHAR Ch,WORD Color); void Scroll(int); void Flush(); + bool AiActive(); + }; extern ScreenBuf ScrBuf; Index: scrbufAnnotate.cpp =================================================================== --- scrbufAnnotate.cpp (revision 0) +++ scrbufAnnotate.cpp (revision 0) @@ -0,0 +1,77 @@ +/* +scrbufAnnotation.cpp + +Annotation attributes: misc information transfer (true color is the most +important) via mmapped file to host Console2 process +*/ +/* +Copyright (c) 2010 Igor Russkih +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "headers.hpp" +#include "scrbufAnnotate.hpp" +#pragma hdrstop + +ScrBufAnnotationInfo::ScrBufAnnotationInfo() +{ + wchar_t shareName[255]; + wsprintf(shareName, AnnotationShareName, sizeof(AnnotationInfo), GetConsoleWindow()); + +// wprintf(shareName); +// MessageBox(NULL, shareName, L"far", 0); + + int m_dwSize = 0; + + hSharedMem = OpenFileMapping( + FILE_MAP_ALL_ACCESS, + FALSE, + shareName); + +// printf("-%d-\n", hSharedMem); + + // TODO: error handling + + char * map = (char*)MapViewOfFile( + hSharedMem, + FILE_MAP_ALL_ACCESS, + 0, + 0, + 0); + + header = (AnnotationHeader*)map; + ptr = NULL; + if (!header) return; + + ptr = (AnnotationInfo*) (map + header->struct_size); + +}; + +ScrBufAnnotationInfo::~ScrBufAnnotationInfo() +{ + + UnmapViewOfFile(ptr); + CloseHandle(hSharedMem); + +}; Index: scrbufAnnotate.hpp =================================================================== --- scrbufAnnotate.hpp (revision 0) +++ scrbufAnnotate.hpp (revision 0) @@ -0,0 +1,61 @@ +#pragma once +/* +scrbufAnnotate.hpp + +Annotation attributes: misc information transfer (true color is the most +important) via mmapped file to host Console2 process +*/ +/* +Copyright (c) 2010 Igor Russkih +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include<windows.h> +#include"ConsoleAnnotation.h" + +class ScrBufAnnotationInfo +{ +public: + ScrBufAnnotationInfo(); + ~ScrBufAnnotationInfo(); + AnnotationHeader *header; + + AnnotationInfo *at(int offset) { + if (ptr == NULL) + return NULL; + if (header->bufferSize < offset) + return NULL; + return ptr+offset; + } + + bool active(){ + return ptr != NULL; + } + +private: + HANDLE hSharedMem; + AnnotationInfo *ptr; + + +}; |
|
Если уже с этим связываться, то поддержку 32-битного цвета надо делать глобально и нативно - например, введением структуры типа CHAR_INFO_EX (int BackColor, int ForeColor, флаги там всякие и т.п.) и выделением модуля отрисовки в отдельную библиотеку, которую при желании можно будет заменить альтернативной, выводящей не в консольное окно, а в какое-то свое, со всеми свистелками и сопелками. Ясен пончик, это потребует куда более масштабных переделок. |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-10-14 07:13 | sonar | New Issue | |
2010-10-14 07:13 | sonar | File Added: far2truemod.patch | |
2010-10-14 09:16 | DrKnS | Note Added: 0005911 | |
2011-08-06 17:07 | DrKnS | Build | => 2118 |
2011-08-06 17:07 | DrKnS | Status | new => closed |
2011-08-06 17:07 | DrKnS | Assigned To | => DrKnS |
2011-08-06 17:07 | DrKnS | Resolution | open => fixed |
2011-08-06 17:07 | DrKnS | Fixed in Version | => 3.0 |