Plugins: Source code viewer based on Scintilla

Source code viewer for DOpus

This addin allows the displaying of formatted sourcecode in the DOpus view panel.


Downloads

Installation

  • download dosv_0_0_0_*.zip
  • download the InstallPlugin_*.dcf file from above and place it next to dosv_0_0_0_4.zip file
  • double click the InstallPlugin_*.dcf file (it is a DOpus button).
  • restart DO or refresh the list of viewer plugins via DO prefs

Installation Output in the "Other Logs" utility panel is something like this.

Output in the "Other Logs" utility panel is something like this.

Plugin Installer..
    TabPath        : C:
    TmpDirPath     : C:\dosv_0_0_0_4.zip.tmp
    64bit          : true
    Run Command    : COPY EXTRACT WHENEXISTS=replace COPYFILETIMES=yes COPYDIRTIMES=yes COPYATTR=yes FILE="C:\dosv_0_0_0_4.zip"..
    ZipInnerDirName: 0.0.0.4
    Run Command    : COPY WHENEXISTS=replace COPYFILETIMES=yes COPYDIRTIMES=yes COPYATTR=yes EXTRACT FILE="C:\dosv_0_0_0_4.zip.tmp..
    Run Command    : COPY WHENEXISTS=replace COPYFILETIMES=yes COPYDIRTIMES=yes COPYATTR=yes EXTRACT FILE="C:\dosv_0_0_0_4.zip.tmp..
    Run Command    : COPY WHENEXISTS=replace COPYFILETIMES=yes COPYDIRTIMES=yes COPYATTR=yes FILE="C:\dosv_0_0_0_4.zip.tmp\0.0.0.4\..
    Run Command    : DELETE NOFROMFOCUS QUIET FILE="C:\dosv_0_0_0_4.zip.tmp"
Done!

Expect this:

  • support for 32 and 64bit installations
  • USB export (if I did everything correct according to the information spread here from you Leo)
  • will ask if existing files are to be replaced (which is DO magic)

Note, I am posting this here so there is an easy place to find it. The original dev thread is a bit fragmented, and while this addon was never officially completed its the best we have

Full credit goes to

  • @gdobin who wrote this (but does not seem to be around any more).
  • @Tbone for the installer
5 Likes

Very good plugin! You want to join the topic definition feature as soon as possible.

The dosv plugin above uses scintilla and supports a colour scheme system similar to what notepad++ uses.

Because of this with a little bit of tweaking we can take the original dosv.config.xml merge it with a notepad++ theme and load it in to DOpus.

If you would like to use any of the styles in the table do the flowing:

  • Download the dosv generated file
  • rename the file to dosv.config.xml
  • copy the file to %APPDATA%\GPSoftware\Directory Opus\ConfigFiles\Plugins

Sample themes

Visual Studio 2015 Dark Theme
vsdark

dosv generated file
dosv.config.xml-VS2015-Dark.txt (207.4 KB)

Original Notepad++ file
VS2015-Dark.xml.txt (89.6 KB)

Solarized Light Themes

dosv generated file
dosv.config.xml-Solarized-Light.txt (205.5 KB)

Original Notepad++ file
Solarized-Light.xml.txt (84.9 KB)

Solarized Dark Themes

dosv generated file
dosv.config.xml-Solarized-Dark.txt (206.0 KB)

Original Notepad++ file
Solarized-Dark.xml.txt (85.5 KB)

Bespin theme

dosv generated file
dosv.config.xml-Bespin.txt (208.0 KB)

Original Notepad++ file
Bespin.xml.txt (87.4 KB)

http://orizens.com/wp/topics/update-for-no■■■■n-inspired/

Material Theme (Dark)

dosv generated file
dosv.config.xml-Material-Dark.txt (207.7 KB)

Original Notepad++ file
Material-Dark.xml.txt (89.6 KB)

Dracula

dosv generated file
dosv.config.xml-Dracula.txt (198.6 KB)

Original Notepad++ file
Dracula.xml.txt (42.1 KB)

Obsidian PyCs

dosv generated file
dosv.config.xml-Obsidian_PyCs.txt (206.5 KB)

