Indicator::Ptr Indicators::Impl::AddIndicator(std::string const& name) { Indicator::Ptr indicator(GetIndicator(name)); if (indicator) return indicator; if (name == "libappmenu.so") { auto appmenu = std::make_shared<AppmenuIndicator>(name); appmenu->on_show_appmenu.connect(sigc::mem_fun(owner_, &Indicators::OnShowAppMenu)); indicator = appmenu; } else { indicator = std::make_shared<Indicator>(name); } // The owner Indicators class is interested in the other events. indicator->on_show_menu.connect(sigc::mem_fun(owner_, &Indicators::OnEntryShowMenu)); indicator->on_secondary_activate.connect(sigc::mem_fun(owner_, &Indicators::OnEntrySecondaryActivate)); indicator->on_scroll.connect(sigc::mem_fun(owner_, &Indicators::OnEntryScroll)); indicators_[name] = indicator; owner_->on_object_added.emit(indicator); return indicator; }
void Highlighter::ClearAllIndications(cbStyledTextCtrl* stc)const { if ( stc ) { stc->SetIndicatorCurrent(GetIndicator()); stc->IndicatorClearRange(0, stc->GetLength()); } }
void OnlineSpellChecker::ClearAllIndications(cbStyledTextCtrl* stc)const { if ( stc ) { stc->SetIndicatorCurrent(GetIndicator()); stc->IndicatorClearRange(0, stc->GetLength()); } }
void Indicators::Impl::RemoveIndicator(std::string const& name) { auto indicator = GetIndicator(name); if (indicator) { owner_->on_object_removed.emit(indicator); indicators_.erase(name); } }
void AudioIO::OnTimer() { if (!mProject) return; FillBuffers(); if (mT1!=mT0 && mT >= mT1 && GetIndicator() >= mT1) Stop(); }
int GetIndicatorValue(TowersLib api, int nIndex) { DEBUG_FUNC_NAME; struct Towers* pT = (struct Towers*)api; struct TowersBoard* pBoard = pT->m_pBoard; if( nIndex < 0 || nIndex > pBoard->m_nIndicators ) return -1; struct TowersIndicator* pIndicator = GetIndicator(pBoard, nIndex); return pIndicator->m_nValue; }
int HasIndicatorsOnSide(TowersLib api, int nSide) { DEBUG_FUNC_NAME; struct Towers* pT = (struct Towers*)api; struct TowersBoard* pBoard = pT->m_pBoard; int nIndicator, nNumIndicators = pBoard->m_nIndicators; for(nIndicator=0; nIndicator<nNumIndicators; nIndicator++) { struct TowersIndicator* pIndicator = GetIndicator(pBoard, nIndicator); if( pIndicator->m_nSide == nSide ) return TOWERS_HAS_INDICATOR; } return TOWERS_NO_INDICATOR; }
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce) { if (!g_Settings.bHighlightEnabled || !gce || gce->bIsMe) return FALSE; GCEVENT evTmp = *gce; int dwMask = 0; if (gce->ptszText != NULL) dwMask |= CMUCHighlight::MATCH_TEXT; if (gce->ptszNick != NULL) { dwMask |= CMUCHighlight::MATCH_NICKNAME; if (si && g_Settings.bLogClassicIndicators) { size_t len = _tcslen(gce->ptszNick) + 1; TCHAR *tmp = (TCHAR*)_alloca(sizeof(TCHAR)*(len + 1)); *tmp = GetIndicator(si, gce->ptszNick, 0); _tcscpy(tmp + 1, gce->ptszNick); evTmp.ptszNick = tmp; } } return g_Settings.Highlight->match(&evTmp, si, dwMask); }
virtual wxBitmap GetRadioBitmap(int flags) { return GetIndicator(IndicatorType_Radio, flags); }
virtual wxBitmap GetCheckBitmap(int flags) { return GetIndicator(IndicatorType_Check, flags); }
void Highlighter::DoSetIndications(cbEditor* ctrl)const { cbStyledTextCtrl *stc = ctrl->GetLeftSplitViewControl(); //Returns a pointer to the left (or top) split-view cbStyledTextCtrl. This function always returns a valid pointer. cbStyledTextCtrl *stcr =ctrl->GetRightSplitViewControl(); if (m_AlreadyChecked && m_OldCtrl == ctrl) { if ( m_InvalidatedRangesStart.GetCount() == 0) return; } else { //clear: m_InvalidatedRangesStart.Clear(); m_InvalidatedRangesEnd.Clear(); //add whole document m_InvalidatedRangesStart.Add(0); m_InvalidatedRangesEnd.Add(stc->GetLength()); } m_AlreadyChecked = true; // Set Styling: stc->SetIndicatorCurrent(GetIndicator()); //if(stc->SelectionIsRectangle() || (stcr && stcr->SelectionIsRectangle())) return; if (m_OldCtrl != ctrl) { stc->IndicatorSetStyle(GetIndicator(), wxSCI_INDIC_HIGHLIGHT); stc->IndicatorSetForeground(GetIndicator(), GetIndicatorColor() ); #ifndef wxHAVE_RAW_BITMAP // If wxWidgets is build without rawbitmap-support, the indicators become opaque // and hide the text, so we show them under the text. // Not enabled as default, because the readability is a little bit worse. stc->IndicatorSetUnder(theIndicator,true); #endif } if (stcr) { if (m_OldCtrl != ctrl) { stcr->SetIndicatorCurrent(GetIndicator()); stcr->IndicatorSetStyle(GetIndicator(), wxSCI_INDIC_HIGHLIGHT); stcr->IndicatorSetForeground(GetIndicator(), GetIndicatorColor() ); #ifndef wxHAVE_RAW_BITMAP stcr->IndicatorSetUnder(theIndicator,true); #endif } } m_OldCtrl = ctrl; ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor")); int flag = 0; if (cfg->ReadBool(_T("/highlight_occurrence/case_sensitive_permanently"), true)) flag |= wxSCI_FIND_MATCHCASE; if (cfg->ReadBool(_T("/highlight_occurrence/whole_word_permanently"), true)) flag |= wxSCI_FIND_WHOLEWORD; for (int i = 0; i < (int)m_InvalidatedRangesStart.GetCount(); i++) { int start = m_InvalidatedRangesStart[i]; int end = m_InvalidatedRangesEnd[i]; //bound: if (start < 0) start = 0; if (end < 0) end = 0; if (start >= stc->GetLength()) start = stc->GetLength() - 1; if (end > stc->GetLength()) end = stc->GetLength(); if (start != end) { //remove styling: stc->IndicatorClearRange(start, end - start); for (std::set<wxString>::iterator it = m_Texts.begin(); it != m_Texts.end(); it++ ) { wxString text = *it; // search for occurrences int startpos = start; int endpos = end; int lengthFound = 0; // we need this to work properly with multibyte characters for ( int pos = stc->FindText(startpos, endpos, text, flag, &lengthFound); pos != wxSCI_INVALID_POSITION ; pos = stc->FindText(pos+=text.Len(), endpos, text, flag, &lengthFound) ) { stc->IndicatorFillRange(pos, lengthFound); } } } } m_InvalidatedRangesStart.Clear(); m_InvalidatedRangesEnd.Clear(); }
static char* Log_CreateRTF(LOGSTREAMDATA *streamData) { LOGINFO *lin = streamData->lin; MODULEINFO *mi = pci->MM_FindModule(streamData->si->pszModule); // ### RTF HEADER if (0 == mi->pszHeader) mi->pszHeader = Log_CreateRtfHeader(mi); char *header = mi->pszHeader; streamData->crCount = mi->nColorCount; CMStringA str; if (header) str.Append(header); // ### RTF BODY (one iteration per event that should be streamed in) while (lin) { // filter if ((streamData->si->iType != GCW_CHATROOM && streamData->si->iType != GCW_PRIVMESS) || !streamData->si->bFilterEnabled || (streamData->si->iLogFilterFlags & lin->iType) != 0) { if (lin->next != NULL) str.Append("\\par "); if (streamData->dat->dwFlags & MWF_DIVIDERWANTED || lin->dwFlags & MWF_DIVIDERWANTED) { static char szStyle_div[128] = "\0"; if (szStyle_div[0] == 0) mir_snprintf(szStyle_div, "\\f%u\\cf%u\\ul0\\b%d\\i%d\\fs%u", 17, 18, 0, 0, 5); lin->dwFlags |= MWF_DIVIDERWANTED; if (lin->prev || !streamData->bRedraw) str.AppendFormat("\\qc\\sl-1\\highlight%d %s ---------------------------------------------------------------------------------------\\par ", 18, szStyle_div); streamData->dat->dwFlags &= ~MWF_DIVIDERWANTED; } // create new line, and set font and color str.AppendFormat("\\ql\\sl0%s ", pci->Log_SetStyle(0)); str.AppendFormat("\\v~-+%d+-~\\v0 ", lin); // Insert icon if (g_Settings.bLogSymbols) // use symbols str.AppendFormat("%s %c", pci->Log_SetStyle(17), EventToSymbol(lin)); else if (g_Settings.dwIconFlags) { int iIndex = lin->bIsHighlighted ? ICON_HIGHLIGHT : EventToIcon(lin); str.Append("\\f0\\fs14"); str.AppendFormat(pci->pLogIconBmpBits[iIndex], (int)pci->logIconBmpSize[iIndex]); } if (g_Settings.bTimeStampEventColour) { // colored timestamps static char szStyle[256]; LOGFONT &F = pci->aFonts[0].lf; int iii; if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) { iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1); mir_snprintf(szStyle, "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / pci->logPixelSY); str.Append(szStyle); } else { iii = lin->bIsHighlighted ? 16 : EventToIndex(lin); mir_snprintf(szStyle, "\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", iii + 1, F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / pci->logPixelSY); str.Append(szStyle); } } else str.Append(pci->Log_SetStyle(0)); str.AppendChar(' '); // insert a TAB if necessary to put the timestamp in the right position if (g_Settings.dwIconFlags) str.Append("\\tab "); //insert timestamp if (g_Settings.bShowTime) { TCHAR szTimeStamp[30], szOldTimeStamp[30]; _tcsncpy_s(szTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, lin->time), _TRUNCATE); _tcsncpy_s(szOldTimeStamp, pci->MakeTimeStamp(g_Settings.pszTimeStamp, streamData->si->LastTime), _TRUNCATE); if (!g_Settings.bShowTimeIfChanged || streamData->si->LastTime == 0 || mir_tstrcmp(szTimeStamp, szOldTimeStamp)) { streamData->si->LastTime = lin->time; Log_AppendRTF(streamData, TRUE, str, _T("%s"), szTimeStamp); } str.Append("\\tab "); } // Insert the nick if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) { char pszIndicator[3] = "\0\0"; int crNickIndex = 0; if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog) pszIndicator[0] = GetIndicator(streamData->si, lin->ptszNick, &crNickIndex); str.Append(pci->Log_SetStyle(lin->bIsMe ? 2 : 1)); str.AppendChar(' '); if (g_Settings.bLogClassicIndicators) str.Append(pszIndicator); CMString pszTemp(lin->bIsMe ? g_Settings.pszOutgoingNick : g_Settings.pszIncomingNick); pszTemp.Replace(_T("%n"), _T("%s")); if (!lin->bIsMe) { if (g_Settings.bClickableNicks) pszTemp.Replace(_T("%s"), _T("~~++#%s#++~~")); if (g_Settings.bColorizeNicksInLog && pszIndicator[0]) str.AppendFormat("\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex); } Log_AppendRTF(streamData, TRUE, str, pszTemp, lin->ptszNick); str.AppendChar(' '); } // Insert the message str.Append(pci->Log_SetStyle(lin->bIsHighlighted ? 16 : EventToIndex(lin))); str.AppendChar(' '); streamData->lin = lin; AddEventToBuffer(str, streamData); } lin = lin->prev; } // ### RTF END if (streamData->bRedraw) str.Append("\\par}"); else str.Append("}"); return str.Detach(); }
void OnlineSpellChecker::DoSetIndications(cbEditor* ctrl)const { //Returns a pointer to the left (or top) split-view cbStyledTextCtrl. This function always returns a valid pointer. cbStyledTextCtrl *stc = ctrl->GetLeftSplitViewControl(); cbStyledTextCtrl *stcr =ctrl->GetRightSplitViewControl(); // whatever the current state is, we've already done it once if ( alreadychecked && oldctrl == ctrl ) { if (m_invalidatedRangesStart.GetCount() == 0) return; } else { //clear: m_invalidatedRangesStart.Clear(); m_invalidatedRangesEnd.Clear(); //add whole document m_invalidatedRangesStart.Add(0); m_invalidatedRangesEnd.Add(stc->GetLength()); } alreadychecked = true; oldctrl = ctrl; // Set Styling: stc->SetIndicatorCurrent(GetIndicator()); stc->IndicatorSetStyle(GetIndicator(), wxSCI_INDIC_SQUIGGLE); stc->IndicatorSetForeground(GetIndicator(), GetIndicatorColor() ); #ifndef wxHAVE_RAW_BITMAP // If wxWidgets is build without rawbitmap-support, the indicators become opaque // and hide the text, so we show them under the text. // Not enabled as default, because the readability is a little bit worse. stc->IndicatorSetUnder(GetIndicator(),true); #endif if ( stcr ) { stcr->IndicatorSetStyle(GetIndicator(), wxSCI_INDIC_SQUIGGLE); stcr->IndicatorSetForeground(GetIndicator(), GetIndicatorColor() ); #ifndef wxHAVE_RAW_BITMAP stcr->IndicatorSetUnder(GetIndicator(),true); #endif } // Manager::Get()->GetLogManager()->Log(wxT("OSC: update regions")); for (int i = 0; i < (int)m_invalidatedRangesStart.GetCount(); i++) { int start = m_invalidatedRangesStart[i]; int end = m_invalidatedRangesEnd[i]; //bound: if (start < 0) start = 0; if (end < 0) end = 0; if (start >= stc->GetLength()) start = stc->GetLength() - 1; if (end > stc->GetLength()) end = stc->GetLength(); if (start != end) { //remove styling: stc->IndicatorClearRange(start, end - start); int wordstart = start; int wordend = wordstart; for( int pos = wordstart ; pos < end ; ) { wxString lang = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(ctrl->GetLanguage() ); wxChar ch = stc->GetCharAt(pos); // treat chars which don't have the correct style as whitespace: bool isEscape = SpellCheckHelper::IsEscapeSequenceStart(ch, lang, stc->GetStyleAt(pos)); if ( isEscape || SpellCheckHelper::IsWhiteSpace(ch) || !m_pSpellHelper->HasStyleToBeChecked(lang, stc->GetStyleAt(pos))) { if (wordstart != wordend) DissectWordAndCheck(stc, wordstart, wordend); pos++; if ( isEscape ) pos++; wordstart = pos; wordend = pos; } else { pos++; wordend = pos; } } if (wordstart != wordend) { wxString lang = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(ctrl->GetLanguage() ); if ( m_pSpellHelper->HasStyleToBeChecked(lang, stc->GetStyleAt(wordstart)) ) { DissectWordAndCheck(stc, wordstart, wordend); } } } } m_invalidatedRangesStart.Clear(); m_invalidatedRangesEnd.Clear(); }
int TowersLoadBoard(TowersLib api, char* pstrFile) { DEBUG_FUNC_NAME; struct Towers* pT = (struct Towers*)api; if( pT->m_pBoard != NULL ) { free(pT->m_pBoard); pT->m_pBoard = NULL; } pT->m_pBoard = malloc(sizeof(struct TowersBoard)); if( pT->m_pBoard == NULL ){//Out of memory free(pT); pT = NULL; return TOWERSLIB_OUT_OF_MEMORY; } pT->m_pBoard->m_pItems = NULL; pT->m_pBoard->m_pIndicators = NULL; if( strstr(pstrFile, "Towers ") != pstrFile ) {//Towers file version check free(pT->m_pBoard); pT->m_pBoard = NULL; free(pT); pT = NULL; return TOWERSLIB_NOT_PUZZLE_LEVEL; } if( strstr(pstrFile, "1 ") != (pstrFile + strlen("Towers ")) ) {//Version check free(pT->m_pBoard); pT->m_pBoard = NULL; free(pT); pT = NULL; return TOWERSLIB_UNKNOWN_VERSION; } char* pstr = pstrFile + strlen("Towers 1 "); char buffer[16]; int nSpotInBuffer = 0; int nWidth = -1, nHeight = -1, nIndicators = -1; int nIndicator = 0; int nSide = -1, nPos = -1; while(pstr != '\0') { char ch = *pstr; pstr++; if( isdigit(ch) ) { buffer[nSpotInBuffer++] = ch; } else { if( !isspace(ch) ) break; buffer[nSpotInBuffer] = '\0'; nSpotInBuffer = 0; int nValue = atoi(buffer); if( nWidth < 0 ) { nWidth = nValue; pT->m_pBoard->m_nWidth = nWidth; } else if( nHeight < 0 ) { nHeight = nValue; pT->m_pBoard->m_nHeight = nHeight; pT->m_pBoard->m_pItems = malloc(nWidth*nHeight*sizeof(struct TowersItem)); if( pT->m_pBoard->m_pItems == NULL ) {//Out of memory free(pT->m_pBoard); pT->m_pBoard = NULL; free(pT); pT = NULL; return TOWERSLIB_OUT_OF_MEMORY; } int x,y; for(x=0; x<nWidth; x++) for(y=0; y<nHeight; y++) GetAt(pT->m_pBoard, x, y)->m_nValue = 0; } else if( nIndicators < 0 ) { nIndicators = nValue; pT->m_pBoard->m_nIndicators = nIndicators; pT->m_pBoard->m_pIndicators = malloc(nValue*sizeof(struct TowersIndicator)); if( pT->m_pBoard->m_pIndicators == NULL ) {//Out of memory free(pT->m_pBoard->m_pItems); pT->m_pBoard->m_pItems = NULL; free(pT->m_pBoard); pT->m_pBoard = NULL; free(pT); pT = NULL; return TOWERSLIB_OUT_OF_MEMORY; } int n; for(n=0; n<nIndicators; n++) { struct TowersIndicator* pIndicator = GetIndicator(pT->m_pBoard, n); pIndicator->m_nSide = 0; pIndicator->m_nPosition = 0; pIndicator->m_nValue = 0; } } else { if( nSide <= -1 ) { nSide = nValue; } else if( nPos <= -1 ) { nPos = nValue; } else { struct TowersIndicator* pIndicator = GetIndicator(pT->m_pBoard, nIndicator++); pIndicator->m_nSide = nSide; pIndicator->m_nPosition = nPos; pIndicator->m_nValue = nValue; nSide = nPos = -1; } //Maybe check if has more numbers than it should? } } } if( nSide >= 0 && nPos >= 0 ) { buffer[nSpotInBuffer] = '\0'; int nValue = atoi(buffer); struct TowersIndicator* pIndicator = GetIndicator(pT->m_pBoard, nIndicator); pIndicator->m_nSide = nSide; pIndicator->m_nPosition = nPos; pIndicator->m_nValue = nValue; } pT->m_pSolution = NULL; pstr = strstr(pstrFile, "Solution "); if( pstr == NULL ) { //Should never happen! } pstr = pstr + strlen("Solution "); int nSolX = -1, nSolY = -1, nSolVal = -1; while(pstr != '\0') { char ch = *pstr; pstr++; if( isdigit(ch) ) { buffer[nSpotInBuffer++] = ch; } else { if( !isspace(ch) || ch == '\r' || ch == '\n' || ch == '\0' ) break; buffer[nSpotInBuffer] = '\0'; nSpotInBuffer = 0; int nValue = atoi(buffer); if( nSolX < 0 ) { nSolX = nValue; } else if( nSolY < 0 ) { nSolY = nValue; } else { nSolVal = nValue; AddSolutionItem(pT, nSolX, nSolY, nSolVal); nSolX = -1; nSolY = -1; nSolVal = -1; } } } buffer[nSpotInBuffer] = '\0'; int nValue = atoi(buffer); nSolVal = nValue; AddSolutionItem(pT, nSolX, nSolY, nSolVal); return TOWERSLIB_OK; }