Example #1
0
float EditorQuickOpen::_path_cmp(String search, String path) const {

	if (search == path) {
		return 1.2f;
	}
	if (path.findn(search) != -1) {
		return 1.1f;
	}
	return path.to_lower().similarity(search.to_lower());
}
Example #2
0
void EditorHelpIndex::_update_class_list() {

	class_list->clear();
	tree_item_map.clear();
	TreeItem *root = class_list->create_item();
	class_list->set_hide_root(true);

	String filter = search_box->get_text().strip_edges();
	String to_select = "";

	for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {

		if (filter == "") {
			add_type(E->key(),tree_item_map,root);
		} else {

			bool found = false;
			String type = E->key();

			while(type != "") {
				if (type.findn(filter)!=-1) {

					if (to_select.empty()) {
						to_select = type;
					}

					found=true;
					break;
				}

				type = EditorHelp::get_doc_data()->class_list[type].inherits;
			}

			if (found) {
				add_type(E->key(),tree_item_map,root);
			}
		}
	}

	if (tree_item_map.has(filter)) {
		select_class(filter);
	} else if (to_select != "") {
		select_class(to_select);
	}
}
Example #3
0
void FindInFiles::_scan_file(String fpath) {

	FileAccess *f = FileAccess::open(fpath, FileAccess::READ);
	if (f == NULL) {
		print_line(String("Cannot open file ") + fpath);
		return;
	}

	int line_number = 0;

	while (!f->eof_reached()) {

		// line number starts at 1
		++line_number;

		int begin = 0;
		int end = 0;

		String line = f->get_line();

		// Find all occurrences in the current line
		while (true) {
			begin = _match_case ? line.find(_pattern, end) : line.findn(_pattern, end);

			if (begin == -1)
				break;

			end = begin + _pattern.length();

			if (_whole_words) {
				if (begin > 0 && is_text_char(line[begin - 1])) {
					continue;
				}
				if (end < line.size() && is_text_char(line[end])) {
					continue;
				}
			}

			emit_signal(SIGNAL_RESULT_FOUND, fpath, line_number, begin, end, line);
		}
	}

	f->close();
}
Example #4
0
void ScriptEditorQuickOpen::_update_search() {


	search_options->clear();
	TreeItem *root = search_options->create_item();

	for(int i=0;i<functions.size();i++) {

		String file = functions[i];
		if ((search_box->get_text()=="" || file.findn(search_box->get_text())!=-1)) {

			TreeItem *ti = search_options->create_item(root);
			ti->set_text(0,file);
			if (root->get_children()==ti)
				ti->select(0);

		}
	}

	get_ok()->set_disabled(root->get_children()==NULL);

}
Example #5
0
void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {

    for(int i=0; i<efsd->get_subdir_count(); i++) {

        _parse_fs(efsd->get_subdir(i));
    }

    for(int i=0; i<efsd->get_file_count(); i++) {

        String file = efsd->get_file_path(i);
        file=file.substr(6,file.length());
        if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text()=="" || file.findn(search_box->get_text())!=-1)) {

            TreeItem *root = search_options->get_root();
            TreeItem *ti = search_options->create_item(root);
            ti->set_text(0,file);
            Ref<Texture> icon = get_icon( (has_icon(efsd->get_file_type(i),"EditorIcons")?efsd->get_file_type(i):String("Object")),"EditorIcons");
            ti->set_icon(0,icon);
            if (root->get_children()==ti)
                ti->select(0);

        }
    }
}