Original Notepad++ file
Obsidian PyCs.xml.txt (86.3 KB)

Slush & Poppies

dosv generated file
dosv.config.xml-slush_poppies.txt (205.4 KB)

Original Notepad++ file
slush_poppies.xml.txt (84.2 KB)

Nord Theme

dosv generated file
dosv.config.xml-nord.txt (200.3 KB)

Original Notepad++ file
nord.xml.txt (34.2 KB)

Neon

dosv generated file
dosv.config.xml-Techmantium_Neon.txt (206.4 KB)

Original Notepad++ file
Techmantium_Neon.xml.txt (86.4 KB)

Nautical but Nice

dosv generated file
dosv.config.xml-Techmantium-NauticalButNice.txt (206.4 KB)

Original Notepad++ file
Techmantium_NauticalButNice.xml.txt (86.4 KB)

Girly Edition

dosv generated file
dosv.config.xml-Techmantium_Girly.txt (206.4 KB)

Original Notepad++ file
Techmantium_Girly.xml.txt (86.4 KB)

These colour schemes came from this site, it has a list of some nice Notepad++ colour schemes. I have converted them to work with the dosv DOpus addin. Full credit goes to the original creator of the colour scheme and Tim Trott for the page listing them

Converting from Notepad++ style to dosv
A powershell script was used to to generate the dosv config files in the above table from the original notepad++ styles.
If you have another style form notepad++ you want to use, the script should work. You will need to pass in the notpad ++ style and the original dosvconfig file.

function Format-Xml {
<#
.SYNOPSIS
Format the incoming object as the text of an XML document.
#>
    param(
        ## Text of an XML document.
        [Parameter(ValueFromPipeline = $true)]
        [string[]]$Text
    )
    begin {
        $data = New-Object System.Collections.ArrayList
    }
    process {
        [void] $data.Add($Text -join "`n")
    }
    end {
        $doc=New-Object System.Xml.XmlDataDocument
        $doc.LoadXml($data -join "`n")
        $sw=New-Object System.Io.Stringwriter
        $writer=New-Object System.Xml.XmlTextWriter($sw)
        $writer.Formatting = [System.Xml.Formatting]::Indented
        $doc.WriteContentTo($writer)
        $sw.ToString()
    }
}

function Add-WordStyleElement {
    param(
        [string[]]$Text
    )
}

function Merge-ScintillaConfigElement {
<#
.SYNOPSIS
Converts a scintilla to the DOpus DOSV format
#>
    param(
        [System.Xml.XmlElement]$DosvElement,
        [System.Xml.XmlElement]$ScintillaElement
    )

    $dosv = $DosvElement.OwnerDocument
    #$referenceObject = @($DosElement.WordStyles.WordStyle | Select-Object -ExpandProperty name)
    $dosvWordStyles = $DosvElement.SelectSingleNode("./WordStyles")
    $referenceObject = @($dosvWordStyles.ChildNodes | Select-Object -ExpandProperty name)
    $differenceObject = @($ScintillaElement.ChildNodes | Select-Object -ExpandProperty name)
    $delta = @(Compare-Object $referenceObject $differenceObject -IncludeEqual)
    $delta | ForEach-Object {
        $deltaItem = $_
        write-host "'$($deltaItem.SideIndicator)' WordStyles '$($deltaItem.InputObject)'"

        switch ($deltaItem.SideIndicator)
        {
            '==' { 
                #update
                $dosvItem = $DosvElement.WordStyles.selectSingleNode("./WordStyle[@name='$($deltaItem.InputObject)']")
                $scintillaItem = $ScintillaElement.selectSingleNode("./WordsStyle[@name='$($deltaItem.InputObject)']")
                $dosvItem.SetAttribute('fgColor', $scintillaItem.fgColor) | out-null
                $dosvItem.SetAttribute('bgColor', $scintillaItem.bgColor) | out-null
                $dosvItem.SetAttribute('fontName', $scintillaItem.fontName) | out-null
                $dosvItem.SetAttribute('fontStyle', $scintillaItem.fontStyle) | out-null
                $dosvItem.SetAttribute('fontSize', $scintillaItem.fontSize) | out-null
                $dosvItem.SetAttribute('keywordClass', $scintillaItem.keywordClass) | out-null
            }
            '=>' { 
                #add
                $scintillaItem = $ScintillaElement.selectSingleNode("./WordsStyle[@name='$($deltaItem.InputObject)']")
                [System.Xml.XmlElement]$xmlNode  = $dosv.CreateElement('WordStyle')
                $xmlNode.SetAttribute('bgColor',$($scintillaItem.bgColor)) | out-null
                $xmlNode.SetAttribute('eolFill','') | out-null
                $xmlNode.SetAttribute('fgColor',$($scintillaItem.fgColor)) | out-null
                $xmlNode.SetAttribute('fontName',$($scintillaItem.fontName)) | out-null
                $xmlNode.SetAttribute('fontSize',$($scintillaItem.fontSize))
                $xmlNode.SetAttribute('fontStyle',$($scintillaItem.fontStyle)) | out-null
                $xmlNode.SetAttribute('name',$($scintillaItem.name)) | out-null
                $xmlNode.SetAttribute('styleID',$($scintillaItem.styleID)) | out-null
                $xmlNode.SetAttribute('keywordClass',$($scintillaItem.keywordClass)) | out-null
                $dosvWordStyles.AppendChild($xmlNode);
            }
            '<=' {
                #ignore
            }
        }
        write-host "'$($deltaItem.SideIndicator)' WordStyles '$($deltaItem.InputObject)' - done"
    }

    return $DosvElement
}

