diff --git a/src/graphics.zig b/src/graphics.zig index 70a82c482..9768c43db 100644 --- a/src/graphics.zig +++ b/src/graphics.zig @@ -600,6 +600,12 @@ pub const TextBuffer = struct { // MARK: TextBuffer self.curChar = self.unicodeIterator.nextCodepoint() orelse return null; } + fn peekNextByte(self: *Parser) u8 { + const next = self.unicodeIterator.peek(1); + if(next.len == 0) return 0; + return next[0]; + } + fn parse(self: *Parser) void { self.curIndex = @intCast(self.unicodeIterator.i); self.curChar = self.unicodeIterator.nextCodepoint() orelse return; @@ -614,12 +620,21 @@ pub const TextBuffer = struct { // MARK: TextBuffer } }, '_' => { - self.appendControlGetNext() orelse return; - if(self.curChar == '_') { + if(self.peekNextByte() == '_') { + self.appendControlGetNext() orelse return; + self.appendControlGetNext() orelse return; + self.currentFontEffect.underline = !self.currentFontEffect.underline; + } else { + self.appendGetNext() orelse return; + } + }, + '~' => { + if(self.peekNextByte() == '~') { + self.appendControlGetNext() orelse return; self.appendControlGetNext() orelse return; self.currentFontEffect.strikethrough = !self.currentFontEffect.strikethrough; } else { - self.currentFontEffect.underline = !self.currentFontEffect.underline; + self.appendGetNext() orelse return; } }, '\\' => { diff --git a/src/gui/windows/change_name.zig b/src/gui/windows/change_name.zig index 1074fef4e..ba78c8a8e 100644 --- a/src/gui/windows/change_name.zig +++ b/src/gui/windows/change_name.zig @@ -40,7 +40,7 @@ pub fn onOpen() void { list.add(Label.init(.{0, 0}, width, "#ff0000Warning: #ffffffYou lose access to your inventory data when changing the name!", .center)); } list.add(Label.init(.{0, 0}, width, "Cubyz supports formatting your username using a markdown-like syntax:", .center)); - list.add(Label.init(.{0, 0}, width, "\\**italic*\\* \\*\\***bold**\\*\\* \\__underlined_\\_ \\_\\___strike-through__\\_\\_", .center)); + list.add(Label.init(.{0, 0}, width, "\\**italic*\\* \\*\\***bold**\\*\\* \\_\\___underlined__\\_\\_ \\~\\~~~strike-through~~\\~\\~", .center)); list.add(Label.init(.{0, 0}, width, "Even colors are possible, using the hexadecimal color code:", .center)); list.add(Label.init(.{0, 0}, width, "\\##ff0000ff#ffffff00#ffffff00#ff0000red#ffffff \\##ff0000ff#00770077#ffffff00#ff7700orange#ffffff \\##ffffff00#00ff00ff#ffffff00#00ff00green#ffffff \\##ffffff00#ffffff00#0000ffff#0000ffblue", .center)); textComponent = TextInput.init(.{0, 0}, width, 32, if(settings.playerName.len == 0) "quanturmdoelvloper" else settings.playerName, .{.callback = &apply});