Skip to content

Commit

Permalink
Stream track current tab depth
Browse files Browse the repository at this point in the history
  • Loading branch information
NQNStudios committed Dec 11, 2024
1 parent 6ec40da commit 8e3bb78
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/kiss/Stream.hx
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,20 @@ class Stream {
public function dropChars(count:Int, taking:Bool) {
for (idx in 0...count) {
switch (content.charAt(idx)) {
// newline
case "\n":
_currentTab = "";
absoluteChar += absolutePerNewline;
line += 1;
lineLengths.push(column);
column = 1;
startOfLine = true;
// other whitespace character
case c if (c.trim() == ""):
_currentTab += c;
absoluteChar += 1;
column += 1;
// non-whitespace
default:
absoluteChar += 1;
column += 1;
Expand Down Expand Up @@ -183,6 +188,12 @@ class Stream {
#end
}

var _currentTab = "";

public function currentTab():String {
return _currentTab;
}

public function takeChars(count:Int):Option<String> {
if (count > content.length)
return None;
Expand Down

0 comments on commit 8e3bb78

Please sign in to comment.