Page 1 of 1

Preview Code with Syntax Highlighting

Posted: 25 Mar 2013 20:46
by TheQwerty
[This first post gets updated from time to time, particularly when a new revision is released. You are strongly advised to read this post carefully!]

Preview files with syntax highlighting.
CodePreview.xys
Features

✔ Flexible: Can preview items which are dropped on it or those selected when running.
✔ Prettify: This uses Google's Prettify for color highlighting which has a few themes, works surprisingly well for XYplorer scripts already, and can color even non-source files like INI, Markdown, or bizarre proprietary formats.
✔ Customizable: In addition to the easily accessible options there are also some user tweaks for further fine-tuning.

General structure

For the most part all this does is read in the contents of the dropped, selected, or focused items and then displays them in an HTML preview. The real bulk is in just generating the HTML and parsing back the form response.

As stated above I tried to keep it flexible and customizable, so while it gives preference to storing settings in a permanent variable it can also store them in an INI file, and can play nice if you want to share that INI file with other scripts.

It does make use of _Initialize, but as there is only one entry point it can manage calling it on its own for older versions of XY.

Usage

Select some files to preview and then run the script.
Or add the script to your toolbar or catalog and drop items on it.

If you're completely new to scripting I strongly suggest you read:
Stephen's How to use and execute a script ? and my own Tips: Managing Scripts.

Tested on

* Microsoft® Windows® 7 Professional SP1 x64
* XYplorer v12.30.0002.

Requirements

+ XYplorer (version 12.30.0002 or greater) with
- scripting enabled
+ Internet connection

Notes


:!: :!: :!: I absolutely take no responsibility for whatever damage, direct or indirect, the usage of this script may cause. This code is provided as-is, use at your own risk. You are advised.

* This was developed in response to a wish.

Possible future updates

* Self-Update Checking

Release notes

Code: Select all

Rev. 1.00 / 2013-03-25
 * Initial Release
 :D :D :D Special thanks to...

* Marco, for coming up with the forum template.

Code

Code: Select all

/*##############################################################################
##  CodePreview.xys
##
##  This script file previews code with syntax highlighting via
##  Google's Prettify ( https://code.google.com/p/google-code-prettify/ ).
##
##  By default it will use a permanent variable if the user has XY
##  configured to retain them across sessions. Otherwise, it will create a
##  folder "<xyscripts>\.config" and store them within a file there.
##
##  However there are tweaks in the script which allow you to force the use of
##  an INI file and define its path.
##
##
##    Author: TheQwerty
##   Version: 1.0
##      Date: 2013-03-25 T19:00Z;
##  Requires: XY (Currently only tested on v12.30.0002.)
##############################################################################*/


/*******************************************************************************
** User Tweaks
*******************************************************************************/
"User Tweaks||4 : _getTweaks"
  Global $G_FORCE_INI_USE = false;
  // Set to 'true' to force the script to use an INI file for settings.
  // This causes it to bypass checking if permanent variables are retained.
  // Default: false

  Global $G_INI_FILE = "<xyscripts>\.config\TheQwertysScripts.ini";
  // Set to the path to the INI settings file.
  // Used when G_FORCE_INI_USE is true or permanent variables are not retained.
  // Default: "<xyscripts>\.config\TheQwertysScripts.ini"

  Global $G_INI_SECTION = 'CODE_PREVIEW';
  // Set to the INI file section.
  // This allows you to have multiple scripts share an INI file.
  // Default: 'CODE_PREVIEW'
/************************************************************* END _getTweaks */


"- : _-" //---------------------------------------------------------------------


/*******************************************************************************
** Initialize
*******************************************************************************/
"Initialize||4 : _Initialize"
  Sub('_readOptions');
  Global $G_INITIALIZED = True;
/************************************************************ END _Initialize */


