Example #1
0
void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates) {

	for (int i = 0; i < efsd->get_subdir_count(); i++) {
		_fix_and_find(efsd->get_subdir(i), candidates);
	}

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

		String file = efsd->get_file(i);
		if (!candidates.has(file))
			continue;

		String path = efsd->get_file_path(i);

		for (Map<String, String>::Element *E = candidates[file].front(); E; E = E->next()) {

			if (E->get() == String()) {
				E->get() = path;
				continue;
			}

			//must match the best, using subdirs
			String existing = E->get().replace_first("res://", "");
			String current = path.replace_first("res://", "");
			String lost = E->key().replace_first("res://", "");

			Vector<String> existingv = existing.split("/");
			existingv.invert();
			Vector<String> currentv = current.split("/");
			currentv.invert();
			Vector<String> lostv = lost.split("/");
			lostv.invert();

			int existing_score = 0;
			int current_score = 0;

			for (int j = 0; j < lostv.size(); j++) {

				if (j < existingv.size() && lostv[j] == existingv[j]) {
					existing_score++;
				}
				if (j < currentv.size() && lostv[j] == currentv[j]) {
					current_score++;
				}
			}

			if (current_score > existing_score) {

				//if it was the same, could track distance to new path but..

				E->get() = path; //replace by more accurate
			}
		}
	}
}
Example #2
0
bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin& plugin)
{
        String pathCopy = pluginPath;
    DWORD versionInfoSize = ::GetFileVersionInfoSizeW(pathCopy.charactersWithNullTermination(), 0);
    if (!versionInfoSize)
        return false;

    OwnArrayPtr<char> versionInfoData = adoptArrayPtr(new char[versionInfoSize]);
    if (!::GetFileVersionInfoW(pathCopy.charactersWithNullTermination(), 0, versionInfoSize, versionInfoData.get()))
        return false;

    String name = getVersionInfo(versionInfoData.get(), "ProductName");
    String description = getVersionInfo(versionInfoData.get(), "FileDescription");
    if (name.isNull() || description.isNull())
        return false;

    VS_FIXEDFILEINFO* info;
    UINT infoSize;
    if (!::VerQueryValueW(versionInfoData.get(), L"\\", reinterpret_cast<void**>(&info), &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO))
        return false;

    Vector<String> types;
    getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types);
    Vector<String> extensionLists;
    getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists);
    Vector<String> descriptions;
    getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions);

    Vector<MimeClassInfo> mimes(types.size());
    for (size_t i = 0; i < types.size(); i++) {
        String type = types[i].lower();
        String description = i < descriptions.size() ? descriptions[i] : "";
        String extensionList = i < extensionLists.size() ? extensionLists[i] : "";

        Vector<String> extensionsVector;
        extensionList.split(',', extensionsVector);

        // Get rid of the extension list that may be at the end of the description string.
        int pos = description.find("(*");
        if (pos != -1) {
            // There might be a space that we need to get rid of.
            if (pos > 1 && description[pos - 1] == ' ')
                pos--;
            description = description.left(pos);
        }

        mimes[i].type = type;
        mimes[i].desc = description;
        mimes[i].extensions.swap(extensionsVector);
    }

    plugin.path = pluginPath;
    plugin.info.desc = description;
    plugin.info.name = name;
    plugin.info.file = pathGetFileName(pluginPath);
    plugin.info.mimes.swap(mimes);
    plugin.fileVersion = fileVersion(info->dwFileVersionLS, info->dwFileVersionMS);

    return true;
}
Example #3
0
void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value)
{
    SoupCookieJar* jar = cookieJarForSession(session);
    if (!jar)
        return;

    GUniquePtr<SoupURI> origin = url.createSoupURI();
    GUniquePtr<SoupURI> firstPartyURI = firstParty.createSoupURI();

    // Get existing cookies for this origin.
    GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE);

    Vector<String> cookies;
    value.split('\n', cookies);
    const size_t cookiesCount = cookies.size();
    for (size_t i = 0; i < cookiesCount; ++i) {
        GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookies[i].utf8().data(), origin.get()));
        if (!cookie)
            continue;

        // Make sure the cookie is not httpOnly since such cookies should not be set from JavaScript.
        if (soup_cookie_get_http_only(cookie.get()))
            continue;

        // Make sure we do not overwrite httpOnly cookies from JavaScript.
        if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get())))
            continue;

        soup_cookie_jar_add_cookie_with_first_party(jar, firstPartyURI.get(), cookie.release());
    }

    soup_cookies_free(existingCookies);
}
Example #4
0
Vector<unsigned> WMLSelectElement::parseIndexValueString(const String& indexValue) const
{
    Vector<unsigned> indices;
    if (indexValue.isEmpty())
        return indices;

    Vector<String> indexStrings;
    indexValue.split(';', indexStrings);

    bool ok = false;
    unsigned optionCount = SelectElement::optionCount(m_data, this);

    Vector<String>::const_iterator end = indexStrings.end();
    for (Vector<String>::const_iterator it = indexStrings.begin(); it != end; ++it) {
        unsigned parsedValue = (*it).toUIntStrict(&ok);
        // Spec: Remove all non-integer indices from the value. Remove all out-of-range indices
        // from the value, where out-of-range is defined as any index with a value greater than
        // the number of options in the select or with a value less than one.
        if (!ok || parsedValue < 1 || parsedValue > optionCount)
            continue;

        // Spec: Remove duplicate indices.
        if (indices.find(parsedValue) == notFound)
            indices.append(parsedValue);
    }

    return indices;
}
Example #5
0
void OutputStrings::add_line(const String &p_text, const Variant &p_meta, const LineType p_type) {

	Vector<String> strings = p_text.split("\n");

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

		if (strings[i].length() == 0)
			continue;

		int last = line_map.empty() ? 0 : (line_map.back()->key() + 1);

		Line l;
		l.text = strings[i];
		l.meta = p_meta;
		l.type = p_type;
		line_map.insert(last, l);

		updating = true;
		v_scroll->set_max(last + 1);
		v_scroll->set_min(line_map.front()->key());
		updating = false;
	}

	while (line_map.size() > line_max_count) {

		line_map.erase(line_map.front());
	}

	update();
}
static Vector<OwnArrayPtr<char>> createArgsArray(const String& prefix, const String& executablePath, const String& socket, const String& pluginPath)
{
    ASSERT(!executablePath.isEmpty());
    ASSERT(!socket.isEmpty());

    Vector<String> splitArgs;
    prefix.split(' ', splitArgs);

    splitArgs.append(executablePath);
    splitArgs.append(socket);
    if (!pluginPath.isEmpty())
        splitArgs.append(pluginPath);

    Vector<OwnArrayPtr<char>> args;
    args.resize(splitArgs.size() + 1); // Extra room for null.

    size_t numArgs = splitArgs.size();
    for (size_t i = 0; i < numArgs; ++i) {
        CString param = splitArgs[i].utf8();
        args[i] = adoptArrayPtr(new char[param.length() + 1]); // Room for the terminating null coming from the CString.
        strncpy(args[i].get(), param.data(), param.length() + 1); // +1 here so that strncpy copies the ending null.
    }
    // execvp() needs the pointers' array to be null-terminated.
    args[numArgs] = nullptr;

    return args;
}
Example #7
0
Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {

	Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types());

	if (err != OK) {

		Vector<String> shader = p_code.split("\n");
		for (int i = 0; i < shader.size(); i++) {
			print_line(itos(i) + " " + shader[i]);
		}

		_err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);
		return err;
	}

	r_gen_code.custom_defines.clear();
	r_gen_code.uniforms.clear();
	r_gen_code.texture_uniforms.clear();
	r_gen_code.texture_hints.clear();
	r_gen_code.vertex = String();
	r_gen_code.vertex_global = String();
	r_gen_code.fragment = String();
	r_gen_code.fragment_global = String();
	r_gen_code.light = String();
	r_gen_code.uses_fragment_time = false;
	r_gen_code.uses_vertex_time = false;

	used_name_defines.clear();
	used_rmode_defines.clear();
	used_flag_pointers.clear();

	_dump_node_code(parser.get_shader(), 1, r_gen_code, *p_actions, actions[p_mode], false);

	return OK;
}
XFrameOptionsDisposition parseXFrameOptionsHeader(const String& header)
{
    XFrameOptionsDisposition result = XFrameOptionsInvalid;

    if (header.isEmpty())
        return result;

    Vector<String> headers;
    header.split(',', headers);

    bool hasValue = false;
    for (size_t i = 0; i < headers.size(); i++) {
        String currentHeader = headers[i].stripWhiteSpace();
        XFrameOptionsDisposition currentValue = XFrameOptionsInvalid;
        if (equalIgnoringCase(currentHeader, "deny"))
            currentValue = XFrameOptionsDeny;
        else if (equalIgnoringCase(currentHeader, "sameorigin"))
            currentValue = XFrameOptionsSameOrigin;
        else if (equalIgnoringCase(currentHeader, "allowall"))
            currentValue = XFrameOptionsAllowAll;

        if (!hasValue)
            result = currentValue;
        else if (result != currentValue)
            return XFrameOptionsConflict;
        hasValue = true;
    }
    return result;
}
/* static */
void WebKitCSSKeyframeRule::parseKeyString(const String& s, Vector<float>& keys)
{
    keys.clear();
    Vector<String> strings;
    s.split(',', strings);
    
    for (size_t i = 0; i < strings.size(); ++i) {
        float key = -1;
        String cur = strings[i].stripWhiteSpace();
    
        // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number
        if (cur == "from")
            key = 0;
        else if (cur == "to")
            key = 1;
        else if (cur.endsWith("%")) {
            float k = cur.substring(0, cur.length() - 1).toFloat();
            if (k >= 0 && k <= 100)
                key = k/100;
        }
        
        if (key < 0) {
            keys.clear();
            return;
        }
        else
            keys.append(key);
    }
}
Example #10
0
void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t count, const char* logLevel)
{
    String logLevelString = logLevel;
    Vector<String> components;
    logLevelString.split(',', components);

    for (size_t i = 0; i < components.size(); ++i) {
        String component = components[i];

        WTFLogChannelState logChannelState = WTFLogChannelOn;
        if (component.startsWith('-')) {
            logChannelState = WTFLogChannelOff;
            component = component.substring(1);
        }

        if (equalIgnoringCase(component, "all")) {
            setStateOfAllChannels(channels, count, logChannelState);
            continue;
        }

        if (WTFLogChannel* channel = WTFLogChannelByName(channels, count, component.utf8().data()))
            channel->state = logChannelState;
        else
            WTFLogAlways("Unknown logging channel: %s", component.utf8().data());
    }
}
ContentDispositionType contentDispositionType(const String& contentDisposition)
{
    if (contentDisposition.isEmpty())
        return ContentDispositionNone;

    Vector<String> parameters;
    contentDisposition.split(';', parameters);

    if (parameters.isEmpty())
        return ContentDispositionNone;

    String dispositionType = parameters[0];
    dispositionType.stripWhiteSpace();

    if (equalIgnoringCase(dispositionType, "inline"))
        return ContentDispositionInline;

    // Some broken sites just send bogus headers like
    //
    //   Content-Disposition: ; filename="file"
    //   Content-Disposition: filename="file"
    //   Content-Disposition: name="file"
    //
    // without a disposition token... screen those out.
    if (!isValidHTTPToken(dispositionType))
        return ContentDispositionNone;

    // We have a content-disposition of "attachment" or unknown.
    // RFC 2183, section 2.8 says that an unknown disposition
    // value should be treated as "attachment"
    return ContentDispositionAttachment;
}
Example #12
0
void ProjectExportDialog::_update_feature_list() {

	Ref<EditorExportPreset> current = get_current_preset();
	ERR_FAIL_COND(current.is_null());

	Set<String> fset;
	List<String> features;

	current->get_platform()->get_platform_features(&features);
	current->get_platform()->get_preset_features(current, &features);

	String custom = current->get_custom_features();
	Vector<String> custom_list = custom.split(",");
	for (int i = 0; i < custom_list.size(); i++) {
		String f = custom_list[i].strip_edges();
		if (f != String()) {
			features.push_back(f);
		}
	}

	for (List<String>::Element *E = features.front(); E; E = E->next()) {
		fset.insert(E->get());
	}

	custom_feature_display->clear();
	for (Set<String>::Element *E = fset.front(); E; E = E->next()) {
		String f = E->get();
		if (E->next()) {
			f += ", ";
		}
		custom_feature_display->add_text(f);
	}
}
Example #13
0
bool PluginPackage::fetchInfo()
{
    if (!load())
        return false;

    char* buf = 0;
    NPError err = m_pluginFuncs.getvalue(0, NPPVpluginNameString, (void *)&buf);
    m_name = buf;
    err = m_pluginFuncs.getvalue(0, NPPVpluginDescriptionString, (void *)&buf);
    m_description = buf;

    determineModuleVersionFromDescription();

    String s = m_npInterface->NP_GetMIMEDescription();
    Vector<String> types;
    s.split(UChar('|'), false, types);  // <MIME1>;<ext1,ext2,ext3,...>;<Description>|<MIME2>|<MIME3>|...

    for (int i = 0; i < types.size(); ++i) {
        Vector<String> mime;
        types[i].split(UChar(';'), true, mime);  // <MIME1>;<ext1,ext2,ext3,...>;<Description>
        if (mime.size() > 0) {
            Vector<String> exts;
            if (mime.size() > 1)
                mime[1].split(UChar(','), false, exts); // <ext1,ext2,ext3,...>
            
            m_mimeToExtensions.add(mime[0], exts); // <MIME>,<ext1,ext2,ext3>
            if (mime.size() > 2)
                m_mimeToDescriptions.add(mime[0], mime[2]); // <MIME>,<Description>
        }
    }
    unload();
    return true;
}
Example #14
0
void HTMLViewSourceDocument::addText(const String& text, const AtomicString& className)
{
    if (text.isEmpty())
        return;

    // Add in the content, splitting on newlines.
    Vector<String> lines;
    text.split('\n', true, lines);
    unsigned size = lines.size();
    for (unsigned i = 0; i < size; i++) {
        String substring = lines[i];
        if (m_current == m_tbody)
            addLine(className);
        if (substring.isEmpty()) {
            if (i == size - 1)
                break;
            finishLine();
            continue;
        }
        RefPtr<Text> t = Text::create(this, substring);
        m_current->parserAppendChild(t);
        t->lazyAttach();
        if (i < size - 1)
            finishLine();
    }
}
Example #15
0
Vector<unsigned> WMLSelectElement::valueStringToOptionIndices(const String& value) const
{
    Vector<unsigned> indices;
    if (value.isEmpty())
        return indices;

    const Vector<Element*>& items = m_data.listItems(this);
    if (items.isEmpty())
        return indices;

    Vector<String> indexStrings;
    value.split(';', indexStrings);

    unsigned optionIndex = 0;

    Vector<String>::const_iterator end = indexStrings.end();
    for (Vector<String>::const_iterator it = indexStrings.begin(); it != end; ++it) {
        String value = *it;

        for (unsigned i = 0; i < items.size(); ++i) {
            if (!isOptionElement(items[i]))
                continue;

            ++optionIndex;
            if (OptionElement* optionElement = toOptionElement(items[i])) {
                if (optionElement->value() == value) {
                    indices.append(optionIndex);
                    break;
                }
            }
        }
    }

    return indices;
}
static bool parseKeyTimes(const String& string, Vector<float>& result, bool verifyOrder)
{
    result.clear();
    Vector<String> parseList;
    string.split(';', true, parseList);
    for (unsigned n = 0; n < parseList.size(); ++n) {
        String timeString = parseList[n].stripWhiteSpace();
        bool ok;
        float time = timeString.toFloat(&ok);
        if (!ok || time < 0 || time > 1)
            goto fail;
        if (verifyOrder) {
            if (!n) {
                if (time)
                    goto fail;
            } else if (time < result.last()) {
                goto fail;
            }
        }
        result.append(time);
    }
    return true;
fail:
    result.clear();
    return false;
}
void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSet& headerSet)
{
    Vector<String> results;
    headerValue.split(",", results);
    for (auto& value : results)
        headerSet.add(value.stripWhiteSpace(isWhitespace));
}
void HTMLViewSourceDocument::addText(const String& text, const AtomicString& className, SourceAnnotation annotation)
{
    if (text.isEmpty())
        return;

    // Add in the content, splitting on newlines.
    Vector<String> lines;
    text.split('\n', true, lines);
    unsigned size = lines.size();
    for (unsigned i = 0; i < size; i++) {
        String substring = lines[i];
        if (m_current == m_tbody)
            addLine(className);
        if (substring.isEmpty()) {
            if (i == size - 1)
                break;
            finishLine();
            continue;
        }
        RefPtrWillBeRawPtr<Element> oldElement = m_current;
        maybeAddSpanForAnnotation(annotation);
        m_current->parserAppendChild(Text::create(*this, substring));
        m_current = oldElement;
        if (i < size - 1)
            finishLine();
    }
}
Example #19
0
void WindowFeatures::parseDialogFeatures(const String& string, DialogFeaturesMap& map)
{
    Vector<String> vector;
    string.split(';', vector);
    size_t size = vector.size();
    for (size_t i = 0; i < size; ++i) {
        const String& featureString = vector[i];

        size_t separatorPosition = featureString.find('=');
        size_t colonPosition = featureString.find(':');
        if (separatorPosition != notFound && colonPosition != notFound)
            continue; // ignore strings that have both = and :
        if (separatorPosition == notFound)
            separatorPosition = colonPosition;

        String key = featureString.left(separatorPosition).stripWhiteSpace().lower();

        // Null string for value indicates key without value.
        String value;
        if (separatorPosition != notFound) {
            value = featureString.substring(separatorPosition + 1).stripWhiteSpace().lower();
            value = value.left(value.find(' '));
        }

        map.set(key, value);
    }
}
Example #20
0
void HTMLViewSourceDocument::addText(const String& text, const String& className)
{
    if (text.isEmpty())
        return;

    // Add in the content, splitting on newlines.
    Vector<String> lines;
    text.split('\n', true, lines);
    unsigned size = lines.size();
    for (unsigned i = 0; i < size; i++) {
        String substring = lines[i];
        if (substring.isEmpty()) {
            if (i == size - 1)
                break;
            substring = " ";
        }
        if (m_current == m_tbody)
            addLine(className);
        RefPtr<Text> t = new Text(this, substring);
        m_current->addChild(t);
        t->attach();
        if (i < size - 1)
            m_current = m_tbody;
    }
    
    // Set current to m_tbody if the last character was a newline.
    if (text[text.length() - 1] == '\n')
        m_current = m_tbody;
}
Example #21
0
 hx::Object *runObject(CppiaCtx *ctx)
 {
    String val = strVal->runString(ctx);
    BCR_CHECK;
    String separator = a0->runString(ctx);
    BCR_CHECK;
    return val.split(separator).mPtr;
 }
