summary refs log blame commit diff stats
path: root/src/htm/Properties/Settings.Designer.cs
blob: 35939b710bfd506f6b4bcf9bd9de288028a560b9 (plain) (tree)

























                                                                                                                                                        
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.17626
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace thememan.Properties {
    
    
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
        
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
        
        public static Settings Default {
            get {
                return defaultInstance;
            }
        }
    }
}
background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* HexChat
 * Copyright (c) 2015 Patrick Griffis
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#include "config.h"

#include <Spellcheck.h>
#include <glib.h>

#include "typedef.h" // for ssize_t
#include <enchant-provider.h>

ENCHANT_PLUGIN_DECLARE ("win8")

/* --------- Utils ----------*/

static char *
utf16_to_utf8 (const wchar_t * const str, gboolean from_bcp47)
{
	char *utf8 = g_utf16_to_utf8 ((gunichar2*)str, -1, nullptr, nullptr, nullptr);
	if (utf8 && from_bcp47)
	{
		char *p = utf8;
		/* bcp47 tags use syntax "en-US" while the myspell versions are "en_US" */
		while (*p)
		{
			if (*p == '-')
				*p = '_';
			p++;
		}
	}
	return utf8;
}

static wchar_t *
utf8_to_utf16 (const char * const str, size_t len, gboolean to_bcp47)
{
	wchar_t *utf16 = (wchar_t*)g_utf8_to_utf16 (str, len, nullptr, nullptr, nullptr);
	if (utf16 && to_bcp47)
	{
		wchar_t *p = utf16;
		/* bcp47 tags use syntax "en-US" while the myspell versions are "en_US" */
		while (*p)
		{
			if (*p == L'_')
				*p = L'-';
			p++;
		}
	}
	return utf16;
}

static char **
enumstring_to_chararray (IEnumString *strings, size_t *out_len, gboolean from_bcp47)
{
	char **chars = g_new (char*, 256); /* Hopefully large enough */
	LPOLESTR wstr = nullptr;
	size_t i = 0;

	while (SUCCEEDED (strings->Next (1, &wstr, nullptr)) && i < 256 && wstr)
	{
		char *str = utf16_to_utf8 (wstr, from_bcp47);
		if (str)
		{
			chars[i] = str;
			i++;
		}
		CoTaskMemFree (wstr);
	}
	chars[i] = nullptr;
	strings->Release ();

	*out_len = i;
	return chars;
}

/* ---------- Dict ------------ */

static void
win8_dict_add_to_personal (EnchantDict *dict, const char *const word, size_t len)
{
	auto checker = static_cast<ISpellChecker*>(dict->user_data);
	wchar_t *wword = utf8_to_utf16 (word, len, FALSE);

	checker->Add (wword);
	g_free (wword);
}

static void
win8_dict_add_to_session (EnchantDict *dict, const char *const word, size_t len)
{
	auto checker = static_cast<ISpellChecker*>(dict->user_data);
	wchar_t *wword = utf8_to_utf16 (word, len, FALSE);

	checker->Ignore (wword);
	g_free (wword);
}

static int
win8_dict_check (EnchantDict *dict, const char *const word, size_t len)
{
	auto checker = static_cast<ISpellChecker*>(dict->user_data);
	wchar_t *wword = utf8_to_utf16 (word, len, FALSE);
	IEnumSpellingError *errors;
	ISpellingError *error = nullptr;
	HRESULT hr;

	hr = checker->Check (wword, &errors);
	g_free (wword);

	if (FAILED (hr))
		return -1; /* Error */

	if (errors->Next (&error) == S_OK)
	{
		error->Release ();
		errors->Release ();
		return 1; /* Spelling Issue */
	}
	else
	{
		errors->Release ();
		return 0; /* Correct */
	}
}

