diff options
| author | navewindre <boneyaard@gmail.com> | 2025-07-18 07:49:32 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-07-18 07:49:32 +0200 |
| commit | 79e37269a7340fb13398c6819cead149ed9c0748 (patch) | |
| tree | e57b81220bd3404dd15399a81b5dd48e86894a9c | |
| parent | 3705cf352266bacb7eb9e40bb7921f9d4e8741d8 (diff) | |
| -rw-r--r-- | src/main.zig | 12 | ||||
| -rwxr-xr-x | zjisho-clipboard | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index 62d3fa4..65035e3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -9,14 +9,13 @@ const JishoData = struct { slug: []const u8, japanese: []struct { word: []const u8, - reading: []const u8, + reading: ?[]const u8 = null, }, senses: []struct { english_definitions: [][]const u8 }, }; - meta: struct { status: u32 }, data: []DataEntry, }; @@ -58,7 +57,14 @@ fn formatDef( buf: []u8, data: *JishoData.DataEntry, definition_count: u32, sens return error.NotJapanese; } - const wordb = try z.fmt.bufPrint( buf, "{s}({s}) - ", .{ data.japanese[0].word, data.japanese[0].reading } ); + var wordb: []const u8 = undefined; + if( data.japanese[0].reading == null ) { + wordb = try z.fmt.bufPrint( buf, "{s} - ", .{ data.japanese[0].word } ); + } + else { + wordb = try z.fmt.bufPrint( buf, "{s}({s}) - ", .{ data.japanese[0].word, data.japanese[0].reading.? } ); + } + var len = wordb.len; var engb: []const u8 = buf[len..]; for( data.senses, 0.. ) |sense, i| { diff --git a/zjisho-clipboard b/zjisho-clipboard new file mode 100755 index 0000000..f9953d6 --- /dev/null +++ b/zjisho-clipboard @@ -0,0 +1,4 @@ +#!/bin/sh + + +xclip -selection clipboard -o | xargs zjisho | xclip -selection clipboard |
