Initial commit
commit
6371c76e68
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 muhdnurhidayat MNH48 <mnh48mail@gmail.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.
|
|
@ -0,0 +1,46 @@
|
|||
# Unicode Parser
|
||||
|
||||
## What is Unicode Parser
|
||||
Unicode Parser `unicodeparser` is a client-side mod (CSM) for [Minetest](https://www.minetest.net).
|
||||
It displays a window for you to write unicode codepoint then it will convert to
|
||||
real text string of that codepoint and send it out on public chat.
|
||||
|
||||
![The GUI](/images/thegui.png?raw=true "The GUI")
|
||||
|
||||
## Intended use
|
||||
|
||||
This CSM is used as a workaround of the inability to use Input Method Editors
|
||||
(IME) on Minetest, especially for Windows users as I could use IME on Android
|
||||
version of Minetest but not on Windows version.
|
||||
|
||||
This CSM could also be used by certain Ubuntu version users who couldn't paste
|
||||
text in Minetest (where the paste text appears as codepoints and not real text).
|
||||
|
||||
## How to use
|
||||
|
||||
### As workaround of IME
|
||||
|
||||
Run the included Python2 script under `tools` folder to write the usual text
|
||||
using your IME, click on "Convert" button, then copy (Ctrl-C) the output
|
||||
codepoint. In game, send `.ug` and a formspec will appear asking for input,
|
||||
paste (Ctrl-V) the codepoint and click on "Say".
|
||||
|
||||
### As workaround of paste problem
|
||||
|
||||
The codepoint appeared when you paste into Minetest itself is supposedly already
|
||||
in the same format needed by the CSM, so you don't need to run the Python2 script.
|
||||
Straight away send `.ug` in game and directly paste in the input, then click "Say".
|
||||
|
||||
## CSM in action
|
||||
![In Action](/images/inaction.gif?raw=true "In Action")
|
||||
|
||||
## To do
|
||||
|
||||
- Release C++ and Java version of the tool
|
||||
- Include translation support (which seems to be impossible right now because CSM can't access other files)
|
||||
|
||||
## License
|
||||
|
||||
(C) muhdnurhidayat (MNH48.com) and contributors
|
||||
|
||||
Licensed under The MIT License.
|
|
@ -0,0 +1 @@
|
|||
This client mod adds enable you to paste unicode escapes as real unicode into chat.
|
Binary file not shown.
After Width: | Height: | Size: 9.8 MiB |
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -0,0 +1,110 @@
|
|||
--[[
|
||||
_ _ __ _ _ _____ ______ _____ _____
|
||||
| | | | | \ | | | | | ___| | __ | | __ \ | ___|
|
||||
| | | | | \ | | | | | | | | | | | | \ \ | |___
|
||||
| | | | | |\ \| | | | | | | | | | | | | | | ___|
|
||||
| |_| | | | \ | | | | |___ | |__| | | |_ / / | |___
|
||||
|_____| |_| \__| |_| |_____| |______| |_____/ |_____|
|
||||
____ ____ ____ ______ _____ _____
|
||||
| _ \ / __ \ | _ \ / ____| | ___| | _ \
|
||||
| |_| | | |__| | | |_| | | |____ | |___ | |_| |
|
||||
| ___/ | __ | | _/ \____ \ | ___| | _/
|
||||
| | | | | | | |\ \ ____| | | |___ | |\ \
|
||||
|_| |_| |_| |_| \_\ |______/ |_____| |_| \_\
|
||||
|
||||
written by (C) 2018 muhdnurhidayat (MNH48.com) and contributors
|
||||
released under The MIT License
|
||||
--]]
|
||||
|
||||
-- Load support for intllib.
|
||||
--local S, NS = dofile("/intllib.lua")
|
||||
|
||||
--[[
|
||||
minetest.register_chatcommand("ut", {
|
||||
params = "",
|
||||
description = S("Unicode Text : Paste the unicode escape after the command, then enter to make it send in chat."),
|
||||
func = function(esccde)
|
||||
term = "return "..esccde
|
||||
return pcall(loadstring(esccde))
|
||||
end,
|
||||
})
|
||||
--]]
|
||||
|
||||
minetest.register_chatcommand("ug", {
|
||||
--description = S("Open the GUI to paste unicode escape, then press \"Say\" to send in chat."),
|
||||
description = "Open the GUI to paste unicode escape, then press \"Say\" to send in chat.",
|
||||
func = function(name, escuni)
|
||||
minetest.show_formspec("unicodeparser:upgui",
|
||||
"size[6,3]" ..
|
||||
"field[1,1;5,2;text;Input the unicode escape;]"..
|
||||
"button_exit[2,2;2,1;say;Say]")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_formspec_input(function(formname, fields)
|
||||
if formname ~= "unicodeparser:upgui" then
|
||||
return false
|
||||
end
|
||||
|
||||
local allinput=half(fields.text,"\\")
|
||||
|
||||
local toProcess = {}
|
||||
if allinput == nil then
|
||||
return false
|
||||
else
|
||||
for i,line in ipairs(allinput) do
|
||||
local lineTemp = utf8(tonumber(line))
|
||||
table.insert(toProcess,lineTemp)
|
||||
end
|
||||
local finalOut = table.concat(toProcess)
|
||||
minetest.send_chat_message(finalOut)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
function half(inStr, inToken)
|
||||
if inStr == nil then
|
||||
return nil
|
||||
else
|
||||
local TableWord = {}
|
||||
local fToken = "(.-)" .. inToken
|
||||
local l_end = 1
|
||||
local w, t, halfPos = inStr:find(fToken, 1)
|
||||
while w do
|
||||
if w ~= 1 or halfPos ~= "" then
|
||||
table.insert(TableWord,halfPos)
|
||||
end
|
||||
l_end = t+1
|
||||
w, t, halfPos = inStr:find(fToken, l_end)
|
||||
end
|
||||
if l_end <= #inStr then
|
||||
halfPos = inStr:sub(l_end)
|
||||
table.insert(TableWord, halfPos)
|
||||
end
|
||||
return TableWord
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local string_char = string.char
|
||||
function utf8(codep)
|
||||
if codep < 128 then
|
||||
return string_char(codep)
|
||||
end
|
||||
local s = ""
|
||||
local max_pf = 32
|
||||
while true do
|
||||
local suffix = codep % 64
|
||||
s = string_char(128 + suffix)..s
|
||||
codep = (codep - suffix) / 64
|
||||
if codep < max_pf then
|
||||
return string_char((256 - (2 * max_pf)) + codep)..s
|
||||
end
|
||||
max_pf = max_pf / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local msg = "[unicodeparser] CSM loaded."
|
||||
minetest.log("info", msg)
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
|
@ -0,0 +1,93 @@
|
|||
from Tkinter import Tk, StringVar
|
||||
import tkMessageBox
|
||||
import ttk
|
||||
from Tkinter import *
|
||||
|
||||
## THIS PYTHON CODE IS WRITTEN IN PYTHON 2.7.12, PLEASE CONVERT IT TO PYTHON 3 USING ONLINE CONVERTER FIRST IF YOU'RE
|
||||
## USING PYTHON 3.x BECAUSE A LOT OF LIBRARY HAS BEEN CHANGED SINCE PYTHON 3 CAME OUT. THANK YOU. -warned by Hidayat-
|
||||
|
||||
#### -- (1) DECLARATIONS -- ###
|
||||
##---------------Declare the container
|
||||
root = Tk() ## Declare GUI object
|
||||
root.wm_attributes("-topmost", 1) ## Make it stay topmost
|
||||
winwidth = 450 ## Declare window width
|
||||
winheight = 97 ## Declare window height
|
||||
screenwidth = root.winfo_screenwidth() ## Get current display screen width
|
||||
screenheight = root.winfo_screenheight() ## Get current display screen height
|
||||
coorx = (screenwidth/2) - (winwidth/2) ## Calculate x-coordinate for center position
|
||||
coory = (screenheight/2) - (winheight/2) ## Calculate y-coordinate for center position
|
||||
root.title("UTF-8 Codepoint Converter") ## Declare main title
|
||||
root.geometry('%dx%d+%d+%d' % (winwidth,winheight,coorx,coory)) ## Ask python to display window at specified size and position
|
||||
root.configure(background='grey') ## Declare main background
|
||||
|
||||
##[1]---------------Declare the frames inside container
|
||||
TopMainFrame = Frame(root, width=450, height=7, bg="grey", bd=8)
|
||||
TopMainFrame.pack(side=TOP)
|
||||
CenterMainFrame = Frame(root, width=450, height=90, bg="white", bd=8, relief="ridge")
|
||||
CenterMainFrame.pack(side=TOP, expand=TRUE)
|
||||
|
||||
##[1]---------------Declare values needed to use
|
||||
convertvalue = StringVar() ## Character to be convert
|
||||
tempvalue = StringVar() ## Store temp result
|
||||
resultvalue = StringVar() ## Store result of converted codepoint
|
||||
|
||||
#### -- (2) DEFINITIONS -- ####
|
||||
##[2]---------------Define convert resultvalue function
|
||||
def conUnicode():
|
||||
tempvalue = " "
|
||||
for i, c in enumerate(convertvalue.get()):
|
||||
tempvalue = tempvalue+"\\" + str(hex(ord(c)))
|
||||
resultvalue.set(tempvalue)
|
||||
|
||||
##[2]---------------Define what to do for info button action
|
||||
def ShowInfo():
|
||||
tkMessageBox.showinfo("UTF-8 Codepoint Converter","Unicode UTF-8 Codepoint Converter\n"+
|
||||
"Intended to use with the Minetest client-side mod \"UnicodeParser\"\n\n"+
|
||||
"Python script is\n(C) 2018 muhdnurhidayat (MNH48.com) and contributors\n"+
|
||||
"Available under The MIT License.\n")
|
||||
|
||||
##[2]---------------Define what to do for exit button action
|
||||
def AskExit():
|
||||
AskExit=tkMessageBox.askyesno("Exit System","Do you want to quit?")
|
||||
if AskExit>0:
|
||||
root.destroy()
|
||||
return
|
||||
|
||||
##[2]---------------Define what to do for reset button action
|
||||
def Reset():
|
||||
convertvalue.set(" ")
|
||||
resultvalue.set(" ")
|
||||
|
||||
#### -- (3) MAIN CLASS OF THE PROGRAM -- ####
|
||||
##[3]---------------Put buttons into top frames
|
||||
btnInfo = Button(TopMainFrame, text='Info', padx=1, pady=1, bd=1, bg="grey", fg="black",
|
||||
activebackground="grey", font=('arial', 10, 'normal'), width=8, height=1, command=ShowInfo, relief="raise")
|
||||
btnInfo.grid(row=0,column=0)
|
||||
btnConvert = Button(TopMainFrame, text='Convert', padx=1, pady=1, bd=1, bg="grey", fg="black",
|
||||
activebackground="grey", font=('arial', 10, 'normal'), width=8, height=1, command=conUnicode, relief="raise")
|
||||
btnConvert.grid(row=0,column=1)
|
||||
btnReset = Button(TopMainFrame, text='Reset', padx=1, pady=1, bd=1, bg="grey", fg="black",
|
||||
activebackground="grey", font=('arial', 10, 'normal'), width=8, height=1, command=Reset, relief="raise")
|
||||
btnReset.grid(row=0,column=2)
|
||||
btnExit = Button(TopMainFrame, text='Exit', padx=1, pady=1, bd=1, bg="grey", fg="black",
|
||||
activebackground="grey", font=('arial', 10, 'normal'), width=8, height=1, command=AskExit, relief="raise")
|
||||
btnExit.grid(row=0,column=3)
|
||||
|
||||
##[3]---------------Put text "input" into center frame
|
||||
lblInput= Label (CenterMainFrame,font=('arial',10,'bold'), text='Input:', padx=1, pady=1, bd=1, fg="black", bg="white", width=10)
|
||||
lblInput.grid(row=0,column=0)
|
||||
|
||||
##[3]---------------Put user input textbox into center frame
|
||||
EntInput = Entry(CenterMainFrame,font=('arial',10,'bold'), textvariable=convertvalue, bd=1, fg="orange", width=50, justify='center')
|
||||
EntInput.grid(row=0,column=1)
|
||||
|
||||
##[3]---------------Put text "output" into center frame
|
||||
lblOut= Label (CenterMainFrame,font=('arial',10,'bold'), text='Output:', padx=1, pady=1, bd=1, fg="black", bg="white", width=10)
|
||||
lblOut.grid(row=1,column=0)
|
||||
|
||||
##[3]---------------Put the converted output text into the center frame
|
||||
EntOutput = Entry(CenterMainFrame,font=('arial',10,'bold'), textvariable=resultvalue, bd=1, fg="orange", width=50, justify='center', state='readonly', exportselection='true')
|
||||
EntOutput.grid(row=1,column=1)
|
||||
|
||||
##[3]---------------Make sure program GUI continues to run unless exited
|
||||
root.mainloop()
|
Loading…
Reference in New Issue