コード例 #1
0
ファイル: spelling.c プロジェクト: lunakid/PNotesz
void CreateSpeller(char * affPath, char * dictPath, HWND hMain, COLORREF color){
	char				*enc;

	m_hMain = hMain;
	if(m_hh){
		Hunspell_destroy(m_hh);
		m_hh = NULL;
	}
	m_hh = Hunspell_create(affPath, dictPath);

	enc = _strdup(Hunspell_get_dic_encoding(m_hh));
	enc = _normalizeCodePage(enc);	
	m_CodePage = SendMessage(hMain, SPM_GETCODEPAGE, 0, (LPARAM)enc);
	free(enc);

	if(m_Pen){
		DeleteObject(m_Pen);
		m_Pen = NULL;
	}
	m_Pen = CreatePen(PS_SOLID, 1, color);
	strcpy(m_CustPath, affPath);
	PathRemoveFileSpec(m_CustPath);
	strcat(m_CustPath, "\\");
	_loadCustomDictionary();
}
コード例 #2
0
ファイル: hunspell.c プロジェクト: AncientCode/HAL-old
static int
HunSpell_init(HunSpell * self, PyObject *args, PyObject *kwds)
{
	char *dpath;
	char *apath;

	if (!PyArg_ParseTuple(args, "ss", &dpath, &apath))
		return 1;

	self->handle = Hunspell_create(apath, dpath);
	return 0;
}
コード例 #3
0
ファイル: TCommandLine.cpp プロジェクト: Aico/sfmudlet
TCommandLine::TCommandLine( Host * pHost, TConsole * pConsole, QWidget * parent )
: QPlainTextEdit( parent )
, mpHost( pHost )
, mpConsole( pConsole )
, mSelectedText( "" )
, mSelectionStart( 0 )

