Ejemplo n.º 1
0
USplashWindow::USplashWindow(HINSTANCE hInst)
: UBaseWindow(NULL, hInst, m_cSplashWndClass),
  _clrTrans(huys::white)
{
    ::ZeroMemory(m_sFilename, sizeof(m_sFilename));
    //setWndClassName(m_cSplashWndClass);
    setStyles(WS_POPUP|WS_VISIBLE);
    setTitle(_T("splash"));
    setExStyles(WS_EX_TOPMOST | WS_EX_TOOLWINDOW);
}
Ejemplo n.º 2
0
StylesPlugin::StylesPlugin(unsigned base, const char *config)
        : Plugin(base)
{
    m_saveBaseFont = NULL;
    m_saveMenuFont = NULL;
    m_savePalette = new QPalette(QApplication::palette());
    load_data(stylesData, &data, config);
    setFonts();
    if (getSystemColors()){
        setBtnColor(m_savePalette->active().color(QColorGroup::Button).rgb() & 0xFFFFFF);
        setBgColor(m_savePalette->active().color(QColorGroup::Background).rgb() & 0xFFFFFF);
    }else{
        setColors();
    }
    setStyles();
}
Ejemplo n.º 3
0
void openOptionDlg(void)
{
    if (OptionDlg.doDialog(&Settings) == IDOK)
    {
        saveSettings();
        if (active)
        {
            setStyles(Settings);
            
            NavDlg.SetColor(
                Settings.ColorSettings.added, 
                Settings.ColorSettings.deleted, 
                Settings.ColorSettings.changed, 
                Settings.ColorSettings.moved, 
                Settings.ColorSettings.blank);

            NavDlg.CreateBitmap();
        }
    }
}
Ejemplo n.º 4
0
void FileEditorWnd::setFile(const std::shared_ptr<const File>& file, int line, int col, bool columnIsOffset)
{
	if (m_file != file)
	{
		if (m_file)
			gWorkspace->removeFileSaveFunc(m_file->id);

		m_file = file;
		gWorkspace->setFileDirty(m_file->id, false);
		gWorkspace->setFileSaveFunc(m_file->id, [this](const std::shared_ptr<const File>& file)
		{
			return m_textCtrl->SaveFile(file->fullpath.widen());
		});

		// Find the language we want
		UTF8String ext = file->extension;
		LanguageInfo* lang = nullptr;
		for (auto& l : gLanguages)
		{
			if (cz::find(l.fileextensions, ext) != l.fileextensions.end())
			{
				lang = &l;
				break;
			}
		}

		m_textCtrl->Freeze();

		// Set the default shared style before StyleClearAll, because as specified in scintilla documentation,
		// StyleClearAll will reset all other styles to wxSTC_STYLE_DEFAULT
		setStyle(m_textCtrl, gSharedStyles[0]);
		m_textCtrl->StyleClearAll();
		if (lang)
			m_textCtrl->SetLexer(lang->lexer);
		setCommonStyle();
		setStyles(m_textCtrl, gSharedStyles);
		// Set styles specific to the language
		if (lang)
			setStyles(m_textCtrl, lang->styles);

		updateViewOptions();
	
		m_textCtrl->SetReadOnly(false);
		m_isLoading = true;
		m_textCtrl->LoadFile(file->fullpath.c_str(), wxTEXT_TYPE_ANY);
		m_isLoading = false;
		m_textCtrl->Connect(wxEVT_STC_MARGINCLICK, wxStyledTextEventHandler(FileEditorWnd::OnMarginClick), NULL, this);
		m_textCtrl->Thaw();
		m_textCtrl->SetSavePoint();
		m_textCtrl->EmptyUndoBuffer();

		gWorkspace->iterateBreakpoints(m_file->id, [&](const Breakpoint* brk)
		{
			syncBreakpoint(brk);
		});

		updateErrorMarkers();
		updateMarkers();

		m_textCtrl->Fit();
		this->Layout();
	}

	if (line >= 1 && col >= 0)
	{
		if (columnIsOffset)
		{
			// Column is a real offset into the text (doesn't take into account tab width)
			int pos = m_textCtrl->PositionFromLine(TO_TXTLINE(line));
			m_textCtrl->GotoPos(pos + col);
		} else{
			// Column is a visual offset into the text (takes into account tab width)
			int pos = m_textCtrl->FindColumn(TO_TXTLINE(line), col);
			m_textCtrl->GotoPos(pos);
			// There seems to be a bug with GotoPos, where the Horizontal scrolling gets out of sync, so I'm
			// just resetting it.
			// Maybe this bug: http://sourceforge.net/p/scintilla/bugs/1467/
			//This will of course mean that it will not scroll at all to show the desired column,
			// but (although the caret will still be at the desired column)
			m_textCtrl->SetXOffset(0);
		}
	}


	//m_textCtrl->VerticalCentreCaret();
}
PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument *parent)
    : QSyntaxHighlighter(parent) {
  keywords = QStringList() << "and"
                           << "assert"
                           << "break"
                           << "class"
                           << "continue"
                           << "def"
                           << "del"
                           << "elif"
                           << "else"
                           << "except"
                           << "exec"
                           << "finally"
                           << "for"
                           << "from"
                           << "global"
                           << "if"
                           << "import"
                           << "in"
                           << "is"
                           << "lambda"
                           << "not"
                           << "or"
                           << "pass"
                           << "raise"
                           << "return"
                           << "try"
                           << "while"
                           << "yield"
                           << "None"
                           << "True"
                           << "False";

  operators = QStringList() << "="
                            << "=="
                            << "!="
                            << "<"
                            << "<="
                            << ">"
                            << ">="
                            << "\\+"
                            << "-"
                            << "\\*"
                            << "/"
                            << "//"
                            << "%"
                            << "\\*\\*"
                            << "\\+="
                            << "-="
                            << "\\*="
                            << "/="
                            << "%="
                            << "\\^"
                            << "\\|"
                            << "&"
                            << "~"
                            << ">>"
                            << "<<";

  braces = QStringList() << ":"
                         << ";"
                         << ","
                         << "@"
                         << "{"
                         << "}"
                         << "\\("
                         << "\\)"
                         << "\\["
                         << "\\]";

  builtins = QStringList() << "abs"
                           << "divmod"
                           << "input"
                           << "open"
                           << "staticmethod"
                           << "all"
                           << "enumerate"
                           << "int"
                           << "ord"
                           << "str"
                           << "any"
                           << "eval"
                           << "isinstance"
                           << "pow"
                           << "sum"
                           << "basestring"
                           << "execfile"
                           << "issubclass"
                           << "print"
                           << "super"
                           << "bin"
                           << "file"
                           << "iter"
                           << "property"
                           << "tuple"
                           << "bool"
                           << "filter"
                           << "len"
                           << "range"
                           << "type"
                           << "bytearray"
                           << "float"
                           << "list"
                           << "raw_input"
                           << "unichr"
                           << "callable"
                           << "format"
                           << "locals"
                           << "reduce"
                           << "unicode"
                           << "chr"
                           << "frozenset"
                           << "long"
                           << "reload"
                           << "vars"
                           << "classmethod"
                           << "getattr"
                           << "map"
                           << "repr"
                           << "xrange"
                           << "cmp"
                           << "globals"
                           << "max"
                           << "reversed"
                           << "zip"
                           << "compile"
                           << "hasattr"
                           << "memoryview"
                           << "round"
                           << "__import__"
                           << "complex"
                           << "hash"
                           << "min"
                           << "set"
                           << "apply"
                           << "delattr"
                           << "help"
                           << "next"
                           << "setattr"
                           << "buffer"
                           << "dict"
                           << "hex"
                           << "object"
                           << "slice"
                           << "coerce"
                           << "dir"
                           << "id"
                           << "oct"
                           << "sorted"
                           << "intern";

  exceptions = QStringList() << "BaseException"
                             << "SystemExit"
                             << "KeyboardInterrupt"
                             << "GeneratorExit"
                             << "Exception"
                             << "StopIteration"
                             << "ArithmeticError"
                             << "FloatingPointError"
                             << "OverflowError"
                             << "ZeroDivisionError"
                             << "AssertionError"
                             << "AttributeError"
                             << "BufferError"
                             << "EOFError"
                             << "ImportError"
                             << "LookupError"
                             << "IndexError"
                             << "KeyError"
                             << "MemoryError"
                             << "NameError"
                             << "UnboundLocalError"
                             << "OSError"
                             << "BlockingIOError"
                             << "ChildProcessError"
                             << "ConnectionError"
                             << "BrokenPipeError"
                             << "ConnectionAbortedError"
                             << "ConnectionRefusedError"
                             << "ConnectionResetError"
                             << "FileExistsError"
                             << "FileNotFoundError"
                             << "InterruptedError"
                             << "IsADirectoryError"
                             << "NotADirectoryError"
                             << "PermissionError"
                             << "ProcessLookupError"
                             << "TimeoutError"
                             << "ReferenceError"
                             << "RuntimeError"
                             << "NotImplementedError"
                             << "SyntaxError"
                             << "IndentationError"
                             << "TabError"
                             << "SystemError"
                             << "TypeError"
                             << "ValueError"
                             << "UnicodeError"
                             << "UnicodeDecodeError"
                             << "UnicodeEncodeError"
                             << "UnicodeTranslateError"
                             << "Warning"
                             << "DeprecationWarning"
                             << "PendingDeprecationWarning"
                             << "RuntimeWarning"
                             << "SyntaxWarning"
                             << "UserWarning"
                             << "FutureWarning"
                             << "ImportWarning"
                             << "UnicodeWarning"
                             << "BytesWarning"
                             << "ResourceWarning";

  setStyles();
  mSearchRegex = tr("");
  mSearchHighlight = getTextCharFormat("black", "bold", "yellow");
  triSingleQuote.setPattern("'''");
  triDoubleQuote.setPattern("\"\"\"");

  initializeRules();
}
Ejemplo n.º 6
0
bool startCompare()
{
	LRESULT RODoc1;
	LRESULT RODoc2;
    int win = 3;

    ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&win);
    HWND window = getCurrentHScintilla(win);

    if(!IsWindowVisible(nppData._scintillaMainHandle) || !IsWindowVisible(nppData._scintillaSecondHandle))
    {	
        SendMessage(nppData._nppHandle, WM_COMMAND, IDM_VIEW_GOTO_ANOTHER_VIEW, 0);
        panelsOpened = true;
    }

    if(!IsWindowVisible(nppData._scintillaMainHandle) || !IsWindowVisible(nppData._scintillaSecondHandle))
    {	
        panelsOpened = false;
        ::MessageBox(nppData._nppHandle, TEXT("Nothing to compare!"), TEXT("Error"), MB_OK);
        return true;
    }

    if(!notepadVersionOk)
    {
        int version = ::SendMessage(nppData._nppHandle,NPPM_GETNPPVERSION, 0, 0);
        if(version > 0)
        {
            notepadVersionOk = true;
        }
    }

    if(Settings.AddLine && !notepadVersionOk)
    {
        ::MessageBox(nppData._nppHandle, TEXT("Notepad v4.5 or higher is required to line up matches. This feature will be turned off"), TEXT("Incorrect Version"), MB_OK);
        Settings.AddLine = false;
        ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_ALIGN_MATCHES]._cmdID, (LPARAM)Settings.AddLine);
    }

	// Remove read-only attribute
	if ((RODoc1 = SendMessage(nppData._scintillaMainHandle, SCI_GETREADONLY, 0, 0)) == 1)
		SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, false, 0);

	if ((RODoc2 = SendMessage(nppData._scintillaSecondHandle, SCI_GETREADONLY, 0, 0)) == 1)
		SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, false, 0);

    SendMessageA(nppData._scintillaMainHandle, SCI_SETWRAPMODE, SC_WRAP_NONE, 0);
    SendMessageA(nppData._scintillaSecondHandle, SCI_SETWRAPMODE, SC_WRAP_NONE, 0);

    setStyles(Settings);

    int doc1 = SendMessageA(nppData._scintillaMainHandle, SCI_GETDOCPOINTER, 0, 0);
    int doc2 = SendMessageA(nppData._scintillaSecondHandle, SCI_GETDOCPOINTER, 0, 0);

    setCompare(doc1);
    setCompare(doc2);

    /* sync pannels */
    HMENU hMenu = ::GetMenu(nppData._nppHandle);

    if ((::GetMenuState(hMenu, IDM_VIEW_SYNSCROLLV, MF_BYCOMMAND) & MF_CHECKED) != 0)
    {
        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLV, 0), 0);
    }

    if ((::GetMenuState(hMenu, IDM_VIEW_SYNSCROLLH, MF_BYCOMMAND) & MF_CHECKED) != 0)
    {
        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLH, 0), 0);
    }

    ::SendMessageA(nppData._scintillaMainHandle, SCI_GOTOPOS, 1, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_GOTOPOS, 1, 0);
    ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLV, 0), 0);
    ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLH, 0), 0);
    ::SendMessageA(nppData._scintillaMainHandle, SCI_SETUNDOCOLLECTION, FALSE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_SETUNDOCOLLECTION, FALSE, 0);

    bool result = compareNew();

    ::SendMessageA(nppData._scintillaMainHandle, SCI_SETUNDOCOLLECTION, TRUE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_SETUNDOCOLLECTION, TRUE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle/*window*/, SCI_GRABFOCUS, 0, (LPARAM)1);

	// Restore previous read-only attribute
	if (RODoc1 == 1) SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, true, 0);
	if (RODoc2 == 1) SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, true, 0);

    if (!result)
	{
        if(Settings.UseNavBar)
		{
			// Save current N++ focus
			HWND hwnd = GetFocus();

			// Configure NavBar
			NavDlg.SetColor(
				Settings.ColorSettings.added, 
				Settings.ColorSettings.deleted, 
				Settings.ColorSettings.changed, 
				Settings.ColorSettings.moved, 
				Settings.ColorSettings.blank);

			// Display Navbar
			NavDlg.doDialog(true);
			start_old = -1;

			// Restore N++ focus
			SetFocus(hwnd);

		}
		// Enable Prev/Next menu entry
		::EnableMenuItem(hMenu, funcItem[CMD_NEXT]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_PREV]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_FIRST]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_LAST]._cmdID, MF_BYCOMMAND | MF_ENABLED);
	}

	return result;
}