[[oktatas:programozás:Programok|< Programok]] ====== Scite ====== * **Szerző:** Sallai András * Copyright (c) Sallai András, 2011, 2012, 2013, 2014 * Licenc: GNU Free Documentation License 1.3 * Web: http://szit.hu ===== Bevezetés ===== A Scite egy Scintilla alapú fejlesztői környezet, amelyet több programozási nyelv használatához készítettek. Egyszerű szövegszerkesztő felületet kapunk, de a beállítási lehetőségek bőséges tárházát kapjuk. Lua programozási nyelven saját scripteket is illeszthetünk a szerkesztőhöz. Telepítés nélkül is használható, több platformos. ===== Scintilla ===== A Scintilla egy programozói komponens-gyűjtemény, amelyet fejlesztői eszközök létrehozására találtak ki. Weblapja: * http://www.scintilla.org A weblapján a következőt olvashatjuk: "A free source code editing component for Win32 and GTK+" Ezt úgy fordíthatnák: Szabad forráskódú szerkesztői komponens gyűjtemény Windows és GTK+ alapú felületek számára. A Scintilla weblapján a menük egyik a Scite menüpont. De közvetlen link: * http://www.scintilla.org/SciTE.html ===== Beszerzés ===== FreePascal, C, Java, C# és más fordítok számára fejlesztői környezet: * http://www.scintilla.org/SciTE.html Scite magyarítás (és sok más nyelv): * https://code.google.com/p/scite-files/wiki/Translations ===== A Scite használata ===== Egy fejlesztő eszköz, vagyis egy speciális szövegszerkesztő. Előnye a könnyen scriptelhetősége, beállíthatósága. A Scite több programozási nyelvet is ismer. Hogy éppen milyen programozási nyelvet használunk azt a kiterjesztésből próbálja eldönteni. Ezért fordítás előtt mindenképpen menteni kell. A Scite alapból használni képes azokat a fordítókat, amelyek útvonalba vannak. Ha egy fordító nincs útvonalba, és nem is tudjuk útvonalba tenni, akkor megmondhatjuk számára, hol található az adott fordító. ===== A Scite beállítási ===== A Scite program minden nyelvnek külön beállításállományt tart fenn, kivéve talán a C alapú nyelvek. Ezek a cpp.properties állományban találjuk. Ide tartozik a Java és a C# is. * fortran.properties * cpp.properties * pascal.properties * asm.properties * stb. Ezeken kívül van két beállításfájl: * SciTEGlobal.properties * SciTEUser.properties Ez utóbbiak felülírják az előzőeket, a User pedig felülírja a Global beállításokat. Ezek az állományok elérhetők a Scite Beállítás menüjéből. ===== Magyar nyelv ===== A Scite elve több nyelvű, és magyar nyelvre is lefordították, de a magyar nyelvű csomagot alapból nem tartalmazza. A magyar nyelvű csomag azonban a weblapjáról letölthető. * http://code.google.com/p/scite-files/wiki/Translations A letöltés, kicsomagolás után az egyik konfigurációs állományba jelezni kell hova tettük a fordítást. A következő sort kell beilleszteni: locale.properties=locale.hu.properties Persze itt azt feltételezem, hogy a locale.hu.properties állományt a Scite saját könyvtárába tetted. ===== A Scite beállítások szintaxisa ===== Szintaxis: valtozonev = ertek Bármely változónévre hivatkozok így: $(valtozonev) Vannak olyan változók, amelyekből kinyerhető a Scite aktuális útvonala: $(SciteDefaultHome) Ezt beilleszthetjük saját útvonalunkba. Ha készítettünk például a Scite könyvtárán belül egy "bin" könyvtárat, akkor így hivatkozhatok rá: $(SciteDefaultHome)\bin A C# fordító parancs például így kezdődik: command.compile.*.cs= Hogyan szeretnénk fordítani az egyenlőség jel után kell leírni. Egy fordító parancs kompletten: command.compile.*.cs=$(csharpc) /t:exe $(FileNameExt) /r:system.dll,system.drawing.dll Futtatás például: command.go.*.cs=cmd /C $(FileName) & pause ===== Ajánlott beállítások ===== Az alábbi beállításokhoz kattintsunk a következő helyre: Options -> User Options Mentsük el, és indítsuk újra a Scite programot. A beállítások között van négy olyan, amelyik egy másik állományra vagy programra hivatkozik. Ezeket a helyükre kell másolni, az adott beállítás csak akkor működik. ==== Windows ==== # Speciális beállítások Javahoz toolbar.visible=1 position.left=150 position.top=22 position.width=1000 position.height=600 tabsize=4 use.tabs = 0 indent.size = 4 tab.indents = 1 indent.automatic=1 save.recent=1 line.margin.visible=1 clear.before.execute=0 magnification=4 output.magnification=4 autocompleteword.automatic=1 browser=firefox #command.help.*.java=$(browser) http://szit.hu command.help.*.java=$(browser) "file://$(SciteDefaultHome)\help\index.html command.build.*.c=gcc -o $(FileName) $(FileNameExt) command.go.subsystem.*.c=2 command.go.*.c=cmd /C $(FileName) command.go.needs.*.c=gcc -o $(FileName) $(FileNameExt) command.go.subsystem.*.java=2 command.go.*.java=cmd /C "java $(FileName)" command.go.needs.*.java=javac $(FileNameExt) command.name.0.*=Java alap 1 command.subsystem.0.*=3 command.0.*=dofile $(SciteDefaultHome)\lua\javamin.lua command.name.1.*=Java alap 2 command.subsystem.1.*=3 command.1.*=dofile $(SciteDefaultHome)\lua\javamin2.lua # Az astyle prancsot telepíteni kell, útvonalba kell helyezni. command.name.2.*=AStyle command.subsystem.2.*=0 command.2.*=$(SciteDefaultHome)\bin\astyle -b $(FileNameExt) command.shortcut.2.*=Alt+a command.save.before.2.*=1 command.is.filter.2.*=1 load.on.activate=1 #A Java számára külön rövidítések abbreviations.*.java=java_abbrev.properties # Windows alatt a Scite könyvtárába másoltam locale.properties=locale.hu.properties # UTF-8 =65001 lenne code.page=0 output.code.page=0 ==== Linux ==== position.left=150 position.top=22 position.width=1000 position.height=600 tabsize=4 use.tabs = 0 indent.size = 4 tab.indents = 1 indent.automatic=1 save.recent=1 line.margin.visible=1 clear.before.execute=0 magnification=4 output.magnification=4 autocompleteword.automatic=2 command.help.*.java=epiphany http://szit.hu command.go.subsystem.*.java=1 command.go.*.class=java $(FileName) command.go.needs.*.java=javac $(FileNameExt); command.name.1.*=C alap command.subsystem.1.*=3 command.1.*=dofile /home/andras/tervek/lua/elso/main.lua # Az astyle prancsot telepíteni kell, útvonalba kell állítani. command.name.2.*=AStyle command.subsystem.2.*=0 command.2.*=astyle -b $(FileNameExt) command.shortcut.2.*=Alt+a command.save.before.2.*=1 command.is.filter.2.*=1 load.on.activate=1 #Rövidítések abbreviations.*.java=/home/andras/.scite/java_abbrev.properties # Ide másoltam: /usr/share/scite/locale.hu.properties # Windows alatt a Scite könyvtárába kerül locale.properties=locale.hu.properties # UTF-8 =65001 code.page=65001 output.code.page=65001 ==== Rövidítések ==== /home/andras/.scite/java_abbrev.properties for=for(i = 0; i < 10; i++) Sys=System.outprintln(" Írd be a Scite szerkesztőbe: for Nyomd le a következő billentyűkombinációt: Ctrl+b A forrást kiegészíti. Dokumentáció: * http://www.scintilla.org/SciTEDoc.html ==== Kiegészítéshez és tipekhez ==== api.*.java=$(SciteDefaultHome)\java160.api api.*.cs=$(SciteDefaultHome)\cs.api A tippek azok automatikusak ha zárójelet írunk. A kiegészítés Ctrl + Szóközzel vagy Ctrl + i -vel működik. Írjuk be például: StringB majd nyomjunk Ctrl + szóközt. ==== Egyéb hasznos beállítás ==== Szelekció: selection.alpha=75 Eseltleg: selection.back=#333333 selection.fore=#000000 ===== A Scite programozása Lua nyelven ===== Az alábbiakban egy egyszerű lua programot építünk a Scite programunkba, amely beszúr egy C alap forráskódot. A User Options fájlba: command.name.1.*=C alap command.subsystem.1.*=3 command.1.*=dofile /home/andras/bin/beszur.lua Windows alatt az utolsó sor: command.1.*=dofile c:\bin\beszur.lua Elkészítem Lua nyelven a forrást: /home/andras/bin/beszur.lua -- C beszúrás editor:append("#include \n\nmain()\n{\n\t\tprintf(\"Helló\");\n}") Ha készen van, nyissunk egy új fájlt, majd Eszközök menüben keressük meg a "C alap" nevű menüpontot és futtassuk (Vagy Ctrl+1. A lua nyelvről: * http://www.lua.org/manual/5.1/ A lua és a scite: * http://lua-users.org/wiki/SciteExtMan * http://www.scintilla.org/SciTELua.html ===== Tapasztalat ===== A SciTE alapból felismeri a FreePascal fordítót ha az útvonalban van, nem kell beállítani benne semmit. Elindítjuk és rögtön használható a freepascal fordító, a lefordított program is azonnal futtatható egy billentyűkombinációval, vagy két kattintással. A hibaüzeneteket alapból elfogja és oldalt egy keretben megjeleníti. FreePascal mellett ideális fejlesztőeszköz! Használata kényelmes fejlesztés tesz lehetővé Pascal nyelven. ===== Scite-debug ===== * http://scitedebug.luaforge.net * http://luaforge.net/frs/?group_id=327 ===== Parancssori ékezetek ===== Windows alatt a parancssor felülete más kódrendszerű mint a grafikus felület. Ez ékezetes problémákat okoz. Ezért be kell állítanunk a regisztriben 852 kódlap helyett az 1250-est. Kódlap beállítása: \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ OEMCP=1250 ===== Scite beállítása FreeBASIC-hez ===== A következő sorokat másoljuk a Beállítások -> User Options vagy Beállítások -> Global Options részbe #Basic beállítások command.go.*.bas=cmd /c $(FileName) command.go.subsystem.*.bas=0 command.build.*.bas="c:\FreeBASIC\fbc" $(FileName).bas ===== AStyle ===== A astyle program beállítása: command.name.2.*=AStyle command.subsystem.2.*=0 command.2.*=/usr/bin/astyle --style=allman --indent=tab $(FileNameExt) command.shortcut.2.*=Alt+a command.save.before.2.*=1 command.is.filter.2.*=1 load.on.activate=1 Ebből lényeges ez a sor, az a style program paraméterezése: command.2.*=/usr/bin/astyle --style=allman --indent-switches --indent=tab $(FileNameExt) Esetleg: astyle -b $(FileNameExt) --style=linux --indent-namespaces --indent-switches ===== URL megnyitása ===== Egy fájlban a kijelölt URL-t automatikusan meg tudjuk nyitni. Beállításokhoz: command.name.1.*=Open URL in Browser command.1.*=open_url command.subsystem.1.*=3 command.mode.1.*=savebefore:no command.shortcut.1.*=Ctrl+F1' Beállítások -> Indításkor futtatandó Lua script: -- opens URL via selection or by checking text under cursor -- Kein-Hong Man Public Domain 2008 -- * execute call is non-Win32! tested on Ubuntu 6.10 -- * URL delimited by ", ' or whitespace -- * does nothing about text encoding! function open_url() local string = string local function charat(s, p) return string.sub(s, p, p) end local function delim(c) return string.match(c, "[\"'%s]") end -- if there is a selection, use exactly, else analyze local txt = editor:GetSelText() if #txt == 0 then -- get details of current line, position local p1 = editor.CurrentPos local ln = editor:LineFromPosition(p1) txt = editor:GetLine(ln) if not txt then return end local p2 = editor:PositionFromLine(ln) p1 = p1 - p2 + 1; p2 = p1 -- extend text segment to left while p1 > 1 do if delim(charat(txt, p1 - 1)) then break end p1 = p1 - 1 end -- extend text segment to right while p2 <= #txt do if delim(charat(txt, p2)) then break end p2 = p2 + 1 end -- exit if nothing matched if p1 == p2 then return end txt = string.sub(txt, p1, p2 - 1) else -- trim extraneous whitespace txt = string.gsub(txt, "^%s*(.-)%s*$", "%1") -- fail on embedded whitespace if string.match(txt, "%s") then return end end if string.match(txt, "^http://.+") or string.match(txt, "^ftp://.+") or string.match(txt, "^www%..+") then --print("URL='"..txt.."'") --DEBUG os.execute("x-www-browser "..txt.." &") end end Forrás: http://lua-users.org/wiki/SciteOpenUrl ===== XML tagek kiegészítése ===== Csak másoljuk ide: Beállítások -> Indításkor futtatandó Lua script: function OnChar(c) local nLexer = editor.Lexer if nLexer ~= 4 and nLexer ~= 5 then return false end -- tag completion if c == ">" then local pEnd = editor.CurrentPos - 1 if pEnd < 1 then return false end local nStyle = editor.StyleAt[pEnd - 1] if nStyle > 8 then return false end local nLastChar = editor.CharAt[pEnd - 1] if nStyle == 6 and nLastChar ~= 34 then return false end if nStyle == 7 and nLastChar ~= 39 then return false end if nLastChar == 47 or nLastChar == 37 or nLastChar == 60 or nLastChar == 63 then return false end local pStart = pEnd repeat pStart = pStart - 1 if (editor.CharAt[pStart] == 32) then pEnd = pStart end until editor.CharAt[pStart] == 60 or pStart == 0 if editor.CharAt[pStart + 1] == 47 then return false end if pStart == 0 and editor.CharAt[pStart] ~= 60 then return false end local tag = editor:textrange(pStart + 1, pEnd) editor:InsertText(editor.CurrentPos, "") end -- attribute quotes if c == "=" then local nStyle = editor.StyleAt[editor.CurrentPos - 2] if nStyle == 3 or nStyle == 4 then editor:InsertText(editor.CurrentPos, "\"\"") editor:GotoPos(editor.CurrentPos + 1) end end return false end * http://lua-users.org/wiki/SciteXmlAutocompletion Vagy csak írjuk a beállításokhoz: xml.auto.close.tags=1 ===== HTML tagek kiegészítése ===== Ez abban különbözik az XML kiegészítőtől, hogy nem csinálja meg a kiegészítést br, meta, link és hr tagek esetén. -- Eredeti verzió: XML tagek átírása -- Átírta: Sallai András -- HTML tagek kegeszitese: function OnChar(c) local nLexer = editor.Lexer if nLexer ~= 4 and nLexer ~= 5 then return false end -- tag completion if c == ">" then local pEnd = editor.CurrentPos - 1 if pEnd < 1 then return false end local nStyle = editor.StyleAt[pEnd - 1] if nStyle > 8 then return false end local nLastChar = editor.CharAt[pEnd - 1] if nStyle == 6 and nLastChar ~= 34 then return false end if nStyle == 7 and nLastChar ~= 39 then return false end if nLastChar == 47 or nLastChar == 37 or nLastChar == 60 or nLastChar == 63 then return false end local pStart = pEnd repeat pStart = pStart - 1 if (editor.CharAt[pStart] == 32) then pEnd = pStart end until editor.CharAt[pStart] == 60 or pStart == 0 if editor.CharAt[pStart + 1] == 47 then return false end if pStart == 0 and editor.CharAt[pStart] ~= 60 then return false end local tag = editor:textrange(pStart + 1, pEnd) if tag ~= "br" and tag ~= "meta" and tag ~="hr" and tag ~= "link" and tag ~= "img" then editor:InsertText(editor.CurrentPos, "") end end -- attribute quotes if c == "=" then local nStyle = editor.StyleAt[editor.CurrentPos - 2] if nStyle == 3 or nStyle == 4 then editor:InsertText(editor.CurrentPos, "\"\"") editor:GotoPos(editor.CurrentPos + 1) end end return false end ===== Linkek ===== * http://lua-users.org/wiki/SciteScripts