Projekte
Eine Übersicht meiner Projekte.
Monochromator
Monochromator Light
JavaRustGo
#[derive(Debug, Clone, PartialEq)]
pub struct Token {
pub text: String,
pub pos: usize,
}
/// A lexer over the beta-code apparatus.
pub struct Lexer<'a> {
input: &'a str,
pos: usize,
}
impl<'a> Lexer<'a> {
pub fn new(input: &'a str) -> Self {
Self { input, pos: 0 }
}
/// Converts a beta-code letter with its diacritics into Unicode.
pub fn convert(&mut self, c: char) -> Result<char, ParseError> {
self.pos += 1;
match c {
'a'..='z' => Ok(BASE[(c as u8 - b'a') as usize]),
')' => Ok('\u{0313}'),
'(' => Ok('\u{0314}'),
_ => Err(ParseError::new(
self.pos,
format!("unknown character {c:?}"),
)),
}
}
pub fn words(&self) -> impl Iterator<Item = &str> + '_ {
self.input.split_whitespace().filter(|w| !w.is_empty())
}
}
Monochromator Dark Amber
JavaRustGo
// Palette bundles the color values of a single mode (dark/light).
type Palette struct {
BG string `json:"bg"`
FG string `json:"fg"`
Accent string `json:"accent"`
}
// Pick returns the dark or light value depending on the mode.
func Pick(mode, dark, light string) string {
if mode == "dark" {
return dark
}
return light
}
func (p Palette) Color(name string) (string, error) {
switch name {
case "blue":
return p.Blue, nil
case "magenta":
return p.Magenta, nil
default:
return "", fmt.Errorf("unknown color %q", name)
}
}
func Load(dir string) (*Config, error) {
data, err := os.ReadFile(filepath.Join(dir, "base.json"))
if err != nil {
return nil, fmt.Errorf("loading base palette: %w", err)
}
var palettes map[string]Palette
if err := json.Unmarshal(data, &palettes); err != nil {
return nil, fmt.Errorf("parsing base palette: %w", err)
}
return &Config{Palettes: palettes}, nil
}
Monochromator Dark
JavaRustGo
package at.beem.ntg;
import java.util.List;
import java.util.Objects;
/** A witness to the text: a manuscript siglum with its readings. */
public final class Witness {
private static final String UNKNOWN = "\u2014";
private final String siglum;
private final List<String> readings;
/**
* Creates a witness.
*
* @param siglum the manuscript siglum, for example "P46"
*/
public Witness(String siglum, List<String> readings) {
this.siglum = Objects.requireNonNull(siglum);
this.readings = List.copyOf(readings);
}
public String readingAt(int index) {
if (index < 0 || index >= readings.size()) {
return UNKNOWN;
}
return readings.get(index);
}
@Override
public String toString() {
return siglum + ": " + readings.size() + " readings";
}
}
Monochromator
Ablenkungsfreies, monochromes Theme für VS Code, Zed, Helix und Neovim
PostMissam
Website für eine katholische Gemeinschaft in Salzburg