function Merge-ScintillaGlobalElement {
<#
.SYNOPSIS
Converts a scintilla to the DOpus DOSV format
#>
    param(
        [System.Xml.XmlElement]$DosvElement,
        [System.Xml.XmlElement]$ScintillaGlobalElement
    )

    $dosv = $DosvElement.OwnerDocument
    #$referenceObject = @($DosElement.WordStyles.WordStyle | Select-Object -ExpandProperty name)
    $dosvWordStyles = $DosvElement.SelectSingleNode("./WordStyles")
 
    $dosvWordStyles.OuterXml | Out-Host
    $ScintillaGlobalElement.OuterXml | Out-Host

    $referenceObject = @($dosvWordStyles.ChildNodes | Select-Object -ExpandProperty name)
    if($DosvElement.name -eq "default")
    {
        $differenceObject = @($ScintillaGlobalElement.ChildNodes | Select-Object -ExpandProperty name)
    }
    else
    {
        $differenceObject = @($ScintillaGlobalElement.ChildNodes | Where-Object { $_.name -eq 'Line number margin'} | Select-Object -ExpandProperty name)
    }
    
    $delta = @(Compare-Object $referenceObject $differenceObject -IncludeEqual)
    $delta | ForEach-Object {
        $deltaItem = $_
        write-host "'$($deltaItem.SideIndicator)' GlobalStyles '$($deltaItem.InputObject)'"

        switch ($deltaItem.SideIndicator)
        {
            '==' { 
                #update
            }
            '=>' { 
                #add
                $scintillaItem = $ScintillaGlobalElement.selectSingleNode("./WidgetStyle[@name='$($deltaItem.InputObject)']")
                [System.Xml.XmlElement]$xmlNode  = $dosv.CreateElement('WordStyle')
                $xmlNode.SetAttribute('bgColor',$scintillaItem.bgColor) 
                $xmlNode.SetAttribute('eolFill','') 
                $xmlNode.SetAttribute('fgColor',$scintillaItem.fgColor) 
                $xmlNode.SetAttribute('fontName',$scintillaItem.fontName)
                $xmlNode.SetAttribute('fontSize',$scintillaItem.fontSize) 
                $xmlNode.SetAttribute('fontStyle',$scintillaItem.fontStyle) 
                $xmlNode.SetAttribute('name',$scintillaItem.name)
                $xmlNode.SetAttribute('styleID',$scintillaItem.styleID)
                $xmlNode.SetAttribute('keywordClass',$scintillaItem.keywordClass) 
                $dosvWordStyles.AppendChild($xmlNode)
            }
            '<=' {
                #ignore
            }
        }
        write-host "'$($deltaItem.SideIndicator)' WordStyles '$($deltaItem.InputObject)' - done"
    }

    return $DosvElement
}

