View Clarion Source files in the Explorer Preview Pane

With a simple registry entry Clarion source files can be viewed in the Windows Explorer Preview Pane like below:

The Registry needs a .clw class key HKEY_CLASSES_ROOT\.clw with a Value "PerceivedType" set as "text":

image


I pasted below (and attached) a .REG file that if you double click on it will register the extensions: .CLW .INC .INT .EQU .TRN .CWPROJ .TXA .APV .TPL .TPW

REGEDIT4

[HKEY_CLASSES_ROOT\.clw]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.inc]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.int]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.equ]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.trn]
"PerceivedType"="text"


[HKEY_CLASSES_ROOT\.cwproj]
"PerceivedType"="text"


[HKEY_CLASSES_ROOT\.txa]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.apv]
"PerceivedType"="text"


[HKEY_CLASSES_ROOT\.tpl]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.tpw]
"PerceivedType"="text"

Preview_Clarion_Source.zip (1.3 KB)

8/7 added extensions: .PRJ .PR .EXP .MSBUILD .TXD .DCTX .DCV

Preview_Clarion_Source_Version2.zip (1.6 KB)

3 Likes

I was curious what file extensions might already be setup in the registry so wrote the below PowerShell script to display the PerceivedType for the various HKEY_CLASSES_ROOT.xxx


# PowerShell script by Carl Barnes
# View Registry Explorer Preview "PerceivedType" for Clarion Extensions (.clw .inc ... etc)
# to have an idea if they already have a "PerceivedType" defined that is not "text"
#-----------------------------------------------------------------------------------------
# Save this with the PowerShell extension .PS1" e.g. "ExplorerPreviewClarion-View.PS1"
# In Windows Explorer right-click and select "Run with PowerShell"
#-----------------------------------------------------------------------------------------

function See-PerceivedType {
  Param( [string] $DotExten )
  ECHO "========================================================================"
  try 
  {
#    Get-ItemProperty -path "Registry::HKEY_CLASSES_ROOT\$DotExten" -Name PerceivedType
    $PType = (get-itemproperty -path "Registry::HKEY_CLASSES_ROOT\$DotExten" -Name PerceivedType)
    ECHO ($DotExten + " -- See PerceivedType -- " + $DotExten + " --" )
    ECHO $PType
  }
  catch  [System.Management.Automation.PSArgumentException]
    { ECHO ($DotExten + " -- Error: Value PerceivedType does NOT exist for CLASSES_ROOT\" + $DotExten ) }
  catch  [System.Management.Automation.ItemNotFoundException]
   { ECHO ($DotExten + " -- Error: Registry does NOT have Key CLASSES_ROOT\" + $DotExten ) }  
  catch 
    { ECHO ($DotExten + " -- Error: Get-ItemProperty failed for CLASSES_ROOT\" + $DotExten + "  " + $Error[0] ) }
}
##################### End See-PerceivedType #####################

$ErrorActionPreference = "stop"  #so Try/Catch works, alternate is parm: -ErrorAction Stop

See-PerceivedType '.clw'      # Clarion Source CLW
See-PerceivedType '.inc'      # Clarion Include, already Text on mine
See-PerceivedType '.int'      # Clarion Interface 
See-PerceivedType '.equ'      # Clarion Equates
See-PerceivedType '.trn'      # Clarion Translate

See-PerceivedType '.sln'      # VS Solution, not that useful 
See-PerceivedType '.cwproj'   # Clarion Project

See-PerceivedType '.txa'      # Clarion APP Export
See-PerceivedType '.apv'      # Clarion APP Version Control
See-PerceivedType '.tpl'      # Clarion Template
See-PerceivedType '.tpw'      # Clarion Template

See-PerceivedType '.c'    # .C files was defined as Text on my machine

# See-PerceivedType '.ps1'  # PowerShell scripts not defined but are text
# See-PerceivedType '.sql'  # .SQL files should be defined as Text
# See-PerceivedType '.a'  # .A has Key but no PerceivedType so tests Catch PSArgumentException

ECHO "========================================================================"
pause
exit

This code needs to have a .PS1 file extension, the right-click and choose “Run with PowerShell”

Here’s what it looks like when it runs. On my PC the .INC was already setup as Text.

PS1 is in attached Zip

Preview_Clarion_Source.zip (1.3 KB)

Preview_Clarion_Source_Version2.zip (1.6 KB)

There is a PowerToy that sets up a lot of Preview file extensions and adds some viewers like Mark Down. It mentions Source Code preview for 150 extensions but I do not see color syntax mentioned.

Preview Pane is an existing feature in the Windows File Explorer which allows you to see a preview of the file’s contents in the view’s reading pane. PowerToys adds multiple extensions: Markdown, SVG, PDF, and G-code. In addition to those, PowerToys also adds support for source code files (for more than 150 file extensions: .cs, .cpp, .rs, …).

  • Preview Pane rendering for:
    • SVG icons (.svg)
    • Markdown files (.md)
    • Source code files (.cs, .cpp, .rs, …)
    • PDF files (.pdf)
    • G-code files (.gcode)
  • Thumbnail preview for:
    • SVG icons (.svg)
    • PDF files (.pdf)
    • G-code files (.gcode)
    • STL files (.stl)

Your .REG is much more intuitive than the one I wrote
Below is the start of my file:

Windows Registry Editor Version 5.00 
[HKEY_CLASSES_ROOT\.cln\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}" 

[HKEY_CLASSES_ROOT\.clw\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}" 

I’m guessing this one is an XML viewer
[HKEY_CLASSES_ROOT.txa\shellex{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f2

That is pretty darn cool!!

1 Like

Missing .prj :slight_smile: I’m old, what’s an .apv file these days?

.APV files are the exported TXA for a module in your APP when using my source control addin.

Thanks for posting that! Searching for those 2 GUID’s found some good reading.

Windows Vista added the Explorer Previewer feature. The way it worked then the .Extension\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}] Key specified the .Extension Preview Handler. The {1531d583-8375-4d3f-b5fb-d23bbd169f22} is the value for the Text handler.

Windows 10 made it easier by allowing the value "PerceivedType"="text". There are posts about the new key not always working and needing to use the old ShellEx GUID key, or about having to delete the old ShellEx key, so it’s good to know those keys. If you’re running Windows 7 or 8 you must use those ShellEx keys. Should be able to edit my .REG file with 2 Search-and-Replace’s

The GUID is still the link to the registered Preview Handler. Here are all the ones on my Windows 10 system:

APV is the APP in a text format for Version Control, which is identical to TXA. There is also DCV as the DCT in text format that is .DCTX XML format (not TXD).

More info in this topic and links to others:

I liked the .PRJ format, it was much easier to work on than the Xml .CwProj. There’s also the .PR hand coded project extension that can still be used as an Included Project. It’s a good way to add a bunch of Defines with #pragma define(_MyLibrary_Link_=>1)

I added extensions: .PRJ .PR .EXP .MSBUILD .TXD .DCTX .DCV

Preview_Clarion_Source_Version2.zip (1.6 KB)

I noticed you can turn on Preview in the Open File Dialog with button on the upper right. So in the IDE when you go to open a source file you can see it first:

1 Like