//col_num = col_num(in main)-1 void InsertData(LIST* plist, int line_num, int col_num, char dat){ ListNode* temp = SearchLine(plist,line_num); ListNode* temp_next = NULL; int a = col_num; int b = 0; char temp_c; if(temp == NULL && plist->head == NULL) temp = InsertLine(plist,0); if(temp->next == NULL) temp_next = InsertLine(plist,line_num); if(temp->data[col_num] == ' '){ if (col_num < max_col)//empty data temp->data[col_num] = dat;//end if else{ temp = temp->next; col_num = 0; temp->data[col_num] = dat; } }//end if else{ //enter the middle b = SearchData_NULL(plist,temp,col_num);//find space while(b>=0){ while(a < max_col){ temp_c = temp->data[a]; temp->data[a] = dat; dat = temp_c; a++; b--; if(b < 0){ break; } }//end while(a); if(a == max_col && temp->data[max_col] =='\n'){ if(temp->data[max_col-1] != ' '){ temp->data[max_col] = ' '; temp_next = InsertLine(plist,temp->key); temp_next->data[max_col] = '\n'; }//end if else break; } if(temp->next != NULL) temp = temp->next; else temp = InsertLine(plist,line_num);//end else a = 0; }//end while(b) }//end else if(temp->data[max_col] == '\n' && temp->data[max_col-1] != ' '){ temp->data[max_col] = ' '; temp->next->data[max_col] = '\n'; } // KEY_view(plist); // print_Data(plist,line_num,col_num+1); return ; }
static void bstack_paste() { char buf[MAXEDITLINE+1], buf_a[MAXEDITLINE+1]; const char *q; EditLine *ed,*edn; if (bstack_nums==0) return; q=bstack[bstack_nums-1].s; csr_leupdate(); if (bstack[bstack_nums-1].blkm==BLKM_y) { edn=ed=GetList(GetLineOffset()-1); for(;;) { q=str_paste(buf, q); if (q==NULL) break; InsertLine(ed, MakeLine(buf)); ed=ed->next; } csrse.ed = edn -> next; } else { ed=GetList(GetLineOffset()); strcpy(buf, ed->buffer); buf[GetBufferOffset()]='\0'; strcpy(buf_a, ed->buffer+GetBufferOffset()); q=str_paste(buf+GetBufferOffset(), q); if (q==NULL) { strcat(buf, buf_a); Realloc(ed, buf); } else { Realloc(ed, buf); for(;;) { q=str_paste(buf, q); if (q==NULL) break; InsertLine(ed, MakeLine(buf)); ed=ed->next; } strcat(buf, buf_a); InsertLine(ed, MakeLine(buf)); } } SetFileChangeFlag(); csr_lenew(); OffsetSetByColumn(); }
void AssParser::ParseScriptInfoLine(std::string const& data) { if (boost::starts_with(data, ";")) { // Skip stupid comments added by other programs // Of course, we'll add our own in place later... ;) return; } if (boost::starts_with(data, "ScriptType:")) { std::string version_str = data.substr(11); boost::trim(version_str); boost::to_lower(version_str); if (version_str == "v4.00") version = 0; else if (version_str == "v4.00+") version = 1; else throw SubtitleFormatParseError("Unknown SSA file format version", nullptr); } // Nothing actually supports the Collisions property and malformed values // crash VSFilter, so just remove it entirely if (boost::starts_with(data, "Collisions:")) return; size_t pos = data.find(':'); if (pos == data.npos) return; InsertLine(new AssInfo(data.substr(0, pos), boost::trim_left_copy(data.substr(pos + 1)))); }
void DeleteLineAll(LIST*pList,char select){ //tempNode points next node of DeleteNode //for move DeleteNode after deleting node ListNode* DeleteNode = pList->head; ListNode* tempNode = DeleteNode; while(DeleteNode != NULL){ printf("D\n"); tempNode = tempNode->next; DeleteNode->key = 0; DeleteNode->next = NULL; // DeleteNode->dataPtr = NULL; free(DeleteNode); DeleteNode = tempNode; } free(DeleteNode); free(tempNode); //if you want to remain list selete = 'D' if(select == 'D'){ pList->head = NULL; pList->tail = NULL; pList->line_count = 0; } else{//if you want to delete list completely pList->line_count = 0; free(pList->head); free(pList->tail); free(pList); } InsertLine(pList,0); return ; }
//--------------------------------------------------------------------------- void WordMacros::CreateRuningMacros() { BeginMacros(); for (int i = 1; i < m_MacroCounter; i++) InsertLine("Application.Run \"M" + string_t(aux::itoa(i)) + "\""); EndMacros(); }
void AssFile::InsertAttachment(agi::fs::path const& filename) { AssEntryGroup group = AssEntryGroup::GRAPHIC; auto ext = boost::to_lower_copy(filename.extension().string()); if (ext == ".ttf" || ext == ".ttc" || ext == ".pfb") group = AssEntryGroup::FONT; InsertLine(new AssAttachment(filename, group)); }
void RichEdit::InsertTable() { if(IsSelection()) return; WithCreateTableLayout<TopWindow> dlg; CtrlLayoutOKCancel(dlg, t_("Insert table")); dlg.header = false; dlg.columns <<= 2; dlg.columns.MinMax(1, 20); dlg.ActiveFocus(dlg.columns); if(dlg.Run() != IDOK) return; RichTable::Format fmt; int nx = minmax((int)~dlg.columns, 1, 20); for(int q = nx; q--;) fmt.column.Add(1); if(dlg.header) fmt.header = 1; RichTable table; table.SetFormat(fmt); for(int i = 0; i < (dlg.header ? 2 : 1); i++) for(int j = 0; j < nx; j++) { RichText h; h.SetStyles(text.GetStyles()); RichPara p; p.format = formatinfo; p.format.newpage = false; p.format.label.Clear(); h.Cat(p); table.SetPick(i, j, pick(h)); } NextUndo(); if(cursorp.posinpara) InsertLine(); if(text.GetRichPos(cursor).paralen) { InsertLine(); cursor = anchor = cursor - 1; begtabsel = false; } SaveFormat(cursor, 0); AddUndo(new UndoCreateTable(text.SetTable(cursor, table))); Finish(); }
// // Loads the access spec lines from the application's test spec structure // into an MFC list control and into working space in memory. By using working // space, we allow the user to abort all changes by hitting cancel. // void CAccessDialog::LoadList() { int spec_line_no = 0; Access_Spec *new_spec; // Abort if we encounter an error. if (spec == NULL) { ErrorMessage("Unexpectedly found spec == NULL in CAccessDialog::LoadList()"); CDialog::OnOK(); return; } // Clear display before loading accesses. m_LAccess.DeleteAllItems(); // Update the name edit box with the spec's name. m_EName.SetWindowText(spec->name); // Update the default assignment settings. m_CDefaultAssignment.SetCurSel(spec->default_assignment); // Fill in the access spec list. // An "of_size" of IOERROR indicates the end of the list if the list isn't full. item_being_changed = 0; while (spec->access[spec_line_no].of_size != IOERROR && item_being_changed < MAX_ACCESS_SPECS) { // Allocate memory for a new access spec line. if (!(new_spec = new Access_Spec)) { ErrorMessage("Unable to allocate memory to insert new access " "spec line."); return; } // Add the new access spec line to the display. memcpy((void *)new_spec, (void *)&(spec->access[spec_line_no++]), sizeof(Access_Spec)); if (InsertLine(new_spec, item_being_changed)) { item_being_changed++; new_spec = NULL; } else { // Remove the memory for the new spec. It was not used. // (This should rarely happen.) delete new_spec; } } // The last line successfully inserted will be the one available for // editing. This line number is one less than where we tried to insert at. --item_being_changed; // If there are no entries in the access spec, disable the OK button. This // avoids the error message about incomplete access specs for this special // case. if (item_being_changed < 0) m_BOk.EnableWindow(FALSE); m_LAccess.SetFocus(); }
void nuiCSV::InsertComment(const nglString& rComment) { std::vector<nglString> vec; if (!mCommentsEnabled) return; vec.push_back(NUICSV_COMMENT_TAG); vec.push_back(rComment); InsertLine(vec); }
void AssFile::SetScriptInfo(std::string const& key, std::string const& value) { for (auto info : Line | agi::of_type<AssInfo>()) { if (boost::iequals(key, info->Key())) { if (value.empty()) delete info; else info->SetValue(value); return; } } if (!value.empty()) InsertLine(new AssInfo(key, value)); }
void AssParser::ParseAttachmentLine(std::string const& data) { bool is_filename = boost::starts_with(data, "fontname: ") || boost::starts_with(data, "filename: "); bool valid_data = data.size() > 0 && data.size() <= 80; for (auto byte : data) { if (byte < 33 || byte >= 97) { valid_data = false; break; } } // Data is over, add attachment to the file if (!valid_data || is_filename) { InsertLine(attach.release()); AddLine(data); } else { attach->AddData(data); // Done building if (data.size() < 80) InsertLine(attach.release()); } }
BOOL CCrystalTextBuffer::InitNew(int nCrlfStyle /*= CRLF_STYLE_DOS*/) { ASSERT(! m_bInit); ASSERT(m_aLines.GetSize() == 0); ASSERT(nCrlfStyle >= 0 && nCrlfStyle <= 2); InsertLine(_T("")); m_bInit = TRUE; m_bReadOnly = FALSE; m_nCRLFMode = nCrlfStyle; m_bModified = FALSE; m_nSyncPosition = m_nUndoPosition = 0; m_bUndoGroup = m_bUndoBeginGroup = FALSE; m_nUndoBufSize = UNDO_BUF_SIZE; ASSERT(m_aUndoBuf.GetSize() == 0); UpdateViews(NULL, NULL, UPDATE_RESET); return TRUE; }
// // Insert a new line into the access spec after or before the current one. // void CAccessDialog::InsertWrapper(BOOL after) { int current_line; Access_Spec *spec = NULL; if (!(spec = new Access_Spec)) { ErrorMessage("Unable to allocate memory to insert new access " "spec line."); return; } // Get the first selected line. if (item_being_changed == -1) { // Nothing is selected. Create a default entry. item_being_changed = 0; spec->of_size = 100; spec->reads = 67; spec->random = 100; spec->delay = 0; spec->burst = 1; spec->align = 0; spec->reply = 0; spec->size = 2048; } else { // If we're inserting after the current selection, we need to find the // last selected line. current_line = m_LAccess.GetNextItem(-1, LVNI_SELECTED); if (after) { // Find the last selected line number. while (current_line != -1) { item_being_changed = current_line; current_line = m_LAccess.GetNextItem(current_line, LVNI_SELECTED); } // Get the last selected line's information. GetAll(spec); item_being_changed++; } else { // We're inserting before the first selected line. if (current_line != -1) item_being_changed = current_line; GetAll(spec); } } // Insert the new line. InsertLine(spec, item_being_changed); }
void open_list(LIST* plist,FILE* fp){ char ch = 'a'; int col = 0; int i = 0; ListNode* line = plist->head; while(ch != '\0'){ while(col < max_col){ ch = fgetc(fp); if(ch == '\0') break; if(ch != 94) printf("%c",ch); else printf(" "); InsertData(plist,line->key,col,ch); col++; } if(ch == '\0'){ // DeleteLine(plist,line->key);//if don't delete line, add 1 line // return; break; } if((ch = fgetc(fp)) == ' '){ line->data[max_col] = ' '; } printf("\n"); line = InsertLine(plist,line->key); col = 0; }//end while '\0' DeleteLine_N(plist,line->next); // printf("tail %d",plist->tail->key); // KEY_view(plist); return ; }
int PM_parameter() { char * table_label[]= {"DH","QDZH","ZDZH","X","Y","FWJ","ZX","QDBJ","ZDBJ"}; char * icons[] = {"","","","",""}; char * ch_text[] = {"\xb5\xe3\xc3\xfb", "起点桩号", "终点桩号", "X坐标 ", "Y坐标 ", "方位角 ", "转向 ", "起点半径", "终点半径"}; int x = 0,y = 0,i,j,t; int left = 0,top = 0; int refresh = REDRAW_ALL; int enter,suc; char str[13]=""; char c; PMproduce(); //打开交点参数转换平面参数 InsertLine(l_pqx.length,&y,&refresh); GetListq(); //取链表链表线元参数 while(1){ if (refresh==REDRAW_ALL){ Bdisp_AllClr_VRAM(); for (i=0;i<4;++i) PrintTablesPM(i,0,table_label[left+i],1,1); t = pmroute.size<= 1 ? 2 : 5; //如果交点个数小于等于1 那么T=2 否则等于5 if (t>=2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(2,56,"\xCE\xC4\xBC\xFE"); DispStr(23,56,"添加"); } if (t>2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(45,56,"插入 "); DispStr(65,56,"删行 "); DispStr(86,56,"清空 "); } for (i=0;i< t;++i) // i<2 或 i<5 PrintIcon(i,icons[i],0); //打印下标 PrintIcon(5,"?",0); //固定打印下标 refresh = REDRAW_PART; // 重画部分 } if (refresh==REDRAW_PART){ //如果画部分 double * sd; for (i=top;i<top+4 && i<pmroute.size;++i){ sd = & (pmroute.set[i].pm_qk); for (j=(left==0 ? 1:0);j<4;++j){ //if (i==0 && j+left>3) ////////////////////////////////////////// //PrintTablesPM(j,i+1-top,"",y==i && x-left==j,0);/////////////// //else///////// PrintTableFormatPM(j,i+1-top,y==i && x-left==j,0,"%lf",sd[j+left-1]); } if (left==0) PrintTableFormatPM(0,i+1-top,y==i && x-left==0,0,"%s",pmroute.set[i].name); PrintTableIndexPM(i-top+1,i); } SetMyFont(&stHz12x12,&stAsc6x12); if(x>0){ //if (!(y==0 && x>2)){ sd = & (pmroute.set[y].pm_qk); //取地址的值*************** DispStr(0,42,ch_text[x]); PrintFloat(sd[x-1],49,42,0,setup_data.point); //打印 //} }else{ DispStr(0,42,ch_text[x]); PrintXY(51,44,pmroute.set[y].name,0); } refresh = 0; } GetKey(&key); switch (key){ case KEY_CTRL_UP: y--;refresh = REDRAW_ALL;break; case KEY_CTRL_DOWN: y++;refresh = REDRAW_ALL;break; case KEY_CTRL_LEFT: x--;refresh = REDRAW_ALL;break; case KEY_CTRL_RIGHT: x++;refresh = REDRAW_ALL;break; case KEY_CTRL_EXIT: pmroute_initial(&pmroute); InitList(&l_pqx); return 0 ; case KEY_CTRL_F1: /* Set */ refresh = REDRAW_ALL; SelectfilePM(); break; case KEY_CTRL_F2: /* Add */ pmroute_push_back (&pmroute); y = pmroute.size - 1; refresh = REDRAW_ALL; break; case KEY_CTRL_F3: /* ins */ //if (y==0) break; pmroute_insert (&pmroute,y); y++; refresh = REDRAW_ALL; break; case KEY_CTRL_F4: /* Del a point */ //if (y==0) break; refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"删 除 一 行?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_del(&pmroute,y);y--; } break; case KEY_CTRL_F5: /* Del All */ refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"清 空 所 有 ?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_initial(&pmroute); pmroute_push_back(&pmroute); } break; case KEY_CTRL_F6: refresh = REDRAW_ALL; //PrintfXY (70,30,0,"%.3f",route.set[0].xy_zr); //DispStr(15,10,"线路名称"); //if(setup_data.pmroute_name[0]==0) //{ //DispStr(25,27,"请保存线路文件 "); //} //else //{ //DispStr(25,27,setup_data.zdmroute_name); //} break; default: /*other things*/ if (x>0 && (c=GetPressNumChar(key))!=0){ char buffer[14]; int r; //if (y==0 && x > 3)break; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,0,12); if (r!=KEY_CTRL_EXIT){ double * sd; sd = (double*)&(pmroute.set[y].pm_qk); sd[x-1] = atof(buffer); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } else if (x==0 && (c=GetPressChar(key))!=0){ char buffer[14]; int r; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,1,12); if (r!=KEY_CTRL_EXIT){ strncpy(pmroute.set[y].name,buffer,12); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } break; } if (x<0) x = 8,y--; if (x>8) x = 0,y++; if (y<0) y = 0; if (y>=pmroute.size) y = pmroute.size - 1; if (y>top + 3) top = y - 3; if (y<top) top = y; if (x>left +3) left = x - 3; if (x<left) left = x; } }
void AssParser::ParseEventLine(std::string const& data) { if (boost::starts_with(data, "Dialogue:") || boost::starts_with(data, "Comment:")) InsertLine(new AssDialogue(data)); }
bool nuiCSV::Load(nglIStream* pStream, bool CheckNbColumns) { if (!pStream) { NGL_OUT(_T("nuiCSV::Load error : input stream is NULL!\n")); return false; } if (!pStream->Available()) { NGL_OUT(_T("nuiCSV::Load error : nothing to read from the input stream!\n")); return false; } pStream->SetTextFormat(eTextDOS); pStream->SetTextEncoding(eUTF8); // reset the document mDocument.clear(); nglString line; nglString separationString(mSeparationChar); std::vector<nglString> tokens; uint32 numlines = 0; uint32 numcols = 0; // for each line from input stream while (pStream->ReadLine(line, NULL)) { //NGL_OUT(_T("%3d ReadLine: %s\n"), numlines, line.GetChars()); numlines++; // first, handle the comment lines, if the comment option has been enabled if (mCommentsEnabled && (line.GetChar(0) == mCommentTag)) { line.DeleteLeft(1); InsertComment(line); continue; } // now, handle the usual text lines : // // first of all, look for the separation chars that would be between ["..."] : they are not separation chars, they're part of the text // => replace'em with a special tag, in order to let the tokenization process correctly int32 pos1=0; int32 pos2,pos3,tmppos; while ((pos2 = line.Find(_T('\"'), pos1)) >= 0) { // if it's a double '""', it'a part of the text, don't do anything if (line.GetChar(pos2+1) == _T('\"')) { pos1 = pos2+1; continue; } // it'a single '"'. look for the closing occurence pos3 = line.Find(_T('\"'), pos2+1); if (pos3 < 0) { NGL_OUT(_T("nuiCSV syntax error : a '\"' char is missing on line %d!\n"), numlines); return false; } // but don't be fooled by the double '""' (it's a part from the text) while (line.GetChar(pos3+1) == _T('\"')) { pos3 = line.Find(_T('\"'), pos3+1); } if (pos3 < 0) { NGL_OUT(_T("nuiCSV syntax error : a '\"' char is missing on line %d!\n"), numlines); return false; } // now [pos2 - pos3] matches '" ... "'. look for the separation chars inside this range and replace'em with the special tag while ((tmppos = line.Find(mSeparationChar, pos2, pos3)) >= 0) { line.Replace(tmppos, 1, NUICSV_SEPARATION_TAG); pos3 += nglString(NUICSV_SEPARATION_TAG).GetLength(); pos2 = tmppos; } // offset for the next cycle pos1 = pos3+1; } // // ok, we can now tokenize the line, without making mistakes // tokens.clear(); line.Tokenize(tokens, mSeparationChar, true); // check number of columns uint32 nbcols = tokens.size(); if (CheckNbColumns) { if (nbcols < numcols) { NGL_OUT(_T("nuiCSV syntax error : not enough columns from the csv document in line %d! Could not process it!\n"), numlines); return false; } else if (numcols == 0) { numcols = nbcols; } else if (nbcols > numcols) { NGL_OUT(_T("nuiCSV syntax error : the number of columns in line %d (%d columns) doesn't match (%d columns)! Could not process it!\n"), numlines, nbcols, numcols); return false; } } // for all columns, // remove useless whitespaces, // remove '"' from begin and end, unless it's a double '""' for (uint i=0; i < nbcols; i++) { tokens[i].Trim(); //uint32 length = strlen(tokens[i].GetStdString().c_str()); uint32 length = tokens[i].GetLength(); if ((tokens[i].GetChar(0) == _T('\"')) && (tokens[i].GetChar(1) != _T('\"'))) { if ((tokens[i].GetChar(length-1) == _T('\"')) && (tokens[i].GetChar(length-2) != _T('\"'))) { tokens[i].DeleteLeft(1); tokens[i].DeleteRight(1); } } // finally, replace all double '""' by single '"' tokens[i].Replace(_T("\"\""), _T("\"")); // and replace nuicsv special tag by the separation char (once again, here, it's not a separation char, it's a part from the text) tokens[i].Replace(NUICSV_SEPARATION_TAG, separationString); } // now we can add this line to the document InsertLine(tokens); if (pStream->GetState() != eStreamReady) return true; } return true; }
BOOL CCrystalTextBuffer::LoadFromFile(LPCTSTR pszFileName, int nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/) { ASSERT(! m_bInit); ASSERT(m_aLines.GetSize() == 0); HANDLE hFile = NULL; int nCurrentMax = 256; char *pcLineBuf = new char[nCurrentMax]; BOOL bSuccess = FALSE; __try { DWORD dwFileAttributes = ::GetFileAttributes(pszFileName); if (dwFileAttributes == (DWORD) -1) __leave; hFile = ::CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) __leave; int nCurrentLength = 0; const DWORD dwBufSize = 32768; char *pcBuf = (char *) _alloca(dwBufSize); DWORD dwCurSize; if (! ::ReadFile(hFile, pcBuf, dwBufSize, &dwCurSize, NULL)) __leave; if (nCrlfStyle == CRLF_STYLE_AUTOMATIC) { // Try to determine current CRLF mode for (DWORD I = 0; I < dwCurSize; I ++) { if (pcBuf[I] == _T('\x0a')) break; } if (I == dwCurSize) { // By default (or in the case of empty file), set DOS style nCrlfStyle = CRLF_STYLE_DOS; } else { // Otherwise, analyse the first occurance of line-feed character if (I > 0 && pcBuf[I - 1] == _T('\x0d')) { nCrlfStyle = CRLF_STYLE_DOS; } else { if (I < dwCurSize - 1 && pcBuf[I + 1] == _T('\x0d')) nCrlfStyle = CRLF_STYLE_UNIX; else nCrlfStyle = CRLF_STYLE_MAC; } } } ASSERT(nCrlfStyle >= 0 && nCrlfStyle <= 2); m_nCRLFMode = nCrlfStyle; const char *crlf = crlfs[nCrlfStyle]; m_aLines.SetSize(0, 4096); DWORD dwBufPtr = 0; int nCrlfPtr = 0; USES_CONVERSION; while (dwBufPtr < dwCurSize) { int c = pcBuf[dwBufPtr]; dwBufPtr ++; if (dwBufPtr == dwCurSize && dwCurSize == dwBufSize) { if (! ::ReadFile(hFile, pcBuf, dwBufSize, &dwCurSize, NULL)) __leave; dwBufPtr = 0; } pcLineBuf[nCurrentLength] = (char) c; nCurrentLength ++; if (nCurrentLength == nCurrentMax) { // Reallocate line buffer nCurrentMax += 256; char *pcNewBuf = new char[nCurrentMax]; memcpy(pcNewBuf, pcLineBuf, nCurrentLength); delete pcLineBuf; pcLineBuf = pcNewBuf; } if ((char) c == crlf[nCrlfPtr]) { nCrlfPtr ++; if (crlf[nCrlfPtr] == 0) { pcLineBuf[nCurrentLength - nCrlfPtr] = 0; InsertLine(A2T(pcLineBuf)); nCurrentLength = 0; nCrlfPtr = 0; } } else nCrlfPtr = 0; } pcLineBuf[nCurrentLength] = 0; InsertLine(A2T(pcLineBuf)); ASSERT(m_aLines.GetSize() > 0); // At least one empty line must present m_bInit = TRUE; m_bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0; m_bModified = FALSE; m_bUndoGroup = m_bUndoBeginGroup = FALSE; m_nUndoBufSize = UNDO_BUF_SIZE; m_nSyncPosition = m_nUndoPosition = 0; ASSERT(m_aUndoBuf.GetSize() == 0); bSuccess = TRUE; UpdateViews(NULL, NULL, UPDATE_RESET); } __finally { if (pcLineBuf != NULL) delete pcLineBuf; if (hFile != NULL) ::CloseHandle(hFile); } return bSuccess; }
BOOL Delete( LPCLASSDATA lpcd ) { /* * Read only? */ if ( ISREADONLY ) return TRUE; /* * Do we have a mark and * is it valid? */ if ( HasMark( lpcd )) { /* * Remove the text. */ DeleteText( lpcd, &lpcd->ptSelStart, &lpcd->ptSelEnd, TRUE ); /* * We _must_ have atleast one * empty line. */ if ( ArrayGetSize( lpcd->lpLines ) == 0 ) { if ( InsertLine( lpcd, NULL, 0, -1, TRUE ) == FALSE ) return FALSE; } /* * Hide the caret. */ DisplayCaret( lpcd, FALSE ); /* * Move to the start position. */ lpcd->ptCaretPos = lpcd->ptSelStart; /* * Update column position. */ lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x ); /* * Invalidate marks. */ lpcd->ptSelStart.x = lpcd->ptSelStart.y = -1; lpcd->ptSelEnd.x = lpcd->ptSelEnd.y = -1; /* * Is the caret inside * the view? */ if ( CaretInView( lpcd ) == FALSE ) /* * No. Move the view to * make it visible. */ MakeCaretVisibleNoRedraw( lpcd ); /* * Re-render. */ InvalidateRect( lpcd->hWnd, NULL, FALSE ); /* * Setup scrollers. */ SetupHScroller( lpcd ); SetupVScroller( lpcd ); /* * We are modified. */ SetModified( lpcd, TRUE ); /* * Send status message. */ SendStatusMessage( lpcd ); /* * Show the caret. */ DisplayCaret( lpcd, TRUE ); } return TRUE; }
void AssParser::ParseStyleLine(std::string const& data) { if (boost::starts_with(data, "Style:")) InsertLine(new AssStyle(data, version)); }
BOOL CCrystalTextBuffer::InternalInsertText(CCrystalTextView *pSource, int nLine, int nPos, LPCTSTR pszText, int &nEndLine, int &nEndChar) { ASSERT(m_bInit); // Text buffer not yet initialized. // You must call InitNew() or LoadFromFile() first! // ASSERT(nLine >= 0 && nLine < m_aLines.GetSize()); // ASSERT(nPos >= 0 && nPos <= m_aLines[nLine].m_nLength); if (m_bReadOnly) return FALSE; CInsertContext context; context.m_ptStart.x = nPos; context.m_ptStart.y = nLine; int nRestCount = m_aLines[nLine].m_nLength - nPos; LPTSTR pszRestChars = NULL; if (nRestCount > 0) { pszRestChars = new TCHAR[nRestCount]; memcpy(pszRestChars, m_aLines[nLine].m_pcLine + nPos, nRestCount * sizeof(TCHAR)); m_aLines[nLine].m_nLength = nPos; } int nCurrentLine = nLine; BOOL bNewLines = FALSE; int nTextPos; for (;;) { nTextPos = 0; while (pszText[nTextPos] != 0 && pszText[nTextPos] != _T('\r')) nTextPos ++; if (nCurrentLine == nLine) { AppendLine(nLine, pszText, nTextPos); } else { InsertLine(pszText, nTextPos, nCurrentLine); bNewLines = TRUE; } if (pszText[nTextPos] == 0) { nEndLine = nCurrentLine; nEndChar = m_aLines[nCurrentLine].m_nLength; AppendLine(nCurrentLine, pszRestChars, nRestCount); break; } nCurrentLine ++; nTextPos ++; if (pszText[nTextPos] == _T('\n')) { nTextPos ++; } else { ASSERT(FALSE); // Invalid line-end format passed } pszText += nTextPos; } if (pszRestChars != NULL) delete pszRestChars; context.m_ptEnd.x = nEndChar; context.m_ptEnd.y = nEndLine; if (bNewLines) UpdateViews(pSource, &context, UPDATE_HORZRANGE | UPDATE_VERTRANGE, nLine); else UpdateViews(pSource, &context, UPDATE_SINGLELINE | UPDATE_HORZRANGE, nLine); if (! m_bModified) SetModified(TRUE); return TRUE; }
void LstOdaSrvDetails::LoadDetailsFromServer(Server &In) { DeleteAllItems(); DeleteAllColumns(); if (In.GotResponse() == false) return; // Begin adding data to the control // Set the initial background colour BGItemAlternator = *wxWHITE; InsertColumn(srvdetails_field_name, wxT(""), wxLIST_FORMAT_LEFT, 150); InsertColumn(srvdetails_field_value, wxT(""), wxLIST_FORMAT_LEFT, 150); // Version InsertLine(wxT("Version"), wxString::Format(wxT("%u.%u.%u-r%u"), In.Info.VersionMajor, In.Info.VersionMinor, In.Info.VersionPatch, In.Info.VersionRevision)); InsertLine(wxT("QP Version"), wxString::Format(wxT("%u"), In.Info.VersionProtocol)); // Status of the game InsertLine(wxT(""), wxT("")); InsertHeader(wxT("Game Status"), wxRED, wxWHITE); InsertLine(wxT("Time left"), wxString::Format(wxT("%u"), In.Info.TimeLeft)); if (In.Info.GameType == GT_TeamDeathmatch || In.Info.GameType == GT_CaptureTheFlag) { InsertLine(wxT("Score Limit"), wxString::Format(wxT("%u"), In.Info.ScoreLimit)); } // Patch (BEX/DEH) files InsertLine(wxT(""), wxT("")); InsertHeader(wxT("BEX/DEH Files"), wxRED, wxWHITE); if (In.Info.Patches.size() == 0) { InsertLine(wxT("None"), wxT("")); } else { size_t i = 0; size_t PatchesCount = In.Info.Patches.size(); wxString Current, Next; // A while loop is used to format this correctly while (i < PatchesCount) { Current = stdstr_towxstr(In.Info.Patches[i]); ++i; if (i < PatchesCount) Next = stdstr_towxstr(In.Info.Patches[i]); ++i; InsertLine(Current, Next); Current = wxT(""); Next = wxT(""); } } // Gameplay variables (Cvars, others) InsertLine(wxT(""), wxT("")); InsertHeader(wxT("Game Settings"), wxRED, wxWHITE); // Sort cvars ascending sort(In.Info.Cvars.begin(), In.Info.Cvars.end(), CvarCompare); for (size_t i = 0; i < In.Info.Cvars.size(); ++i) InsertLine(stdstr_towxstr(In.Info.Cvars[i].Name), stdstr_towxstr(In.Info.Cvars[i].Value)); // Resize the columns ResizeNameValueColumns(); }