DECLARE FUNCTION SendMsg LIB "user32" ALIAS "SendMessageA" _
(BYVAL hwnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, lParam AS LONG) AS LONG
DECLARE FUNCTION CMRegister LIB "cmcs21.dll" ALIAS "CMRegisterControl" _
(Version AS DWORD) AS INTEGER
DECLARE FUNCTION CMUnRegister LIB "cmcs21.dll" ALIAS "CMUnregisterControl" _
AS INTEGER
DECLARE FUNCTION CMRegisterLanguage LIB "cmcs21.dll" ALIAS _
"CMRegisterLanguage" (pszName AS LONG, Lang AS LONG) AS LONG
FUNCTION CM_SetLanguage (hWnd AS LONG, pszName AS STRING) AS LONG
DIM LangName AS STRING
LangName = pszName
Result = Sendmsg (hWnd, CMM_SETLANGUAGE, 0, VARPTR(LangName))
END FUNCTION
FUNCTION CM_GetLanguage (hwnd AS LONG) AS STRING
DIM LangName AS STRING
LangName = STRING$(20, CM_MAX_LANGUAGE_NAME)
Sendmsg (hWnd, CMM_GETLANGUAGE, 0, VARPTR(LangName))
Result = LangName
END FUNCTION
FUNCTION Cm_EnableColorSyntax (hWnd AS LONG, Enable AS INTEGER) AS LONG
Result = Sendmsg (hWnd, CMM_ENABLECOLORSYNTAX, Enable, 0)
END FUNCTION
FUNCTION Cm_IsColorSyntaxEnabled (hWnd AS LONG) AS Bool
Result = Sendmsg (hWnd, CMM_ISCOLORSYNTAXENABLED, 0, 0)
END FUNCTION
FUNCTION Cm_SetColors (hWnd AS LONG, colors AS CM_COLORS) AS LONG
DIM Col_Mem AS QMEMORYSTREAM
DIM output AS LONG
Col_Mem.position = 0
Col_Mem.WriteUDT(colors)
output = Sendmsg (hWnd, CMM_SETCOLORS, 0, Col_Mem.pointer)
Col_Mem.CLOSE
Result = output
END FUNCTION
FUNCTION Cm_RegisterLanguage (pszName AS STRING, Lang AS CM_LANGUAGE) AS LONG
DIM ERROR AS LONG
DIM LangName AS STRING
LangName = pszName
DIM RL_Mem AS QMEMORYSTREAM
RL_mem.position = 0
RL_Mem.WriteUDT(Lang)
ERROR = CMRegisterLanguage(VARPTR(LangName), RL_Mem.pointer)
RL_Mem.CLOSE
result = ERROR
END FUNCTION
FUNCTION CM_SetFontStyles (hWnd AS LONG, FontStyles AS CM_FONTSTYLES) AS LONG
DIM Fn_Mem AS QMEMORYSTREAM
DIM output AS LONG
Fn_Mem.position = 0
Fn_Mem.WriteUDT(FontStyles)
output = Sendmsg (hWnd, CMM_SETFONTSTYLES, 0, Fn_Mem.pointer)
Fn_Mem.CLOSE
Result = output
END FUNCTION
FUNCTION CM_SetLinenumbering (hwnd AS LONG, _
LineNumbering AS CM_LINENUMBERING) AS LONG
DIM Ln_Mem AS QMEMORYSTREAM
DIM output AS LONG
Ln_Mem.position = 0
Ln_Mem.WriteUDT(Linenumbering)
output = Sendmsg (hWnd, CMM_SETLINENUMBERING, 0, Ln_Mem.pointer)
Ln_Mem.CLOSE
Result = output
END FUNCTION
FUNCTION CM_EnableLeftMargin (hWnd AS LONG, benable AS BOOL) AS LONG
Result = Sendmsg (hWnd, CMM_ENABLELEFTMARGIN, bEnable, 0)
END FUNCTION
FUNCTION CM_IsLeftMarginEnabled (hWnd AS LONG) AS LONG
Result = Sendmsg (hWnd, CMM_ISLEFTMARGINENABLED,0,0)
END FUNCTION
FUNCTION CM_SetBorderStyle(hWnd AS LONG, dwStyle AS DWORD) AS LONG
Result = Sendmsg (hWnd, CMM_SETBORDERSTYLE, dwStyle,0)
END FUNCTION
FUNCTION CM_SetDivider (hWnd AS LONG, nLine AS INTEGER, bEnable AS BOOL) AS LONG
Result = Sendmsg (hWnd, CMM_SETDIVIDER, nline, bEnable)
END FUNCTION
FUNCTION CM_GetDivider (hWnd AS LONG, nLine AS INTEGER) AS Bool
Result = Sendmsg (hWnd, CMM_GETDIVIDER, nline, 0)
END FUNCTION
FUNCTION CM_EnableDragDrop (hWnd AS LONG, bEnable AS bool) AS LONG
Result = Sendmsg (hWnd, CMM_ENABLEDRAGDROP, bEnable, 0)
END FUNCTION
FUNCTION CM_IsDragDropEnabled (hWnd AS LONG) AS bool
Result = Sendmsg (hWnd, CMM_ISDRAGDROPENABLED, 0, 0)
END FUNCTION
FUNCTION LoadKeywords (Filename AS STRING) AS STRING
DIM Tempstr AS STRING
DIM Load_fs AS QFILESTREAM
Load_fs.OPEN(Filename, 2)
Load_fs.position = 0
Tempstr = Load_fs.readstr(Load_fs.size)
Load_fs.CLOSE
Tempstr = REPLACESUBSTR$(Tempstr, CHR$(13), "")
Result = TempStr
END FUNCTION
SUB RegisterRapidQLanguage
DIM NewLanguage AS CM_LANGUAGE
DIM KeyWords AS STRING
DIM Operators AS STRING
DIM SingleLineComments AS STRING
DIM MultiLineComments1 AS STRING
DIM MultiLineComments2 AS STRING
DIM ScopeKeywords1 AS STRING
DIM ScopeKeywords2 AS STRING
DIM StringDelims AS STRING
DIM chEscape AS STRING
DIM chTerminator AS STRING
DIM TagElementNames AS STRING
DIM TagAttributeNames AS STRING
DIM TagEntities AS STRING
DIM Empty AS STRING
Empty = CHR$(0)
KeyWords = LoadKeyWords("KEYWORD.LST") & CHR$(10) & _
LoadKeyWords("Scope1.lst") & CHR$(10) & _
LoadKeyWords("Operators.LST")
Operators = LoadKeyWords("Qtypes.LST") & CHR$(10) & _
LoadKeyWords("Directives.LST")
SinglelineComments = "'"
ScopeKeywords1 = LoadKeyWords("Properties.LST")
ScopeKeywords2 = LoadKeyWords("Scope2.lst")
StringDelims = CHR$(34)
WITH NewLanguage
.dwStyle = CMLS_PROCEDURAL
.bIsCaseSensitive = False
.pszKeywords = VARPTR(KeyWords)
.pszOperators = VARPTR(Operators)
.pszSingleLineComments = VARPTR(SingleLineComments)
.pszMultiLineComments1 = VARPTR(empty)
.pszMultiLineComments2 = VARPTR(empty)
.pszScopeKeywords1 = VARPTR(ScopeKeywords1)
.pszScopeKeywords2 = VARPTR(ScopeKeywords2)
.pszStringDelims = VARPTR(StringDelims)
.chEscape = VARPTR(empty)
.chTerminator = VARPTR(empty)
.pszTagElementNames = VARPTR(empty)
.pszTagAttributeNames = VARPTR(empty)
.pszTagEntities = VARPTR(empty)
END WITH
Cm_RegisterLanguage("RapidQ", NewLanguage)
END SUB
|
|