Allow unicode characters in custom button command names
parent
da2a02693d
commit
e73e11d554
|
@ -18,7 +18,7 @@
|
||||||
import cmd, printcore, sys
|
import cmd, printcore, sys
|
||||||
import glob, os, time
|
import glob, os, time
|
||||||
import sys, subprocess
|
import sys, subprocess
|
||||||
import math
|
import math, codecs
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
import gettext
|
import gettext
|
||||||
if os.path.exists('/usr/share/pronterface/locale'):
|
if os.path.exists('/usr/share/pronterface/locale'):
|
||||||
|
@ -492,7 +492,7 @@ class pronsole(cmd.Cmd):
|
||||||
def load_rc(self,rc_filename):
|
def load_rc(self,rc_filename):
|
||||||
self.processing_rc=True
|
self.processing_rc=True
|
||||||
try:
|
try:
|
||||||
rc=open(rc_filename)
|
rc=codecs.open(rc_filename,"r","utf-8")
|
||||||
self.rc_filename = os.path.abspath(rc_filename)
|
self.rc_filename = os.path.abspath(rc_filename)
|
||||||
for rc_cmd in rc:
|
for rc_cmd in rc:
|
||||||
if not rc_cmd.lstrip().startswith("#"):
|
if not rc_cmd.lstrip().startswith("#"):
|
||||||
|
@ -534,8 +534,8 @@ class pronsole(cmd.Cmd):
|
||||||
if os.path.exists(self.rc_filename):
|
if os.path.exists(self.rc_filename):
|
||||||
import shutil
|
import shutil
|
||||||
shutil.copy(self.rc_filename,self.rc_filename+"~bak")
|
shutil.copy(self.rc_filename,self.rc_filename+"~bak")
|
||||||
rci=open(self.rc_filename+"~bak","r")
|
rci=codecs.open(self.rc_filename+"~bak","r","utf-8")
|
||||||
rco=open(self.rc_filename,"w")
|
rco=codecs.open(self.rc_filename,"w","utf-8")
|
||||||
if rci is not None:
|
if rci is not None:
|
||||||
overwriting = False
|
overwriting = False
|
||||||
for rc_cmd in rci:
|
for rc_cmd in rci:
|
||||||
|
|
|
@ -1940,16 +1940,26 @@ class ButtonEdit(wx.Dialog):
|
||||||
def macrob_enabler(self,e):
|
def macrob_enabler(self,e):
|
||||||
macro = self.command.GetValue()
|
macro = self.command.GetValue()
|
||||||
valid = False
|
valid = False
|
||||||
|
try:
|
||||||
if macro == "":
|
if macro == "":
|
||||||
valid = True
|
valid = True
|
||||||
elif self.pronterface.macros.has_key(macro):
|
elif self.pronterface.macros.has_key(macro):
|
||||||
valid = True
|
valid = True
|
||||||
elif hasattr(self.pronterface.__class__,"do_"+macro):
|
elif hasattr(self.pronterface.__class__,u"do_"+macro):
|
||||||
valid = False
|
valid = False
|
||||||
elif len([c for c in macro if not c.isalnum() and c != "_"]):
|
elif len([c for c in macro if not c.isalnum() and c != "_"]):
|
||||||
valid = False
|
valid = False
|
||||||
else:
|
else:
|
||||||
valid = True
|
valid = True
|
||||||
|
except:
|
||||||
|
if macro == "":
|
||||||
|
valid = True
|
||||||
|
elif self.pronterface.macros.has_key(macro):
|
||||||
|
valid = True
|
||||||
|
elif len([c for c in macro if not c.isalnum() and c != "_"]):
|
||||||
|
valid = False
|
||||||
|
else:
|
||||||
|
valid = True
|
||||||
self.macrob.Enable(valid)
|
self.macrob.Enable(valid)
|
||||||
def macrob_handler(self,e):
|
def macrob_handler(self,e):
|
||||||
macro = self.command.GetValue()
|
macro = self.command.GetValue()
|
||||||
|
|
Loading…
Reference in New Issue