Example #1
0
void ToDoList::OnReparseCurrent(CodeBlocksEvent& event)
{
#if 0
    if(event.GetEventType()==cbEVT_EDITOR_OPEN)
        Manager::Get()->GetLogManager()->DebugLog(wxT("ToDoList::OnReparseCurrent(): cbEVT_EDITOR_OPEN"));
    else if(event.GetEventType()==cbEVT_EDITOR_SAVE)
        Manager::Get()->GetLogManager()->DebugLog(wxT("ToDoList::OnReparseCurrent(): cbEVT_EDITOR_SAVE"));
    else if(event.GetEventType()==cbEVT_EDITOR_ACTIVATED)
        Manager::Get()->GetLogManager()->DebugLog(wxT("ToDoList::OnReparseCurrent(): cbEVT_EDITOR_ACTIVATED"));
    else if(event.GetEventType()==cbEVT_EDITOR_CLOSE)
        Manager::Get()->GetLogManager()->DebugLog(wxT("ToDoList::OnReparseCurrent(): cbEVT_EDITOR_CLOSE"));
#endif // debug only

    bool forced = (event.GetEventType() == cbEVT_EDITOR_OPEN || event.GetEventType() == cbEVT_EDITOR_SAVE);
    if (m_InitDone && m_AutoRefresh && !(ProjectManager::IsBusy()))
    {
        if (m_ParsePending)
        {
            m_ParsePending = false;
            Parse();
        }
        else
            ParseCurrent(forced);
    }
    event.Skip();
}
Example #2
0
void ToDoList::OnReparseCurrent(CodeBlocksEvent& event)
{
    bool forced = (event.GetEventType() == cbEVT_EDITOR_OPEN || event.GetEventType() == cbEVT_EDITOR_SAVE);
    if (m_InitDone && m_AutoRefresh && !(ProjectManager::IsBusy()))
    {
        if (m_ParsePending)
        {
            m_ParsePending = false;
            Parse();
        }
        else
            ParseCurrent(forced);
    }
    event.Skip();
}
Example #3
0
//Funkcija za prikaz trenutnog vremena
void CurrentWeather(wstring city)
{
	WeatherInfo weather;
	auto result(async(SendRequest, L"weather?q=" + city));//future kupi return iz funkcije da ga mogu posle iskoristiti
	cls();
	Center(16, true); cout << "Fetching data";
	cursorPos = getCursorPos();
	for (int i = 0; result.wait_for(span) != future_status::ready; i++)
	{
		SetConsoleCursorPosition(ConsoleH, cursorPos);
		switch (i % 4)
		{
			case 0:
				cout << "   ";
				break;
			case 1:
				cout << ".  ";
				break;
			case 2:
				cout << ".. ";
				break;
			case 3:
				cout << "...";
		}
		if (i > 50)
		{
			Center(16, true);
			cout << "  Fetch failed  ";
			SetConsoleTextAttribute(ConsoleH, 240);
			Center(4, 4);
			cout << "Back";
			SetConsoleTextAttribute(ConsoleH, 15);
			while (_getch() != 13);
			return;
		}
	}
	weather = ParseCurrent(result.get());
	if (weather.cityName.size() < 1)
	{
		Center(16, true);
		cout << "  Fetch failed  ";
		SetConsoleTextAttribute(ConsoleH, 240);
		Center(4, 4);
		cout << "Back";
		SetConsoleTextAttribute(ConsoleH, 15);
		while (_getch() != 13);
		return;
	}
	cls();
	Center(19 + city.size()); cout << "Current Weather in " << weather.cityName << "\n";
	Center(38); PrintNow(); PrintNum(static_cast<int>(weather.weather[0].temp)); cout << endl;
	Center(26); cout << "Max temp: " << weather.weather[0].tempMax << "  Min temp: " << weather.weather[0].tempMin << "\n\n\n";
	Center(19); cout << "Weather: " << weather.weather[0].main << endl;
	Center(19); cout << "Cloudiness: " << weather.weather[0].cloudiness << "%" << endl;
	Center(19); cout << "Wind speed: " << weather.weather[0].windSpeed << " m/s" << endl;
	SetConsoleTextAttribute(ConsoleH, 240);
	Center(4, 4);
	cout << "Back";
	SetConsoleTextAttribute(ConsoleH, 15);
	while (_getch() != 13);
}
Example #4
0
void ToDoList::OnAddItem(cb_unused wxCommandEvent& event)
{
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
        return;

    EditorColourSet* colour_set = Manager::Get()->GetEditorManager()->GetColourSet();
    if (!colour_set)
        return;

    HighlightLanguage hlang = colour_set->GetLanguageName(ed->GetLanguage());
    bool edIsCCpp = (hlang == _T("C/C++"));

    CommentToken token = colour_set->GetCommentToken(ed->GetLanguage());
    bool hasStreamComments = not token.streamCommentStart.IsEmpty();
    bool hasLineComments = not token.lineComment.IsEmpty();

    if (!(edIsCCpp||hasLineComments||hasStreamComments))
        return;
    std::bitset<(int)tdctError+1> supportedTdcts;
    supportedTdcts[tdctLine] = !(token.lineComment.IsEmpty());
    supportedTdcts[tdctStream] = !(token.streamCommentStart.IsEmpty());
    supportedTdcts[tdctDoxygenLine] = !(token.doxygenLineComment.IsEmpty());
    supportedTdcts[tdctDoxygenStream] = !(token.doxygenStreamCommentStart.IsEmpty());
    supportedTdcts[tdctWarning] = edIsCCpp;
    supportedTdcts[tdctError] = edIsCCpp;
    // display todo dialog
    AddTodoDlg dlg(Manager::Get()->GetAppWindow(), m_Users, m_Types, supportedTdcts );
    PlaceWindow(&dlg);
    if (dlg.ShowModal() != wxID_OK)
        return;
    // Re-load users and types as they might have changed by the user via AddTodoDlg
    LoadUsers();
    LoadTypes();

    cbStyledTextCtrl* control = ed->GetControl();

    // calculate insertion point
    int idx = 0;
    int crlfLen = 0; // length of newline chars
    int origPos = control->GetCurrentPos(); // keep current position in the document
    int line = control->GetCurrentLine(); // current line
    ToDoCommentType CmtType = dlg.GetCommentType();
    if (dlg.GetPosition() == tdpCurrent)
    {
        idx = control->GetCurrentPos(); // current position in the document
        // if the style is cpp comments (// ...), there's the possibility that the current position
        // is somewhere in the middle of a line of code; this would result
        // in everything after the insertion point to turn into comments
        // let's double check this with the user
        if (idx != control->GetLineEndPosition(line) && (CmtType != tdctStream) && (CmtType != tdctDoxygenStream))
        {
            // let's ask the user, and present as options
            // keep cpp style at current position, switch to c style, add the todo at the end (keeping cpp style)
            // if user cancels out / do nothing : just return
            // future idea : check if there's any non white space character
            // if yes -> in the middle of code
            // if no -> then only whitespace after the insertion point -> no harm to turn that into comments
            wxString streamStart = token.streamCommentStart, streamEnd = token.streamCommentEnd;
            if (CmtType == tdctDoxygenLine && !token.doxygenStreamCommentStart.IsEmpty())
            {
                streamStart = token.doxygenStreamCommentStart;
                streamEnd = token.doxygenStreamCommentEnd;
            }
            AskTypeDlg asktype_dlg(Manager::Get()->GetAppWindow(), streamStart, streamEnd);
            PlaceWindow(&asktype_dlg);
            if (asktype_dlg.ShowModal() != wxID_OK)
                return;
            switch(asktype_dlg.GetTypeCorrection())
            {
                case tcStay:
                    break; // do nothing, leave things as they are
                case tcSwitch:
                    if (CmtType == tdctDoxygenLine)
                        CmtType = tdctDoxygenStream;
                    else
                        CmtType = tdctStream;
                    break;
                case tcMove:
                default:
                    idx = control->GetLineEndPosition(line);
                    break;
            } // end switch
        }
    }
    else
    {
        if      (dlg.GetPosition() == tdpAbove)
            idx = control->GetLineEndPosition(line - 1); // get previous line's end
        else if (dlg.GetPosition() == tdpBelow)
            idx = control->GetLineEndPosition(line); // get current line's end
        // calculate insertion point by skipping next newline
        switch (control->GetEOLMode())
        {
            case wxSCI_EOL_CRLF: crlfLen = 2; break;
            case wxSCI_EOL_CR: // fall-though
            case wxSCI_EOL_LF: // fall-though
            default:             crlfLen = 1; break;
        }
        if (idx > 0)
            idx += crlfLen;
    }
    // make sure insertion point is valid (bug #1300981)
    if (idx > control->GetLength())
        idx = control->GetLength();

    // ok, construct todo line text like this:
    // TODO (mandrav#0#): Implement code to do this and the other...
    wxString buffer;

    // start with the comment
    switch(CmtType)
    {
        default:
        case tdctLine:
            buffer << token.lineComment;
            break;
        case tdctDoxygenLine:
            buffer << token.doxygenLineComment;
            break;
        case tdctDoxygenStream:
            buffer << token.doxygenStreamCommentStart;
            break;
        case tdctWarning:
            buffer << _T("#warning");
            break;
        case tdctError:
            buffer << _T("#error");
            break;
        case tdctStream:
            buffer << token.streamCommentStart;
            break;
    } // end switch
    buffer << _T(" ");

    // continue with the type
    buffer << dlg.GetType() << _T(" ");
    wxString priority = wxString::Format(_T("%d"), dlg.GetPriority()); // do it like this (wx bug with int and streams)

    // now do the () part
    buffer << _T("(") << dlg.GetUser() << _T("#") << priority << _T("#") << (dlg.DateRequested() ? (wxDateTime::Today().Format(_T("%x): "))) :  _T("): "));

    wxString text = dlg.GetText();

    // make sure that multi-line notes, don't break the todo
    if ( (CmtType == tdctWarning) || (CmtType == tdctError) )
    {
        if (text.Replace(_T("\r\n"), _T("\\\r\n")) == 0)
            text.Replace(_T("\n"), _T("\\\n"));
        // now see if there were already a backslash before newline
        if (text.Replace(_T("\\\\\r\n"), _T("\\\r\n")) == 0)
            text.Replace(_T("\\\\\n"), _T("\\\n"));
    }
    else if (CmtType == tdctLine || (CmtType == tdctDoxygenLine))
    {
        wxString lc;
        if (CmtType == tdctLine)
            lc = token.lineComment;
        else
            lc = token.doxygenLineComment;
        // comment every line from the todo text
        if ( text.Replace(_T("\r\n"), _T("\r\n")+lc) == 0 )
            text.Replace(_T("\n"), _T("\n")+lc);
        // indicate (on the first line) that there is some more text
        if ( text.Replace(_T("\r\n"), _T(" ...\r\n"),false) == 0 )
            text.Replace(_T("\n"), _T(" ...\n"),false);
    }

    // add the actual text
    buffer << text;

    if ( CmtType == tdctStream )
        buffer << _T(" ") << token.streamCommentEnd;
    if ( CmtType == tdctDoxygenStream )
        buffer << _T(" ") << token.doxygenStreamCommentEnd;

    // add newline char(s), only if dlg.GetPosition() != tdpCurrent
    if (dlg.GetPosition() != tdpCurrent)
        buffer << GetEOLStr(control->GetEOLMode());

    // ok, insert the todo line text
    control->InsertText(idx, buffer);
    if (dlg.GetPosition() == tdpAbove)
        origPos += buffer.Length() + crlfLen;
    control->GotoPos(origPos);
    control->EnsureCaretVisible();

    ParseCurrent(true);
} // end of OnAddItem
Example #5
0
void ToDoList::OnAddItem(wxCommandEvent& event)
{
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
        return;

    // display todo dialog
    AddTodoDlg dlg(Manager::Get()->GetAppWindow(), m_Users, m_Types);
    PlaceWindow(&dlg);
    if (dlg.ShowModal() != wxID_OK)
        return;
    // Re-load users and types as they might have changed by the user via AddTodoDlg
    LoadUsers();
    LoadTypes();

    cbStyledTextCtrl* control = ed->GetControl();

    // calculate insertion point
    int idx = 0;
    int crlfLen = 0; // length of newline chars
    int origPos = control->GetCurrentPos(); // keep current position in the document
    int line = control->GetCurrentLine(); // current line
    ToDoCommentType CmtType = dlg.GetCommentType();
    if (dlg.GetPosition() == tdpCurrent)
    {
        idx = control->GetCurrentPos(); // current position in the document
        // if the style is cpp comments (// ...), there's the possibility that the current position
        // is somewhere in the middle of a line of code; this would result
        // in everything after the insertion point to turn into comments
        // let's double check this with the user
        if (idx != control->GetLineEndPosition(line))
        {
            // let's ask the user, and present as options
            // keep cpp style at current position, switch to c style, add the todo at the end (keeping cpp style)
            // if user cancels out / do nothing : just return
            // future idea : check if there's any non white space character
            // if yes -> in the middle of code
            // if no -> then only whitespace after the insertion point -> no harm to turn that into comments
            AskTypeDlg dlg(Manager::Get()->GetAppWindow());
            PlaceWindow(&dlg);
            if (dlg.ShowModal() != wxID_OK)
                return;
            switch(dlg.GetTypeCorrection())
            {
                case tcCppStay:
                    break; // do nothing, leave things as they are
                case tcCpp2C:
                    CmtType = tdctC;
                    break;
                case tcCppMove:
                default:
                    idx = control->GetLineEndPosition(line);
                    break;
            } // end switch
        }
    }
    else
    {
        if      (dlg.GetPosition() == tdpAbove)
            idx = control->GetLineEndPosition(line - 1); // get previous line's end
        else if (dlg.GetPosition() == tdpBelow)
            idx = control->GetLineEndPosition(line); // get current line's end
        // calculate insertion point by skipping next newline
        switch (control->GetEOLMode())
        {
            case wxSCI_EOL_CR:
            case wxSCI_EOL_LF:   crlfLen = 1; break;
            case wxSCI_EOL_CRLF: crlfLen = 2; break;
        }
        if (idx > 0)
            idx += crlfLen;
    }
    // make sure insertion point is valid (bug #1300981)
    if (idx > control->GetLength())
        idx = control->GetLength();

    // ok, construct todo line text like this:
    // TODO (mandrav#0#): Implement code to do this and the other...
    wxString buffer;

    // start with the comment
    switch(CmtType)
    {
        case tdctCpp:
            buffer << _T("// ");
            break;
        case tdctDoxygenC:
            buffer << _T("/** ");
            break;
        case tdctDoxygenCPP:
            buffer << _T("/// ");
            break;
        case tdctWarning:
            buffer << _T("#warning ");
            break;
        case tdctError:
            buffer << _T("#error ");
            break;
        default:
            buffer << _T("/* ");
            break;
    } // end switch

    // continue with the type
    buffer << dlg.GetType() << _T(" ");
    wxString priority = wxString::Format(_T("%d"), dlg.GetPriority()); // do it like this (wx bug with int and streams)

    // now do the () part
    buffer << _T("(") << dlg.GetUser() << _T("#") << priority << _T("#): ");

    wxString text = dlg.GetText();
    if ( (CmtType != tdctC) && (CmtType != tdctDoxygenC) )
    {
        // make sure that multi-line notes, don't break the todo
        if (text.Replace(_T("\r\n"), _T("\\\r\n")) == 0)
            text.Replace(_T("\n"), _T("\\\n"));
        // now see if there were already a backslash before newline
        if (text.Replace(_T("\\\\\r\n"), _T("\\\r\n")) == 0)
            text.Replace(_T("\\\\\n"), _T("\\\n"));
    }

    // add the actual text
    buffer << text;

    if ( (CmtType == tdctWarning) || (CmtType == tdctError) )
        buffer << _T("");

    else if ( (CmtType == tdctC) || (CmtType == tdctDoxygenC) )
        buffer << _T(" */");

    // add newline char(s), only if dlg.GetPosition() != tdpCurrent
    if (dlg.GetPosition() != tdpCurrent)
    {
        switch (control->GetEOLMode())
        {
            // NOTE: maybe this switch, should make it in the SDK (maybe as cbStyledTextCtrl::GetEOLString())???
            case wxSCI_EOL_CR:   buffer << _T("\n");   break;
            case wxSCI_EOL_CRLF: buffer << _T("\r\n"); break;
            case wxSCI_EOL_LF:   buffer << _T("\r");   break;
        }
    }

    // ok, insert the todo line text
    control->InsertText(idx, buffer);
    if (dlg.GetPosition() == tdpAbove)
        origPos += buffer.Length() + crlfLen;
    control->GotoPos(origPos);
    control->EnsureCaretVisible();

    ParseCurrent(true);
} // end of OnAddItem