// called by OnNewDocument() // returns FALSE if the user cancels the dialog BOOL CProjectDoc::doNewFromCarlaMenu(CString& sProjectPath) { CWizNewFromCarla dlg(this); // stick in CCarlaLanguages's default font //getSourceLang()->getFont()->GetLogFont(&dlg.m_srcLangDisplayPage.m_logFont); if(IDOK != dlg.DoModal()) return FALSE; // note that during the wizard we parsed in the carla.set file sProjectPath = dlg.m_projectPage.m_sProjectPath; SetDirectory(sProjectPath); // make this the working directory if(!getSourceLang() || !getSourceLang()->getAbrev().GetLength()) { MessageBox( NULL, _T("This does not appear to be a valid CARLA.SET file (no \\src sMarker found)\n"), NULL, MB_OK); return FALSE; } CCarlaLanguage* pLang = m_pLangDocs[0]->getLang(); ASSERTX(pLang); //pLang->setAbrev(dlg.m_srcLangDisplayPage.m_sAbrev); //pLang->setName(dlg.m_srcLangDisplayPage.m_sName); //pLang->setFont(&dlg.m_srcLangDisplayPage.m_logFont); pLang->readLangDisplayPage(dlg.m_srcLangDisplayPage); pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); if(m_pLangDocs.GetSize()==2) // if there was a target lang specified { pLang = m_pLangDocs[1]->getLang(); ASSERTX(pLang); // pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); // pLang->setAbrev(dlg.m_tarLangDisplayPage.m_sAbrev); // pLang->setName(dlg.m_tarLangDisplayPage.m_sName); //pLang->setFont(&dlg.m_tarLangDisplayPage.m_logFont); pLang->readLangDisplayPage(dlg.m_tarLangDisplayPage); pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); // if there were two languages, tell the first one (the source) to copy in the // control files for transfering to the other language. We skip asking to got // the other direction to, out of the lack of expecation that those files exist. // It might not do any harm to try, though, if someone comes up with a reason. m_pLangDocs[0]->getLang()->setConversionTargetLang(m_pLangDocs[1]->getLang()); } /* getSourceLang()->setAbrev(dlg.m_srcLangDisplayPage.m_sAbrev); getSourceLang()->setName(dlg.m_srcLangDisplayPage.m_sName); getSourceLang()->setFont(&dlg.m_srcLangDisplayPage.m_logFont); getSourceLang()->readCARLAMenuLangFile(); if(getTargetLang()) { getTargetLang()->readCARLAMenuLangFile(); getTargetLang()->setAbrev(dlg.m_tarLangDisplayPage.m_sAbrev); getTargetLang()->setName(dlg.m_tarLangDisplayPage.m_sName); getTargetLang()->setFont(&dlg.m_tarLangDisplayPage.m_logFont); // won't find any files because carlamenu is one-way transfer only, // so leave this one out // getTargetLang()->setConversionTargetLang(m_pSource); getSourceLang()->setConversionTargetLang(getTargetLang()); } */ return TRUE; }
// called by the CPageCMenu::OnWizardNext() after the page where the user chooses // the carla.set file so that subsequent page can show some of the information // (e.g. abbreviation) we'll read in that file BOOL CProjectDoc::readCarlaMenuSettings(CString& sPath, CString& sSrcAbrev, CString& sTargAbrev, char& cCommentChar) { LPCTSTR lpzPath = LPCTSTR(sPath); USES_CONVERSION_U8; SFMFile f(T2CA(lpzPath), '*'); // comment won't be found in this kind of file if(!f.isOpen()) { CString s(_T("Couldn't open CARLAMenu File named:")); s += sPath; MessageBox( NULL, s, NULL, MB_OK); return FALSE; } CString sMarker, sField; BOOL bEnabled; // note that we currently don't store the abreviations or control directories // instead, we store paths to each file relative to the project file while(f.getField(sMarker, sField, &bEnabled)) { try { // note: within CStudio we don't really have a set // source and target languages; we just have languages // that are at any one time assigned to be the source // or the target during processing. // The following make the languages found here be the // source or target initially, // according to how they were in the CARLAMenu settings file. if(sMarker == _T("src")) { sSrcAbrev = sField; } else if(sMarker == _T("trg")) { sTargAbrev = sField; } else if(sMarker == _T("comm")) // notice, it's part of the whole cmenu project, not each lang as you would expect { sField.TrimLeft(); if(sField.GetLength()) { #if !defined(rde270) && defined(_DEBUG) CString str(sField[0]); ASSERT(strlen(T2CU8(str)) <= 1); #endif cCommentChar = (char)sField[0]; } } else if(sMarker == _T("lang")) // FIELD example: \lang xyz c:\srcinfo { // we need to figure out if this is the src or trg lang CString sLang, sDir; // and set the corresponding directory variable CParseStream stream(sField); THROW_STR_IF_NOT(stream.word(sLang, FALSE), sField); // for some reason, some \lang fields aren't the src or the target (see Cline:anufo). // I don't know what these are in there for or what to do with them if(sLang != sSrcAbrev && sLang != sTargAbrev) { //f.logSkip("CarlaMenu-Import",sMarker,sField, "Was neither the source nor target."); } else { if(!stream.word(sDir, FALSE)) { // if the path isn't specified, sDir = getDirectory(lpzPath);// then expect the path to the langauge.set file to be the same as the carla.set file } // make sure the directory ends in a slash (CARLAMenu allows both ways) if(sDir[sDir.GetLength()-1] != '\\') // look at last character sDir += _T("\\"); /**** when I tried to make the langdoc this way, I get a failed assert like the views weren't being setup correctly. CLangModelsDoc* pLangDoc = new CLangModelsDoc(sLang, sDir); // since we didn't do a new or open, need to create the window CFrameWnd* pf = ((CCarlaStudioApp*)AfxGetApp())->getLangDocTemplate() ->CreateNewFrame( pLangDoc, NULL); pf->ActivateFrame(); ***/ gsNewLangAbrev = sLang; gsDirContainingCarlaSet = sDir; CDocTemplate* pT = theApp.getDocTemplate(CLangModelsDoc::getRegFileTypeID()); CLangModelsDoc* pLangDoc = (CLangModelsDoc*) pT->CreateNewDocument(); ASSERTX(pLangDoc); gsNewLangAbrev = _T(""); gsDirContainingCarlaSet = _T(""); // during that previous construction the lang registered itself with this project if(sLang == sSrcAbrev) setSourceLangDoc(pLangDoc); else if(sLang == sTargAbrev) setTargetLangDoc(pLangDoc); else ASSERTX(FALSE); // get this if a lang appeared that didn't have a corresponding \src or \trg } } else ; //TRACE("CARLAMENU Skipping Field [%s]\n", sMarker); } catch(CString sError) { CString s(_T("loadCarlaMenuFile() Couldn't parse: ")); s += sError; MessageBox( NULL, s, NULL, MB_OK); } } return TRUE; }
// override // used when pasting into a list or undoing a deletion CWListRowItem* CWClass::getCopy() { CWClass* pNew = new CWClass(this); ASSERTX(pNew); return pNew; }
VOID Emulate2Address(OPCODE opcode, INS ins, ADDRINT (*OpRM)(ADDRINT,ADDRINT*), ADDRINT (*OpRV)(ADDRINT,ADDRINT), VOID (*OpMV)(ADDRINT*,ADDRINT)) { if (INS_Opcode(ins) != opcode) return; if (INS_OperandIsMemory(ins, 0) // This will filter out segment overrides && INS_IsMemoryWrite(ins)) { if (INS_OperandIsReg(ins, 1) && REG_is_gr(INS_OperandReg(ins, 1))) { // Source register, dst memory INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(OpMV), IARG_MEMORYWRITE_EA, IARG_REG_VALUE, INS_OperandReg(ins, 1), IARG_END); INS_Delete(ins); } else { ASSERTX(!INS_OperandIsMemory(ins, 1)); } } else if (INS_OperandIsReg(ins, 0)) { REG dst = INS_OperandReg(ins, 0); if ((dst == REG_SEG_GS) || (dst == REG_SEG_FS)) return; if (INS_OperandIsReg(ins, 1)) { // Source register, dst register INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(OpRV), IARG_REG_VALUE, INS_OperandReg(ins, 0), IARG_REG_VALUE, INS_OperandReg(ins, 1), IARG_RETURN_REGS, INS_OperandReg(ins, 0), IARG_END); INS_Delete(ins); } else if (INS_OperandIsMemory(ins, 1) // This will filter out segment overrides && INS_IsMemoryRead(ins)) { // Source register, dst register INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(OpRM), IARG_REG_VALUE, INS_OperandReg(ins, 0), IARG_MEMORYREAD_EA, IARG_RETURN_REGS, INS_OperandReg(ins, 0), IARG_END); INS_Delete(ins); } } #if 0 if (KnobCount == icount) fprintf(stderr,"Last one %s\n",INS_Disassemble(ins).c_str()); else if (icount > KnobCount) return; icount++; #endif }
void CSentransProcess::processANAFile(CProcessStatus& status) { // (jdh 6/99) i think this is now defunct; an impossible condition // if((m_iFunction == kAdjustSrcGlossing) // && (status.m_pProcPrefs->getGoal() != CProcessingPrefs::kGlossedInterlinear)) // return; // skip this process if there is nothing to do switch(m_iFunction) { case kDisambig: if(status.getInputLang()->getSentransDisambigModel().m_rules.getSize() ==0) return; break; case kAdjustSrcGlossing: if(status.getInputLang()->getSentransGlossAdjustmentModel().m_rules.getSize() ==0) return; break; // JDH 6/2/99 Added Sentrans Adjust Rules Set for analysis case kAdjustAnalysis: if(status.getInputLang()->getSentransAnaAdjustmentModel().m_rules.getSize() ==0) return; break; case kOtherRuleFile: // jdh 15June2000 if(!m_sOtherRuleFilePath.fileExists()) { CString sMsg; sMsg.Format("The external SENTRANS rule file could not be found.\n\"%s\"", LPCTSTR(m_sOtherRuleFilePath)); AfxMessageBox(sMsg); return; } break; //case kTransfer: // haven't handled this because we would have to travers the transfer models (just a little more work, probabl) } // remember, we could be operating on ana from any process, including another sentrans process try { CString sBase = getTempFileNameBase(status); m_sOutPath = status.makeTempPath(sBase, ".ana" ); m_sLOGPath = status.makeTempPath(sBase, ".log" ); m_sInPath = status.sANAPath; m_sOutPath.deleteFile(); m_sLOGPath.deleteFile(); if(!executeTool(status)) { throw(CProcessFailure(this, "SentransProccess failed")); } waitForCompletion(&status, &m_sLOGPath, &m_sOutPath); // register ana output so the user can view it CString sShortDesc, sLongDesc, sTabLabel; CCarlaLanguage *pOutANALang=NULL; switch(m_iFunction) { case kDisambig: sShortDesc = "Disambiguated ANA"; sLongDesc = "ANA of the source-language file, after filtering through Sentrans disambiguation rules."; sTabLabel = "ST-Disamb ANA"; pOutANALang = status.getInputLang(); break; case kAdjustSrcGlossing: sShortDesc = "Gloss Adjusted ANA"; sLongDesc = "ANA of the source-language file, after performing 'adjustment' transfer for glossing purposes."; sTabLabel = "ST-Gloss-Adj ANA"; pOutANALang = status.getInputLang(); break; // JDH 6/2/99 Added Sentrans Adjust Rules Set for analysis case kAdjustAnalysis: sShortDesc = "Analysis Adjusted ANA"; sLongDesc = "ANA of the source-language file, after performing 'adjustment' transfer for analysis purposes."; sTabLabel = "ST-Anal-Adj ANA"; pOutANALang = status.getInputLang(); break; // jdh 15June2000 case kOtherRuleFile: sShortDesc = "Other Rule File ANA"; sLongDesc.Format("ANA of the source-language file, after running through Sentrans using the file: %s",LPCTSTR(m_sOtherRuleFilePath)); sTabLabel = "ST-Anal-Other ANA"; pOutANALang = status.getInputLang(); break; case kTransfer: sShortDesc = "Transfered ANA"; sLongDesc = "ANA of the target-language file, after performing Sentrans transfer."; sTabLabel = "ST-Trans ANA"; pOutANALang = status.getOutputLang(); break; default: ASSERTX(FALSE); break; } CResultStreamFile* anaStream = new CResultStreamFile( new CResultStreamDescriptor(this, sShortDesc, //short description sLongDesc, // long description sTabLabel // tab label ), m_sOutPath.getFullPath(), pOutANALang); status.registerResultStream(anaStream); // when we're doing transfer, the log could reasonably be in either language font, // but what to do? registerLog(status, m_sLOGPath, status.getInputLang()); status.sANAPath = m_sOutPath; } catch(CProcessFailure failure) { registerLog(status, m_sLOGPath); throw(failure); } catch(CString sError) { registerLog(status, m_sLOGPath); throw(CProcessFailure(this, sError)); } }
//jdh 3/13/2000 added in support of dictionary preprocessing for quickparse const CProcessingPrefs* CProcessStatus::getProcPrefs() { ASSERTX(m_pProcPrefs); return m_pProcPrefs; }
VOID SwizzleArg(ADDRINT * arg) { ASSERTX(SwizzleSpace(*arg)); *arg = ProcessAddress(*arg, 0); }
CCarlaLanguage* CLangModelsDoc::getLang() { ASSERTX(m_pLang); return m_pLang; }
// bDisabled is ignored on input; on return, it is false if a "\dis" was found // at the beginning of the line. // bEnabled can be null where it isn't relevant BOOL SFMFile::getField(CString& marker, CString& contents, BOOL *bEnabled) { ASSERTX(fin.is_open()); const int kBuffSize = 5000; // CURRENTLY MAX FIELD SIZE TOO! // suck up and thow away lines at the beginning of the file that start // with the comment character if( fin.peek() == m_cCommentChar) { #ifndef rde270 // these files are not wide characters... therefore CString won't be that helpful LPSTR sLeadingComments = (LPSTR)alloca(kBuffSize+2); LPSTR x = sLeadingComments; LPSTR xStart = x; #else // rde270 CString sLeadingComments; LPTSTR x = sLeadingComments.GetBuffer(kBuffSize+2); LPTSTR xStart = x; #endif // rde270 do { fin.getline(x, kBuffSize - (x-xStart), '\n'); x += fin.gcount(); if(fin.gcount()) { *(x-1) = '\n'; // put a carriage return in place of the null terminator *x = '\0'; // null terminate in case the next getline fails } } while (fin.good() && fin.gcount() && fin.peek() != '\\'); #ifndef rde270 #else // rde270 sLeadingComments.ReleaseBuffer(); #endif // rde270 } #ifndef rde270 LPSTR sField = (LPSTR)alloca(kBuffSize+2); LPSTR buff = sField; LPSTR start_buff = buff; #else // rde270 CString sField; //LPTSTR start_buff = sField.GetBuffer(kBuffSize+2); //LPTSTR buff = start_buff; LPTSTR buff = sField.GetBuffer(kBuffSize+2); LPTSTR start_buff = buff; #endif // rde270 fin.eatwhite(); LPSTR b = buff; do { fin.getline(b, kBuffSize - (b-buff), '\n'); b += fin.gcount(); if(fin.gcount()) { *(b-1) = '\n'; // put a carriage return in place of the null terminator *b = '\0'; // null terminate in case the next getline fails } //strlen(buff); } while (fin.good() && fin.gcount() && fin.peek() != '\\'); if( (kBuffSize-1) <= (b-buff)) // to long (and thus fin.gcount() == 0) { CString s; s.Format(_T("The file %s appears to have a line which is longer than the maximum of %d characters which Carla Studio can handle.\n"), (LPCTSTR)m_pathName, kBuffSize); throw(s); } if(!buff[0]) // end of file { #ifndef rde270 #else sField.ReleaseBuffer(-1); #endif return FALSE; } if(bEnabled) { *bEnabled = (strncmp(buff, "\\dis", 4) != 0); // if the first marker is '\dis', the rule is disabled if(!*bEnabled) { buff +=4; // skip the \dis } } // eat white space before the SFM Code (will always be there after a \dis) while(*buff && _ismbcspace(*buff)) { *buff='~'; // a hack so that iSpaceLoc, below, isn't set to the space between the "\dis" and marker ++buff; } // say we had \dis sr blah, now we want \sr blah // but don't do anything if \dis \sr foo if(bEnabled && !*bEnabled && *buff != '\\') { --buff; *buff= '\\'; } BOOL bHaveEnvironment = FALSE; if(buff[0] == '/' || (buff[0] == '+' && buff[1] == '/') || /*sentrans*/(buff[0] == '&' && buff[1] == '/')) { bHaveEnvironment = TRUE; } USES_CONVERSION_U8; // some lines may begin with \dis and be followed by an environment // these must be treated special if(!bHaveEnvironment && buff[0] != '\\' && bEnabled && *bEnabled) // can't expect a \ if we started with a \dis { //ASSERTX(FALSE); // line didn't have backslash as first non-whitespace char static CString sRest; #ifndef rde270 sRest = U82CT(start_buff); #else // rde270 sRest = start_buff; sField.ReleaseBuffer(-1); #endif // rde270 ostrstream sout; sout << "Carla Studio encountered a serious problem while trying to read\n " << T2CA(m_pathName) << '\n'; sout << "It was expecting to find an SFM marker, but found instead:\n"; sout << start_buff << '\n'; // to do: add line number? #ifndef rde270 // I'm just not sure if sout.str is going to be null terminated, so do it the long way. int nLen = sout.pcount(); char* pSout = (char*)alloca(nLen + 1); strncpy(pSout, sout.str(), nLen); pSout[nLen] = '\0'; CString sError(U82CT(pSout)); #else // rde270 CString sError (sout.str(), sout.pcount()); #endif// rde270 sout.rdbuf()->freeze(0); // else get a memory leak throw(sError); } int iSpaceLoc ; if(bHaveEnvironment) iSpaceLoc = (buff-start_buff)-1; else { // figure out where the marker ends and field contents begin #ifndef rde270 LPSTR lpsz = strpbrk(sField, " \t\n"); iSpaceLoc = (lpsz == NULL) ? -1 : (int)(lpsz - sField); #else iSpaceLoc = sField.FindOneOf(" \t\n"); #endif if(iSpaceLoc <= 1)// [0] should be the slash, [1] at least one char { #ifndef rde270 #else sField.ReleaseBuffer(-1); #endif return FALSE; } } if(bHaveEnvironment) marker = _T("ENV"); else { start_buff[iSpaceLoc] = '\0'; #ifndef rde270 marker = U82CT(buff + 1); // +1 to skip the slash #else marker = buff + 1; // +1 to skip the slash #endif marker.TrimRight(); } #ifndef rde270 contents = U82CT(start_buff + iSpaceLoc+1); #else contents = start_buff + iSpaceLoc+1; #endif contents.TrimLeft(); contents.TrimRight(); #ifndef rde270 #else sField.ReleaseBuffer(-1); #endif return TRUE; }
INT32 RegIndex(REG reg) { ASSERTX(GpReg(reg)); return reg - REG_EDI; }
void CInputDocView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { if(!m_pEditCtrls.GetSize()) return; // not setup yet ASSERTX(m_pBaseStream); // there is a bug here where the visible screen-full of text does not reset its // leading to that of the new font. (jan 99) /* None of this had any effect! CHARRANGE csel; csel.cpMin=0; csel.cpMax=-1; m_pEditCtrls[0]->SetSel(csel); CFont* pf=m_pBaseStream->getFont(); LOGFONT lf; pf->GetLogFont(&lf); CHARFORMAT cr; cr.dwMask = CFM_SIZE; cr.yHeight=lf.lfHeight; cr.cbSize = sizeof(CHARFORMAT); //m_pEditCtrls[0]->SetDefaultCharFormat(cr); m_pEditCtrls[0]->SetSelectionCharFormat(cr); */ m_pEditCtrls[0]->SetFont(m_pBaseStream->getFont()); m_pEditCtrls[0]->Invalidate(); // set the fonts; fonts can change from one update to the next, // when the user changes the font, for, say, the source language CProjectDoc *pProjectDoc = theApp.getProject(); CInputDoc* pDoc = (CInputDoc*) GetDocument(); CProcessStatus* pResults = pDoc->getProcessResults(); if(pResults) { // note that the first panel is not from a result stream; it is the source. int x = pResults->m_pResultStreams.GetSize(); int y = m_pEditCtrls.GetSize(); // ASSERTX( x == y-1); for(int i=1; i< m_pEditCtrls.GetSize(); i++) { if(m_pEditCtrls[i]->m_hWnd) { // note that the first panel is not from a result stream; it is the source. // thus, we have [i-1] for this index ASSERTX(::IsWindow(m_pEditCtrls[i]->m_hWnd)); // there's a bug that sometime show up on this // call; the above assert is to narrow down the // problem, but I'm waiting for the bug to // reappear again. july 15 CResultStream* pS = pDoc->getNthVisibleStream(i-1); // there is a bug here where iTotalExpectedStreams is too small, so this // fails. I have removed the asserts until I find the problem because // it isn't really catastrophic // ASSERTX(pS); if(pS) m_pEditCtrls[i]->SetFont(pS->getFont(), FALSE); // pResults->m_pResultStreams[i-1]->getFont(), FALSE); m_pEditCtrls[i]->Invalidate(); } } } // disable the parse button if there is no open project // if(m_parseButton.m_hWnd) // m_parseButton.EnableWindow(pProjectDoc != NULL); // UpdateData(FALSE); // run the DDX updating stuff }
// if the user is trying to jump to Shoebox, the existing code was failing when you alt-tab // away from CS and then go back; basically, the RE ctrl no longer had the focus. Now use // something a little more explicit to get the appropriate control. AsyncLoadRichEditCtrl* CInputDocView::GetSelCtrl() { int iTab = m_tabCtrl.GetCurSel(); ASSERTX(iTab <= m_pEditCtrls.GetSize()); return m_pEditCtrls[iTab]; }
void CInputDocView::addPanel(CResultStream* pStream, int id) #endif { CRect r;//(0,0, 100, 100); GetClientRect(&r); #ifndef rde270 // change the dimensions a little so we don't get the annoying non-repaint of m_tabCtrl // when we repaint the RECtrl after a chunk has been loaded offline. r.top = 21; AsyncLoadRichEditCtrl* pEC = new AsyncLoadRichEditCtrl; #else // rde270 r.top = 25; r.right -= 5; r.bottom -= 5; CRichEditCtrl* pEC = new CRichEditCtrl;//CPanelRichEditCtrl;// #endif // CEdit* pEC = new CEdit; m_pEditCtrls.Add(pEC); DWORD dwFlags = ECO_SAVESEL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_VISIBLE | ES_WANTRETURN; #ifndef jdhhab621 // a hack to get a scrollbar for pc-patr. This could be generalized or put in the user's // control, but not without work that seems unjustified if it's just for pcpatr. if (pStream->getDescriptor()->getTabLabel().Find(_T("PATR")) != -1) dwFlags |= WS_HSCROLL | ES_AUTOHSCROLL; #endif // jdhhab261 pEC->Create(dwFlags, (RECT&)r, &m_tabCtrl, id); CFont* test = pStream->getFont(); pEC->SetFont(test); #ifndef rde270 // delay StreamIn until after setting up of the associated tab (because during StreamIn // our callback must have the pStream which is stored in the tab's lParam member. #else // rde270 // NOTE: I'm not clear on whether StreamIn is done with the stream when it returns; // it doesn't seem to delete it, but you'd think it would need // to keep it around so it can get at large files when the user // scrolls down; maybe not. Why it matters is, what if the cwCOOKIE // member points to a CResultsStream that I've deleted? // For now, I'm going to go on the assumption that the whole // file is read right here. pEC->StreamIn(SF_TEXT, pStream->getEditStreamIn()); // icon may be set in here // Set editing flags and limit CInputDoc* pDoc = (CInputDoc*) GetDocument(); if(id==kBasePanelID && pDoc->m_bBaseIsEditable) { pEC->SetReadOnly(FALSE); const long kMaxAddableChars = 2000; long l = pEC->GetTextLength() + kMaxAddableChars; pEC->LimitText(l); pEC->SetEventMask( ENM_KEYEVENTS| ENM_CHANGE );// want to know when the user changes something } else pEC->SetReadOnly(TRUE); #endif // rde270 /* ALL THIS WAS FOR CEDIT, NOT CRICHEDIT EDITSTREAM es = pStream->getEditStreamIn(); long sz = pEC->GetLimitText()-10; LPTSTR buff = new char [sz+1]; ASSERTX(buff); long actual; (es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, sz, &actual); buff[actual] = '\0'; CString sOverflowMsg = pStream->getOverflowMsg(); if(actual > sz - sOverflowMsg.GetLength()) { buff[sz-sOverflowMsg.GetLength()] = '\0'; CString s = buff; s += sOverflowMsg; pEC->SetWindowText(s); } else pEC->SetWindowText(buff); // make it close (es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, 0, &actual); delete buff; */ // make the tab for this item TC_ITEM tie; tie.mask = TCIF_TEXT |TCIF_PARAM ; tie.lParam = (LPARAM)pStream; tie.pszText = (LPTSTR) LPCTSTR(pStream->getDescriptor()->getTabLabel()); int iconEnum = pStream->getTabIconEnum(); if(iconEnum>=0) { tie.mask |= TCIF_IMAGE; tie.iImage = iconEnum; } #ifndef rde270 // save the inserted tab's index (so it can be accessed by knowing the EC). int nIndex = m_tabCtrl.InsertItem(99, &tie ); ::SetWindowLong(pEC->GetSafeHwnd(),GWL_USERDATA,nIndex); if( -1 == nIndex ) #else // rde270 if (-1 == m_tabCtrl.InsertItem(99, &tie )) #endif // rde270 { ASSERTX(FALSE); } else { //CToolTipCtrl* pTip = new CToolTipCtrl; //pTip->Create(this); // <--- or should it be the tab bar? //pTip-> CToolTipCtrl* pTip = m_tabCtrl.GetToolTips(); ASSERT(pTip); CRect r; m_tabCtrl.GetItemRect(m_tabCtrl.GetItemCount()-1, &r); CString s; s.Format(_T("%s"), (LPCTSTR)pStream->getToolTipText()); pTip->AddTool(&m_tabCtrl, s, &r, id); } #ifndef rde270 // moved 'StreamIn' here because we want the tab already setup for when we get the // 'finished-a-chunk' callback. // use the 'AsyncLoadRichEdit' to stream it in [load asynchronously so we don't kill // the UI for minutes (on big files).] #pragma message("If you subclass CResultStream with something besides CResultStreamFile, this'll break!") CResultStreamFile* pStreamFile = (CResultStreamFile*)pStream; // ASSERT(pStreamFile->IsKindOf(RUNTIME_CLASS(CResultStreamFile))); // this assert is what *should* be, but the various streams are from the processor DLLs // and for some reason IsKindOf doesn't appear to work across DLL boundaries. pEC->StreamIn(pStreamFile->getPath(), bSyncStreamIn, CInputDocView::OnStreamInChunkComplete, (DWORD_PTR)this); // Set editing flags and limit CInputDoc* pDoc = (CInputDoc*) GetDocument(); if(id==kBasePanelID && pDoc->m_bBaseIsEditable) { pEC->SetReadOnly(FALSE); const long kMaxAddableChars = 2000; long l = pEC->GetTextLength() + kMaxAddableChars; pEC->LimitText(l); pEC->SetEventMask( ENM_KEYEVENTS| ENM_CHANGE );// want to know when the user changes something // if the editable file was imported as UTF-16, then we must make it 'modified' so // it'll be saved as UTF-8 before processing (Ample, et al., can deal with UTF-8, // but not UTF-16). if( (pEC->FileEncoding() != eUTF8) && (pEC->FileEncoding() != eAnsi) ) GetDocument()->SetModifiedFlag(); } else pEC->SetReadOnly(TRUE); #endif // rde270 }
///////////////////////////////////////////////////////////////////////////// // CWListCtrl message handlers // we have this lower-case version because // CListCtrl::GetItemText doesn't appear to be virtual CString CWListCtrl::getItemText(int nItem, int nCol) { CWListRowItem* pItem = (CWListRowItem*)GetItemData(nItem); ASSERTX(pItem); return pItem->getText(nCol); }
BOOL CSentransModel::loadFromFile(LPCTSTR lpszPathName, CWCommonModel& commonModel, BOOL bLogIfMissing) { ASSERTX(lpszPathName); SFMFile f(lpszPathName, commonModel.m_cCommentChar); if(!f.ensureOpen("Sentrans File", bLogIfMissing)) return FALSE; char cCommentChar = commonModel.m_cCommentChar; #ifndef hab17a1 CCommentOrTestDataCollector coOrTdCollector; BOOL bSeenSenTransField = FALSE; // 1.7a1 need to ignore comments from non-Sentrans specific items; using this flag to do so #else // hab17a1 CCommentCollector commentCollector; // jdh 11/9/99 #endif //hab17a1 #ifndef hab211 CWList * pLastList = 0; #endif //hab211 CString sMarker, sField; BOOL bEnabled; BOOL bIsDisambig = this->IsKindOf(RUNTIME_CLASS(CSentransDisambigModel)); try { while(f.getField(sMarker, sField, &bEnabled)) { try { if(sMarker == "ru") { if(!bIsDisambig) { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransTransferModel*)this)->m_rules); #else // hab17a1 commentCollector.disgorge(((CSentransTransferModel*)this)->m_rules); // jdh 11/9/99 #endif // hab17a1 CSentransTransferRule *r = new CSentransTransferRule(sField, bEnabled, cCommentChar); ((CSentransTransferModel*)this)->m_rules.addItem(r); #ifndef hab17a1 bSeenSenTransField = TRUE; #endif // hab17a1 } else { CString s("SENTRANS-Disambig files can't have transfer rules."); f.logSkip("SENTRANS-Disambig", sMarker, sField, s); } } #ifndef hab17a1 else if(sMarker == "co" || sMarker == "cm") #else // hab17a1 else if(sMarker == "co") #endif // hab17a1 { /* // JDH 5/25/99 3:28:36 PM Added List Comment Capbility (\co) CListEntryComment *com = new CListEntryComment(sField); if(bIsDisambig) ((CSentransDisambigModel*)this)->m_rules.addItem(com); else ((CSentransTransferModel*)this)->m_rules.addItem(com); */ // jdh 11/9/99 changed to use the commentCollector because now have two lists (rules and \cl list) #ifndef hab17a1 coOrTdCollector.add(sField, "co"); #else // hab17a1 commentCollector.add(sField); #endif // hab17a1 } else if(sMarker == "am" || sMarker == "rej" || sMarker == "reject" || sMarker == "amun" || sMarker == "rejun") { bool bAccept = (sMarker == "am" || sMarker == "amun" ); bool bUnanimousEnvirons = (sMarker == "amun" || sMarker == "rejun"); if(bIsDisambig) { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); #else // hab17a1 commentCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); #endif // hab17a1 CSentransDisambigRule *r = new CSentransDisambigRule(sField, bAccept, bEnabled, bUnanimousEnvirons, cCommentChar); ((CSentransDisambigModel*)this)->m_rules.addItem(r); #ifndef hab17a1 bSeenSenTransField = TRUE; #endif // hab17a1 } else { CString s("SENTRANS-Transfer files can't have disambiguation rules."); f.logSkip("SENTRANS-Transfer", sMarker, sField, s); //MessageBox( NULL, s, "Parsing Error", MB_OK); } } // various SentransDirectiveTypes // jdh 11/9/99 todo: add commentCollector.disgorge() in each of these else if(sMarker == "...") { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); bSeenSenTransField = TRUE; #endif // hab17a1 addRule( new CSentransDirective(CSentransDirective::kLimit, sField, bEnabled, cCommentChar)); } else if(sMarker == "ruleset") { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); bSeenSenTransField = TRUE; #endif // hab17a1 addRule( new CSentransDirective(CSentransDirective::kBeginRuleSet, sField, bEnabled, cCommentChar)); } else if(sMarker == "endruleset") { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); bSeenSenTransField = TRUE; #endif // hab17a1 addRule( new CSentransDirective(CSentransDirective::kEndRuleSet, sField, bEnabled, cCommentChar)); } else if(sMarker == "ruleson") { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); bSeenSenTransField = TRUE; #endif // hab17a1 addRule( new CSentransDirective(CSentransDirective::kRulesOn, sField, bEnabled, cCommentChar)); } else if(sMarker == "rulesoff") { #ifndef hab17a1 coOrTdCollector.disgorge(((CSentransDisambigModel*)this)->m_rules); bSeenSenTransField = TRUE; #endif // hab17a1 addRule( new CSentransDirective(CSentransDirective::kRulesOff, sField, bEnabled, cCommentChar)); } // jdh 11/9/99 add \cl field else if(sMarker == "cl") { #ifndef hab17a1 #ifndef hab264 coOrTdCollector.disgorge(m_genericClasses); #else coOrTdCollector.disgorge(commonModel.morphemeClasses); #endif // hab264 #else // hab17a1 commentCollector.disgorge(commonModel.morphemeClasses); bSeenSenTransField = TRUE; #endif // hab17a1 CWClass *c = new CWClass(sField, bEnabled, commonModel.m_cCommentChar); m_genericClasses.addItem(c); } // jdh 5/29/01 add \pat field else if(sMarker == "pat") { #ifndef hab264 coOrTdCollector.disgorge(m_patterns); #else coOrTdCollector.disgorge(commonModel.morphemeClasses); // why these, why here? I just copied from the generic_class code above. #endif // hab264 CWClass *c = new CWClass(sField, bEnabled, commonModel.m_cCommentChar); m_patterns.addItem(c); } // punctuation fields else if(sMarker == "sentpunc") { m_sSentencePunctuation.setData(sField); } else if(sMarker == "punc") { m_sPunctuation.setData(sField); } else if(sMarker == "bpunc") { m_sBeginPunctuation.setData(sField); } else if(sMarker == "tagchar") // tagchar added feb 99 { if(sField.GetLength()>0) m_cTagChar.setData(sField[0]); } else if(sMarker == "CarlaStudioPrefs") getRuleList()->readPrefsField(sField); // fields to ignore else if(sMarker == "id") {} // skip it else if(sMarker == "_sh") // shoebox {} // skip it else if(sMarker == "mcl" /*|| sMarker == "cl" jdh commented out 11/9/99*/ || sMarker=="scl" || sMarker == "ca" || sMarker=="ccl" || sMarker=="ap" || sMarker=="mp") #ifndef hab17a1 { // skip these, which are duplicated in several files, but don't bother the user coOrTdCollector.removeAll(); } #else // hab17a1 {} // skip these, which are duplicated in several files, but don't bother the user #endif // hab17a1 #ifndef hab17a1 else if(sMarker == "td") // 1.7a1 hab test data { coOrTdCollector.add(sField, "td"); } #endif //hab17a1 #ifndef hab211 else if(sMarker == "CSbegca") { pLastList = 0; // belongs in ad file } else if(sMarker == "CSbegmp") { pLastList = 0; // belongs in ad file } else if(sMarker == "CSbegap") { pLastList = 0; // belongs in ad file } else if(sMarker == "CSbegccl") { pLastList = 0; // belongs in ad file } else if(sMarker == "CSbegmcl") { pLastList = 0; // belongs in ad file } else if(sMarker == "CSbegcl") { pLastList = &m_genericClasses; } else if(sMarker == "CSbegpat") //jdh 5/29/01 { pLastList = &m_patterns; } else if(sMarker == "CSbegru") { pLastList = &((CSentransTransferModel*)this)->m_rules; } else if(sMarker == "CSend") // CS-specific section end marker { if (pLastList) { // dump any comments or test data to list coOrTdCollector.disgorge(*pLastList); pLastList = 0; } else coOrTdCollector.removeAll(); } #endif //hab211 else { if(bIsDisambig) { f.logSkip("SENTRANS-Disambig", sMarker, sField); } else f.logSkip("SENTRANS-Transfer", sMarker, sField); } } catch(CString sProblemStr) // these ones we can keep going { f.logParseFailure("Sentrans", sMarker, sField); } }
// virtual override needed because we don't store the text in the list item itself void CWListCtrl::setItemText(int nItem, int nSubItem, LPCTSTR pszText) { CWListRowItem* pItem = (CWListRowItem*)GetItemData(nItem); ASSERTX(pItem); pItem->setText(nSubItem, pszText); }
// these two are useful, even though the languages themselves are // directly availible, so that processors don't need to include // CarlaLanguage.h, which is especially bad for DLLs CModelFilesSet* CProcessStatus::getInputMFS() { ASSERTX(m_pInputMFS); return m_pInputMFS; //return m_pInputLang->getMFS();<-- this call will cause a linking problem for dlls }
//called by cProjectDoc OnSaveDocument. void CLangModelsDoc::writeProjectDocLine(ofstream & fout) { ASSERTX(!m_pLang->getFilePath().IsEmpty()); // should save language before calling this so the path is set fout << "\\" << getProjectDocMarker() << " " << m_pLang->getFilePath() << "\n"; }
CString CSentransProcess::getCommandLine(CProcessStatus& status) { strstream sout; CModelFilesSet* pSourceMFS = status.getInputMFS(); ASSERTX(pSourceMFS); CModelFilesSet* pTargetMFS = status.getOutputMFS(); // may be null if('|' != status.getInputMFS()->getCommentChar()) sout << " -c " << status.getInputMFS()->getCommentChar() << " "; /* m_bMonitorAmbiguities = FALSE; m_bMonitorRulesApplied = FALSE; m_bTraceRules = FALSE; m_bOutputClassContents = FALSE; */ if(m_bMonitorAmbiguities) sout << "-a "; if(m_bMonitorRulesApplied) sout << "-m "; // jdh 11/10/99 if(status.m_pProcPrefs->m_dwFlags & CProcessingPrefs::kTrace) // jdh 11/10/99 sout << "-t "; else if(m_bTraceRules) sout << "-t "; if(m_bOutputClassContents) sout << "-v "; sout << "-i " << m_sInPath.getQuotedPath(); //.getShortPath(); sout << " -r "; switch(m_iFunction) { case kDisambig: sout << pSourceMFS->getShortCtrlFilePath("disam.sen"); break; case kAdjustSrcGlossing: ASSERTX(!status.getOutputMFS()); // "adj" is now a bad name ("adj-gloss" would be better, // but to change it would break everyone sout << pSourceMFS->getShortCtrlFilePath("adj.sen"); break; // jdh 15June2000 case kOtherRuleFile: sout << m_sOtherRuleFilePath.getShortPath() << " "; break; // JDH 6/2/99Add Sentrans Adjust Rules Set for analysis case kAdjustAnalysis: sout << pSourceMFS->getShortCtrlFilePath("ana.sen"); break; case kTransfer: ASSERTX(status.getOutputMFS()); ASSERTX(pTargetMFS); #ifndef hab17a1 sout << ::shortenPath(pTargetMFS->getSentransTransferPath(pSourceMFS->getAbrev(), pTargetMFS->getAbrev())); #else // hab17a1 sout << ::shortenPath(pSourceMFS->getSentransTransferPath(pTargetMFS->getAbrev())); #endif // hab17a1 break; default: ASSERTX(FALSE); break; } // I removed the short paths here just because we haven't // yet implemented the artificial creation of files to get // short paths if the file doesn't exist // sout << " -o " << m_sOutPath.getShortPath() << " "; sout << " -o " << m_sOutPath.getQuotedPath() << " "; //sout << " >> " << m_sLOGPath.getShortPath(); sout << " > " << m_sLOGPath.getQuotedPath(); CString s(sout.str(), sout.pcount()); sout.rdbuf()->freeze(0); // else get a memory leak // !!!!!!!!!! TO DO: make sure the string is going to be short enough (under 128?) return s; }