static char **
win8_dict_suggest (EnchantDict *dict, const char *const word, size_t len, size_t *out_n_suggs)
{
	auto checker = static_cast<ISpellChecker*>(dict->user_data);
	wchar_t *wword = utf8_to_utf16 (word, len, FALSE);
	IEnumString *suggestions;
	HRESULT hr;

	hr = checker->Suggest (wword, &suggestions);
	g_free (wword);

	if (FAILED (hr))
	{
		*out_n_suggs = 0;
		return nullptr;
	}

	return enumstring_to_chararray (suggestions, out_n_suggs, FALSE);
}

/* ---------- Provider ------------ */

static EnchantDict *
win8_provider_request_dict (EnchantProvider *provider, const char *const tag)
{
	auto factory = static_cast<ISpellCheckerFactory*>(provider->user_data);
	ISpellChecker *checker;
	EnchantDict *dict;
	wchar_t *wtag = utf8_to_utf16 (tag, -1, TRUE);
	HRESULT hr;

	hr = factory->CreateSpellChecker (wtag, &checker);
	g_free (wtag);

	if (FAILED (hr))
		return nullptr;

	dict = g_new0 (EnchantDict, 1);
	dict->suggest = win8_dict_suggest;
	dict->check = win8_dict_check;
	dict->add_to_personal = win8_dict_add_to_personal;
	dict->add_to_exclude = win8_dict_add_to_personal; /* Basically the same */
	dict->add_to_session = win8_dict_add_to_session;

	dict->user_data = checker;

	return dict;
}

static void
win8_provider_dispose_dict (EnchantProvider *provider, EnchantDict *dict)
{
	if (dict)
	{
		auto checker = static_cast<ISpellChecker*>(dict->user_data);

		checker->Release ();
		g_free (dict);
	}
}

static int
win8_provider_dictionary_exists (EnchantProvider *provider, const char *const tag)
{
	auto factory = static_cast<ISpellCheckerFactory*>(provider->user_data);
	wchar_t *wtag = utf8_to_utf16 (tag, -1, TRUE);

	BOOL is_supported = FALSE;
	factory->IsSupported (wtag, &is_supported);

	g_free (wtag);
	return is_supported;
}


static char **
win8_provider_list_dicts (EnchantProvider *provider, size_t *out_n_dicts)
{
	auto factory = static_cast<ISpellCheckerFactory*>(provider->user_data);
	IEnumString *dicts;

	if (FAILED(factory->get_SupportedLanguages (&dicts)))
	{
		*out_n_dicts = 0;
		return nullptr;
	}

	return enumstring_to_chararray (dicts, out_n_dicts, TRUE);
}

static void
win8_provider_free_string_list (EnchantProvider *provider, char **str_list)
{
	g_strfreev (str_list);
}

static void
win8_provider_dispose (EnchantProvider *provider)
{
	if (provider)
	{
		auto factory = static_cast<ISpellCheckerFactory*>(provider->user_data);

		factory->Release();
		g_free (provider);
	}
}

static const char *
win8_provider_identify (EnchantProvider *provider)
{
	return "win8";
}

static const char *
win8_provider_describe (EnchantProvider *provider)
{
	return "Windows 8 SpellCheck Provider";
}

extern "C"
{

EnchantProvider *
init_enchant_provider (void)
{
	EnchantProvider *provider;
	ISpellCheckerFactory *factory;

	if (FAILED (CoCreateInstance (__uuidof(SpellCheckerFactory), nullptr,
				CLSCTX_INPROC_SERVER, IID_PPV_ARGS (&factory))))
		return nullptr;

	provider = g_new0 (EnchantProvider, 1);
	provider->dispose = win8_provider_dispose;
	provider->request_dict = win8_provider_request_dict;
	provider->dispose_dict = win8_provider_dispose_dict;
	provider->dictionary_exists = win8_provider_dictionary_exists;
	provider->identify = win8_provider_identify;
	provider->describe = win8_provider_describe;
	provider->list_dicts = win8_provider_list_dicts;
	provider->free_string_list = win8_provider_free_string_list;

	provider->user_data = factory;

	return provider;
}

}