/*******************************************************************************
** Get Configuration
**   Reads settings from permanent variables or INI file depending on
**   circumstances.
*******************************************************************************/
"Get Configuration||4 : _readOptions"
  Status 'Reading configuration...',, 'progress';

  // Retrieve internal script tweaks.
  Sub('_getTweaks');
  Global $G_INI_FILE, $G_FORCE_INI_USE, $G_INI_SECTION;

  //FORMAT: Warn|WarnLimit|SkipEmpty|Sounds|Width|Height|LineNums|Skin
  Global $G_OPTIONS = "1|10|0|1|60%|60%|0|Default";

  // Skip permanent variable check if user is forcing INI use.
  if ($G_FORCE_INI_USE) {
    $ScriptRetainPVs = false;
  } else {
    $ScriptRetainPVs = GetKey('ScriptRetainPVs', 'Settings');
  }

  // Use permanent variables if the user has XY retain them.
  if ($ScriptRetainPVs && $P_THEQWERTY_PREVIEW_CODE__OPTIONS) {
    Status 'Read configuration from permanent variables.',, 'progress';
    $G_OPTIONS = $P_THEQWERTY_PREVIEW_CODE__OPTIONS;

  // Use an INI file.
  } else {
    if (1 == Exists($G_INI_FILE)) {
      $iniOptions = GetKey('Options', $G_INI_SECTION, $G_INI_FILE);
      if ($iniOptions) {
        Status 'Read configuration from INI file.',, 'progress';
        $G_OPTIONS = $iniOptions;
      }
    }
  }
/*********************************************************** END _readOptions */


/*******************************************************************************
** Set Configuration
**   Writes settings to permanent variables or INI file depending on
**   circumstances.
*******************************************************************************/
"Set Configuration||4 : _setOptions"
  Status 'Saving configuration...',, 'progress';

  // Retrieve internal script tweaks.
  Sub('_getTweaks');
  Global $G_INI_FILE, $G_FORCE_INI_USE, $G_INI_SECTION;

  Global $G_OPTIONS;

  // Skip permanent variable check if user is forcing INI use.
  if ($G_FORCE_INI_USE) {
    $ScriptRetainPVs = false;
  } else {
    $ScriptRetainPVs = GetKey('ScriptRetainPVs', 'Settings');
  }

  // Use permanent variables if the user has XY retain them.
  if ($ScriptRetainPVs) {
    perm $P_THEQWERTY_PREVIEW_CODE__OPTIONS = $G_OPTIONS;
    Status 'Saved configuration to permanent variable.',, 'progress';

  // Use an INI file.
  } else {
    if (1 != Exists($G_INI_FILE)) {
      Status 'Creating INI file...',, 'progress';
      New($G_INI_FILE, 'file');
    }
    SetKey $G_OPTIONS, 'Options', $G_INI_SECTION, $G_INI_FILE;
    Status 'Saved configuration to INI file.',, 'progress';
  }
/************************************************************ END _setOptions */


"- : _-" //---------------------------------------------------------------------


