Commit 39fe99cd authored by Ivan Denisov's avatar Ivan Denisov
Browse files

добавил скрипт установки, иконку и поддержку Cortex-M3 компилятора

parent b835f61b
*~
*.pyc
Encoding of this file is KOI8-R
Простой текстовый (р)едактор в первую очередь для языков программирования семейства (О)берон с (п)роверкой (с)интаксиса
()
()
() ()
This is a simple text editor
first of all for Oberon-family programming languages
with syntax checking
This is a simple text editor first of all for Oberon-family programming languages with syntax checking
ROPS is transliterated abbreviation
Alexander Shiryaev, 2010-2013
Alexander Shiryaev, 2010–2014
Простой текстовый (р)едактор
в первую очередь для языков программирования семейства (О)берон
с (п)роверкой (с)интаксиса
This is a simple text editor
first of all for Oberon-family programming languages
with syntax checking
ROPS is transliterated abbreviation
Alexander Shiryaev, 2010-2013
#!/bin/sh
if [ ! -f '/usr/lib/libgtksourceview-2.0.so.0' ]; then
sudo apt-get install libgtksourceview2.0
fi
if [ ! -f '/usr/lib/pyshared/python2.7/gtksourceview2.so' ]; then
sudo apt-get install python-gtksourceview2
fi
mkdir -p $HOME'/.local/share/gtksourceview-2.0/language-specs/'
mkdir -p $HOME'/.local/share/gtksourceview-2.0/styles/'
if [ ! -f $HOME'/.local/share/gtksourceview-2.0/language-specs/oberon.lang' ]; then
cp $PWD'/oberon.lang' $HOME'/.local/share/gtksourceview-2.0/language-specs/'
fi
if [ ! -f $HOME'/.local/share/gtksourceview-2.0/language-specs/zonnon.lang' ]; then
cp $PWD'/zonnon.lang' $HOME'/.local/share/gtksourceview-2.0/language-specs/'
fi
if [ ! -f $HOME'/.local/share/gtksourceview-2.0/styles/strict.xml' ]; then
cp $PWD'/strict.xml' $HOME'/.local/share/gtksourceview-2.0/styles/'
fi
if [ -L '/usr/bin/rops' ]; then
sudo rm '/usr/bin/rops'
fi
sudo ln -s $PWD'/rops/ide.py' '/usr/bin/rops'
sudo chmod +x '/usr/bin/rops'
if [ -f $HOME'/.local/share/applications/rops.desktop' ]; then
rm $HOME'/.local/share/applications/rops.desktop'
fi
echo '[Desktop Entry]' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Encoding=UTF-8' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Name=Rops' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Comment=Source code editor for Oberon family languages.' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Exec=rops' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Icon='$PWD'/logo.png' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Categories=Development' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Version=1.0' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Type=Application' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Terminal=0' >> $HOME'/.local/share/applications/rops.desktop'
echo 'Name[ru_RU]=РОПС' >> $HOME'/.local/share/applications/rops.desktop'
echo '' >> $HOME'/.local/share/applications/rops.desktop'
chmod 664 $HOME'/.local/share/applications/rops.desktop'
if [ -f $HOME'/.local/share/mime/packages/x-oberon.xml' ]; then
rm $HOME'/.local/share/mime/packages/x-oberon.xml'
fi
echo "<?xml version='1.0'?>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo "<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo " <mime-type type='text/x-oberon'>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo " <comment>Oberon source code</comment>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo " <glob pattern='*.mod'/>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo " </mime-type>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
echo "</mime-info>" >> $HOME'/.local/share/mime/packages/x-oberon.xml'
update-mime-database $HOME'/.local/share/mime'
echo 'text/x-oberon=rops.desktop;' >> $HOME'/.local/share/applications/mimeapps.list'
exit
logo.png

17.6 KB

