Closed x87 closed 3 years ago
This is an example of semantic highlighting: requires scanning prior source code and collecting constant symbols. Can be CPU consuming. Other elements get coloring purely after their syntax.
The editor will rescan the document on open and save events. If you added or removed a new constant, it won't be reflecting in highlighting until you save the document. It saves a lot of resources on background scanning.
A small preview on const/variable highlighting:
Note the difference:
Opinions?
I think it should be unified into one color. In addition, I think blue is not very good. @x87 Can I modify the highlight color by myself in the menu settings?
It uses Variable color.
The variable name uses the variable color (blue), and the constant name uses the color of the data type. I think the color in your example is indeed fine.
@x87 Does Constants highlight support header files? I believe that many people write large cleos and usually use header file instructions to insert code. When I write const...end in the header file, will the code name of the cleo file be highlighted after my cleo uses the header file instruction?
Good point! Yes it definitely should, however it makes it a bit more complicated. I will look into it
Constants highlighting can be previewed in 3.7.0-alpha.0 https://github.com/sannybuilder/dev/releases
Constants highlighting only works after file save/open events. It also accounts for included files. See more details in https://github.com/sannybuilder/core/pull/4
@x87 I did a highlight test for the new version. There is no problem with the highlighting of the declared data type (int float). However, the highlighting of const_end does not support the highlighting of hexadecimal data names:
RsGlobal = 0x009B48D8
Another strange question. It seems that for some cleo I wrote before, I opened the source code txt with SB, const will not be highlighted, even if I modify and save them, it still will not be highlighted. I noticed that the language service status of the lower display panel is "Disabled" , To be honest, I don't understand its meaning too much, but this kind of txt will not be highlighted.
An additional question: highlighting will only be displayed after the file is saved. This seems inconvenient to write. Shouldn't this be your final plan? Is it possible to highlight when writing?
highlighting of hexadecimal data
thanks for noticing, I missed this.
I noticed that the language service status of the lower display panel is "Disabled"
Interesting. Do you have any Unicode characters in the opened file path? Do you have Language service enabled in the options (F10->Editor tab).
An additional question: highlighting will only be displayed after the file is saved. This seems inconvenient to write. Shouldn't this be your final plan? Is it possible to highlight when writing?
That was my initial plan to offload main thread and not block rendering. Now that I have a separate service that scans files in background I can probably revisit the initial approach and try to scan symbols in-memory. I will think about it.
Any non-English paths are currently not supported. There is also a new problem:
const
_access = 30@ //int access(const char *filenpath, int mode)
end
0DD0: _access = get_label_addr @access
0DD1: _access = get_func_addr_by_cstr_name _access
@x87 When there is a comment behind, it will not be highlighted
@XMDS Thanks for your feedback. I have published alpha.1 with some of the issues addressed. Please check it out: https://github.com/sannybuilder/dev/releases/tag/v3.7.0-alpha.1
@x87 The alpha 1 version of the highlight has been greatly improved. But some minor problems:
{$CLEO}
0000:
{$INCLUDE ConstVar.txt}
{$INCLUDE CLEO.txt}
ConstVar.txt:
const
_player = $PLAYER_CHAR
GS = 1.0
xmds = "xmds"
_HAAA = 3000
RsGlobal = 0x009B48D8
end
float x
float y
float z
int _health
int Resolution_w
CLEO.txt:
:1
wait 0
if
0256: player _PLAYER defined
jf @1
015D: set_gamespeed GS
00A0: store_actor $PLAYER_ACTOR position_to x y z
0226: _health = actor $PLAYER_ACTOR health
_health += _HAAA
06D2: 28@v = xmds // @v = string
0223: set_actor $PLAYER_ACTOR health_to _health
0A8D: Resolution_w = read_memory RsGlobal size 4 virtual_protect 0
cleo.txt will not be highlighted. This hierarchical header file should be supported
3.The last problem is still an old one, just like SB does not support non-English paths since 3.6.0, highlighting usually does not support non-English paths, even if we use non-English naming cleo, it also does not support highlighting.
cleo.txt will not be highlighted. This hierarchical header file should be supported
this is by design. When you open CLEO.txt as a separate document in Sanny it has the isolated file tree. CLEO.txt does not have references to other files or const declarations so there is nothing to highlight. If you try to compile CLEO.txt Sanny throws an error as it does not know what _PLAYER is.
_PLAYER will be highlighted only in the main document (one with $INCLUDE) and in ConstVar.txt.
Using the cleo.txt of the header file, it cannot be highlighted immediately after opening it, but it will be highlighted only after typing or modifying the current cleo (for example, just press Enter to add a line or delete a line, it will be highlighted) .
Can you please provide a screenshot of Sanny Builder window so I know what files you have opened and what symbols are not highlighted?
Using the cleo.txt of the header file, it cannot be highlighted immediately after opening it, but it will be highlighted only after typing or modifying the current cleo (for example, just press Enter to add a line or delete a line, it will be highlighted) .
Can you please provide a screenshot of Sanny Builder window so I know what files you have opened and what symbols are not highlighted?
When i open: They are not highlighted,When I typed two carriage returns two more lines, it was highlighted:
@x87 I just tested it again, some cleo.txt is opened, and a few lines need to be added or deleted, otherwise it will not be highlighted
In addition, I noticed that even if there are non-English characters behind the comment "//", they will still not be highlighted after saving it.
@x87 I encountered a new problem. I am not sure how they came about. Maybe it is because the cleo code is long and bright, or it is caused by other reasons. I was writing cleo, and an error message appeared: I use the alpha-1 version. After this prompt appears during writing, if you continue writing, it may cause the sb tool to freeze and not respond.
x87 I have conducted multiple tests. As long as I press Enter to empty multiple lines or delete these lines, SB will enter an unresponsive state. It seems to only appear when highlighting is used (I said before that when you enter a few blank lines, it will highlight). In addition, it seems that when highlighting, press Enter at the end of cleo, and the line number of sb will flash and jump. This should also be a bug.
In addition, there is such a prompt if there is no response:
@XMDS do you have sanny.log file next to sanny.exe? it may have some extra details regarding last error
@x87 My latest crash just now:
= 2021/1/4 21:02:00 =
==============================================================================
Access violation at address 00401CF2 in module 'sanny.exe'. Write of address 20627573.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Exception class: EAccessViolation
Exception message: Access violation at address 00401CF2 in module 'sanny.exe'. Write of address 20627573.
Exception address: 00401CF2
------------------------------------------------------------------------------
Main thread ID = 2512
Exception thread ID = 2512
------------------------------------------------------------------------------
Exception stack
Stack list, generated 2021/1/4 21:01:59
(00000CF2){sanny.exe } [00401CF2]
(000014CB){sanny.exe } [004024CB]
(000017D9){sanny.exe } [004027D9]
(00003144){sanny.exe } [00404144]
(0000353A){sanny.exe } [0040453A]
(0002BE3E){sanny.exe } [0042CE3E]
(0000318C){sanny.exe } [0040418C]
(0002BDE4){sanny.exe } [0042CDE4]
(0002D540){sanny.exe } [0042E540]
(0002CA84){sanny.exe } [0042DA84]
(0002DDBC){sanny.exe } [0042EDBC]
(000CBE0E){sanny.exe } [004CCE0E]
(000CB34C){sanny.exe } [004CC34C]
(000CB639){sanny.exe } [004CC639]
(0001B354){sanny.exe } [0041C354]
(000CB280){sanny.exe } [004CC280]
(0015DE32){sanny.exe } [0055EE32]
(0015DC5C){sanny.exe } [0055EC5C]
(0006F1A0){sanny.exe } [004701A0]
(00005C3D){sanny.exe } [00406C3D]
(0001A7B0){sanny.exe } [0041B7B0]
(00005C2C){sanny.exe } [00406C2C]
(0014A617){sanny.exe } [0054B617]
(000720EB){sanny.exe } [004730EB]
(001681BF){sanny.exe } [005691BF]
(00057E61){sanny.exe } [00458E61]
(00164C12){sanny.exe } [00565C12]
(000C76CB){sanny.exe } [004C86CB]
(00071D68){sanny.exe } [00472D68]
(00024FF0){sanny.exe } [00425FF0]
(0001CEE1){sanny.exe } [0041DEE1]
(000C341A){sanny.exe } [004C441A]
(0014CEDB){sanny.exe } [0054DEDB]
(0014CEFE){sanny.exe } [0054DEFE]
(0002FA9E){sanny.exe } [00430A9E]
(000C7097){sanny.exe } [004C8097]
(000C6D9A){sanny.exe } [004C7D9A]
(0005E297){sanny.exe } [0045F297]
(0005E2CE){sanny.exe } [0045F2CE]
(0005E4EE){sanny.exe } [0045F4EE]
(00164444){sanny.exe } [00565444]
(00194976){sanny.exe } [00595976]
------------------------------------------------------------------------------
Call stack for main thread
Stack list, generated 2021/1/4 21:01:59
(0007154C){ntdll.dll } [774E254C] ZwGetContextThread + $C
(0018F492){sanny.exe } [00590492]
(0018F518){sanny.exe } [00590518]
(001918DE){sanny.exe } [005928DE]
(00191669){sanny.exe } [00592669]
(001930B4){sanny.exe } [005940B4]
(0006F1A0){sanny.exe } [004701A0]
(000720EB){sanny.exe } [004730EB]
(00057E61){sanny.exe } [00458E61]
(0001A7B0){sanny.exe } [0041B7B0]
(0002BB44){sanny.exe } [0042CB44]
(00071D68){sanny.exe } [00472D68]
(00071D7D){sanny.exe } [00472D7D]
(00024FF0){sanny.exe } [00425FF0]
(000720EB){sanny.exe } [004730EB]
(00057E61){sanny.exe } [00458E61]
(00071D68){sanny.exe } [00472D68]
(00024FF0){sanny.exe } [00425FF0]
(0002FA9E){sanny.exe } [00430A9E]
(000C7097){sanny.exe } [004C8097]
(000C6D9A){sanny.exe } [004C7D9A]
(0005E297){sanny.exe } [0045F297]
(0005E2CE){sanny.exe } [0045F2CE]
(0005B03D){sanny.exe } [0045C03D]
(00192FDB){sanny.exe } [00593FDB]
(00192781){sanny.exe } [00593781]
(000C64B8){sanny.exe } [004C74B8]
(000C6B6E){sanny.exe } [004C7B6E]
(0005E5B9){sanny.exe } [0045F5B9]
(00071DA3){sanny.exe } [00472DA3]
(000014CB){sanny.exe } [004024CB]
(000017D9){sanny.exe } [004027D9]
(00003144){sanny.exe } [00404144]
(0000353A){sanny.exe } [0040453A]
(0002BE3E){sanny.exe } [0042CE3E]
(0000318C){sanny.exe } [0040418C]
(0002BDE4){sanny.exe } [0042CDE4]
(0002D540){sanny.exe } [0042E540]
(0002CA84){sanny.exe } [0042DA84]
(0002DDBC){sanny.exe } [0042EDBC]
(000CBE0E){sanny.exe } [004CCE0E]
(000CB34C){sanny.exe } [004CC34C]
(000CB639){sanny.exe } [004CC639]
(0001B354){sanny.exe } [0041C354]
(000CB280){sanny.exe } [004CC280]
(0015DE32){sanny.exe } [0055EE32]
(0015DC5C){sanny.exe } [0055EC5C]
(0006F1A0){sanny.exe } [004701A0]
(00005C3D){sanny.exe } [00406C3D]
(0001A7B0){sanny.exe } [0041B7B0]
(00005C2C){sanny.exe } [00406C2C]
(0014A617){sanny.exe } [0054B617]
(000720EB){sanny.exe } [004730EB]
(001681BF){sanny.exe } [005691BF]
(00057E61){sanny.exe } [00458E61]
(00164C12){sanny.exe } [00565C12]
(000C76CB){sanny.exe } [004C86CB]
(00071D68){sanny.exe } [00472D68]
(00024FF0){sanny.exe } [00425FF0]
(0001CEE1){sanny.exe } [0041DEE1]
(000C341A){sanny.exe } [004C441A]
(0014CEDB){sanny.exe } [0054DEDB]
(0014CEFE){sanny.exe } [0054DEFE]
(0002FA9E){sanny.exe } [00430A9E]
(000C7097){sanny.exe } [004C8097]
(000C6D9A){sanny.exe } [004C7D9A]
(0005E297){sanny.exe } [0045F297]
(0005E2CE){sanny.exe } [0045F2CE]
(0005E4EE){sanny.exe } [0045F4EE]
(00164444){sanny.exe } [00565444]
(00194976){sanny.exe } [00595976]
------------------------------------------------------------------------------
System : Windows 10 Professional, Version: 6.2, Build: 23F0, ""
Processor: Intel, Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz, 2800 MHz MMX SSE SSE2 SSE3 SSSE3 SSE41 SSE42 64 bits DEP
Memory: 8067; free 3576
Display : 1536x864 pixels, 32 bpp
------------------------------------------------------------------------------
List of loaded modules:
[00400000] H:\Sanny Builder 3\sanny.exe
3.7.0.5661 - 3.7.0.5661
Sanny Builder
Unit versioning information:
JCL\source\common $URL$ $Revision$ $Date$
[00C80000] H:\Sanny Builder 3\lib\common.dll
<00400000> (no module version info)
[064A0000] F:\Program Files (x86)\SogouInput\9.8.0.3746\Resource.dll
<10000000> 9.8.0.3746 - 9.8.0.3746
搜狗输入法 资源
[10000000] C:\WINDOWS\system32\SogouPy.ime
9.8.0.3746 - 9.8.0.3746
搜狗输入法
[58560000] C:\WINDOWS\SYSTEM32\HHCtrl.ocx
6.2.19041.1 - 10.0.19041.561 (WinBuild.160101.0800)
Microsoft (R) HTML 帮助控制
[5FCD0000] C:\WINDOWS\SYSTEM32\ColorAdapterClient.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Microsoft Color Adapter Client
[5FCE0000] C:\WINDOWS\SYSTEM32\mscms.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Microsoft 颜色匹配系统 DLL
[5FD80000] F:\Program Files (x86)\SogouInput\Components\PicFace\1.1.0.1870\PicFace.dll
1.1.0.1870 - 1.1.0.1870
搜狗输入法 图片表情
[5FF40000] C:\WINDOWS\System32\SogouTSF.ime
9.8.0.3746 - 9.8.0.3746
搜狗输入法
[60BC0000] H:\Sanny Builder 3\lib\core.dll
(no module version info)
[60F20000] H:\Sanny Builder 3\lib\GetObjectID.dll
(no module version info)
[60F30000] H:\Sanny Builder 3\lib\coordsmanager.dll
(no module version info)
[6CD50000] C:\WINDOWS\SYSTEM32\OLEACC.dll
7.2.19041.546 - 7.2.19041.546 (WinBuild.160101.0800)
Active Accessibility Core Component
[70290000] C:\WINDOWS\SYSTEM32\TextShaping.dll
(no module version info)
[704A0000] C:\WINDOWS\SYSTEM32\wintypes.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
Windows 基本类型 DLL
[70580000] C:\WINDOWS\SYSTEM32\CoreUIComponents.dll
6.2.19041.546 - 10.0.19041.546
Microsoft Core UI Components Dll
[70800000] C:\WINDOWS\SYSTEM32\CoreMessaging.dll
6.2.19041.546 - 10.0.19041.546
Microsoft CoreMessaging Dll
[708A0000] C:\WINDOWS\SYSTEM32\textinputframework.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
"TextInputFramework.DYNLINK"
[717D0000] C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll
14.24.28127.4 - 14.24.28127.4 built by: vcwrkspc
Microsoft? C Runtime Library
[72150000] C:\WINDOWS\system32\uxtheme.dll
6.2.19041.610 - 10.0.19041.561 (WinBuild.160101.0800)
Microsoft UxTheme 库
[724C0000] C:\WINDOWS\System32\MSIMG32.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
GDIEXT Client DLL
[724D0000] C:\WINDOWS\SYSTEM32\dwmapi.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Microsoft 桌面窗口管理器 API
[72500000] C:\WINDOWS\SYSTEM32\winspool.drv
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Windows 后台处理程序驱动程序
[72570000] C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.488_none_11b1e5df2ffd8627\comctl32.dll
6.10.19041.488 - 6.10 (WinBuild.160101.0800)
用户体验控件库
[728C0000] C:\WINDOWS\SYSTEM32\winmm.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
MCI API DLL
[72940000] C:\WINDOWS\System32\dbghelp.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
Windows Image Helper
[72FD0000] C:\WINDOWS\SYSTEM32\WINHTTP.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Windows HTTP 服务
[73BA0000] C:\WINDOWS\SYSTEM32\mpr.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
多提供程序路由器 DLL
[740B0000] C:\WINDOWS\SYSTEM32\CRYPTBASE.DLL
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Base cryptographic API DLL
[741C0000] C:\WINDOWS\SYSTEM32\profapi.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
User Profile Basic API
[743C0000] C:\WINDOWS\SYSTEM32\ntmarta.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Windows NT MARTA 提供程序
[743F0000] C:\WINDOWS\SYSTEM32\kernel.appcore.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
AppModel API Host
[74BF0000] C:\WINDOWS\SYSTEM32\Wldp.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
Windows 锁定策略
[74C20000] C:\WINDOWS\SYSTEM32\windows.storage.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
Microsoft WinRT Storage API
[752E0000] C:\WINDOWS\SYSTEM32\USERENV.dll
6.2.19041.572 - 10.0.19041.561 (WinBuild.160101.0800)
Userenv
[75320000] C:\WINDOWS\SYSTEM32\version.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Version Checking and File Installation Libraries
[754F0000] C:\WINDOWS\System32\clbcatq.dll
2001.12.10941.16384 - 2001.12.10941.16384 (WinBuild.160101.0800)
COM+ Configuration Catalog
[75570000] C:\WINDOWS\System32\GDI32.dll
6.2.19041.685 - 10.0.19041.685 (WinBuild.160101.0800)
GDI Client DLL
[755A0000] C:\WINDOWS\System32\sechost.dll
6.2.19041.662 - 10.0.19041.1 (WinBuild.160101.0800)
Host for SCM/SDDL/LSA Lookup APIs
[75620000] C:\WINDOWS\System32\bcryptPrimitives.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
Windows Cryptographic Primitives Library
[75710000] C:\WINDOWS\System32\shcore.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
SHCORE
[757E0000] C:\WINDOWS\System32\MSCTF.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
MSCTF 服务器 DLL
[758C0000] C:\WINDOWS\System32\combase.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
用于 Windows 的 Microsoft COM
[75B50000] C:\WINDOWS\System32\ole32.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
用于 Windows 的 Microsoft OLE
[75C40000] C:\WINDOWS\System32\imagehlp.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Windows NT Image Helper
[75C60000] C:\WINDOWS\System32\comdlg32.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
Common Dialogs DLL
[75D10000] C:\WINDOWS\System32\KERNEL32.DLL
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
Windows NT 基本 API 客户端 DLL
[75E00000] C:\WINDOWS\System32\SHLWAPI.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
外壳简易实用工具库
[75EB0000] C:\WINDOWS\System32\ucrtbase.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Microsoft? C Runtime Library
[75FE0000] C:\WINDOWS\System32\RPCRT4.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
远程过程调用运行时
[760A0000] C:\WINDOWS\System32\imm32.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Multi-User Windows IMM32 API Client DLL
[76510000] C:\WINDOWS\System32\KERNELBASE.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
Windows NT 基本 API 客户端 DLL
[76730000] C:\WINDOWS\System32\msvcp_win.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Microsoft? C Runtime Library
[767B0000] C:\WINDOWS\System32\PSAPI.DLL
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
Process Status Helper
[767C0000] C:\WINDOWS\System32\shell32.dll
6.2.19041.662 - 10.0.19041.561 (WinBuild.160101.0800)
Windows Shell 公用 DLL
[76D80000] C:\WINDOWS\System32\win32u.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
Win32u
[76DA0000] C:\WINDOWS\System32\msvcrt.dll
7.0.19041.546 - 7.0.19041.546 (WinBuild.160101.0800)
Windows NT CRT DLL
[76ED0000] C:\WINDOWS\System32\WS2_32.dll
6.2.19041.546 - 10.0.19041.561 (WinBuild.160101.0800)
Windows Socket 2.0 32 位 DLL
[76F40000] C:\WINDOWS\System32\advapi32.dll
6.2.19041.610 - 10.0.19041.561 (WinBuild.160101.0800)
高级 Windows 32 基本 API
[77130000] C:\WINDOWS\System32\gdi32full.dll
6.2.19041.685 - 10.0.19041.685 (WinBuild.160101.0800)
GDI Client DLL
[77210000] C:\WINDOWS\System32\user32.dll
6.2.19041.685 - 10.0.19041.561 (WinBuild.160101.0800)
多用户 Windows 用户 API 客户端 DLL
[773B0000] C:\WINDOWS\System32\oleaut32.dll
6.2.19041.546 - 10.0.19041.546 (WinBuild.160101.0800)
OLEAUT32.DLL
[77470000] C:\WINDOWS\SYSTEM32\ntdll.dll
6.2.19041.662 - 10.0.19041.662 (WinBuild.160101.0800)
NT 层 DLL
------------------------------------------------------------------------------
Active Controls hierarchy:
TSynEdit "SynEditor"
TEditorForm "EditorForm"
TEditorTabSheet ""
TPageControl "pctrlMain"
TWorkbookMainForm "WorkbookMainForm"
@XMDS Please try alpha.2 version. It should be much more stable now.
Let syntax highlighter colorize constants using the same rules as for values they represent.