Lex *.cuda-session Files as JSON if Opened as Raw Content

Post Reply
Random Void User
Posts: 98
Joined: 13.07.2024 21:19

Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by Random Void User »

Title. Cud knows session files are JSON format, even though the file extension is custom.

The yes/no dialog buttons need different labels. I suggest "Launch Session" and "View Raw File" button labels instead of yes/no.
main Alexey
Posts: 2906
Joined: 25.08.2021 18:15

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by main Alexey »

To open session-files as JSON, use this Cud feature:
https://wiki.freepascal.org/CudaText#File_types

Yes/no dialog btns - will think, if it's easy.
main Alexey
Posts: 2906
Joined: 25.08.2021 18:15

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by main Alexey »

Yes/no buttons - done, update the plugin Session_Manager.
Random Void User
Posts: 98
Joined: 13.07.2024 21:19

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by Random Void User »

Thanks, that helps. Anyway I do think the default user.json should have preset

Code: Select all

  "detect": {
      "*.cuda-session": "JSON"
  }
The default settings have no such detection section at all, so adding this would help users see how to configure it.
main Alexey
Posts: 2906
Joined: 25.08.2021 18:15

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by main Alexey »

ok, added default preset for *.cuda-session in memory (not in default.json).

I can add to settings_default/default.json these lines

Code: Select all

  //[Detect]
  "detect": {
    "*.cuda-session": "JSON"
  },

  "detect_line": {
    "<\\?xml .+": "XML",
    "\\#!/bin/(ba)?sh": "Bash script",
    "\\#!/usr/bin/env (ba)?sh": "Bash script",
    "\\#!/usr/bin/env python\\d*": "Python",
    "\\#!.*\\b(node|js|bun|osascript\\s+-l\\s+JavaScript)": "JavaScript"
  },

EDIT
ops, OptionsEditor + OptionsEditorLite plugins cannot handle these lines in default.json. shows errors. so declined.
Random Void User
Posts: 98
Joined: 13.07.2024 21:19

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by Random Void User »

The default preset file only needs *.cuda-session, other file types already work without a detection setting, as far as I know. I do not have a Python detection setting, but Cud always lexes Python files correctly by its own mechanism (filename?).
main Alexey
Posts: 2906
Joined: 25.08.2021 18:15

Re: Lex *.cuda-session Files as JSON if Opened as Raw Content

Post by main Alexey »

Python files usually have the .py extension.
'data/lexlib/Python.lcf' file:

Code: Select all

  Extentions = 
    'py py3 pyw pyi rpy cpy SConstruct SConscript gyp gypi Snakefile ' +
    'smk vpy wscript bazel bzl'
Post Reply