/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Original Code is Komodo code.
 * 
 * The Initial Developer of the Original Code is ActiveState Software Inc.
 * Portions created by ActiveState Software Inc are Copyright (C) 2000-2007
 * ActiveState Software Inc. All Rights Reserved.
 * 
 * Contributor(s):
 *   ActiveState Software Inc
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */

// Find contexts (i.e., in what to search)

#include "nsISupports.idl"

interface koIContainer;
interface koIPart_file;


[scriptable, uuid(DC6E2856-3B9B-4d7a-A9D1-92102DDCDC0A)]
interface koIFindContext : nsISupports {
    // context types
    const long FCT_CURRENT_DOC = 0;   // in the current document
    const long FCT_SELECTION = 1;     // in the current selection
    const long FCT_ALL_OPEN_DOCS = 2; // in all open documents
    const long FCT_IN_FILES = 3;      // in files
    const long FCT_IN_COLLECTION = 4; // in a collection of search targets

    attribute PRUint32 type;
    readonly attribute wstring name;   // a human readable name
};

[scriptable, uuid(AC460813-782F-40e4-887F-B9B2BFBD5DF6)]
interface koIRangeFindContext : koIFindContext {
    // These are *character* offsets (as opposed to *byte* offsets).
    attribute PRUint32 startIndex;
    attribute PRUint32 endIndex;
};

[scriptable, uuid(4F9ECE5C-D88C-46A2-B087-5E159CC3177D)]
interface koIFindInFilesContext : koIFindContext {
    // A working directory from which to base relative paths.
    attribute wstring cwd;
};


/**
 * A find context which groups a bunch of possibly complex search targets.
 *
 * Usage:
 *  var coll = Components.classes["@activestate.com/koCollectionFindContext;1"]
 *          .createInstance(Components.interfaces.koICollectionFindContext);
 *  // Add one or more items.
 *  coll.add_koIContainer(<koIContainer instance>); // e.g. a project, live folder, folder
 *  coll.add_file(<koIPart_file>);
 *  coll.add_path(<path>);
 *  
 *  // Then, use the normal find JS api...
 *  Find_FindAllInCollection(editor, coll, pattern, ...);
 *  // ...or pass it to the find dialog to fill out the details.
 *  ko.launch.findInCollection(coll, ...);
 */
[scriptable, uuid(84a0ab4c-b9c0-45c7-aded-7a9e5fb2d0cc)]
interface koICollectionFindContext : koIFindContext {
    // A short description of the find context (generally for display
    // in the Komodo UI).
    readonly attribute wstring desc;
    
    // Methods to add things in which to search to the collections.
    void add_koIContainer(in koIContainer container);
    void add_file(in koIPart_file file);
    void add_path(in wstring path);
    
    // Generate the paths for this collection. This is a generator so
    // you need to UnwrapObject and use this from Python.
    //attribute generator paths;
};