Example #22
0
//////////////////////////////////////////////////////////
// PRE: string is a line from log file
// POST: LogEntry object is given values from line of input file
//
LogEntry::LogEntry(String s)
{
    
    std::vector<String> vec = s.split(' ');
    
    if (vec.size() == 10) {
        host = vec[0];
        
        // split vec[3] on a colon to start with
        
        std::vector<String> date_time = vec[3].split(':');
        //date_time has four strings date_time[0] contains date
        //date_time[1] = hour, date_time[2] = minute,
        //date_time[3] = second
        
        std::vector<String> date_string = date_time[0].split('/');
        //date_string has three strings date_string[0] contains day,
        //date_string[1] = month, date_string[2] = year
        
        String stringday = date_string[0].substr(1, date_string[0].length());
        date.setday(stringday);
        //sets the day equal to the substring of date_string[0]
        //i.e. "[18"; from position 1 to length of string
        //takes into account if day is single digit
        
        String stringmonth = date_string[1];
        date.setmonth(stringmonth);
        
        int intyear = date_string[2].to_i();
        date.setyear(intyear);
        
        time.sethour(date_time[1].to_i());
        time.setminute(date_time[2].to_i());
        time.setsecond(date_time[3].to_i());
        
        request = vec[5] + vec[6] + vec[7];
        
        status = vec[8];
        
        if (vec[9] == '-') {
            number_of_bytes = 0;
        }
        
        number_of_bytes = vec[9].to_i();
    } else {
        host = "";
        date.setday("");
        date.setmonth("");
        date.setyear(0);
        time.sethour(0);
        time.setminute(0);
        time.setsecond(0);
        request = "";
        status = "";
        number_of_bytes = 0;
    }
    
}
Example #23
0
void Extensions3DOpenGLCommon::initializeAvailableExtensions()
{
    String extensionsString = getExtensions();
    Vector<String> availableExtensions;
    extensionsString.split(" ", availableExtensions);
    for (size_t i = 0; i < availableExtensions.size(); ++i)
        m_availableExtensions.add(availableExtensions[i]);
    m_initializedAvailableExtensions = true;
}
Example #24
0
bool ValidityState::typeMismatch() const
{
    if (!m_control->hasTagName(inputTag))
        return false;

    HTMLInputElement* input = static_cast<HTMLInputElement*>(m_control);
    String value = input->value();

    if (value.isEmpty())
        return false;

    switch (input->inputType()) {
    case HTMLInputElement::COLOR:
        return !isValidColorString(value);
    case HTMLInputElement::NUMBER:
        return !parseToDoubleForNumberType(value, 0);
    case HTMLInputElement::URL:
        return !KURL(KURL(), value).isValid();
    case HTMLInputElement::EMAIL: {
        if (!input->multiple())
            return !isValidEmailAddress(value);
        Vector<String> addresses;
        value.split(',', addresses);
        for (unsigned i = 0; i < addresses.size(); ++i) {
            if (!isValidEmailAddress(addresses[i]))
                return true;
        }
        return false;
    }
    case HTMLInputElement::DATE:
    case HTMLInputElement::DATETIME:
    case HTMLInputElement::DATETIMELOCAL:
    case HTMLInputElement::MONTH:
    case HTMLInputElement::TIME:
    case HTMLInputElement::WEEK:
        return !HTMLInputElement::parseToDateComponents(input->inputType(), value, 0);
    case HTMLInputElement::BUTTON:
    case HTMLInputElement::CHECKBOX:
    case HTMLInputElement::FILE:
    case HTMLInputElement::HIDDEN:
    case HTMLInputElement::IMAGE:
    case HTMLInputElement::ISINDEX:
    case HTMLInputElement::PASSWORD:
    case HTMLInputElement::RADIO:
    case HTMLInputElement::RANGE:
    case HTMLInputElement::RESET:
    case HTMLInputElement::SEARCH:
    case HTMLInputElement::SUBMIT:
    case HTMLInputElement::TELEPHONE: // FIXME: Is there validation for <input type=telephone>?
    case HTMLInputElement::TEXT:
        return false;
    }

    ASSERT_NOT_REACHED();
    return false;
}
Example #25
0
void parseAccessControlExposeHeadersAllowList(const String& headerValue, HTTPHeaderSet& headerSet)
{
    Vector<String> headers;
    headerValue.split(',', false, headers);
    for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) {
        String strippedHeader = headers[headerCount].stripWhiteSpace();
        if (!strippedHeader.isEmpty())
            headerSet.add(strippedHeader);
    }
}
Example #26
0
void ScriptEditor::edit(const Ref<Script>& p_script) {

	if (p_script.is_null())
		return;

	// see if already has it

	if (p_script->get_path().is_resource_file() && bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) {

		String path = EditorSettings::get_singleton()->get("external_editor/exec_path");
		String flags = EditorSettings::get_singleton()->get("external_editor/exec_flags");
		List<String> args;
		flags=flags.strip_edges();
		if (flags!=String()) {
			Vector<String> flagss = flags.split(" ",false);
			for(int i=0;i<flagss.size();i++)
				args.push_back(flagss[i]);
		}

		args.push_back(Globals::get_singleton()->globalize_path(p_script->get_path()));
		Error err = OS::get_singleton()->execute(path,args,false);
		if (err==OK)
			return;
		WARN_PRINT("Couldn't open external text editor, using internal");
	}


	for(int i=0;i<tab_container->get_child_count();i++) {

		ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
		if (!ste)
			continue;

		if (ste->get_edited_script()==p_script) {

			if (tab_container->get_current_tab()!=i)
				tab_container->set_current_tab(i);
			ste->get_text_edit()->grab_focus();
			return;
		}
	}

	// doesn't have it, make a new one

	ScriptTextEditor *ste = memnew( ScriptTextEditor );
	ste->set_edited_script(p_script);
	ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste);
	tab_container->add_child(ste);
	tab_container->set_current_tab(tab_container->get_tab_count()-1);

	_update_window_menu();
	_save_files_state();

}
Example #27
0
//--------------------------------------------------------------------------------------------------
/// Set the title (text that will be rendered above the legend)
/// 
/// The legend supports multi-line titles. Separate each line with a '\n' character
//--------------------------------------------------------------------------------------------------
void OverlayColorLegend::setTitle(const String& title)
{
    // Title
    if (title.isEmpty())
    {
        m_titleStrings.clear();
    }
    else
    {
        m_titleStrings = title.split("\n");
    }
}
static HashSet<String> parseExtensions(const String& extensionsString)
{
    Vector<String> extNames;
    extensionsString.split(" ", extNames);
    HashSet<String> splitExtNames;
    unsigned size = extNames.size();
    for (unsigned i = 0; i < size; ++i)
        splitExtNames.add(extNames[i]);
    extNames.clear();

    return splitExtNames;
}
Example #29
0
void LocalShaderParam::setParamValueFromString(int type, String pvalue) {
        switch(type) {
            case ProgramParam::PARAM_NUMBER:
            {
                setNumber(atof(pvalue.c_str()));
            }
                break;
            case ProgramParam::PARAM_VECTOR2:
            {
                std::vector<String> values = pvalue.split(" ");
                if(values.size() == 2) {
                    setVector2(Vector2(atof(values[0].c_str()), atof(values[1].c_str())));
                } else {
                    printf("Material parameter error: A Vector2 must have 2 values (%d provided)!\n", (int)values.size());
                }
            }
                break;
            case ProgramParam::PARAM_VECTOR3:
            {
                std::vector<String> values = pvalue.split(" ");
                if(values.size() == 3) {
                    setVector3(Vector3(atof(values[0].c_str()), atof(values[1].c_str()), atof(values[2].c_str())));
                } else {
                    printf("Material parameter error: A Vector3 must have 3 values (%d provided)!\n", (int)values.size());
                }
            }
                break;
            case ProgramParam::PARAM_COLOR:
            {
                std::vector<String> values = pvalue.split(" ");
                if(values.size() == 4) {
                    setColor(Color(atof(values[0].c_str()), atof(values[1].c_str()), atof(values[2].c_str()), atof(values[3].c_str())));
                } else {
                    printf("Material parameter error: A Vector3 must have 3 values (%d provided)!\n", (int)values.size());
                }
            }
                break;
        }
}
Example #30
0
bool EmailInputType::typeMismatchFor(const String& value) const
{
    if (value.isEmpty())
        return false;
    if (!element()->multiple())
        return !isValidEmailAddress(value);
    Vector<String> addresses;
    value.split(',', true, addresses);
    for (unsigned i = 0; i < addresses.size(); ++i) {
        if (!isValidEmailAddress(stripLeadingAndTrailingHTMLSpaces(addresses[i])))
            return true;
    }
    return false;
}