function Convert-ScintillaConfig {
<#
.SYNOPSIS
Converts a scintilla to the DOpus DOSV format
#>
    param(
        [string[]]$ScintillaConfigPath,
        [string[]]$DosvConfigPath
    )

    $lexerCounter = 0

    [xml]$scintillaConfig = Get-Content -Path $ScintillaConfigPath
    [xml]$dosvConfig = Get-Content -Path $DosvConfigPath
 
    $scintillaConfig.SelectNodes("//comment()") | ForEach-Object { $_.ParentNode.RemoveChild($_); } | out-null
    $dosvConfig.SelectNodes("//comment()") | ForEach-Object { $_.ParentNode.RemoveChild($_); } | out-null


    $scintillaGlobalStyles = $scintillaConfig.NotepadPlus.GlobalStyles

    $referenceObject = @($dosvConfig.Config.Styles.Style | Select-Object -ExpandProperty name)
    $differenceObject = @($scintillaConfig.NotepadPlus.LexerStyles.LexerType | Select-Object  -ExpandProperty name)

    $delta = @(Compare-Object $referenceObject $differenceObject -IncludeEqual)
    $delta | ForEach-Object {
        $deltaItem = $_
        write-host "'$($deltaItem.SideIndicator)' Style '$($deltaItem.InputObject)'"

        switch ( $deltaItem.SideIndicator)
        {
            '==' { 
                #update
                $dosvItem = $dosvConfig.Config.Styles.selectSingleNode("./Style[@name='$($deltaItem.InputObject)']")
                $scintillaItem = $scintillaConfig.NotepadPlus.LexerStyles.selectSingleNode("./LexerType[@name='$($deltaItem.InputObject)']")
                $dosvItem = Merge-ScintillaConfigElement $dosvItem $scintillaItem
            }
            '=>' { 
                #add
                #$result = 'Monday'    
            }
            '<=' {
                #ignore
                #$result = 'Tuesday'   
            }
        }
        
        write-host "'$($deltaItem.SideIndicator)' Style '$($deltaItem.InputObject)' - Done"
        $dosvItem = $dosvConfig.Config.Styles.selectSingleNode("./Style[@name='$($deltaItem.InputObject)']")
        if( $dosvItem -ne $null)
        {
            $dosvItem = Merge-ScintillaGlobalElement $dosvItem $scintillaGlobalStyles
            write-host "'$($deltaItem.SideIndicator)' Style Defaults '$($deltaItem.InputObject)' - Done"
        }
    }

    write-host "Done All"
        
    return $dosvConfig
}

$originalDosvConfigPath = 'c:\dosv.config.original.xml'
$notepadConfigPath = 'C:\yourstyle.xml'
$outputpath = 'c:\dosv.config.xml'

$result = Convert-ScintillaConfig $notepadConfigPath $originalDosvConfigPath
$result.OuterXml | set-content -LiteralPath $outputpath
2 Likes

I've successfully installed this plugin on one computer, backed up settings using DO built-in features of course, and tried to restore the backup on another PC.

However, this plugin does not work on the other PC, to be precise the plugin is not available there in preferences to re-enable it.

Is there a chance to include this into the backup to get it running on my other computer?

Michael

Plugins aren't included in config backups. (Plugin configs are, however.) You'd need to install the plugin on the other machine as well. (Usually means just copying the DLL over.)

Impressed by your ultra fast reply, as usual, Leo - unimpressed by the manual steps I've to take :roll_eyes:

Wasn't there a DO folder that get's include into any backup? I mean I could move the installer/zip file into that folder, backup and restore it on the other machine to not have to search for the appropriate files again.

As far as I rememer you once gave me the hint where to store some images, ah yes it was /dopusdata\user data, right? Would that be the correct place to copy the plugin's files?

Michael

Replying myself: yes, it works! However, not that way I will get happy with it.

Anyway, thanks for reading and replying :wink:

There's a folder you can put anything you want included in config backups into, but Opus won't load plugin DLLs out of that folder.

1 Like

dopus 13.0.59 Show narrowing

