4 Commits
0.3 ... 0.3.1

Author SHA1 Message Date
Ben S
46fe844c16 Version bump 2015-02-21 13:29:11 +00:00
Ben S
bfdc57e356 Fix infinite loop when writing code at end of file
This resulted in my BBEdit hanging.
2015-02-21 13:27:29 +00:00
Ben S
1154b0df63 Highlight module names in 'use...as' statements 2015-02-21 13:27:05 +00:00
Ben S
2c05ab8682 Download link bump 2015-02-15 14:06:55 +00:00
3 changed files with 35 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ By default, it highlights anything beginning with a capital letter in a certain
### Installation
The simplest way is to just [download the package](https://github.com/ogham/Rust.bblm/releases/tag/0.2) and put it in this folder:
The simplest way is to just [download the package](https://github.com/ogham/Rust.bblm/releases/tag/0.3.1) and put it in this folder:
~/Application Support/BBEdit/Language Modules

26
rust.mm
View File

@@ -569,7 +569,7 @@ OSErr calculateRuns(BBLMParamBlock &params, const BBLMCallbackBlock *callbacks)
bool wordchr = false;
while ((ch = iter.GetNextChar()))
{
if (ch == 'r' && iter.strcmp("##\"", 3) == 0)
if (ch == 'r' && iter.CharsLeft() >= 3 && iter.strcmp("##\"", 3) == 0)
{
iter--;
if (!makeCodeRun(iter, runStart, *callbacks)) return noErr;
@@ -675,7 +675,7 @@ OSErr calculateRuns(BBLMParamBlock &params, const BBLMCallbackBlock *callbacks)
iter--;
}
}
else if (ch == 'a' && iter.strcmp("cro_rules!", 10) == 0)
else if (ch == 'a' && iter.CharsLeft() >= 10 && iter.strcmp("cro_rules!", 10) == 0)
{
iter += 10;
ch = iter.GetNextChar();
@@ -763,11 +763,31 @@ OSErr calculateRuns(BBLMParamBlock &params, const BBLMCallbackBlock *callbacks)
if (!addRun(kBBLMFileIncludeRunKind, runStart, runLen, *callbacks)) return noErr;
break;
}
else
else if (ch)
{
spacey = isspace(ch) || ch == ':' || ch == '{';
runLen++;
}
else
{
break;
}
if (iter.strcmp(" as ", 4) == 0)
{
if (!addRun(kBBLMFileIncludeRunKind, runStart, runLen, *callbacks)) return noErr;
runStart = iter.Offset();
iter += 4;
if (!addRun(kBBLMCodeRunKind, runStart, 4, *callbacks)) return noErr;
runStart = iter.Offset();
runLen = skipWord(iter);
if (!addRun(moduleColour, runStart, runLen, *callbacks)) return noErr;
iter++;
runLen = 0;
break;
}
}
if (!addRun(kBBLMFileIncludeRunKind, runStart, runLen, *callbacks)) return noErr;

View File

@@ -118,3 +118,14 @@
macro_rules! parse {
($thing: expr) => { $thing };
}
// `use` statements
// ----------------
use flux;
use flux::capacitor;
use flux::capacitor::Component::*;
use flux::capacitor::Component::{ImpurePalladium, ThinkingAluminium, TimeyWimeyDevice};
use flux::capacitor as cap;
use super;
use self;