{
    QString path;
#ifdef Q_OS_LINUX
    path = "/usr/share/hunspell/";
#else
    path = "./";
#endif

    QString spell_aff = path + pHost->mSpellDic + ".aff";
    QString spell_dic = path + pHost->mSpellDic + ".dic";
    mpHunspell = Hunspell_create( spell_aff.toLatin1().data(), spell_dic.toLatin1().data() );//"en_US.aff", "en_US.dic");
    mpKeyUnit = mpHost->getKeyUnit();
    setAutoFillBackground(true);
    setFocusPolicy(Qt::StrongFocus);

    QFont font = mpHost->mDisplayFont;
    setFont(font);

    mRegularPalette.setColor(QPalette::Text, mpHost->mCommandLineFgColor );//QColor(0,0,192));
    mRegularPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mRegularPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mRegularPalette.setColor(QPalette::Base,mpHost->mCommandLineBgColor);//QColor(255,255,225));

    setPalette( mRegularPalette );

    mTabCompletionPalette.setColor(QPalette::Text,QColor(0,0,192));
    mTabCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mTabCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mTabCompletionPalette.setColor(QPalette::Base,QColor(235,255,235));

    mAutoCompletionPalette.setColor(QPalette::Text,QColor(0,0,192));
    mAutoCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mAutoCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mAutoCompletionPalette.setColor(QPalette::Base,QColor(255,235,235));


    mHistoryBuffer = 0;
    mAutoCompletion = false;
    setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setCenterOnScroll( false );
    setWordWrapMode( QTextOption::WrapAnywhere );
//    setMaximumBlockCount(1);
    setContentsMargins(0,0,0,0);
}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: PrasadHonrao/zoggle
void allPossibleWords::run()
{
    QTextStream out(stdout); //for debug;
    out << "Running " << startingDice << "\n";out.flush();
    Bools diceUsed;
    for(int i=0;i<16;i++) {
        diceUsed.bools[i] = false;
    }
    QString word("");

    spellChecker = Hunspell_create("/usr/share/myspell/en_US.aff","/usr/share/myspell/en_US.dic");
    missedWordsRecursion(word,startingDice,diceUsed);
    out << "Dice " << startingDice << " done.\n";
    out.flush();
    emit done();
}
コード例 #5
0
void * spellcheck_create(const char * lang)
{
	size_t i = 0, j = 0;
	Hunhandle *h = NULL;

	memset(hunspell_aff_file, 0, FPATHLEN);
	memset(hunspell_dic_file, 0, FPATHLEN);
	for (i = 0; i < sizeof(spellcheck_lang_mapping)/sizeof(char *); i += 2)
	{
		if (0 != strcmp(lang, spellcheck_lang_mapping[i])) continue;

		/* check in each hunspell_dict_dir if the files exist */
		for (j = 0; j < sizeof(hunspell_dict_dirs)/sizeof(char *); ++j)
		{
			FILE *fh;
			/* if the directory name is NULL then ignore */
			if (hunspell_dict_dirs[j] == NULL) continue;

			snprintf(hunspell_aff_file, FPATHLEN, "%s/%s.aff", hunspell_dict_dirs[j],
					spellcheck_lang_mapping[i+1]);
			snprintf(hunspell_dic_file, FPATHLEN, "%s/%s.dic", hunspell_dict_dirs[j],
					spellcheck_lang_mapping[i+1]);

			/* Some versions of Hunspell_create() will succeed even if
			 * there are no dictionary files. So test for permissions.
			 */
			fh = fopen(hunspell_aff_file, "r");
			if (fh) fclose (fh);
			else continue;

			fh = fopen(hunspell_dic_file, "r");
			if (fh) fclose (fh);
			else continue;

			h = Hunspell_create(hunspell_aff_file, hunspell_dic_file);
			/* if hunspell handle was created break from loop */
			if (h != NULL)
				break;
		}
		/* if hunspell handle was created break from loop */
		if (h != NULL) break;
	}
	return h;
}
コード例 #6
0
ファイル: mainwindow.cpp プロジェクト: PrasadHonrao/zoggle
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    QTextStream out(stdout); //for debug

    ui->setupUi(this);
    setWindowTitle("Zoggle");
    gameRunning = false;
    setupDice();

    spellChecker = Hunspell_create("en_US.aff","en_US.dic");
    if(Hunspell_spell(spellChecker,"GEO")) {
        out << "GEO is a word\n";
    }
    if(Hunspell_spell(spellChecker,"geo")) {
        out << "geo is a word\n";
    }
    if(Hunspell_spell(spellChecker,"Geo")) {
        out << "Geo is a word\n";
    }

    timeRemaining = TOTAL_TIME; //in seconds;
    ui->timeBar->setMaximum(TOTAL_TIME);
    ui->timeBar->setValue(TOTAL_TIME - timeRemaining);
    ui->timeRemaining->display(timeRemaining);
    QPalette timePalette = ui->timeRemaining->palette();
    timePalette.setColor(QPalette::Foreground, QColor("green"));
    ui->timeRemaining->setPalette(timePalette);
    timePalette = ui->timeBar->palette();
    timePalette.setColor(QPalette::Highlight, QColor("green"));
    ui->timeBar->setPalette(timePalette);
    ui->calculateBar->setValue(0);
    ui->calculateBar->setEnabled(false);

    connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newGame()));
    connect(ui->newWord,SIGNAL(returnPressed()),this,SLOT(addToList()));
    ui->newWord->setFocus();
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeRemaining()));

    //validWords->setup(button,buttonLink);
}
コード例 #7
0
ファイル: hunspell.c プロジェクト: tyll/pyhunspell
static int
HunSpell_init(HunSpell * self, PyObject *args, PyObject *kwds)
{
	PyObject *dpath;
	PyObject *apath;

#if PY_VERSION_HEX < 0x03010000
	if (!PyArg_ParseTuple(args, "etet", Py_FileSystemDefaultEncoding, &dpath, Py_FileSystemDefaultEncoding, &apath))
#else
	if (!PyArg_ParseTuple(args, "O&O&", PyUnicode_FSConverter, &dpath, PyUnicode_FSConverter, &apath))
#endif
		return 1;

	self->handle = Hunspell_create(PyBytes_AsString(apath), PyBytes_AsString(dpath));
	self->encoding = Hunspell_get_dic_encoding(self->handle);

	Py_DECREF(dpath);
	Py_DECREF(apath);

	return 0;
}
コード例 #8
0
static Hunhandle*
lw_morphologyengine_hunspell_new_by_locale (const gchar *LOCALE)
{
    gchar **pathlist;
    gchar *path, *dpath, *affpath;
    gchar *locale;
    gint i;
    Hunhandle *handle;

    handle = NULL;

    locale = lw_morphologyengine_hunspell_build_noramalized_locale (LOCALE);
    if (locale != NULL)
    {
      pathlist = lw_morphologyengine_hunspell_get_dictionary_paths ();
      if (pathlist != NULL)
      {
        for (i = 0; handle == NULL && pathlist[i] != NULL; i++)
        {
          path = g_build_filename (pathlist[i], locale, NULL);
          dpath = g_strjoin (".", path, "dic", NULL);
          affpath = g_strjoin (".", path, "aff", NULL);
          if (g_file_test (affpath, G_FILE_TEST_IS_REGULAR) && 
              g_file_test (dpath, G_FILE_TEST_IS_REGULAR))
            handle = Hunspell_create (affpath, dpath);
          if (path != NULL) g_free (path); path = NULL;
          if (dpath != NULL) g_free (dpath); dpath = NULL;
          if (affpath != NULL) g_free (affpath); affpath = NULL;
        }
        g_strfreev (pathlist); pathlist = NULL;
      }
      g_free (locale); locale = NULL;
    }
    
    return handle;
}
コード例 #9
0
ファイル: TCommandLine.cpp プロジェクト: Mudlet/Mudlet
TCommandLine::TCommandLine(Host* pHost, TConsole* pConsole, QWidget* parent)
: QPlainTextEdit(parent)
, mpHost(pHost)
, mpConsole(pConsole)
, mSelectedText()
, mSelectionStart(0)
, mTabCompletion()
, mTabCompletionCount()
, mAutoCompletionCount()
, mUserKeptOnTyping()
, mHunspellSuggestionNumber()
, mpHunspellSuggestionList()
{
    QString path;
    // This is duplicated (and should be the same as) the code in:
    // (void) dlgProfilePreferences::initWithHost(Host*)
#if defined(Q_OS_MACOS)
    path = QStringLiteral("%1/../Resources/").arg(QCoreApplication::applicationDirPath());
#elif defined(Q_OS_FREEBSD)
    if (QFile::exists(QStringLiteral("/usr/local/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
        path = QLatin1String("/usr/local/share/hunspell/");
    } else if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
        path = QLatin1String("/usr/share/hunspell/");
    } else {
        path = QLatin1String("./");
    }
#elif defined(Q_OS_LINUX)
    if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) {
        path = QLatin1String("/usr/share/hunspell/");
    } else {
        path = QLatin1String("./");
    }
#else
    // Probably Windows!
    path = "./";
#endif

    QString spell_aff = QStringLiteral("%1%2.aff").arg(path, pHost->mSpellDic);
    QString spell_dic = QStringLiteral("%1%2.dic").arg(path, pHost->mSpellDic);
    // The man page for hunspell advises Utf8 encoding of the pathFileNames for
    // use on Windows platforms which can have non ASCII characters...
    mpHunspell = Hunspell_create(spell_aff.toUtf8().constData(), spell_dic.toUtf8().constData());
    mpKeyUnit = mpHost->getKeyUnit();
    setAutoFillBackground(true);
    setFocusPolicy(Qt::StrongFocus);

    QFont font = mpHost->mDisplayFont;
    setFont(font);

    mRegularPalette.setColor(QPalette::Text, mpHost->mCommandLineFgColor); //QColor(0,0,192));
    mRegularPalette.setColor(QPalette::Highlight, QColor(0, 0, 192));
    mRegularPalette.setColor(QPalette::HighlightedText, QColor(Qt::white));
    mRegularPalette.setColor(QPalette::Base, mpHost->mCommandLineBgColor); //QColor(255,255,225));

    setPalette(mRegularPalette);

    mTabCompletionPalette.setColor(QPalette::Text, QColor(0, 0, 192));
    mTabCompletionPalette.setColor(QPalette::Highlight, QColor(0, 0, 192));
    mTabCompletionPalette.setColor(QPalette::HighlightedText, QColor(Qt::white));
    mTabCompletionPalette.setColor(QPalette::Base, QColor(235, 255, 235));

    mAutoCompletionPalette.setColor(QPalette::Text, QColor(0, 0, 192));
    mAutoCompletionPalette.setColor(QPalette::Highlight, QColor(0, 0, 192));
    mAutoCompletionPalette.setColor(QPalette::HighlightedText, QColor(Qt::white));
    mAutoCompletionPalette.setColor(QPalette::Base, QColor(255, 235, 235));


    mHistoryBuffer = 0;
    mAutoCompletion = false;
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setCenterOnScroll(false);
    setWordWrapMode(QTextOption::WrapAnywhere);
    setContentsMargins(0, 0, 0, 0);
}