User Tools

Site Tools


brightscript

BrightScript

Here are some BrightScript tips.

tags

Make tags more useful with BrightScript support. What follows is the same, but with the necessary case-insensitive support.

Add this to your $HOME/.ctags file.

--langdef=BrightScript
--langmap=BrightScript:.brs
--regex-BrightScript=/^function[ \t]*([a-zA-Z0-9_]+)/\1/f,function/i
--regex-BrightScript=/^sub[ \t]*([a-zA-Z0-9_]+)/\1/s,sub/i
--regex-BrightScript=/^[ \t]*(\w+) ?=/\1/v,variable/

Then, run ctags from the channel's main directory like so:

#/bin/bash
set -eu -o pipefail # See: https://sipb.mit.edu/doc/safe-shell/
 
# Make the tags file at the project root
ctags -n --if0=yes --c++-kinds=+p --file-tags=yes -R \
    --links=no --extra=fq \
    --exclude='*/images/*'
 
# Append to it symbols from the BrightScript SDK
ctags --append=yes -n --if0=yes --c++-kinds=+p --file-tags=yes -R \
     --links=no --extra=fq \
     ../../../dev/Netflix/Include # \
#     ../../../dev/Netflix/Scripting
 
# Then do the tags in /source and its subdirectories
find . -mindepth 1 \
        '(' -path '*/images' ')' -prune \
    -or '(' -type d ')' -print | while read i
do
    pushd "$i" 1> /dev/null
    ctags -n --if0=yes --c++-kinds=+p --file-tags=yes -R \
        --links=no --extra=fq
    popd 1> /dev/null
done
 
# Finally, there'll be empty tags files, unlink those
# find . -name tags -size -2 -mtime -1 -print | xargs rm
find . -name tags -size -2 -mtime -1 -delete

Sublime Text 3

On a Windows system, here's a template Sublime project:

My_Project.sublime-project
{
	"build_systems":
	[
		{
			"name": "Zip",
			"working_dir": "$project_path",
			"windows": {
				"cmd": "\"C:\\Program Files\\7-Zip\\7z.exe\" a -tzip \"$project_base_name.zip\" manifest source/*.* images"
			},
			"osx": {
				"shell_cmd": "zip \"$project_base_name.zip\" manifest source/*.* images/*.*"
			},
			"linux": {
				"shell_cmd": "zip \"$project_base_name.zip\" manifest source/*.* images/*.*"
			}
		}
	],
	"folders":
	[
		{
			"path": ".",
			"file_exclude_patterns":
			[
				"tags",
				"*.zip",
				"*.sublime-project"
			],
			"folder_exclude_patterns":
			[
				"obj"
			],
		}
	]
}

Syntax Highlighting

BrightScript Language Definition Bundle for Sublime Text 2 is available here: cmink/BrightScript.tmbundle

Once you've git cloned the project, remove the extra git-only files, and zip it up to BrightScript.sublime-package.

$ rm TODO
$ rm .gitignore
$ rm -rf .git
$ cd .. 
$ zip BrightScript.sublime-package BrightScript.tmbundle/*

Vim

Add BrightScript syntax hightlighting in vim. (ftdetect/ and syntax/ go in your $HOME/.vim/ subdirectory.)

brightscript.txt · Last modified: 2023/04/12 20:44 by 127.0.0.1