// THColorer.pkg // This is TheHammer 3.0 Code Colorer // by Sergey V. Natarov // *** COLORS *** // _WindowColr_ _LftMrgnClr_ _BookmarkCl_ _BookmarkBg_ _TextColorX_ _TextBackgr_ _NumberColr_ _NumberBkGr_ _KeywordsCl_ _KeywordsBg_ _OperatorCl_ _OperatorBg_ _ScopeKwClr_ _ScopeKwBkg_ _CommentClr_ _CommentBkg_ _StringColr_ _StringBkgr_ _TagTextClr_ _TagTextBkg_ _TagEntyClr_ _TagEntyBkg_ _TagElemClr_ _TagElemBkg_ _TagAttrClr_ _TagAttrBkg_ _LineNrColr_ _LineNrBkgr_ _HrDivLinCl_ _VrDivLinCl_ _HiLtLineCl_ // 255255255000 192192192000 255255255255 255255255255 000000000000 255255255000 255000255000 255255255000 000000255000 255255255000 255000000000 255255255000 000000255000 255255255000 000128000000 255255255000 128128128000 255255255000 000128128000 255255255255 255000000000 255255255255 000000255000 255255255255 128000000000 255255255255 255255255000 128128128000 255255255255 192192192000 192192192000 000 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 // *** FONTS *** (PSFONTSTYLES) // Nr Sc Ct TT En At // _ _ _ _ _ _ _ _ _ _ _ _ // 000000000000000002000001000001000000000 // _ - - - - - // Tx Kw Op St El Ln // 1 2 3 4 5 6 7 8 9 10 11 12 // 1 2 3 // Normal = 0 // Bold = 1 // Italics = 2 // Bold + Italics = 3 // Underline = 4 // B+U = 5 // I+U = 6 // B+I+U = 7 Use cRichEdit.pkg Use THColorer.h Procedure Add_Color_Element Integer iIndex String sName Integer iFront Integer iBack Integer iFont Integer iStyle Integer iCM // iIndex = Element Index // Name of the Element Move sName to gtColorer[iIndex].sName // Front Color OffSet *at the color line (if any) Move iFront to gtColorer[iIndex].iForeOff // Background Color OffSet *at the color line (if any) Move iBack to gtColorer[iIndex].iBackOff // Font attributes allowed Move iFont to gtColorer[iIndex].iFont // Font Style Move iStyle to gtColorer[iIndex].iStyle // CodeMax Support Move iCM to gtColorer[iIndex].iCM End_Procedure Function RGBColorFromString String sColorStr Returns Integer Integer iRed iGreen iBlue If (Length(sColorStr)<>12) Begin Function_Return 0 End If (sColorStr="255255255255") Begin Function_Return -1 // Default color End // 1 4 7 // RRRGGGBBBAAA Move (Mid(sColorStr, 3, 1)) to iRed Move (Mid(sColorStr, 3, 4)) to iGreen Move (Mid(sColorStr, 3, 7)) to iBlue Function_Return (RGB(iRed, iGreen, iBlue)) End_Function Function RGBStringFromRGB String iRed String iGreen String iBlue Returns String String sColorStr Move (sColorStr+Right(("000"+iRed), 3)) to sColorStr Move (sColorStr+Right(("000"+iGreen), 3)) to sColorStr Move (sColorStr+Right(("000"+iBlue), 3)) to sColorStr Move (sColorStr+"000") to sColorStr // Returns string as RRRGGGBBBAAA (128128128000) Function_Return sColorStr End_Function Procedure SetColorerCurrentStyles String sColors String sFontStyle Integer iItem iItems iColor iFont String sColorStr sFontStr // If (sColors="") ; Get psColors of ghoEditorProperties to sColors If (sFontStyle="") ; Get psFontStyles of ghoEditorProperties to sFontStyle // Move (SizeOfArray(gtColorer)) to iItems For iItem from 0 to (iItems-1) If (gtColorer[iItem].iForeOff) Begin Move (Mid(sColors, 12, ((gtColorer[iItem].iForeOff-1)*12)+1)) to sColorStr Get RGBColorFromString sColorStr to iColor Move iColor to gtColorer[iItem].iForeC End If (gtColorer[iItem].iBackOff) Begin Move (Mid(sColors, 12, ((gtColorer[iItem].iBackOff-1)*12)+1)) to sColorStr Get RGBColorFromString sColorStr to iColor Move iColor to gtColorer[iItem].iBackC End If (gtColorer[iItem].iFont) Begin Move (Mid(sFontStyle, 3, ((gtColorer[iItem].iStyle-1)*3)+1)) to sFontStr Move sFontStr to iFont Move ((iFont iand THFS_BOLD )<>0) to gtColorer[iItem].iBold Move ((iFont iand THFS_ITALICS )<>0) to gtColorer[iItem].iItalics Move ((iFont iand THFS_UNDERLINE)<>0) to gtColorer[iItem].iUnderline End Loop End_Procedure Procedure Register_Color_Elements tColorer[] ltColorer Move ltColorer to gtColorer // Index Name Tran Fr Bk Fnt Stl CM Send Add_Color_Element EC_WINDOW (_T("Window" , 1063)) 1 0 0 0 1 Send Add_Color_Element EC_LEFTMARGIN (_T("Left Margin" , 1064)) 2 0 0 0 1 Send Add_Color_Element EC_BOOKMARK (_T("Bookmarks" , 1065)) 3 4 0 0 1 Send Add_Color_Element EC_TEXT (_T("Text" , 1066)) 5 6 1 1 1 Send Add_Color_Element EC_NUMBERS (_T("Numbers" , 1067)) 7 8 1 2 1 Send Add_Color_Element EC_KEYWORDS (_T("Keywords" , 1068)) 9 10 1 3 1 Send Add_Color_Element EC_OPERATORS (_T("Operators" , 1069)) 11 12 1 4 1 Send Add_Color_Element EC_SCOPEKWORDS (_T("Scope Keywords" , 1070)) 13 14 1 5 1 Send Add_Color_Element EC_COMMENTS (_T("Comments" , 1071)) 15 16 1 6 1 Send Add_Color_Element EC_STRINGS (_T("String" , 1072)) 17 18 1 7 1 Send Add_Color_Element EC_TAGTEXT (_T("Tag Text" , 1073)) 19 20 1 8 1 Send Add_Color_Element EC_TAGENTITIES (_T("Tag Entities" , 1074)) 21 22 1 9 1 Send Add_Color_Element EC_TAGELEMENT (_T("Tag Element Names" , 1075)) 23 24 1 10 1 Send Add_Color_Element EC_TAGATTRIBUTE (_T("Tag Attributes" , 1076)) 25 26 1 11 1 Send Add_Color_Element EC_LINENUMBERS (_T("Line Numbers" , 1077)) 27 28 1 12 1 Send Add_Color_Element EC_HDIVLINES (_T("Horz Divider Lines" , 1078)) 29 0 0 0 1 Send Add_Color_Element EC_VDIVLINES (_T("Vert Divider Lines" , 1079)) 30 0 0 0 1 Send Add_Color_Element EC_HLIGHTEDLINE (_T("Highlighted Line" , 1080)) 31 0 0 0 1 // Scintilla extras (Not supported by CodeMax, see CM column) Send Add_Color_Element EC_STRINGTYPING (_T("String Typing" , 1081)) 32 33 1 13 0 Send Add_Color_Element EC_BRACEHLIGHT (_T("Brace Highlight" , 1082)) 34 35 1 14 0 Send Add_Color_Element EC_UNMATCHEDBRACE (_T("Unmatched Brace" , 1083)) 36 37 1 15 0 Send Add_Color_Element EC_METATAGS (_T("Meta Tags" , 1084)) 38 39 1 16 0 Send Add_Color_Element EC_SELECTION (_T("Selection" , 1085)) 40 0 0 0 0 Send Add_Color_Element EC_PREPROCESSOR (_T("Pre-processor (Macro)", 1086)) 41 42 1 17 0 // Load current options Send SetColorerCurrentStyles "" "" End_Procedure Send Register_Color_Elements Function CurrentColors Returns String String[SC_COLORS_STRSIZE] sNewColors Integer iElement iElements String sColorStr sColors Integer iClr Move (SizeOfArray(gtColorer)) to iElements For iElement from 0 to (iElements-1) If (gtColorer[iElement].iForeOff) Begin Move gtColorer[iElement].iForeC to iClr If (iClr=-1) Begin Move "255255255255" to sColorStr End Else Begin Get RGBStringFromRGB (R_From_RGB(iClr)) (G_From_RGB(iClr)) (B_From_RGB(iClr)) to sColorStr End Move sColorStr to sNewColors[gtColorer[iElement].iForeOff-1] End If (gtColorer[iElement].iBackOff) Begin Move gtColorer[iElement].iBackC to iClr If (iClr=-1) Begin Move "255255255255" to sColorStr End Else Begin Get RGBStringFromRGB (R_From_RGB(iClr)) (G_From_RGB(iClr)) (B_From_RGB(iClr)) to sColorStr End Move sColorStr to sNewColors[gtColorer[iElement].iBackOff-1] End Loop // Move "" to sColors For iElement from 0 to (SizeOfArray(sNewColors)-1) Move (sColors + sNewColors[iElement]) to sColors Loop Move (sColors+"000") to sColors Function_Return sColors End_Function Function CurrentFontStyles Returns String String[17] sFontStyle Integer iElement iElements String sFontStr sFontStyles Integer iFont Move (SizeOfArray(gtColorer)) to iElements For iElement from 0 to (iElements-1) If (gtColorer[iElement].iFont) Begin Move (gtColorer[iElement].iBold+gtColorer[iElement].iItalics+gtColorer[iElement].iUnderline) to sFontStr Move (Right('000'+sFontStr, 3)) to sFontStr Move sFontStr to sFontStyle[gtColorer[iElement].iStyle-1] End Loop // Move "" to sFontStyles For iElement from 0 to (SizeOfArray(sFontStyle)-1) Move (sFontStyles + sFontStyle[iElement]) to sFontStyles Loop Move (sFontStyles+"000") to sFontStyles Function_Return sFontStyles End_Function Class cEditorPreview is a cRichEdit Procedure Construct_Object Forward Send Construct_Object Set Border_Style to Border_None Set psTypeFace to "Courier New" Set piFontSize to (10*20) Set Read_Only_State to True End_Procedure Procedure ChangeFontStyle String sFont Integer iFontSize Send HideSelection True Send Select_All Set psTypeFace to sFont Set piFontSize to (iFontSize*20) Send SetSel 0 0 // remove selection Send HideSelection False End_Procedure Procedure AddElement Integer iElement String sElement Set TextColor to gtColorer[iElement].iForeC Set TextBackColor to gtColorer[iElement].iBackC Set pbBold to gtColorer[iElement].iBold Set pbItalics to gtColorer[iElement].iItalics Set pbUnderline to gtColorer[iElement].iUnderline Send AppendText sElement End_Procedure Procedure AddComment String sComment Send AddElement EC_COMMENTS sComment End_Procedure Procedure AddScopeKeyword String sKeyword Send AddElement EC_SCOPEKWORDS sKeyword End_Procedure Procedure AddKeyword String sKeyword Send AddElement EC_KEYWORDS sKeyword End_Procedure Procedure AddText String sText Send AddElement EC_TEXT sText End_Procedure Procedure AddNumber String sNumber Send AddElement EC_NUMBERS sNumber End_Procedure Procedure AddOperator String sOperator Send AddElement EC_OPERATORS sOperator End_Procedure Procedure AddString String sString Send AddElement EC_STRINGS sString End_Procedure Procedure AddStringTyping String sString Send AddElement EC_STRINGTYPING sString End_Procedure Procedure AddBraceHLight String sBraces Send AddElement EC_BRACEHLIGHT sBraces End_Procedure Procedure AddUnmatchedBrace String sBraces Send AddElement EC_UNMATCHEDBRACE sBraces End_Procedure Procedure AddPreProcessor String sMacro Send AddElement EC_PREPROCESSOR sMacro End_Procedure Procedure AddSpacing String sSpaces Set TextColor to gtColorer[EC_TEXT].iForeC Set TextBackColor to gtColorer[EC_TEXT].iBackC Set pbBold to 0 Set pbItalics to 0 Set pbUnderline to 0 Send AppendText sSpaces End_Procedure Procedure AddMetaTag String sMeta Send AddElement EC_METATAGS sMeta End_Procedure End_Class