int CxEdit::DeleteLine(int nLine, BOOL bScroll, int nCount /*= 1*/) { if (nCount >= 1) { const int linecount = GetLineCount(); const BOOL bFirstLine = (nLine == 0); const BOOL bLastLine = (nLine == (linecount - 1)); //TRACE("%i,%i,%i\n", LineIndex(nLine - 1), LineLength(nLine - 1), LineIndex(nLine)); const int nStartChar = (bLastLine && (!bFirstLine)) ? (LineIndex(nLine - 1) + LineLength(nLine - 1) + 0) : LineIndex(nLine); const int nEndChar = ((nLine + nCount) >= linecount) ? (LineIndex(linecount - 1) + LineLength(linecount - 1) + 0) : LineIndex(nLine + nCount); const BOOL bReadOnly = IsStyleReadOnly(); if (bReadOnly) { SetReadOnly(FALSE); } SetSel(nStartChar, nEndChar, !bScroll); // end of edit text Clear(); // ..then delete GotoEnd(bScroll); if (bReadOnly) { SetReadOnly(TRUE); } } return GetLineCount(); }
/* ================ CSyntaxRichEditCtrl::GetVisibleRange ================ */ CHARRANGE CSyntaxRichEditCtrl::GetVisibleRange(void) const { RECT rectArea; int firstLine, lastLine; CHARRANGE range; firstLine = GetFirstVisibleLine(); GetClientRect(&rectArea); lastLine = firstLine + (rectArea.bottom / (defaultCharFormat.yHeight / 20)); if (lastLine >= GetLineCount()) { lastLine = GetLineCount() - 1; } range.cpMin = LineIndex(firstLine); if (range.cpMin < 0) { range.cpMin = 0; } range.cpMax = LineIndex(lastLine); if (range.cpMax == -1) { range.cpMax = range.cpMin + LineLength(range.cpMin); } else { range.cpMax += LineLength(range.cpMax); } if (range.cpMax >= GetTextLength()) { range.cpMax = GetTextLength() - 1; } return range; }
void ScintillaWrapper::forEachLine(PyObject* function) { if (PyCallable_Check(function)) { BeginUndoAction(); long lineCount = GetLineCount(); for(int line = 0; line < lineCount;) { boost::python::object result = boost::python::call<boost::python::object>(function, GetLine(line), line, lineCount); if (result.is_none() || !PyInt_Check(result.ptr())) { ++line; } else { line += PyInt_AsLong(result.ptr()); } lineCount = GetLineCount(); } EndUndoAction(); } }
bool wxExTextFile::RunTool() { if (!wxTextFile::Open(m_FileName.GetFullPath())) { return false; } m_Stats.m_Elements.Set(_("Files"), 1); if (m_Tool.IsCount()) { m_Stats.m_Elements.Inc(_("Total Size"), m_FileName.GetStat().st_size); m_Stats.m_Elements.Inc(_("Lines"), GetLineCount()); } if (GetLineCount() > 0) { if (!Parse()) { Close(); return false; } } if (m_Tool.IsStatisticsType()) { if (m_Tool.GetId() == ID_TOOL_REPORT_KEYWORD) { if (!m_FileName.GetLexer().GetKeywordsString().empty()) { IncActionsCompleted(); } } ReportStatistics(); } if (m_Modified && !m_FileName.GetStat().IsReadOnly()) { if (!Write()) { Close(); return false; } } Close(); return true; }
int pIndexOf(const wxString& sSearch, bool bIncludeComments = false, int iStart = 0) { wxString sTest = sSearch; sTest.MakeLower(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for(size_t i = iStart; i < GetLineCount(); i++) { wxString sLine = GetLine(i); if(bIncludeComments || ! sLine.StartsWith(wxT("#"))) { if(sLine.StartsWith(sTest)) return (int)i; } } return wxNOT_FOUND; }
void ZToolTip::SetBounds(void) { MFont* pFont = GetFont(); char szName[MWIDGET_NAME_LENGTH]; RemoveAnd(szName, m_bUseParentName==true?GetParent()->m_szName:m_szName); int nWidth = pFont->GetWidthWithoutAmpersand(szName); int nHeight = pFont->GetHeight(); int x, y; GetPosAlignedWithParent(x, y, nWidth, nHeight); // 최소사이즈 16 size bitmap 일경우.. 32x32 규정? int w = max(nWidth+ZTOOLTIP_WIDTH_GAP*2,32); int h = max(nHeight+ZTOOLTIP_HEIGHT_GAP*2,32); if(w) { // int line = (w / (ZTOOLTIP_MAX_W-20))+1; int _max=0; int line = GetLineCount( szName , _max ); int _max_w = MAX_TOOLTIP_LINE_STRING*(pFont->GetWidth("b")); if(line) { w = _max_w; h = h + ((nHeight + ZTOOLTIP_LINE_GAP) * line); } // else w = min(w,_max_w); } MWidget::SetBounds(MRECT(x-ZTOOLTIP_WIDTH_GAP, y-ZTOOLTIP_HEIGHT_GAP,w,h)); }
void CPlot::DrawLines(CDC *pDC) { // 遍历每一条曲线 for(int i=0;i<GetLineCount();i++) { CLine* nLine = GetLineByIndex(i); // if(!nLine->IsShow || nLine->GetPointCount()<1){ continue; } // 动态申请临时数组 CPoint* nCPointArray = new CPoint[nLine->GetPointCount()]; // 画笔 CPen pen(nLine->LineType, nLine->LineWidth, nLine->LineColor); CPen *oldPen = pDC->SelectObject(&pen); // 坐标转化与处理 for(int k=0;k<nLine->GetPointCount();k++) { // 将浮点数Point坐标数据转为整数 int x = (int)(m_rectPlot.right-((m_axisX.GetRangeUpperLimit()-nLine->GetPointX(k))/(m_axisX.GetAxisRange())*m_rectPlot.Width())); int y = (int)(m_rectPlot.bottom - ((nLine->GetPointY(k)-m_axisY.GetRangeLowerLimit())/(m_axisY.GetAxisRange())*m_rectPlot.Height())); // 将转化后的值存入数组 nCPointArray[k].x = x; nCPointArray[k].y = y; } // 绘制单条曲线 DrawLine(pDC,&(this->m_rectPlot),nCPointArray,nLine->GetPointCount()); // 释放数组空间 if(nCPointArray){ delete [] nCPointArray; } // 恢复画笔 pDC->SelectObject(oldPen); } }
void CCrystalEditView::OnEditDelete() { if (! QueryEditable() || m_pTextBuffer == NULL) return; CPoint ptSelStart, ptSelEnd; GetSelection(ptSelStart, ptSelEnd); if (ptSelStart == ptSelEnd) { if (ptSelEnd.x == GetLineLength(ptSelEnd.y)) { if (ptSelEnd.y == GetLineCount() - 1) return; ptSelEnd.y ++; ptSelEnd.x = 0; } else ptSelEnd.x ++; } CPoint ptCursorPos = ptSelStart; ASSERT_VALIDTEXTPOS(ptCursorPos); SetAnchor(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); m_pTextBuffer->DeleteText(this, ptSelStart.y, ptSelStart.x, ptSelEnd.y, ptSelEnd.x, CE_ACTION_DELETE); // [JRT] }
void CLog::WriteHeader(const char *str ) { if (GetLineCount() == 0) { WriteLog(str); } }
void CLogEx::Flush() { char str[10240] = {""}; if (GetLineCount() == 0) { for (int i=0;i<(int)vecLogItem.size();i++) { strcat(str, vecLogItem[i].name); strcat(str, ","); } strcat(str, "\n"); WriteHeader(str); } for (int i=0;i<(int)vecLogItem.size();i++) { WriteLog("%s,", vecLogItem[i].str); } WriteLog("\n"); }
bool wxSTEditorShell::SetMaxLines(int max_lines) { m_max_lines = max_lines; if (m_max_lines < 0) return false; int total_lines = GetLineCount(); total_lines = wxMax(0, total_lines-1); // delete lines when more than m_max_lines, you'll eventually crash otherwise if (total_lines > m_max_lines) { BeginWriteable(); int marker = MarkerGet(total_lines - m_max_lines); SetTargetStart(0); SetTargetEnd(PositionFromLine(total_lines - m_max_lines)); ReplaceTarget(wxEmptyString); // wipe marker that has moved up if there shouldn't be a marker if ((marker & (1<<markerPrompt)) == 0) MarkerDelete(0, markerPrompt); EndWriteable(); return true; } return false; }
void CEditLogB::Update () { //LOCK_BLOCK (_lock); if (!_init) { SetLimitText(_maxLine*1024); _init = true; } int lineCount = GetLineCount (); if (_maxLine < lineCount) { LockWindowUpdate(); SetSel (0, LineIndex (lineCount - _maxLine*8/10)); ReplaceSel (""); _textLength = GetWindowTextLength(); LineScroll(_maxLine, 0); UnlockWindowUpdate(); } for (int i=0, n=_logList.size (); i<n; ++i) { string &smsg = _logList[i]; SetSel (_textLength, _textLength); ReplaceSel (smsg.c_str ()); _textLength += smsg.length (); } _logList.clear (); }
bool CodeEditor::GetStringRange(int cursor, int& b, int &e) const { int cl = GetLine(cursor); cursor -= GetPos(cl); bool is_begin, is_end; //@@@@@@ Vector<Point> list = GetLineString(GetWLine(cl), is_begin, is_end); int i = list.GetCount(); while(--i >= 0 && (list[i].x > cursor || list[i].y < cursor)) ; if(i < 0) return false; int bl = cl, bp = list[i].x; int el = cl, ep = list[i].y; while(is_begin && bl > 0) { list = GetLineString(GetWLine(bl - 1), is_begin, is_end); if(list.IsEmpty() || !is_end) break; bl--; bp = list.Top().x; } while(el + 1 < GetLineCount() && ep >= GetLineLength(el)) { list = GetLineString(GetWLine(el + 1), is_begin, is_end); if(list.IsEmpty() || !is_begin) break; el++; ep = list[0].y; } b = GetPos(bl, bp); e = GetPos(el, ep); return b < e; }
BOOL WINAPI duListCtrl::DeleteLine(int nIndex, BOOL fAdjust) { int nLineCount = GetLineCount(); if (nIndex < 0 || nIndex >= nLineCount) return FALSE; duPlugin *pDelete = m_vtLines[nIndex]; if (pDelete == NULL) return FALSE; duRect rcDelete; pDelete->GetRect(&rcDelete); if (nIndex < m_nFirstLine) m_nFLTotalHeight -= rcDelete.Height(); m_nViewCy -= rcDelete.Height(); vector<duPlugin *>::iterator iterDelete = m_vtLines.begin() + nIndex; m_vtLines.erase(iterDelete); UpdateScroll(); if (pDelete == m_pSel) m_pSel = NULL; if (pDelete == m_pHot) m_pHot = NULL; Plugin_Delete(pDelete); CompleteAdjustLine(); return TRUE; }
void Edit::OnGoto(wxCommandEvent &WXUNUSED(event)) { const wxString message = wxString::Format(_("Line number : 1 - %d"), GetLineCount()); const long line_number = wxGetNumberFromUser(wxEmptyString, message, wxT("Go To Line"), 1, 1, 100, this); if (line_number > 0) { GotoLine(line_number - 1); } }
BOOL CxEdit::LineSwap(int line0, int line1, BOOL bScroll /*= TRUE*/, BOOL bCanUndo /*= FALSE*/) { BOOL bOK = TRUE; if (line0 != line1) { const int linecount = GetLineCount(); CString str[2]; int line[2]; line[0] = min(line0, line1); line[1] = max(line0, line1); bOK = (linecount > line[1]); if (bOK) { GetLine(line[0], &str[0]); GetLine(line[1], &str[1]); DeleteLine(line[1], FALSE); DeleteLine(line[0], FALSE); //return bOK; CString temp = str[1] + _T("\r\n"); InsertString(line[0], temp, FALSE, bCanUndo); temp = str[0] + ((line[1] == (linecount - 1)) ? &afxChNil : _T("\r\n")); InsertString(line[1], temp, bScroll, bCanUndo); } } return bOK; }
void IWnd_stc::UpdateMarginLineNumWidth(bool flag) { BitFlags &flags(param.flags); if(!flags.get(FLAG_LINENUM)) { if(m_nLineNumWidth==0) { return; } m_nLineNumWidth=0; SetMarginWidth(StcManager::LINE_NR_ID,0); } else { int _nWidth=3+(int)::log10(double(GetLineCount())); if(_nWidth<4) _nWidth=4; if(_nWidth>7) _nWidth=7; if(_nWidth==m_nLineNumWidth && !flag) { return; } m_nLineNumWidth=_nWidth; static const char* text="999999999999999"; int wd=TextWidth (wxSTC_STYLE_LINENUMBER, wxString(text,m_nLineNumWidth)); SetMarginWidth(StcManager::LINE_NR_ID,wd); } }
void CStatusCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { ClientToScreen(&point); CMenu menu; menu.LoadMenu(IDR_OUTPUTCONTEXT); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; //while (pWndPopupOwner->GetStyle() & WS_CHILD) // pWndPopupOwner = pWndPopupOwner->GetParent(); if (!GetLineCount()) { pPopup->EnableMenuItem(ID_OUTPUTCONTEXT_COPYTOCLIPBOARD,MF_GRAYED); pPopup->EnableMenuItem(ID_OUTPUTCONTEXT_CLEARALL,MF_GRAYED); } HCURSOR hCursor; hCursor=AfxGetApp()->LoadStandardCursor( IDC_ARROW ); m_doPopupCursor = TRUE; SetCursor(hCursor); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
void CLineNumberEdit::UpdateTopAndBottom() /* ============================================================ Function : CLineNumberEdit::UpdateTopAndBottom Description : Updates the top- and bottom line number for the line number control. Return : void Parameters : none Usage : Should be called as soon as the contents of the control is changed. ============================================================*/ { CRect rect; GetClientRect( &rect ); int maxline = GetLineCount() + m_LineDelta; // Height for individual lines int lineheight = m_zero.cy; // Calculate the number of lines to draw int topline = GetFirstVisibleLine() + m_LineDelta; if( ( topline + ( rect.Height() / lineheight ) ) < maxline ) maxline = topline + ( rect.Height() / lineheight ); if ( m_maxval > 0 && maxline > m_maxval + m_LineDelta ) maxline = m_maxval + m_LineDelta; m_line.SetTopAndBottom( topline, maxline ); }
/* TextEditor::trimWhitespace * Removes any unneeded whitespace from the ends of lines *******************************************************************/ void TextEditor::trimWhitespace() { // Go through lines for (int a = 0; a < GetLineCount(); a++) { // Get line start and end positions int pos = GetLineEndPosition(a) - 1; int start = pos - GetLineLength(a); while (pos > start) { int chr = GetCharAt(pos); // Check for whitespace character if (chr == ' ' || chr == '\t') { // Remove character if whitespace Remove(pos, pos+1); pos--; } else break; // Not whitespace, stop } } }
bool wxTextFile::OnWrite(wxTextFileType typeNew, const wxMBConv& conv) { wxFileName fn = m_strBufferName; // We do NOT want wxPATH_NORM_CASE here, or the case will not // be preserved. if ( !fn.IsAbsolute() ) fn.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_LONG); wxTempFile fileTmp(fn.GetFullPath()); if ( !fileTmp.IsOpened() ) { wxLogError(_("can't write buffer '%s' to disk."), m_strBufferName.c_str()); return false; } size_t nCount = GetLineCount(); for ( size_t n = 0; n < nCount; n++ ) { fileTmp.Write(GetLine(n) + GetEOL(typeNew == wxTextFileType_None ? GetLineType(n) : typeNew), conv); } // replace the old file with this one return fileTmp.Commit(); }
void MiniStyledTextCtrl::SyncFoldState(cbStyledTextCtrl *stc) { return; /// doing this would also require to calculate different positions for the marker to designate the visible area for(int line = 0; line < GetLineCount() ; ++line) SetFoldLevel(line, stc->GetFoldLevel(line)); }
void SciEdit::ClearBreakpoints(void) { long lLines = GetLineCount(); for (long i = 0; i < lLines; i++) { if (HasBreakpoint(i)) RemoveBreakpoint(i); } }
int LineEdit::GetIndexLinePos(Point pos) const { if(pos.y < 0) return 0; if(pos.y >= GetLineCount()) return total; return GetPos(pos.y, minmax(pos.x, 0, line[pos.y].GetLength())); }
duPlugin *WINAPI duListCtrl::GetLine(int nIndex) { int nLineCount = GetLineCount(); if (nIndex < 0 || nIndex >= nLineCount) return NULL; return m_vtLines[nIndex]; }
///////////////////////////////////////////////////////////////////////////// // CNotifyShowCase message handlers void CNotifyShowCase::AddLine(LPCTSTR lpsz) { TCHAR szt[50]; int nLastChar; int cLines; if (GetLineCount() >= m_totalLines) { SetSel(0, LineLength(0), TRUE/*bNoScroll*/); // select the first line Clear(); // and remove it } nLastChar = LineIndex((cLines = GetLineCount() - 1)) + LineLength(cLines); _stprintf_s(szt, 50, _T("%s\x0D\x0A"), lpsz); SetSel(nLastChar, nLastChar, TRUE/*bNoScroll*/); ReplaceSel(szt); }
duPlugin *WINAPI duListCtrl::GetFirstVisibleLine() { int nLineCount = GetLineCount(); if (m_nFirstLine < 0 || m_nFirstLine >= nLineCount) return NULL; return m_vtLines[m_nFirstLine]; }
wxString GetCmd(size_t i) { if (i > GetLineCount() ) return wxEmptyString; wxString sTmp = GetLine(i).AfterFirst(wxT('=')); return sTmp; }
wxString GetVerb(size_t i) { if (i > GetLineCount() ) return wxEmptyString; wxString sTmp = GetLine(i).BeforeFirst(wxT('=')); return sTmp; }
void LoggerCtrl::Updated() { int lc = GetLineCount(); if(lc <= maxlines) { DocEdit::Updated(); return; } int lp = DocEdit::GetPos(lc/2); Remove(0, lp); DocEdit::Updated(); }