最終更新日 2024-06-21

hmPython3が持つエディタ編集領域の関数

編集中エディタに対する関数

現在秀丸エディタで開いているテキストに対して、以下の関数を利用することが出来ます。

普通のPython的ソースの中に、hmPython3の関数が混じる例

以下は、Pythonスクリプト全体の中で、秀丸専用関数となるhm.Edit.TotalTextを利用した例となります。
スクリプト全体の中で、hmPython3専用関数が使われるイメージのようなものの参考としてください。

#PY = loaddll( hidemarudir + @"\hmPython3.dll" );

if (! #PY) {
  message("hmPython3が導入されいません。");
  endmacro;
}

#_ = dllfuncw( #PY, "DoString", R"PY(

from hmPython import *

from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):
    def handle_starttag(self, tag, attrs):
        hm.debuginfo("Encountered a start tag:" + ',' + str(tag))

    def handle_endtag(self, tag):
        hm.debuginfo("Encountered an end tag :" + ',' + str(tag))

    def handle_data(self, data):
        hm.debuginfo("Encountered some data  :" + ',' + str(tag))

parser = MyHTMLParser()
parser.feed(hm.Edit.TotalText)

)PY"
);

freedll( #PY );