Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blueset committed Dec 22, 2019
0 parents commit 913b1d6
Show file tree
Hide file tree
Showing 20 changed files with 648 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The MIT License (MIT)
=====================

Copyright © 2019 Eana Hufwe <https://1a23.com>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Search Unicode
Search Unicode is an Alfred 4 Workflow to lookup and reverse lookup Unicode
characters and emoji with their names.

## Download
Download it at the [release page](https://github.com/blueset/alfred-search-unicode/releases).

You need to install Python 3 on your macOS in order for this to work.
You can install that with [Homebrew] using the command below:

```sh
brew install python
```

[Homebrew]: https://brew.sh/

## Usage
### Search character by description

![Screenshot for command u superscript](images/u_superscript.png)

Type `u keyword` (ex. `u superscript`) to get a list of characters
matching the keyword.
- Press <kbd>Return</kbd> to copy the character to clipboard (ex. ``)
- Press <kbd>Cmd</kbd> + <kbd>Return</kbd> to copy its Hex code to clipboard (ex. `U+2070`)
- Press <kbd>Option</kbd> + <kbd>Return</kbd> to copy its name to clipboard (ex. `Superscript Zero`)

### Search character by code point

![Screenshot for command u fffd ff10](images/u_fffd_ff10.png)

Type `u codepoint [[codepoint] ...]` (ex. `u fffd ff10`) to look up characters by its codepoint.

The same 3 options apply here too.


### Search emoji by name

![Screenshot for command e face](images/e_face.png)

Type `e keywords` (ex. `e face`) to look up characters by its codepoint. Press <kbd>Return</kbd> to copy the character to clipboard (ex. `😀`)


### Identify characters in a string

![Screenshot for command uid lenny face](images/uid_lenny.png)

Type `uid string` (ex. `uid ( ͡° ͜ʖ ͡°)`) to identify characters in a string.

For the first 4 rows (hex sequence, integer sequence, UTF-8 sequence and XML escape sequence):
- Press <kbd>Return</kbd> to copy the sequence to clipboard (ex. `28 20 0361 B0 20 035C 0296 20 0361 B0 29`)

For the following rows that identifies each individual characters:
- Press <kbd>Cmd</kbd> + <kbd>Return</kbd> to copy its Hex code to clipboard (ex. `U+2070`)
- Press <kbd>Option</kbd> + <kbd>Return</kbd> to copy its name to clipboard (ex. `Superscript Zero`)

# Credit
This workflow depends on resources from:
- [arp242/uni] 1.0.0 with Unicode 12.1 Data
- [Twemoji] 12.1.4 for emoji preview

[arp242/uni]: https://github.com/arp242/uni
[Twemoji]: https://twemoji.twitter.com/

# License

Copyright 2019 Eana Hufwe <https://1a23.com>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alfred-search-unicode/emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions alfred-search-unicode/emoji_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/local/bin/python3
"""
Search for Unicode 12.1 Emoji Descriptions
uni binary from: https://github.com/arp242/uni
Twemoji updated to 12.1.4
"""

import sys
import re
import subprocess
import json
import unicodedata
from pathlib import Path

if len(sys.argv) >= 2:
query = sys.argv[1]

try:
out: str = subprocess.check_output(
["./uni", "-q", "emoji", query]).decode()

out = out.strip().splitlines()
except subprocess.CalledProcessError:
out = []

else:
out = []

data = []

for i in out[:20]:
match = re.match(
r"^([^ ]+?) (.+?) +(.+?) +(.+?)$", i)
if not match:
continue
char, name, cat, sub_cat = match.groups()

lookup_char = char.replace('\ufe0f', '')
hexes = tuple(hex(ord(i))[2:].lower() for i in lookup_char)
lookup_sequence = "-".join(hexes)
uid = "_".join(hexes)
c_hex = " ".join(f"U+{i.upper()}" for i in hexes)
name = name.title()

p = Path(f"twemoji/{lookup_sequence}.png")
if p.exists():
icon_path = str(p)
else:
icon_path = "emoji.png"

data.append({
"uid": f"emoji_{lookup_sequence}",
"title": f"{char}{name}",
"subtitle": f"{c_hex}: {cat}, {sub_cat}",
"arg": char,
"text": {
"copy": char,
"largetype": char
},
"icon": {
"path": icon_path
}
})

json.dump({"items": data}, sys.stdout)
Binary file added alfred-search-unicode/hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alfred-search-unicode/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 913b1d6

Please sign in to comment.