Yes, Dopus version 13 has this problem. It seems that scintilla control of this plugin doesn't take into account dpi/scale of parent control (lister?). Or something has changed in the public dopus api for viewers.
Anyway, if you set the scale of the viewer window to 150% (I have the scale set to 150% on my system), the text becomes normally readable.

Of course, it would be nice if the plugin developer would fix this, or if he is no longer interested in the plugin, he could post the source code on github for example, then those interested will fix it).

I think I've found the reason for strange behavior of the this plugin in do13. It's all about the configuration file - there are empty attributes fontName="" fontSize="" (which means probably taking these parameters from "default"), and they mess everything up. I don't know why this became important when the plugin works with do13, but I just removed them - and plugin now works fine again in do13 (just as it did in do12, same settings file).

BUT every time you change settings in the plugin configuration dialog - those attributes are serialized again. so you should be aware of that). I am attaching correcred dosv.config.xml.txt (173.3 KB).
hope this helps someone else.

p.s. I don't know if the DOpus developer request list is available, but I would add an item there about adding a syntax highlighting feature for the text viewer.

Good advice, thanks a lot!

Sorry for this seemingly obvious question but where do you need to place the 2 files (zip and dcf)?
When I run the dcf from within dopus "scripts" folder or from the root of the c drive or from de desktop, I always get:
An error occured copying 'dosv.dll', The system cannot find the path specified. (3)

  • I make sure that the zip is at the same location as the dcf
  • I am running dopus 13.2 trial on windows 11

I also use this plugin error, should be applicable to Dopus12, does not apply to Dopus13, suggest the author test, update

Summarized Installation Instructions

I summarized this forum and fixed .xml file to keep formatting even after modifying via GUI.
I include new zip file with all files included and README.txt with installation instructions.
dosv_0_0_0_4.zip (1.9 MB)

| CLICK FOR MORE | README.txt file explaining more details

Install on Windows (tested on Win11 Directory Opus 13.5 x64):

  1. Copy and Replace Plugin (You can backup original files before replacing):
    x64/dosv.dll and x64/SciLexer.dll (or x86/.. for 32 bit) -->
    C:\Program Files\GPSoftware\Directory Opus\Viewers
  2. Copy and Replace Plugin Config (or create folder if doesn't exist):
    dosv.config.xml -->
    C:\Users\YOUR_USERNAME\AppData\Roaming\GPSoftware\Directory Opus\ConfigFiles\Plugins
    Change YOUR_USERNAME
    2.1 (Optional) For different theme copy dosv.config_*.xml file and rename to dosv.config.xml
  3. Fully restart Directory Opus. Exit DO from System Tray as it runs in background or kill with Task Manager.
  4. Open Viewer Pane (F7). Click on any code file (.py .xml etc.) and syntax should be highlighted

Install on Linux (not tested):

  1. Extract InstallPlugin_v0.1 to the same folder as dosv_0_0_0_4.zip
    For example:
    myfolder
    |- InstallPlugin_v0.1
    |- dosv_0_0_0_4.zip
  2. Open Directory Opus and navigate to that myfolder
  3. In Directory Opus double click InstallPlugin_v0.1
    In case of error you could copy files manually like we did in Windows installation just paths will be different but I don't know those paths this might help tho: How to backup or locate your Opus configuration (Simple)
  4. Fully restart Directory Opus. Exit DO from System Tray as it runs in background or kill with Task Manager.

Fixing and Editing Syntax Theme File dosv.config.xml:

Other xml theme files might contain empty parameters: eolFill="" fontName="" fontSize=""
With such empty parameters formatting doesn't look nice. Simply deleting those parameters could help but if you modify it through GUI Preferences -> Viewer -> Plugins -> DOSV gear icon. Those empty lines will be added again and it will mess up formatting.
Solution is to fill in each empty parameter e.g. from this

to this

To make it easier you can use "Find & Replace" with regex in a text editor (I use Sublime Text)
Find: eolFill="" (.*) fontName="" fontSize=""
Replace: eolFill="0" $1 fontName="Courier New" fontSize="10"
After replacing all lines everything should work well even if updated in GUI.

1 Like