/*******************************************************************************
** Preview Code
**   Displays a preview for the dropped, selected, or focused items using
**   syntax highlighting.
*******************************************************************************/
"Preview Code||1 : previewCode"
  // Ensure _Initialize was executed.
  Global $G_INITIALIZED;
  if (! $G_INITIALIZED) {
    Sub '_Initialize';
  }
  Unset $G_INITIALIZED;

  // Extract Options.
  Global $G_OPTIONS;
  $optSep = '|';
  $optI = 0;

  $optWarn      = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optWarnLimit = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optSkipEmpty = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optSounds    = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optWidth     = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optHeight    = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optLineNums  = GetToken($G_OPTIONS, $optI++, $optSep, 't');
  $optSkin      = GetToken($G_OPTIONS, $optI++, $optSep, 't', 2);

  $optLineNumValue = ($optLineNums) ? 'linenums' : '';
  $optSkinValue = ($optSkin LikeI 'Default') ? '' : Recase($optSkin, 'lower');
  Unset $optSep, $optI;

  // Guesses which items the user wants us to handle.
  //   Precedence: Dropped > Selected > Focused
  $files = Get('Drop');
  if (! $files) {
    $files = Get('SelectedItemsPathNames');

    if (! $files) {
      $files = Get('Item');
      Status 'Previewing Focused Item...',, 'progress';

    } else {
      Status 'Previewing Selection...',, 'progress';
    }

  } else {
    Status 'Previewing Dropped...',, 'progress';
  }

  // Warn user when previewing many items.
  $fileCount = GetToken($files, 'Count', "<crlf>");
  if ($optWarn && $fileCount > $optWarnLimit) {
    $res_OK = Confirm(<<<#HEREDOC
Preparing this preview may take some time.

Are you sure you want to preview $fileCount items?
#HEREDOC);
    if (! $res_OK) {
      Status 'Aborted Preview',, 'stop';
      if ($optSounds) { Sound 'SystemHand'; }
      End true;
    }
    Unset $res_OK;
  }

  // Collect the contents of each file.
  Status 'Checking items...',, 'progress';
  $content = '';

  // Track whether we got any true contents.
  $noFiles = True;

  // If we see the emptyMsg something went horribly wrong above.
  foreach($file, $files, "<crlf>",, 'No file to preview.') {
    if (! $file) {
      continue;
    }

    // Check if item is not a text file....
    $fileType = FileType($file);
    if (RegexMatches($fileType, 'Binary|Empty|Cannot|NoFile')) {
      $fileType = ReplaceList(  $fileType,
                                'Cannot|NoFile',
                                'Could not open|File not found', '|');
      $fileContent = "&nbsp;&nbsp;Skipped &ndash; $fileType.<BR />";

    // Otherwise get its contents....
    } else {
      $noFiles = False;

      $fileName = GetPathComponent($file, 'file');
      Status "Reading $fileName...",, 'progress';

      $fileContent = ReadFile($file);
      // Lazy, half-hearted sanitation.
      $fileContent = ReplaceList($fileContent, '<|>', '<|>', '|');
      $fileContent = <<<#HEREDOC
<PRE class='prettyprint $optLineNumValue'>
<CODE>$fileContent</CODE>
</PRE>
#HEREDOC;
    }

    $content = $content . "<H4>$file:</H4>$fileContent";
  }
  Unset $file, $fileType, $fileContent, $fileName, $optLineNumValue;

  // Skip empty previews.
  if ($optSkipEmpty && $noFiles) {
    Status 'Skipped empty preview.',, 'stop';
    if ($optSounds) { Sound 'SoundNotification'; }
    End true;
  }
  Unset $noFiles;

  Status 'Generating preview...',, 'progress';

  // Initialize form.
  $optWarnChecked = ($optWarn == 1) ? 'checked' : '';
  $optWarnLimitDisabled = ($optWarn != 1) ? 'disabled' : '';
  $optSkipEmptyChecked = ($optSkipEmpty == 1) ? 'checked' : '';
  $optSoundsChecked = ($optSounds == 1) ? 'checked' : '';
  $optLineNumsChecked = ($optLineNums == 1) ? 'checked' : '';

  // Generate options for Width & Height Selection
  $i = 10;
  $widthOptions = '';
  $heightOptions = '';
  while ($i <= 100) {
    if ($optWidth == "$i%") {
      $widthOptions = "$widthOptions<OPTION selected>$i%</OPTION>";
    } else {
      $widthOptions = "$widthOptions<OPTION>$i%</OPTION>";
    }

    if ($optHeight == "$i%") {
      $heightOptions = "$heightOptions<OPTION selected>$i%</OPTION>";
    } else {
      $heightOptions = "$heightOptions<OPTION>$i%</OPTION>";
    }

    $i = $i + 5;
  }
  Unset $i;

  // Generate options for Skin / Theme Selection
  $skinOptions = '';
  foreach ($skin, 'Default|Desert|Sunburst|Sons-Of-Obsidian|Doxy') {
    if ($skin) {
      $selected = ($optSkin == $skin) ? ' selected' : '';
      $skinOptions = $skinOptions . "<OPTION$selected>$skin</OPTION>";
    }
  }
  Unset $skin, $selected;

  $html = <<<#HEREDOC
<!DOCTYPE html>
<BODY>
<DIV align='right'>
<A href='javascript:document.getElementById("Options").scrollIntoView(true);'>
Options
</A>
</DIV>
$content
<HR />
<DIV id='Options'>
<H3>Options:</H3>
<SCRIPT type='text/javascript'>
  function cbx(cb, ctrlID) {
    document.getElementById(ctrlID).disabled = ! cb.checked;
  }
  function val() {
    var f = document.getElementById('optWarnLimit');
    var n = parseInt(f.value, 10);
    if (isNaN(n) || n < 0) {
      alert('The count of items must be a positive integer or zero.');
      f.focus();
      return false;
    }
    f.value = n;
    f.disabled = false;
    return true;
  }
</SCRIPT>
<FORM method='GET' action='xys:' onsubmit='return val();'>
  <LABEL for='optWarn'>
    <INPUT  id='optWarn' name='optWarn' type='checkbox' value='1'
            onchange='cbx(this,"optWarnLimit");'
            onclick='cbx(this,"optWarnLimit");'
            $optWarnChecked>Show warning when previewing more than
      <INPUT  id='optWarnLimit' name='optWarnLimit' type='text' size='3'
              value='$optWarnLimit' $optWarnLimitDisabled /> items.
    </INPUT>
  </LABEL>
  <BR />
  <LABEL for='optSkipEmpty'>
    <INPUT  id='optSkipEmpty' name='optSkipEmpty' type='checkbox' value='1'
            $optSkipEmptyChecked>Skip showing empty previews.</INPUT>
  </LABEL>
  <BR />
  <LABEL for='optSounds'>
    <INPUT  id='optSounds' name='optSounds' type='checkbox' value='1'
            $optSoundsChecked>Play Sounds.</INPUT>
  </LABEL>
  <BR />
  <LABEL  for='optLineNums'
          title='Disable this if the code does not display properly.'>
    <INPUT  id='optLineNums' name='optLineNums' type='checkbox' value='1'
            title='Disable this if the code does not display properly.'
            $optLineNumsChecked>Display line numbers.</INPUT>
  </LABEL>
  <BR />
  <BR />
  <LABEL for='optWidth'>Width:&nbsp;</LABEL>
  <SELECT id='optWidth' name='optWidth'>$widthOptions</SELECT>&nbsp;
  <LABEL for='optHeight'>Height:&nbsp;</LABEL>
  <SELECT id='optHeight' name='optHeight'>$heightOptions</SELECT>
  <BR /><BR />
  <LABEL for='optSkin'>Theme:&nbsp;</LABEL>
  <SELECT id='optSkin' name='optSkin'>$skinOptions</SELECT>
  <BR /><BR />
  <INPUT type='submit' value='Exit Preview & Save Settings' />
</FORM>
</DIV>
<SCRIPT src='https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=true&skin=$optSkinValue'></SCRIPT>
</BODY>
</HTML>
#HEREDOC;

  Unset $content, $optWarnLimitDisabled, $optLineNumsChecked, $optWarnChecked,
        $optSkipEmptyChecked, $optSoundsChecked, $widthOptions, $heightOptions,
        $skinOptions, $optSkinValue;

  Status 'Showing preview...',, 'progress';

  // Generate the window caption.
  if ($fileCount > 1) {
    $caption = "Code Preview: $fileCount items.";
  } else {
    $caption = "Code Preview: $files";
  }
  Unset $fileCount, $files;

  // Display preview(s).
  if ($optSounds) { Sound 'SystemExclamation'; }
  $res = HTML($html, $optWidth, $optHeight, $caption);
  Unset $html, $caption;

  // Update options...
  if ($res) {
    $res = SubStr($res, 1);

    // Reset boolean options.
    // When unchecked they won't be part of the form response,
    // so assume they are disabled to begin with.
    $optWarn = 0;
    $optSkipEmpty = 0;
    $optSounds = 0;
    $optLineNums = 0;

    foreach ($resOpt, $res, '&') {
      if (! $resOpt) {
        continue;
      }

      $resName  = GetToken($resOpt, 1, '=', 't');
      $resValue = GetToken($resOpt, 2, '=', 't');
      $resValue = UrlDecode($resValue);

          if ($resName LikeI 'optWarn'     ) { $optWarn      = $resValue; }
      elseif ($resName LikeI 'optWarnLimit') { $optWarnLimit = $resValue; }
      elseif ($resName LikeI 'optSkipEmpty') { $optSkipEmpty = $resValue; }
      elseif ($resName LikeI 'optSounds'   ) { $optSounds    = $resValue; }
      elseif ($resName LikeI 'optWidth'    ) { $optWidth     = $resValue; }
      elseif ($resName LikeI 'optHeight'   ) { $optHeight    = $resValue; }
      elseif ($resName LikeI 'optLineNums' ) { $optLineNums  = $resValue; }
      elseif ($resName LikeI 'optSkin'     ) { $optSkin      = $resValue; }
      // else { Echo $resOpt; }
    }

    $G_OPTIONS = "$optWarn|$optWarnLimit|$optSkipEmpty|$optSounds";
    $G_OPTIONS = "$G_OPTIONS|$optWidth|$optHeight|$optLineNums|$optSkin";
    Sub('_setOptions');
  }
  Unset $res, $resOpt, $resName, $resValue, $G_OPTIONS;

  Status 'Preview Complete!',, 'ready';
  if ($optSounds) { Sound 'SystemExit'; }
  Unset $optWarn,  $optWarnLimit, $optSkipEmpty, $optSounds,
        $optWidth, $optHeight,    $optLineNums,  $optSkin;
/************************************************************ END previewCode */


"- : _-" //---------------------------------------------------------------------


/*******************************************************************************
** Internal Variables
**   For storing some information about this script.
*******************************************************************************/
"Internal Variables||4 : _aboutMe"
  Global $G_AUTHOR = 'TheQwerty';
  Global $G_VERSION = 1.0;
  Global $G_DATE = '2013-03-25T19:00Z';
/*************************************************************** END _aboutMe */
[/size]

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 11:26
by Marco
Great script, congrats! :appl:
In the last days I was wondering what syntax scheme could be applied XY scripts... well, your script gives a great highlighting just out of the box!

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 11:59
by Enternal
Oh dang this is awesome! Pick a file, run script, beautiful coloring! Love the fact that it also works with xys scripts!

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 17:59
by klownboy
Very nice indeed. Something I'll definitely use. It's been working fine for selected files, but when I drag and drop an XYscript file on it, I receive the following error message:
CodePreview01.JPG
My drag and drop function is working fine with other CTBs that I have setup. Sorry, I just figured it out as I continued to play, but I figured I'd go ahead and pass it on anyway. I got the message below when I right dragged. The message doesn't occur and it works fine on a left drag. This is absolutely fine, because I can set it do do something different reserved for a right drag.

Certainly not a biggie, but I noticed with a few scripts in which I have some special ASCII code contained within them, I will receive the following error message, "Skipped - Binary". The xyscripts contain some special spaces made by hitting the alt key along with "255", or a bullet by hitting alt-007. See attached:
CodePreview02.JPG
I attached a small XY script as an example. Note: You can't see the "bullets" but they are in the white space in the menu after the lead-in quotes. The bullets as well as the extra spaces do display in a CTB.

Code: Select all

"_Initialize"

    perm $Flash_Folder, $Rem_Dr; 

    $Rem_Dr = get("drives", 2), "|");
    $Dr_Cnt = gettoken($Rem_Dr, "count", "|");
    end $Dr_Cnt < "1", "You have no removable drives on-line, aborting!";
    if ($Dr_Cnt > "1") {
      status "You have more than one flash or external hard drive on-line!";
      $Rem_Dr = inputselect("Select the Target Drive: <crlf>","$Rem_Dr", | ,4, ,350, 250, "Target Drive Selection");}

