livekeys icon indicating copy to clipboard operation
livekeys copied to clipboard

Add editor search/search & replace box.

Open dinusv opened this issue 8 years ago • 1 comments

dinusv avatar Jul 21 '16 15:07 dinusv

There are 2 types:

  1. Search and replace within a document
  2. Search and replace within a project

1. Search and replace within a document

UI

  • Input Boxes: Search box, replace box
  • Buttons: Replace, Find & Replace, Replace All, Switch to Project Search

Approach

  • Create the UI in qml

  • Whenever a keypress happens, the "Find" action is triggered

  • When "Find" is triggered:

    • Create and use lveditor/DocumentHandler::findText to find the text for the document

      • If the search text is different than the previous search text:

        • Clear the previous highlighting model
        • Search the text and create the new model
        • Reghighlight the doucment with each of those sections
      • Return the next index

    • Place the cursor on the index of the next highlight

  • When "Replace" is triggered:

    • Create and uselveditor/DocumentHandler::replace to replace the cursor index of the document
  • When "Find & Replace" is triggered:

    • Create and use lveditor/ProjectDocument::replace to replace the cursor index of the document

    • Return the next index

    • Place the cursor on the index of the next highlight

  • When "Replace all" is triggered:

    • Create and use lveditor/ProjectDocument::replaceAll to replace all the instances

    • Clear all highlighting

2. Search and replace within a project

UI

  • Input Boxes: Search box, Replace Box
  • Buttons: Find, Replace All

Approach

  • Create the UI in qml

  • When "Find" is triggered:

    • Create and use lveditor/Project::findText to find the text in the project, a ListModel with the items is returned. The ListModel contains the path to the file, then the findings in the file, like line number, offset and fragment with the actual text

    • The model is displayed as a List of files and when collpsed, the findings are displayed

  • When "Replace all" is triggered:

    • Use lveditor/Project::replaceText to replace the text in the project

    • Clear the current model

dinusv avatar Nov 08 '18 14:11 dinusv