Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed Jul 18, 2024
1 parent 019db4b commit fd59ad6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
29 changes: 13 additions & 16 deletions data/lib/red/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,23 @@ function syntax:process(pos, epos)
local txt = self.txt
local cols = self.cols
local i = self.pos
if pos < i then -- nothing to do
if i > pos or i > #txt or i > epos then -- nothing to do
return
end
while i <= #txt do
local d, aux
cols[i] = self.ctx.col or 0
for _, c in ipairs(self.ctx) do
d, aux = self:match_start(c, txt, i, epos)
if d then
colorize(cols, i, d, c.scol or c.col)
i = i + d
table.insert(stack, 1, { self.ctx, aux })
self.ctx = c
break
end
local d, aux
cols[i] = self.ctx.col or 0
for _, c in ipairs(self.ctx) do
d, aux = self:match_start(c, txt, i, epos)
if d then
colorize(cols, i, d, c.scol or c.col)
i = i + d
table.insert(stack, 1, { self.ctx, aux })
self.ctx = c
break
end
i = i + self:context(i, epos)
self.pos = i
break
end
i = i + self:context(i, epos)
self.pos = i
end

return syntax
2 changes: 1 addition & 1 deletion data/lib/red/win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ function win:colorize()
end
self:make_epos()
local state
-- print("Colorize:", start, epos, #colorizer.stack)
-- print("Colorize:", start, self.epos, #colorizer.stack, colorizer.dirty)
colorizer.saved = nil
for i = start, self.epos - 1 do
if not state and
Expand Down
11 changes: 6 additions & 5 deletions src/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ WindowTitle(const char *title)
SDL_SetWindowTitle(window, title);
}

#if 1
#ifdef _WIN32
/* SDL2 realization after 2.0.16 may sleep. BUG? */
int
SDL_WaitEventTo(int timeout)
Expand Down Expand Up @@ -115,11 +115,12 @@ WakeEvent(void)
int
WaitEvent(float n)
{
#ifdef _WIN32
/* standard function may sleep longer than 20ms (in Windows) */
// if (n >= 0.05f)
// return SDL_WaitEventTimeout(NULL, (int)(n * 1000));
// else
return SDL_WaitEventTo((int)(n * 1000));
return SDL_WaitEventTo((int)(n * 1000));
#else
return SDL_WaitEventTimeout(NULL, (int)(n * 1000));
#endif
}

void
Expand Down

0 comments on commit fd59ad6

Please sign in to comment.