-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10a9f4b
commit bc67e3b
Showing
7 changed files
with
294 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
socat EXEC:"/bin/bash",pty,stderr,setsid,sane PTY,link=/dev/ttyS11,setsid,raw,echo=0 & | ||
commy /dev/ttyS11 921600 | ||
commy /dev/ttyS11 921600 -b 1000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const std = @import("std"); | ||
|
||
// sliding window keybuffer to spot multi-char sequences in input | ||
pub const KeyWindow = struct { | ||
const Self = @This(); | ||
window: [4]u8, | ||
holding: u8, // how many valid bytes in window | ||
|
||
pub fn init() Self { | ||
return Self{ | ||
.window = undefined, | ||
.holding = 0, | ||
}; | ||
} | ||
|
||
pub fn push(self: *Self, c: u8) void { | ||
if (self.holding < self.window.len) { | ||
self.window[self.holding] = c; | ||
self.holding += 1; | ||
} else { | ||
std.mem.copyForwards(u8, self.window[0 .. self.holding - 1], self.window[1..]); | ||
self.window[self.window.len - 1] = c; | ||
} | ||
} | ||
|
||
pub fn clear(self: *Self) void { | ||
self.holding = 0; | ||
} | ||
|
||
pub fn match(self: *const Self, s: []const u8) bool { | ||
if (self.holding < s.len) { | ||
return false; | ||
} | ||
return std.mem.containsAtLeast(u8, &self.window, 1, s); | ||
} | ||
}; |
Oops, something went wrong.