"Select Flash Drive Folder|:wipe"  load self(file);

"-"
"        $Rem_Dr&";
    sub _drop_it;
"        $Rem_Dr&AHK";
    sub _drop_it;
"        $Rem_Dr&Downloads";
    sub _drop_it;
"        $Rem_Dr&Misc";
    sub _drop_it;
"        $Rem_Dr&XY";
    sub _drop_it;


"_drop_it";
     if (<get drop |> == ""){
       status "Nothing to do" , , "alert";
     }
     else {
       $Flash_Folder = ($Rem_Dr . gettoken(caller("caption"), -1, "&", "t"));
       if (exists($Flash_Folder) >= 1) {
              copyto $Flash_Folder, <get drop |>;
       }
       else {
             msg "This path doesn't exist!";
       }
     }  
"_Terminate"
 unset $Flash_Folder, $Rem_Dr;
Thanks again for another great XYplorer tool,
Ken

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 18:26
by TheQwerty
klownboy wrote:It's been working fine for selected files, but when I drag and drop an XYscript file on it, I receive the following error message...
EDIT 1:

I lack basic reading skills today. :oops:
klownboy wrote:I got the message below when I right dragged. The message doesn't occur and it works fine on a left drag. This is absolutely fine, because I can set it do do something different reserved for a right drag.
So was this because nothing was configured for the Right-Click script? Or does this happen when this script is configured there? /edit1

