/* Copyright (c) 2000-2006 ActiveState Software Inc.
   See the file LICENSE.txt for licensing information. */

#include "nsISupports.idl"
#include "nsITreeView.idl"
#include "koIFinder.idl"
#include "koIFindContext.idl"


[scriptable, uuid(19692197-756C-41b9-88A3-331125971FEA)]
interface koIFindResultsView : nsITreeView {
    // An tree view for find results data.

    attribute long id; // the unique id of this results view, set by creator
    attribute wstring rootPath;

    // Clear the list of find results.
    void Clear();

    // Add a single find/replace result.
    void AddFindResult(in wstring type,
                       in wstring url,
                       in unsigned long startIndex, // character offset
                       in unsigned long endIndex,  // character offset
                       in wstring value,
                       in wstring fileName,
                       in unsigned long lineNum,
                       in unsigned long columnNum,
                       in wstring context_);
    void AddReplaceResult(in wstring type,
                          in wstring url,
                          in unsigned long startIndex, // character offset
                          in unsigned long endIndex, // character offset
                          in wstring value,
                          in wstring replacement,
                          in wstring fileName,
                          in unsigned long lineNum,
                          in unsigned long columnNum,
                          in wstring context_);

    // Optimization: add multiple find/replace results at once.
    void AddFindResults(in unsigned long type_count,
                        [array, size_is(type_count)] in wstring type,
                        in unsigned long url_count,
                        [array, size_is(url_count)] in wstring url,
                        in unsigned long startIndex_count,
                        [array, size_is(startIndex_count)] in unsigned long startIndex, // character offset
                        in unsigned long endIndex_count,
                        [array, size_is(endIndex_count)] in unsigned long endIndex, // character offset
                        in unsigned long value_count,
                        [array, size_is(value_count)] in wstring value,
                        in unsigned long fileName_count,
                        [array, size_is(fileName_count)] in wstring fileName,
                        in unsigned long lineNum_count,
                        [array, size_is(lineNum_count)] in unsigned long lineNum,
                        in unsigned long columnNum_count,
                        [array, size_is(columnNum_count)] in unsigned long columnNum,
                        in unsigned long context_count,
                        [array, size_is(context_count)] in wstring context_);
    void AddReplaceResults(
            in unsigned long type_count,
            [array, size_is(type_count)] in wstring type,
            in unsigned long url_count,
            [array, size_is(url_count)] in wstring url,
            in unsigned long startIndex_count,
            [array, size_is(startIndex_count)] in unsigned long startIndex,
            in unsigned long endIndex_count,
            [array, size_is(endIndex_count)] in unsigned long endIndex,
            in unsigned long value_count,
            [array, size_is(value_count)] in wstring value,
            in unsigned long replacement_count,
            [array, size_is(replacement_count)] in wstring replacement,
            in unsigned long fileName_count,
            [array, size_is(fileName_count)] in wstring fileName,
            in unsigned long lineNum_count,
            [array, size_is(lineNum_count)] in unsigned long lineNum,
            in unsigned long columnNum_count,
            [array, size_is(columnNum_count)] in unsigned long columnNum,
            in unsigned long context_count,
            [array, size_is(context_count)] in wstring context_);

    // Extract part of the find result data at a specific index.
    wstring GetType(in unsigned long index);
    wstring GetUrl(in unsigned long index);
    unsigned long GetStartIndex(in unsigned long index); // character offset
    unsigned long GetEndIndex(in unsigned long index); // character offset
    wstring GetValue(in unsigned long index);
    wstring GetReplacement(in unsigned long index);
    unsigned long GetLineNum(in unsigned long index);
    unsigned long GetColumnNum(in unsigned long index);

    // Sort the find result data by a certain key (this key typically matches
    // the <treecol id=.../>  id's).
    void Sort(in string sortBy);

    // Filter the results using the given text.
    void SetFilterText(in AString text);

    // Some useful queries into the current find results data
    unsigned long GetNumUrls();
};


// Implemented in find's JS code. This is too allow find's Python code to
// work with the Find Results Tab.
//
// History: This was added because the "Find in Files" functionality is
// asynchronous and the Python-level and needed a way to callback (I could
// have used nsIObserverService instead but chose this).
[scriptable, uuid(53A53E47-A32E-4BC3-A242-8935D9271CFA)]
interface koIFindResultsTabManager : nsISupports {
    attribute koIFindResultsView view;
    attribute koIFindContext context_;
    
    // Set the "Find Results" tab's description label.
    //
    // "important" message will be marked in red and will, as well, be
    // sent to the status bar.
    void setDescription(in wstring desc, in boolean important);
    
    // Methods for the Find back-end to notify the UI of the searching state.
    void searchStarted();
    void searchFinished(in boolean success,  // terminated normally
                        in long numResults,
                        in long numFiles,
                        in long numFilesSearched,
                        in wstring journalId);  // for "Replace All in Files" operation
};


