まず、配色を選択します。 それらはすべてGtk-shnyhから取得されているため、ここに移動して選択します。 なんらかの理由で、私は白い背景を消化せず、青色で止めます。 そして、私たちはそれを味わうために仕上げ、真夜中の司令官、FAR-ovsky Colorer、そして正直なところ、Borlandsの時代のTurbo Visionのような平均的なものを得ました。 すぐに目を引くのは、ブラケットに別の色がないことです。 これはperl.langの def:special-constantのために修正します (他の言語では、おそらく同様に、 def:special-constantの使用を考慮に入れています)。 ファイルを〜/ .local / share / medit-1 / language-specs /にコピーして追加します:
<styles> <!-- ... --> <style id="special-constant" _name="Brackets" map-to="def:special-constant"/>
<definitions> <context id="perl" class="no-spell-check"> <include> <!-- ... --> <context ref="special-constant"/>
<define-regex id="special-constant" extended="true"> \( | \) | \[ | \] | \{ | \} </define-regex> <context id="special-constant" style-ref="special-constant"> <match>\%{special-constant}</match> </context>
したがって、ファイル〜/ .local / share / medit-1 / language-specs / our-style.xmlで :
<style name="perl:special-constant" foreground="#66FFFF"/>
結果:
![](https://habrastorage.org/getpro/habr/post_images/4b6/c39/d25/4b6c39d2597491e9a47af18499ba3ce8.png)
次に、構文チェックを追加します。
![](https://habrastorage.org/getpro/habr/post_images/d0a/c52/d2f/d0ac52d2fb72159e9d12bd06acece4ae.png)
何かが間違っています...エラーのある行ジャンプが十分ではありません。
![](https://habrastorage.org/getpro/habr/post_images/d3f/edb/4b2/d3fedb4b2dcb8cab1443a474c5a8622a.png)
このため、出力の行はfile_name:line_number [:position]の形式である必要があります。 位置は利用できませんが、行番号で問題を解決できます。 〜/ bin /に 、次のコードを含むスクリプトを入れます。
#!/usr/bin/perl use strict; die "Usage: $0 file\n" unless $ARGV[0]; my $out = `/usr/bin/perl -c $ARGV[0] 2>&1`; $out =~ s|^(.*) at (($ARGV[0]) line (\d+))(.*)$|$3:$4 $1$5|gm; print $out;
perl -cの代わりにユーティリティとして記述します。 エラーのある行をクリックすると、エディターウィンドウの適切な場所に移動します。
![](https://habrastorage.org/getpro/habr/post_images/967/8b2/f93/9678b2f93b37be422ceedc01ea996fd1.png)
次のステップは、 perltidyを使用してソースのフォーマットを構成することです 。 ここではそれほど単純ではありません。 実際、構文エラーがある場合、エディターウィンドウのソースは単純に上書きされます。 これを回避するには、まずテストを実行してからフォーマットします。 Luaではスクリプトを使用します。これは、必要な場合にのみ、エディターウィンドウに結果を無条件に表示できるようにするためです。
![](https://habrastorage.org/getpro/habr/post_images/de3/061/c4c/de3061c4cadbb2ecbe1c409bd5ae81bf.png)
filename = doc.get_filename() codefile = os.tmpname() rc = os.execute(string.format("/usr/bin/perl -c \"%s\" > \"%s\" 2>&1",filename,codefile)) if rc == 0 then tidyfile = os.tmpname() os.execute(string.format("/usr/bin/perltidy -nsak=\"if elsif unless for while\" -pt=0 -i=4 -bl -vt=2 -vtc=2 -boc -st \"%s\" > \"%s\"",filename,tidyfile)) out = io.open(tidyfile,"r") doc.select_all() doc.replace_selected_text(out:read("*a")) doc.save() os.remove(tidyfile) else out = io.open(codefile,"r") moo.error_dialog(string.format("Run syntax check!\n\n%s",out:read("*a"))) end os.remove(codefile)
この方法には1つの欠点があります。出力ウィンドウを取得できないため、構文エラーの場合はダイアログを表示する必要があります。 Luaの代わりに同様のPythonスクリプトを使用してもあまり役に立ちません。出力用のオブジェクトを取得できますが、既に存在する場合のみ、新しいオブジェクトを作成することはできません。 mooeditの作者はこれについて既に通知されており、彼は考えることを約束しました:)
さて、これらのユーティリティはすべて別々のボタンに掛けます。
![](https://habrastorage.org/getpro/habr/post_images/fea/2ec/531/fea2ec5311f65ca5e706f41cf8f7c862.png)
![](https://habrastorage.org/getpro/habr/post_images/702/39c/578/70239c578779c57a35dd9d00d594d57e.png)
同様に、出力付きのスクリプト起動をエディターの通知領域(ここではすべてが簡単です)、外部デバッガー(ただし、これらは