コード例 #1
0
ファイル: CozyKnightModifyDlg.cpp プロジェクト: MaxTan/cozy
CString CozyKnightModifyDlg::GetEditText(const CEdit& editCtrl)
{
    int nLenght = editCtrl.LineLength(1);
    CString strValue;
    editCtrl.GetLine(1, strValue.GetBuffer(nLenght), nLenght);
    strValue.ReleaseBuffer(nLenght);
    return strValue;
}
コード例 #2
0
// TODO: factor this code
static	void concatEdit2Lines(CEdit &edit)
{
	const	uint lineLen= 1000;
	uint	n;
	// retrieve the 2 lines.
	char	tmp0[2*lineLen];
	char	tmp1[lineLen];
	n= edit.GetLine(0, tmp0, lineLen);	tmp0[n]= 0;
	n= edit.GetLine(1, tmp1, lineLen);	tmp1[n]= 0;
	// concat and update the CEdit.
	edit.SetWindowText(strcat(tmp0, tmp1));
}
コード例 #3
0
/**
 * Gets change directory info from previous lines, feature only 
 * for cmdl and compiler tab, all other tabs return sFile unchanged.
 *
 * @param           iLine: zero based line index from where to 
 *                  search cd [path] commands backward until
 *                  first line or cd <fullpath> or special cd $(prjdir) 
 *                  is found
 * @param           editCtrl: holds the text data
 * @param           sFile: in/out. gets updated to point to final path
 * @param  (HACK)   pMsgFrame: CMsgFrame, used to check if cmdl, compiler tab
 * @param  (HACK)   pDoc:      CMsgDoc, used to check if cmdl, compiler tab
 *                  may still be a (project) relative path on exit.
 * @see             -
*/
static void GetCDInfo(int iLine, CEdit& editCtrl, CString& sFile, CMsgFrame* pMsgFrame, CMsgDoc* pDoc)
{
    int          nLen;
    const TCHAR* pszDir;
    TCHAR        buffer[2*MAX_PATH];


    if(FC_StringIsAbsPath(sFile))
        return;
    if(iLine >= editCtrl.GetLineCount())
        return;

    //feature only for compiler tab (HACK):
    ASSERT (pMsgFrame != NULL);
    if (!pMsgFrame)
        return;
    int iIndex=-1;
    pMsgFrame->m_tabWnd.GetActiveTab(iIndex);
    if(!pDoc  || iIndex<0 || iIndex >= pDoc->m_arrMsgData.GetSize())
    {
        ASSERT (!"bad pDoc, iIndex");
        return;
    }
    MSG_VIEWER_TYPE msgTyp = pDoc->m_arrMsgData[iIndex].m_MsgViewerType;
    if(msgTyp != MSG_CmdLineMsgViewer && msgTyp != MSG_CompileMsgViewer)
        return;


    while(iLine>=0)
    {
        nLen = editCtrl.GetLine(iLine, buffer, FC_ARRAY_LEN(buffer)-10);
        iLine--;
        if(nLen<=0)
            continue;
        buffer[nLen] = 0;//<-needed ?
        FC_StringTrim(buffer);
        if((pszDir = IsLineCDInfo(buffer)) != NULL)
        {
            if(!*pszDir)
                break;//cd $(prjdir): don't prepend default prj dir as an abs path to sFile

            //all other rel or abs cd commands must be prepended:
            sFile.Insert(0, '\\');
            sFile.Insert(0, pszDir);
            //if is abs must stop here:
            if(FC_StringIsAbsPath(pszDir))
                break; 
        }
    }
}
コード例 #4
0
ファイル: mfcterm.cpp プロジェクト: mbentz80/jzigbeercp
void
mfc_goto::OnOK()
{
  CEdit *ce = (CEdit *)GetDlgItem(IDC_GOTO_LINE);
  char line[16];
  int n = ce->GetLine(0, line, 12);
  if (n>0) {
    line[n] = '\0';
    n = atoi(line)-1;
    if (n < 0) n = 0;
    n = view->GetRichEditCtrl().LineIndex(n);
    view->GetRichEditCtrl().SetSel(n,n);
  }
  CDialog::OnOK();
}
コード例 #5
0
// @pymethod int|PyCEdit|GetLine|Returns the text in a specified line.
static PyObject *
PyCEdit_get_line(PyObject *self, PyObject *args)
{
	CEdit *pEdit = GetEditCtrl(self);
	if (!pEdit)
		return NULL;
	GUI_BGN_SAVE;
	int lineNo = pEdit->LineFromChar();
	GUI_END_SAVE;
	// @pyparm int|lineNo|current|Contains the zero-based index value for the desired line.
	// @comm This function is not an MFC wrapper.
	if (!PyArg_ParseTuple(args, "|i:GetLine", &lineNo))
		return NULL;
	int size = 1024;	// ahhhhh-this fails with 128, even when line len==4!
					// god damn it - try and write a fairly efficient normal case,
					// and handle worst case, and look what happens!
	CString csBuffer;			// use dynamic mem for buffer
	TCHAR *buf;
	int bytesCopied;
	// this TRACE _always_ returns the length of the first line - hence the
	// convaluted code below.
//	TRACE("LineLength for line %d is %d\n", lineNo, pView->GetEditCtrl().LineLength(lineNo));
	// loop if buffer too small, increasing each time.
	while (size<0x7FFF)			// reasonable line size max? - maxuint on 16 bit.
	{
		buf = csBuffer.GetBufferSetLength(size);
		if (buf==NULL)
			RETURN_ERR("Out of memory getting Edit control line value");

		GUI_BGN_SAVE;
		bytesCopied = pEdit->GetLine(lineNo, buf, size);
		GUI_END_SAVE;
		if (bytesCopied!=size)	// ok - get out.
			break;
		// buffer too small
		size += size;	// try doubling!
		TRACE0("Doubling buffer for GetLine value\n");
	}
	if (bytesCopied==size)	// hit max.
		--bytesCopied;	// so NULL doesnt overshoot.
	if (buf[bytesCopied-1]=='\r' || buf[bytesCopied-1]=='\n')	// kill newlines.
		--bytesCopied;
	buf[bytesCopied] = '\0';
	return PyWinObject_FromTCHAR(buf);
}
コード例 #6
0
ファイル: LogView.cpp プロジェクト: BoonieBear/7000m
void CLogView::showlog(WPARAM wParam, LPARAM lParam)
{
	UINT nlength = (UINT)wParam;
	CString log =(char*)lParam;
	char tmpstr[100];
	CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
	UpdateData(TRUE);
	m_log+=log;
	if (m_log.GetLength()>2048)
	{
		m_log = m_log.Right(1024);//先去掉512字节
		UpdateData(FALSE);
		pEdit->GetLine(0,tmpstr,100);
		int nlength = strlen(tmpstr); //得到可能乱码的长度
		m_log = m_log.Right(1024-nlength);//去掉nlength长度
	}
	UpdateData(FALSE);
	
	
	pEdit->LineScroll(pEdit->GetLineCount(),0);
	delete (char*)lParam;
	lParam =NULL;
}