EDIT 2: I checked it out and that is indeed the error when your right-drop on a CTB that doesn't have a right-click action. That should probably be a better error message from XY. /edit2
klownboy wrote:Certainly not a biggie, but I noticed with a few scripts in which I have some special ASCII code contained within them, I will receive the following error message, "Skipped - Binary".
The script relies on XYplorer's FileType SC, which does claim that file is Binary, so this would be a bug in XY itself. Don might need to tweak this. Let me consider some ways I could provide a workaround.

EDIT 3: If you save this file as UTF-8 with BOM (I used Sublime Text 2 > File > Save with Encoding), it will not be treated as Binary, and should still function correctly. However, the special characters won't show up in the preview. Not sure what I can do about that - character encoding is one of my deeply disliked topics. :? /edit3


Thanks for reporting these issues!

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 19:16
by klownboy
Just to followup. When I placed a load statement in the "right click" entry for the CTB, CodePreview.xys works fine (i.e., no error message). In some ways that surprises me since it's a right drag, not a right click. I didn't look through your code to see if you take into account a right drag or a left drag, but I would think that the loading of the file in the normal "left click" entry of the CTB could take care of weather a file was dragged using the right or left button of the mouse, but on second thought I guess not. It looks like you don't distinguish in the code if it was a left drop "1" or right drop "2" so that's why it works for me now with the right drag as long the entry is made in the CTB for "right click". In this case http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9288 where I wanted to have different functions for left click, left drag, right click, and right drag, I ended up having to use a left click label to properly all 4 situations.

