0

GPS ADA (バージョン: GPS 6.0.1 with GNAT Pro 6.4.2) のオートコンプリートを改善する方法を検討しています。

GPS オートコンプリートは、入力したテキストで始まる一致を検索します。

テキスト内の任意の場所に文字列を一致させたいと思います。

現在、正規表現は次のようになります: /myString.*/i

次のようにしたい: /.*myString.*/i

  1. これを行うために見逃したオプションはありますか?
  2. これを行うGPSプラグインを知っている人はいますか?

また、このプラグインを自分で作成することも検討しました。http://docs.adacore.com/gps-docs/users_guide/_build/html/GPS.html#GPS.Completionのドキュメントで、 「completion.py」を参照しています。 - 私は見つけることができませんでした - これは後のバージョンの GPS にのみ含まれている可能性があると推測しています。

4

1 に答える 1

2

実際にこれを自分で作成することもできます (最近の GPS の開発にはこの機能が含まれていません。以前は要求されていなかったと思います)。

目標は、キー ショートカットにバインドできるアクションを定義することです。たとえば、プラグインは次のように始まります。

import GPS, gps_utils

@gps_utils.interactive(name='My Completion', filter='Source editor'):
def my_completion():
    buffer = GPS.EditorBuffer.get()       # the current editor
    loc = buffer.current_view().cursor()  # the current location
    start = loc.forward_word(-1)          # beginning of word
    end = loc.forward_word(1)             # end of word
    text = buffer.get_chars(start, end)   # the text the user is currently typing

    # then search in current buffer (or elsewhere) for matching text
    match = buffer.beginning_of_buffer().search(text)
    if match:
       match_start, match_end = match
       match_text = buffer.get_chars(match_start, match_end)

       # then go back to initial location, remove text and replace with match
       buffer.delete(start, end)
       buffer.insert(start, match_text)

これは大まかな概要であり、私が見ていない詳細が何百もある可能性があります。ただし、開始する必要があります。

于 2014-07-23T13:44:50.687 に答える