#! /usr/bin/env python2.7
# -*- coding: koi8-r -*-
# -*- coding: utf-8 -*-
# Alexander Shiryaev, 2010-2012
#
# IMPLEMENTATION NOTES:
# (locale.getpreferredlocale())
# gtk.TextView unicode
# имена файлов храним в кодировке системы (locale.getpreferredlocale())
# текст gtk.TextView храним в unicode
import pygtk
pygtk.require('2.0')
......@@ -218,8 +218,8 @@ def importText (prof, encodedText, parent):
assert not prof.has_key('preferredFileEncoding')
text = prof['import'](encodedText)
# ,
# ,
# знать кодировку при явном импорте в дальнейшем не нужно,
# потому что в этом случае экспорт тоже должен быть явным, а для него знать кодировку при импорте не нужно
encoding = None
autoDetected = False
else:
......@@ -515,7 +515,7 @@ def setCursorPos (textView, line, col):
it.forward_chars(col)
buffer.place_cursor(it)
# textView.scroll_to_iter(it, ...) , (. gtk.TextView)
# textView.scroll_to_iter(it, ...) не пользуемся, потому что срабатывает не всегда (см. документацию gtk.TextView)
textView.scroll_to_mark(buffer.get_insert(), 0, use_align=True, xalign=1)
def restoreCurPos (fileName, textView):
......@@ -548,7 +548,7 @@ saveSettings = lambda settings: store.save(_settingsStoreName, settings)
def translateBuilder (builder):
for obj in builder.get_objects():
# , SeparatorMenuItem (- gtk pygtk)
# делаем так, потому что при попытке получения свойств по крейней мере у SeparatorMenuItem он исчезает (где-то ошибка в gtk или в pygtk)
if type(obj) in (gtk.Window, gtk.MenuItem, gtk.Label, gtk.Button, gtk.CheckButton):
if type(obj) is gtk.Window:
label = obj.get_title().decode('utf-8')
......@@ -581,8 +581,8 @@ def detectLineSep (text):
else:
return '\n'
# ( )
# gtk.TextView
# разделить такст на строки (в тексте могут использоваться разные разделители строк)
# похоже совпадает с алгоритмом разделения на строки gtk.TextView
def splitToLines (text):
lines = []
for l in text.split('\r\n'):
......@@ -712,7 +712,7 @@ class Application:
buffer = self.srcTextView.get_buffer()
buffer.place_cursor(matchStart)
# textView.scroll_to_iter(it, ...) , (. gtk.TextView)
# textView.scroll_to_iter(it, ...) не пользуемся, потому что срабатывает не всегда (см. документацию gtk.TextView)
self.srcTextView.scroll_to_mark(buffer.get_insert(), 0, use_align=True)
buffer.select_range(matchStart, matchEnd)
......@@ -804,7 +804,7 @@ class Application:
def on_entry1_key_press_event (self, widget, event):
# if Trace: print 'on find entry key press:', event
if event.keyval == gtk.keysyms.Tab:
# TAB
# вставляем символ TAB вместо смены фокуса
pos = widget.get_position()
widget.insert_text( '\t', position=pos )
widget.set_position(pos + 1)
......@@ -813,7 +813,7 @@ class Application:
def on_entry2_key_press_event (self, widget, event):
# if Trace: print 'on replace entry key press:', event
if event.keyval == gtk.keysyms.Tab:
# TAB
# вставляем символ TAB вместо смены фокуса
pos = widget.get_position()
widget.insert_text( '\t', position=pos )
widget.set_position(pos + 1)
......@@ -1263,11 +1263,11 @@ def main ():
setTrLang( x.split('_')[0] )
if gtk.gdk.get_display() != None:
# 4 :
# 1)
# 2)
# 3)
# 4)
# 4 варианта начала работы:
# 1) запустили без параметров для создания нового файла
# 2) запустили без параметров для открытия нового файла
# 3) запустили для открытия заданного файла
# 4) запустили для создания заданного файла
if len(sys.argv) == 2:
fileName = sys.argv[1]
prof = getProf(None, fileName)
......
# -*- coding: koi8-r -*-
# -*- coding: utf-8 -*-
# Alexander Shiryaev, 2010-2013
import compiler, re, subprocess, os, sys, locale, tempfile, time, errno
......@@ -43,7 +43,7 @@ def setnonblock (fd):
flags = flags | os.O_NONBLOCK
fcntl.fcntl(fd, fcntl.F_SETFL, flags)
# ģ (wine)
# не ждём завершения дочерних процессов (wine)
# not mswindows
def cmdPollOnly (args):
if Trace: print 'cmdPollOnly', args
......@@ -319,7 +319,7 @@ def dcc32Compile (text, encodedText, encoding, fileName):
return (msg, None, None)
o = dcc32FilterStdout(o)
# , , dcc32 ascii-
# указываем кодировку вывода такую же, как и кодировка содержимого файла, хотя скорее всего dcc32 использует только ascii-кодировку
msg = e + o.decode( encoding )
eLines = e.count('\n')
......@@ -550,7 +550,8 @@ def astrobeCompile (text, encodedText, encoding, fileName):
tryMono = True
if tryMono:
try:
e, o = cmdPollOnly(["env", "MONO_IOMAP=all", "mono", os.path.join(os.getenv('HOME'), "install", "Astrobe Professional Edition", "AstrobeCompile.exe"), fName])
# e, o = cmdPollOnly(["env", "MONO_IOMAP=all", "mono", os.path.join(os.getenv('HOME'), "install", "Astrobe Professional Edition", "AstrobeCompile.exe"), fName])
e, o = cmdPollOnly(["AstrobeCompileM3", fName])
isMono = True
except Exception, e:
msg = 'mono AstrobeCompile: ' + exMsg(e)
......@@ -591,6 +592,110 @@ def astrobeCompile (text, encodedText, encoding, fileName):
msg = u"'MODULE Ident;' expected"
return (msg, None, None)
# fileName may be None
def astrobeCompileM3 (text, encodedText, encoding, fileName):
assert type(text) is unicode
assert type(encodedText) is str
assert encoding != None
r = _pMod.match(text)
if r != None:
modName = r.group(1).encode('ascii')
baseName = modName + '.$$$'
if fileName == None:
fName = baseName
inCurDir = True
else:
d = os.path.dirname(fileName)
if (d == '') or sameFile(os.getcwd(), d):
fName = baseName
inCurDir = True
else:
fName = os.path.join(d, baseName)
inCurDir = False
if not os.path.exists(fName):
try: # for remove file fName
try:
util.writeFile( fName, encodedText.replace('\t', ' '), sync=False )
except Exception, e:
msg = tr('#File write error') + ': ' + exMsg(e)
return (msg, None, None)
isMono = False
if mswindows:
exe = os.path.join( os.getenv('ProgramFiles'), 'Astrobe Professional Edition', 'AstrobeCompile.exe' )
try:
e, o = cmd([exe, fName])
except Exception, e:
msg = 'AstrobeCompileM3: ' + exMsg(e)
return (msg, None, None)
else: # not mswindows
tryWine = False
if tryWine:
if not inCurDir:
ok, s = winePath(fName)
if not ok:
return (s, None, None)
else:
s = baseName
try:
e, o = cmdPollOnly(["wine", "C:\\Program Files\\Astrobe Professional Edition\\AstrobeCompile.exe", s])
tryMono = False
except Exception, e:
if e.errno == errno.ENOENT:
tryMono = True
else:
msg = 'wine AstrobeCompile: ' + exMsg(e)
return (msg, None, None)
else:
tryMono = True
if tryMono:
try:
# e, o = cmdPollOnly(["env", "MONO_IOMAP=all", "mono", os.path.join(os.getenv('HOME'), "install", "Astrobe Professional Edition", "AstrobeCompile.exe"), fName])
e, o = cmdPollOnly(["AstrobeCompileM3", fName])
isMono = True
except Exception, e:
msg = 'mono AstrobeCompileM3: ' + exMsg(e)
return (msg, None, None)
msg = e + o.decode( encoding )
eLines = e.count('\n')
errs = []
warns = []
i = eLines
if isMono:
sep = '\n'
else:
sep = '\r\n'
for l in o.split(sep):
r = _paLineCol.match(l + '\n')
if r:
line = int(r.group(1)) - 1
col = int(r.group(2)) - 1
pos = (line, col)
link = (i, pos)
m = r.group(4)
if r.group(3) == 'Warning':
warns.append(link)
else:
errs.append(link)
i = i + 1
return (msg, errs, warns)
finally:
try:
os.remove(fName)
except:
pass
else:
msg = "%s: %s %s %s!" % (tr('#Error'), tr('#file'), fName.decode(locale.getpreferredencoding()), tr('#already exists'))
return (msg, None, None)
else:
msg = u"'MODULE Ident;' expected"
return (msg, None, None)
def cCompile (text, encodedText, encoding, fileName):
assert type(text) is unicode
assert type(encodedText) is str
......@@ -671,7 +776,7 @@ def zcCompile (text, encodedText, encoding, fileName):
return (msg, errs, warns)
# example:
# 304 14/3 CRC8.mpas Syntax error: Expected "end" but "" found
# 304 14/3 CRC8.mpas Syntax error: Expected "end" but "п" found
_pmkpLineCol = re.compile("^(?:[0-9]+)\t([0-9]+)/([0-9]+)\t([^\t]+)\t([^\n]+)\n")
def mikroPascalCompile (text, encodedText, encoding, fileName):
......@@ -897,7 +1002,7 @@ def pyImport (encodedText):
encodedText = encodedText[3:]
encoding = 'utf-8'
else:
# ascii
# вообще должна быть ascii
encoding = locale.getpreferredencoding()
if Trace: print 'pyImportEncoding:', encoding
......@@ -1245,7 +1350,7 @@ dcc32 = {
'compile': dcc32Compile,
'preferredFileEncoding': winEncoding(),
'empty': delphiEmpty,
'lineSep': '\r\n', #
'lineSep': '\r\n', # не обязательно
}
fpc = {
......@@ -1255,7 +1360,7 @@ fpc = {
'compile': fpcCompile,
# 'preferredFileEncoding': winEncoding(),
'empty': delphiEmpty,
# 'lineSep': '\r\n', #
# 'lineSep': '\r\n', # не обязательно
}
astrobe = {
......@@ -1266,7 +1371,18 @@ astrobe = {
'compile': astrobeCompile,
'preferredFileEncoding': winEncoding(),
'empty': modObEmpty,
'lineSep': '\r\n', #
'lineSep': '\r\n', # не обязательно
}
astrobeM3 = {
'name': 'AstrobeM3/Oberon-07',
'lang': 'oberon', # gtksourceview
'style': ('strict',), # gtksourceview
'extensions': ('mod',),
'compile': astrobeCompileM3,
'preferredFileEncoding': winEncoding(),
'empty': modObEmpty,
'lineSep': '\r\n', # не обязательно
}
gpcp = {
......@@ -1276,7 +1392,7 @@ gpcp = {
'extensions': ('cp',),
'compile': gpcpCompile,
'empty': modObEmpty,
'lineSep': '\r\n', #
'lineSep': '\r\n', # не обязательно
}
mocka = {
......@@ -1385,7 +1501,7 @@ pyCoco = {
#}
profiles = (
oo2c, obc, astrobe, gpcp, zc, xcO2, xmO2, xcM2, xmM2, mocka, mikroPascal,
astrobe, astrobeM3, oo2c, obc, gpcp, zc, xcO2, xmO2, xcM2, xmM2, mocka, mikroPascal,
dcc32, fpc,
python, lua,
ocaml,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment