Adding support for the Brightscript language, with samples.

This commit is contained in:
Max Peterson
2013-11-21 19:26:44 -06:00
parent 46779da3b5
commit c88585cffb
3 changed files with 580 additions and 3 deletions

View File

@@ -181,6 +181,11 @@ Brainfuck:
extensions:
- .bf
Brightscript:
type: programming
lexer: Text only
primary_extension: .brs
Bro:
type: programming
primary_extension: .bro

View File

@@ -27,6 +27,9 @@
"Bluespec": [
".bsv"
],
"Brightscript": [
".brs"
],
"C": [
".c",
".h"
@@ -477,8 +480,8 @@
".gemrc"
]
},
"tokens_total": 423589,
"languages_total": 488,
"tokens_total": 424168,
"languages_total": 489,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -2573,6 +2576,268 @@
"addRules": 1,
"preempts": 1
},
"Brightscript": {
"**": 17,
"Simple": 1,
"Grid": 2,
"Screen": 2,
"Demonstration": 1,
"App": 1,
"Copyright": 1,
"(": 32,
"c": 1,
")": 31,
"Roku": 1,
"Inc.": 1,
"All": 3,
"Rights": 1,
"Reserved.": 1,
"************************************************************": 2,
"Sub": 2,
"Main": 1,
"set": 2,
"to": 10,
"go": 1,
"time": 1,
"get": 1,
"started": 1,
"while": 4,
"gridstyle": 7,
"<": 1,
"print": 7,
";": 10,
"screen": 5,
"preShowGridScreen": 2,
"showGridScreen": 2,
"end": 2,
"End": 4,
"Set": 1,
"the": 17,
"configurable": 1,
"theme": 3,
"attributes": 2,
"for": 10,
"application": 1,
"Configure": 1,
"custom": 1,
"overhang": 1,
"and": 4,
"Logo": 1,
"are": 2,
"artwork": 2,
"colors": 1,
"offsets": 1,
"specific": 1,
"app": 1,
"******************************************************": 4,
"Screens": 1,
"can": 2,
"make": 1,
"slight": 1,
"adjustments": 1,
"default": 1,
"individual": 1,
"attributes.": 1,
"these": 1,
"greyscales": 1,
"theme.GridScreenBackgroundColor": 1,
"theme.GridScreenMessageColor": 1,
"theme.GridScreenRetrievingColor": 1,
"theme.GridScreenListNameColor": 1,
"used": 1,
"in": 3,
"theme.CounterTextLeft": 1,
"theme.CounterSeparator": 1,
"theme.CounterTextRight": 1,
"theme.GridScreenLogoHD": 1,
"theme.GridScreenLogoOffsetHD_X": 1,
"theme.GridScreenLogoOffsetHD_Y": 1,
"theme.GridScreenOverhangHeightHD": 1,
"theme.GridScreenLogoSD": 1,
"theme.GridScreenOverhangHeightSD": 1,
"theme.GridScreenLogoOffsetSD_X": 1,
"theme.GridScreenLogoOffsetSD_Y": 1,
"theme.GridScreenFocusBorderSD": 1,
"theme.GridScreenFocusBorderHD": 1,
"use": 1,
"your": 1,
"own": 1,
"description": 1,
"background": 1,
"theme.GridScreenDescriptionOffsetSD": 1,
"theme.GridScreenDescriptionOffsetHD": 1,
"return": 5,
"Function": 5,
"Perform": 1,
"any": 1,
"startup/initialization": 1,
"stuff": 1,
"prior": 1,
"style": 6,
"as": 2,
"string": 3,
"As": 3,
"Object": 2,
"m.port": 3,
"CreateObject": 2,
"screen.SetMessagePort": 1,
"screen.": 1,
"The": 1,
"will": 3,
"show": 1,
"retreiving": 1,
"categoryList": 4,
"getCategoryList": 1,
"[": 3,
"]": 4,
"+": 1,
"screen.setupLists": 1,
"categoryList.count": 2,
"screen.SetListNames": 1,
"StyleButtons": 3,
"getGridControlButtons": 1,
"screen.SetContentList": 2,
"i": 3,
"-": 15,
"getShowsForCategoryItem": 1,
"screen.Show": 1,
"true": 1,
"msg": 3,
"wait": 1,
"getmessageport": 1,
"does": 1,
"not": 2,
"work": 1,
"on": 1,
"gridscreen": 1,
"type": 2,
"if": 3,
"then": 3,
"msg.GetMessage": 1,
"msg.GetIndex": 3,
"msg.getData": 2,
"msg.isListItemFocused": 1,
"else": 1,
"msg.isListItemSelected": 1,
"row": 2,
"selection": 3,
"yes": 1,
"so": 2,
"we": 3,
"come": 1,
"back": 1,
"with": 2,
"new": 1,
".Title": 1,
"endif": 1,
"**********************************************************": 1,
"this": 3,
"function": 1,
"passing": 1,
"an": 1,
"roAssociativeArray": 2,
"be": 2,
"sufficient": 1,
"springboard": 2,
"display": 2,
"add": 1,
"code": 1,
"create": 1,
"now": 1,
"do": 1,
"nothing": 1,
"Return": 1,
"list": 1,
"of": 5,
"categories": 1,
"filter": 1,
"all": 1,
"categories.": 1,
"just": 2,
"static": 1,
"data": 2,
"example.": 1,
"********************************************************************": 1,
"ContentMetaData": 1,
"objects": 1,
"shows": 1,
"category.": 1,
"For": 1,
"example": 1,
"cheat": 1,
"but": 2,
"ideally": 1,
"you": 1,
"dynamically": 1,
"content": 2,
"each": 1,
"category": 1,
"is": 1,
"dynamic": 1,
"s": 1,
"one": 3,
"small": 1,
"step": 1,
"a": 4,
"man": 1,
"giant": 1,
"leap": 1,
"mankind.": 1,
"http": 14,
"//upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg": 2,
"I": 2,
"have": 2,
"Dream": 1,
"PG": 1,
"dream": 1,
"that": 1,
"my": 1,
"four": 1,
"little": 1,
"children": 1,
"day": 1,
"live": 1,
"nation": 1,
"where": 1,
"they": 1,
"judged": 1,
"by": 2,
"color": 1,
"their": 2,
"skin": 1,
"character.": 1,
"//upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_": 2,
"_March_on_Washington.jpg": 2,
"Flat": 6,
"Movie": 2,
"HD": 6,
"x2": 4,
"SD": 5,
"Netflix": 1,
"//upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif": 2,
"Landscape": 1,
"x3": 6,
"Channel": 1,
"Store": 1,
"//upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px": 2,
"Dunkery_Hill.jpg": 2,
"Portrait": 1,
"x4": 1,
"posters": 3,
"//upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg": 2,
"Square": 1,
"x1": 1,
"//upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px": 2,
"SQUARE_SHAPE.svg.png": 2,
"x9": 1,
"//upload.wikimedia.org/wikipedia/commons/thumb/2/22/": 2,
"%": 8,
"C3": 4,
"cran_TV_plat.svg/200px": 2,
"cran_TV_plat.svg.png": 2,
"}": 1,
"buttons": 1
},
"C": {
"#include": 150,
"const": 358,
@@ -43369,6 +43634,7 @@
"Awk": 544,
"BlitzBasic": 2065,
"Bluespec": 1298,
"Brightscript": 579,
"C": 58858,
"C++": 21308,
"Ceylon": 50,
@@ -43495,6 +43761,7 @@
"Awk": 1,
"BlitzBasic": 3,
"Bluespec": 2,
"Brightscript": 1,
"C": 26,
"C++": 19,
"Ceylon": 1,
@@ -43610,5 +43877,5 @@
"Xtend": 2,
"YAML": 1
},
"md5": "e0528838deafd471674bb0a8d79906ce"
"md5": "d77910fe214f3654d7538485c7388f89"
}

View File

@@ -0,0 +1,305 @@
' *********************************************************
' ** Simple Grid Screen Demonstration App
' ** Jun 2010
' ** Copyright (c) 2010 Roku Inc. All Rights Reserved.
' *********************************************************
'************************************************************
'** Application startup
'************************************************************
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
gridstyle = "Flat-Movie"
'set to go, time to get started
while gridstyle <> ""
print "starting grid style= ";gridstyle
screen=preShowGridScreen(gridstyle)
gridstyle = showGridScreen(screen, gridstyle)
end while
End Sub
'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************
Sub initTheme()
app = CreateObject("roAppManager")
app.SetTheme(CreateDefaultTheme())
End Sub
'******************************************************
'** @return The default application theme.
'** Screens can make slight adjustments to the default
'** theme by getting it from here and then overriding
'** individual theme attributes.
'******************************************************
Function CreateDefaultTheme() as Object
theme = CreateObject("roAssociativeArray")
theme.ThemeType = "generic-dark"
' All these are greyscales
theme.GridScreenBackgroundColor = "#363636"
theme.GridScreenMessageColor = "#808080"
theme.GridScreenRetrievingColor = "#CCCCCC"
theme.GridScreenListNameColor = "#FFFFFF"
' Color values work here
theme.GridScreenDescriptionTitleColor = "#001090"
theme.GridScreenDescriptionDateColor = "#FF005B"
theme.GridScreenDescriptionRuntimeColor = "#5B005B"
theme.GridScreenDescriptionSynopsisColor = "#606000"
'used in the Grid Screen
theme.CounterTextLeft = "#FF0000"
theme.CounterSeparator = "#00FF00"
theme.CounterTextRight = "#0000FF"
theme.GridScreenLogoHD = "pkg:/images/Overhang_Test_HD.png"
theme.GridScreenLogoOffsetHD_X = "0"
theme.GridScreenLogoOffsetHD_Y = "0"
theme.GridScreenOverhangHeightHD = "99"
theme.GridScreenLogoSD = "pkg:/images/Overhang_Test_SD43.png"
theme.GridScreenOverhangHeightSD = "66"
theme.GridScreenLogoOffsetSD_X = "0"
theme.GridScreenLogoOffsetSD_Y = "0"
' to use your own focus ring artwork
'theme.GridScreenFocusBorderSD = "pkg:/images/GridCenter_Border_Movies_SD43.png"
'theme.GridScreenBorderOffsetSD = "(-26,-25)"
'theme.GridScreenFocusBorderHD = "pkg:/images/GridCenter_Border_Movies_HD.png"
'theme.GridScreenBorderOffsetHD = "(-28,-20)"
' to use your own description background artwork
'theme.GridScreenDescriptionImageSD = "pkg:/images/Grid_Description_Background_SD43.png"
'theme.GridScreenDescriptionOffsetSD = "(125,170)"
'theme.GridScreenDescriptionImageHD = "pkg:/images/Grid_Description_Background_HD.png"
'theme.GridScreenDescriptionOffsetHD = "(190,255)"
return theme
End Function
'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************
Function preShowGridScreen(style as string) As Object
m.port=CreateObject("roMessagePort")
screen = CreateObject("roGridScreen")
screen.SetMessagePort(m.port)
' screen.SetDisplayMode("best-fit")
screen.SetDisplayMode("scale-to-fill")
screen.SetGridStyle(style)
return screen
End Function
'******************************************************
'** Display the gird screen and wait for events from
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the show posters
'******************************************************
Function showGridScreen(screen As Object, gridstyle as string) As string
print "enter showGridScreen"
categoryList = getCategoryList()
categoryList[0] = "GridStyle: " + gridstyle
screen.setupLists(categoryList.count())
screen.SetListNames(categoryList)
StyleButtons = getGridControlButtons()
screen.SetContentList(0, StyleButtons)
for i = 1 to categoryList.count()-1
screen.SetContentList(i, getShowsForCategoryItem(categoryList[i]))
end for
screen.Show()
while true
print "Waiting for message"
msg = wait(0, m.port)
'msg = wait(0, screen.GetMessagePort()) ' getmessageport does not work on gridscreen
print "Got Message:";type(msg)
if type(msg) = "roGridScreenEvent" then
print "msg= "; msg.GetMessage() " , index= "; msg.GetIndex(); " data= "; msg.getData()
if msg.isListItemFocused() then
print"list item focused | current show = "; msg.GetIndex()
else if msg.isListItemSelected() then
row = msg.GetIndex()
selection = msg.getData()
print "list item selected row= "; row; " selection= "; selection
' Did we get a selection from the gridstyle selection row?
if (row = 0)
' yes, return so we can come back with new style
return StyleButtons[selection].Title
endif
'm.curShow = displayShowDetailScreen(showList[msg.GetIndex()])
else if msg.isScreenClosed() then
return ""
end if
end If
end while
End Function
'**********************************************************
'** When a poster on the home screen is selected, we call
'** this function passing an roAssociativeArray with the
'** ContentMetaData for the selected show. This data should
'** be sufficient for the springboard to display
'**********************************************************
Function displayShowDetailScreen(category as Object, showIndex as Integer) As Integer
'add code to create springboard, for now we do nothing
return 1
End Function
'**************************************************************
'** Return the list of categories to display in the filter
'** banner. The result is an roArray containing the names of
'** all of the categories. All just static data for the example.
'***************************************************************
Function getCategoryList() As Object
categoryList = [ "GridStyle", "Reality", "History", "News", "Comedy", "Drama"]
return categoryList
End Function
'********************************************************************
'** Given the category from the filter banner, return an array
'** of ContentMetaData objects (roAssociativeArray's) representing
'** the shows for the category. For this example, we just cheat and
'** create and return a static array with just the minimal items
'** set, but ideally, you'd go to a feed service, fetch and parse
'** this data dynamically, so content for each category is dynamic
'********************************************************************
Function getShowsForCategoryItem(category As Object) As Object
print "getting shows for category "; category
showList = [
{
Title: category + ": Header",
releaseDate: "1976",
length: 3600-600,
Description:"This row is category " + category,
hdBranded: true,
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif",
Description:"Short Synopsis #1",
Synopsis:"Length",
StarRating:10,
}
{
Title: category + ": Beverly Hillbillies",
releaseDate: "1969",
rating: "PG",
Description:"Come and listen to a story about a man named Jed: Poor mountaineer, barely kept his family fed. Then one day he was shootin at some food, and up through the ground came a bubblin crude. Oil that is, black gold, Texas tea.",
numEpisodes:42,
contentType:"season",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg",
StarRating:80,
UserStarRating:40
}
{
Title: category + ": Babylon 5",
releaseDate: "1996",
rating: "PG",
Description:"The show centers on the Babylon 5 space station: a focal point for politics, diplomacy, and conflict during the years 2257-2262.",
numEpisodes:102,
contentType:"season",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg",
StarRating:80,
UserStarRating:40
}
{
Title: category + ": John F. Kennedy",
releaseDate: "1961",
rating: "PG",
Description:"My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg",
StarRating:100
}
{
Title: category + ": Man on the Moon",
releaseDate: "1969",
rating: "PG",
Description:"That's one small step for a man, one giant leap for mankind.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg",
StarRating:100
}
{
Title: category + ": I have a Dream",
releaseDate: "1963",
rating: "PG",
Description:"I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin, but by the content of their character.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg",
StarRating:100
}
]
return showList
End Function
function getGridControlButtons() as object
buttons = [
{ Title: "Flat-Movie"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "Flat-Movie (Netflix) style"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif"
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif"
}
{ Title: "Flat-Landscape"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "Channel Store"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg",
}
{ Title: "Flat-Portrait"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "3x4 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
}
{ Title: "Flat-Square"
ReleaseDate: "HD:7x3 SD:6x3"
Description: "1x1 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
}
{ Title: "Flat-16x9"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "HD style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
}
]
return buttons
End Function