I just noticed your Edit 3. I use Textpad. I'll see what happens when I use your suggestion. Thanks

Edit: I saved the above file as UTF-8 and it does display now with CodePreview (like you said without the special characters, but that's not a problem). I'm not sure, should I be saving all these XY scripts or AHK scripts as UTF-8 instead of ANSI? Is CodePreview saved in UTF-8? I ask because in Textpad (in the save as dropdown box) reflects CodePreview to be ANSI.

Thanks again for a very nice script.

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 20:13
by TheQwerty
klownboy wrote:It looks like you don't distinguish in the code if it was a left drop "1" or right drop "2"...
I wasn't aware it was possible to do this. That said, I'm not liking the current Get('Trigger') behavior. It doesn't seem to buy you much more than eliminating the trouble of calling different Left/Right scripts, but since it fails on drops you still need at least one of them. Seems to me if you wanted to do it reliably you're better off having Left and Right entry points. Plus it's limited to CTBs, so the Catalog or dropping on the file itself can't distinguish. Sadly Get('Drop') doesn't even seem to be documented at this point except in an example of using Self.

That said the error dialog is a result of dropping when the corresponding action isn't defined, so I created a separate bug report here.
klownboy wrote:Edit: I saved the above file as UTF-8 and it does display now with CodePreview (like you said without the special characters, but that's not a problem). I'm not sure, should I be saving all these XY scripts or AHK scripts as UTF-8 instead of ANSI? Is CodePreview saved in UTF-8? I ask because in Textpad (in the save as dropdown box) reflects CodePreview to be ANSI.
CodePreview is plain ASCII - I'm really not sure what the best practice would be. Just that it seems you're using characters that cannot be represented in ASCII and saving them as ASCII/ANSI instead of UTF causes problems when other programs attempt to read them.

For what it's worth neither Textpad nor Sublime Text 2 seem to catch this when saving your script, so maybe I'm completely wrong as well. :eh:

I am very lost when it comes to character encoding - I have a very limited understanding of it and even less of a grasp of working with them correctly. Trying to figure it out just leaves me dizzy. :veryconfused:

Re: Preview Code with Syntax Highlighting

Posted: 26 Mar 2013 21:29
by klownboy
I wasn't aware it was possible to do this. That said, I'm not liking the current Get('Trigger') behavior. It doesn't seem to buy you much more than eliminating the trouble of calling different Left/Right scripts
A big reason for the get trigger, at least in part, was to be able to have a menu come up directly and immediately with a right click of a CTB. Sure you could run code with a label on right click, but you could not display a menu directly using a right click label because an intermediate menu would first display and not the menu you actually wanted. What I forgot to mention is that I'm talking about menus for left and right click, all with in the same script resource file. Obviously you could do it with separate script resource files assigned to the left and right click. So I have to say that feature has been very useful at least to me :) (i.e., getting a right click menu to display and run various programs just as you can with a standard left click of a CTB). See http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=8917 and here http://www.xyplorer.com/xyfc/viewtopic. ... boy#p79618