bool CKolejka::FirstFitMU() { fstream fDMC(DMC.c_str(), ios::in); int linia = 2; GotoLine(fDMC, linia); int k = 0; for (unsigned i = 0; i<m_uIloscMulti; i++) { m_psKolejka[i].typ = "M"; m_psKolejka[i].nIndeksZadania = i; m_psKolejka[i].nNumerSciezki = 1; fDMC >> m_psKolejka[i].nPrzepust; linia++; GotoLine(fDMC, linia); } fDMC.close(); for (unsigned j = m_uIloscMulti; j<m_uIloscMulti+m_uIloscUni; j++) { m_psKolejka[j].typ = "U"; m_psKolejka[j].nIndeksZadania = k; m_psKolejka[j].nNumerSciezki = 1; m_psKolejka[j].nPrzepust = m_ppnKolejkaUni[k][2]; k++; } return true; }
std::string en::GetNoun(Noun* NounObj,bool ObjCase) { #ifdef DEBUG std::cout << "[EN] GetNoun(noun* NounObj)" <<std::endl; #endif std::ifstream is(DICTIONARY EN_FOLDER "nouns"); if (GotoLine(is,NounObj->ID)) return ""; int Typ = is.get(); if (Typ == 'd') { int GetID = 1; if (ObjCase && NounObj->IsReflexive) GetID = 4; else if (ObjCase) GetID = 2; if (GotoSegment(is,GetID)) return ""; return GetSegment(is); } else if (Typ == 'n' || Typ == 'm' || Typ == 'f') { if (GotoSegment(is,1)) return ""; std::string Base = GetSegment(is); if (NounObj->IsPlural) Base += "s"; return Base; } else if (Typ == 'o') { int GetID = 1; if (NounObj->IsPlural) GetID = 2; if (GotoSegment(is,GetID)) return ""; return GetSegment(is); } return ""; }
void wxHexView::OnMouseWheel(wxMouseEvent &evt) { int th_size = m_vscroll->GetThumbSize(); int th_max = m_vscroll->GetRange(); if (th_max <= th_size) return; int th_cur = m_vscroll->GetThumbPosition(); if (evt.m_wheelRotation > 0) { // scroll up if (th_cur > th_size) th_cur -= th_size; else th_cur = 0; } else { // scroll down if (th_cur < th_max - (th_size * 2)) th_cur += th_size; else th_cur = th_max - th_size; } if (th_cur == (int)m_curLine) return; GotoLine(th_cur); }
void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) { const int lastLine = LineFromPosition(GetLastPosition()); long line = wxGetNumberFromUser(wxT(""), wxT("Goto line:"), wxT("Goto Line"), 1, 1, 1000000, this); if(line <= lastLine) { GotoLine(line - 1); } }
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); } }
INT_PTR CALLBACK DlgLine( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int y; static DWORD HelpArray[]= { ID_LINE_LINE, IDH_LINE, 0, 0 }; Unused(lParam); switch (message) { case WM_HELP: WinHelp((HWND)((LPHELPINFO) lParam)->hItemHandle, "windbg.hlp", HELP_WM_HELP, (DWORD_PTR)(LPVOID) HelpArray ); return TRUE; case WM_CONTEXTMENU: WinHelp ((HWND) wParam, "windbg.hlp", HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID) HelpArray ); return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: // Retrieve selected item text and compute line nbr y = GetDlgItemInt(hDlg, ID_LINE_LINE, NULL, FALSE); if (y <= 0) { ErrorBox2(hDlg, MB_TASKMODAL, ERR_Goto_Line); SetFocus(GetDlgItem(hDlg, ID_LINE_LINE)); } else { GotoLine(curView, y, FALSE); EndDialog(hDlg, TRUE); } return (TRUE); case IDCANCEL : EndDialog(hDlg, TRUE); return (TRUE); } break; } return (FALSE); } /* DlgLine() */
void wxHexView::GotoOffset(wxFileOffset offset) { // don't move the screen if the line is already onscreen unsigned int line = offset / 16; if (line < m_curLine || line > m_curLine + m_visibleLines) GotoLine(offset / 16); }
void wxHexView::OnVScroll(wxScrollEvent &evt) { unsigned int pos = evt.GetPosition(); if (pos == m_curLine) return; GotoLine(pos); }
//返回文件中某行数的内容 std::string getLineFromFile(const std::string& fn, int lineNum){ std::fstream file (fn); GotoLine(file, lineNum); std::string line; std::getline(file, line); file.close(); return line; }
bool CKolejka::RandomUMU() { srand( time( NULL ) ); int liczba; vector<int> wylosowane; SZadania* m_psBufor = new SZadania[m_uIloscUni+m_uIloscMulti]; unsigned zakres = m_uIloscUni+m_uIloscMulti; //-----------------------wladowanie zadan------------- fstream fDMC(DMC.c_str(), ios::in); int linia = 2; GotoLine(fDMC, linia); int k = 0; for (unsigned i = 0; i<m_uIloscMulti; i++) { m_psKolejka[i].typ = "M"; m_psKolejka[i].nIndeksZadania = i; m_psKolejka[i].nNumerSciezki = ( rand() % LiczbaDrzew ) + 1; fDMC >> m_psKolejka[i].nPrzepust; linia++; GotoLine(fDMC, linia); } fDMC.close(); for (unsigned i = m_uIloscMulti; i<m_uIloscMulti+m_uIloscUni; i++) { m_psKolejka[i].typ = "U"; m_psKolejka[i].nIndeksZadania = k; m_psKolejka[i].nNumerSciezki = ( rand() % LiczbaSciezek ) + 1; m_psKolejka[i].nPrzepust = m_ppnKolejkaUni[k][2]; k++; } //--------------------koniec wladowania zadan------------- //-------mieszanie zadan----------- for (unsigned j = 0; j<zakres; j++){ liczba = rand() % zakres; do{ liczba = rand() % zakres; } while (SprawdzCzyJest(wylosowane, liczba) == true); m_psBufor[j] = m_psKolejka[liczba]; wylosowane.push_back(liczba); } for (unsigned j = 0; j<m_uIloscUni+m_uIloscMulti; j++){ m_psKolejka[j] = m_psBufor[j]; } return true; }
std::string en::GetConjunction(int ConjunctionNum) { if (ConjunctionNum < 0) return ""; std::ifstream is(DICTIONARY EN_EN_FOLDER "conjunctions"); if(GotoLine(is,ConjunctionNum)) return ""; std::string Conjunction = GetSegment(is); is.close(); return Conjunction; }
std::string en::GetVerbPreAdd(int VerbNum) { std::ifstream is (DICTIONARY EN_EN_FOLDER "verb_present"); if (GotoLine(is,VerbNum)) return ""; int Data = is.get(); if (Data == '1') { if (GotoSegment(is,2)) return ""; std::string Segment = GetSegment(is); is.close(); return Segment; } else if (Data == '0') { if (GotoSegment(is,11)) return ""; std::string Segment = GetSegment(is); is.close(); return Segment; } else { if (GotoSegment(is,1)) return ""; std::string Segment = GetSegment(is); is.close(); //Now follow all the english spelling rules //http://www.oxforddictionaries.com/words/verb-tenses-adding-ed-and-ing //http://www.grammar.cl/Notes/Spelling_ING.htm int u = Segment.length(); if (Segment[u-1] == 'e' && Segment[u-2] == 'i') { //Turn 'ie' into y Segment = Segment.substr(0,u-2); Segment += "y"; } else if (Segment[u-1] == 'e' && ( Segment[u-2] != 'e' && Segment[u-2] != 'y' && Segment[u-2] != 'o' )) { //Drop final e, if e is not before y,e or o //make -> mak ( + {ed,ing} ) Segment = Segment.substr(0,u-1); } else if (Segment[u-1] == 'c') { //Add a k after a c //picnic -> picnick ( + {ed,ing} ) Segment += "k"; } else if (!IsVowel(Segment[u-3]) && IsVowel(Segment[u-2]) && !IsVowel(Segment[u-1]) && Segment[u-1]!='x' && Segment[u-1]!='y' && Segment[u-1]!='z' && Segment[u-1]!='w') { //Double consonant after consonant-vowel-consonant cluster. //Provided that final consonant is not w,x,y or z //Travel -> Travell ( + {ed,ing} ) Segment += Segment[u-1]; } return Segment; } return ""; }
int en::GetNounType(int NounNum) { if (NounNum < 0) return 0; std::ifstream is(DICTIONARY EN_EN_FOLDER "nouns"); GotoLine(is,NounNum); int Data = is.get(); is.close(); return Data; }
void TextEditorStc::PrevMarker() { int line = edwnd->GetCurrentLine(); if (edwnd->MarkerGet(line)) line--; line = edwnd->MarkerPrevious(line, 1); if (line >= 0) GotoLine(line); }
void en::ParseVerb(int verb,int n){ std::ifstream is(DICTIONARY EN_EN_FOLDER "extverbs.txt"); if (GotoLine(is,n)) return; std::string Line; std::getline(is,Line); is.close(); Parser p; p.parseExt(Line,this,verb); }
void TextEditorStc::NextMarker() { int line = edwnd->GetCurrentLine(); if (edwnd->MarkerGet(line)) line++; int found = edwnd->MarkerNext(line, 1); if (found == -1 && line) found = edwnd->MarkerNext(0, 1); if (found >= 0) GotoLine(found); }
MibEditor::MibEditor(Snmpb *snmpb) { s = snmpb; // Menu items connect( s->MainUI()->fileNewAction, SIGNAL( triggered() ), this, SLOT( MibFileNew() ) ); connect( s->MainUI()->fileOpenAction, SIGNAL( triggered() ), this, SLOT( MibFileOpen() ) ); connect( s->MainUI()->fileSaveAction, SIGNAL( triggered() ), this, SLOT( MibFileSave() ) ); connect( s->MainUI()->fileSaveAsAction, SIGNAL( triggered() ), this, SLOT( MibFileSaveAs() ) ); connect( s->MainUI()->actionVerifyMIB, SIGNAL( triggered() ), this, SLOT( VerifyMIB() ) ); connect( s->MainUI()->actionExtractMIBfromRFC, SIGNAL( triggered() ), this, SLOT( ExtractMIBfromRFC() ) ); connect( s->MainUI()->MIBLog, SIGNAL ( itemDoubleClicked ( QListWidgetItem* ) ), this, SLOT( SelectedLogEntry ( QListWidgetItem* ) ) ); connect( s->MainUI()->MIBFile->document(), SIGNAL(modificationChanged(bool)), this, SLOT( MibFileModified(bool) )); connect( s->MainUI()->actionGotoLine, SIGNAL( triggered() ), this, SLOT( GotoLine() ) ); connect( s->MainUI()->actionFind, SIGNAL( triggered() ), this, SLOT( Find() ) ); connect( s->MainUI()->actionReplace, SIGNAL( triggered() ), this, SLOT( Replace() ) ); connect( s->MainUI()->actionFindNext, SIGNAL( triggered() ), this, SLOT( ExecuteFindNext() ) ); // Syntax highlighter highlighter = new MibHighlighter(s->MainUI()->MIBFile->document()); // Marker widget s->MainUI()->MIBFileMarker->setTextEditor(s->MainUI()->MIBFile); // Line number statusbar widget lnum = new QLabel(); s->MainUI()->MIBFileStatus->addPermanentWidget(lnum); // Filename statusbar widget lfn = new QLabel(); s->MainUI()->MIBFileStatus->addWidget(lfn); SetCurrentFileName(""); connect( s->MainUI()->MIBFile, SIGNAL( cursorPositionChanged() ), this, SLOT( SetLineNumStatus() ) ); SetLineNumStatus(); find_string = ""; replace_string = ""; }
LRESULT ScoreErrorsDlg::OnPrev(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { int index = errLst.GetCurSel(); if (index > 0) { errLst.SetCurSel(--index); ErrSelect(index, errLst.GetCount()); } GotoLine(); return 0; }
bool CKolejka::RandomUM() { srand( time( NULL ) ); int liczba; vector<int> wylosowaneM, wylosowaneU; fstream fDMC(DMC.c_str(), ios::in); int linia = 2; GotoLine(fDMC, linia); for (unsigned i = 0; i<m_uIloscUni; i++){ do{ liczba = rand() % m_uIloscUni; } while (SprawdzCzyJest(wylosowaneU, liczba) == true); wylosowaneU.push_back(liczba); } for (unsigned i = 0; i<m_uIloscMulti; i++){ do{ liczba = rand() % m_uIloscMulti; } while (SprawdzCzyJest(wylosowaneM, liczba)); wylosowaneM.push_back(liczba); } for (unsigned j = 0; j<m_uIloscUni; j++){ m_psKolejka[j].typ = "U"; m_psKolejka[j].nIndeksZadania = wylosowaneU[j]; m_psKolejka[j].nNumerSciezki = ( rand() % LiczbaSciezek ) + 1; m_psKolejka[j].nPrzepust = m_ppnKolejkaUni[wylosowaneU[j]][2]; } int k = 0; for (unsigned j = m_uIloscUni; j<m_uIloscUni+m_uIloscMulti; j++){ m_psKolejka[j].typ = "M"; m_psKolejka[j].nIndeksZadania = wylosowaneM[k]; m_psKolejka[j].nNumerSciezki = ( rand() % LiczbaDrzew ) + 1; fDMC >> m_psKolejka[j].nPrzepust; linia++; k++; GotoLine(fDMC, linia); } fDMC.close(); return true; }
void wxHexView::SetData(wxByte *ptr, wxFileOffset len) { m_data = ptr; m_datalen = len; m_numLines = m_datalen / 16; if (m_datalen % 16) m_numLines++; UpdateScrollBar(); // GotoLine refreshes the display GotoLine(0); }
LRESULT ScoreErrorsDlg::OnNext(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { int index = errLst.GetCurSel(); int count = errLst.GetCount(); if (index < count) { errLst.SetCurSel(++index); ErrSelect(index, count); } GotoLine(); return 0; }
std::string en::GetAdjective(int AdjectiveNum) { if (AdjectiveNum <= 0 ) return ""; #ifdef DEBUG std::cout << "[EN] GetAdjective(int AdjectiveNum = " << AdjectiveNum << " )" << std::endl; #endif std::ifstream is(DICTIONARY EN_EN_FOLDER "adjectives"); if (GotoLine(is,AdjectiveNum)) return ""; std::string Adjective = GetSegment(is); is.close(); return Adjective; }
std::string en::GetVerbPastSimple(int VerbForm, int VerbNum, std::string Mid, bool Perfect, bool IgnoreMid, bool HelperVerb) { std::ifstream is(DICTIONARY EN_EN_FOLDER "verb_past"); GotoLine(is,VerbNum); int Data = is.get(); if (Data == '2' || Data == '3') { is.close(); if (!IgnoreMid && Mid.compare("")!=0) { return GetVerbPastSimple(VerbForm,68,"",Perfect,true) + " " + Mid + " " + GetVerbPresentSimple(0,VerbNum,"",true,false); } std::string V = GetVerbPreAdd(VerbNum); if (Data == '3') V += "e"; V += "d"; return V; } else if (Data == '1') { if (!IgnoreMid && Mid.compare("")!=0) { is.close(); return GetVerbPastSimple(VerbForm,68,"",Perfect,true,true) + " " + Mid + " " + GetVerbPresentSimple(0,VerbNum,"",true); } if(GotoSegment(is,Perfect?2:1)) { is.close(); return ""; } std::string Verb = GetSegment(is); is.close(); return Verb; } else if (Data == '0') { if (Perfect) VerbForm = 0; if (GotoSegment(is,VerbForm+1)) { is.close(); return ""; } std::string Verb = GetSegment(is); is.close(); if (!IgnoreMid && (VerbNum == 1 || HelperVerb) && Mid.compare("")!=0 ) Verb += " " + Mid; else if (!IgnoreMid && Mid.compare("")!=0) { return GetVerbPastSimple(VerbForm,68,"",Perfect,true,true) + " " + Mid + " " + GetVerbPresentSimple(0,VerbNum,"",true); } return Verb; } return ""; }
bool CScenariusze::Wypelnij() { fstream file("scenariusze20.txt"); GotoLine(file, 2); string linia; for (unsigned i = 0; i<m_uLiczbaScen; i++) { getline(file, linia); m_pnScenariusze[i] = linia; //cout << m_pnScenariusze[i] << endl; } file.close(); return true; }
bool CKolejka::TabUnicast() { m_ppnKolejkaUni = new int* [m_uIloscUni]; for (unsigned i = 0; i<m_uIloscUni; i++) m_ppnKolejkaUni[i] = new int [3]; fstream file(DEM.c_str(), ios::in); GotoLine(file, 2); for (unsigned i = 0; i<m_uIloscUni; i++){ for (unsigned j = 0; j<3; j++){ file >> m_ppnKolejkaUni[i][j]; } } file.close(); return true; }
std::string en::GetVerbPresentSimple(int VerbForm, int VerbNum, std::string Mid, bool IgnoreMid, bool HelperVerb) { std::ifstream is(DICTIONARY EN_EN_FOLDER "verb_present"); if (GotoLine(is,VerbNum)) return ""; int Data = is.get(); if (Data == '0') { if (GotoSegment(is,VerbForm+1)) return ""; std::string Segment = GetSegment(is); is.close(); if (!IgnoreMid && (VerbNum == 1 || HelperVerb) && Mid.compare("")!=0 ) Segment += " " + Mid; else if (!IgnoreMid && Mid.compare("")!=0) { return GetVerbPresentSimple(VerbForm,68,"",true) + " " + Mid + " " + GetVerbPresentSimple(0,VerbNum,"",true); } return Segment; } else { if (!IgnoreMid && Mid.compare("")!=0 && Data != '3') { is.close(); return GetVerbPresentSimple(VerbForm,68,"",true) + " " + Mid + " " + GetVerbPresentSimple(0,VerbNum,"",true); } if (GotoSegment(is,1)) return ""; std::string Segment = GetSegment(is); if (Data != '3') { if (VerbForm > 2 && VerbForm < 6) { //Need to add 's' conjugation int u = Segment.length(); if (Segment[u-1]=='o' || (Segment[u-1]=='s' && Segment[u-2]=='s') || (Segment[u-1]=='h' && Segment[u-2]=='s') || (Segment[u-1]=='h' && Segment[u-2]=='c') || (Segment[u-1]=='z' && Segment[u-2]=='z') || Segment[u-1]=='x') { Segment +="e"; } Segment += "s"; } } else if (!IgnoreMid && Mid.compare("")!=0) Segment+= " " + Mid; is.close(); return Segment; } is.close(); return ""; }
bool wxSTEditorShell::CaretOnPromptLine(STE_CaretPos_Type option) { int prompt_line = GetPromptLine(); bool on_last = GetCurrentLine() >= prompt_line; //wxPrintf(wxT("Caret on last line total %d current %d onlast %d\n"), total_lines, GetCurrentLine(), (int)on_last); if (!on_last && (option != STE_CARET_MOVE_NONE)) { if ((option & STE_CARET_MOVE_LASTLINE) != 0) GotoLine(prompt_line); else if ((option & STE_CARET_MOVE_ENDTEXT) != 0) GotoPos(GetLength()); } return GetCurrentLine() >= prompt_line; }
std::string en::GetOtherVerb(int VerbNum1,int VerbNum2) { int data = '1'; if (VerbNum1!=0) { std::ifstream is(DICTIONARY EN_EN_FOLDER "verb_present"); GotoLine(is,VerbNum1); is.get(); data = is.get(); is.close(); } if (data == '2') return GetVerbPreAdd(VerbNum2) + "ing"; else if (data == '3' || data == '0') return GetVerbPresentSimple(0,VerbNum2); else if (data == '1') return "to " + GetVerbPresentSimple(0,VerbNum2); return GetVerbPresentSimple(0,VerbNum2); }
std::string de::GetSubClause() { if (Conjunction < 0) return ""; std::ifstream is(DICTIONARY DE_FOLDER "conjunctions.txt"); if (GotoLine(is,Conjunction)) return ""; int Data = is.get(); if (GotoSegment(is,1)) return ""; std::string ConjunctionString = GetSegment(is); is.get(); if (Data == '0') SubClause->IsClause = true; else if (Data == '2') SubClause->Data |= 1; SubClause->Punctuation = 0; SubClause->Capital = false; std::string ClauseString = SubClause->createSentence(); return ", " + ConjunctionString + " " + ClauseString; }
bool CKolejka::BiggerDemFirst() { vector<int> vPrzepustowosci, vIndeksyZadan; SZadania* m_psBufor = new SZadania[m_uIloscUni+m_uIloscMulti]; int nBufor = 0; unsigned j; //-----------------------wladowanie zadan------------- fstream fDMC(DMC.c_str(), ios::in); int linia = 2; GotoLine(fDMC, linia); int k = 0; for (unsigned i = 0; i<m_uIloscMulti; i++) { m_psKolejka[i].typ = "M"; m_psKolejka[i].nIndeksZadania = i; m_psKolejka[i].nNumerSciezki = ( rand() % LiczbaDrzew ) + 1; fDMC >> m_psKolejka[i].nPrzepust; linia++; GotoLine(fDMC, linia); } fDMC.close(); for (unsigned i = m_uIloscMulti; i<m_uIloscMulti+m_uIloscUni; i++) { m_psKolejka[i].typ = "U"; m_psKolejka[i].nIndeksZadania = k; m_psKolejka[i].nNumerSciezki = ( rand() % LiczbaSciezek ) + 1; m_psKolejka[i].nPrzepust = m_ppnKolejkaUni[k][2]; k++; } //--------------------koniec wladowania zadan------------- //wybieranie najwyzszej przepustowosci for (unsigned i = 0; i<m_uIloscUni+m_uIloscMulti; i++){ if (nBufor <= m_psKolejka[i].nPrzepust){ nBufor = m_psKolejka[i].nPrzepust; j = i; } } vPrzepustowosci.push_back(nBufor); vIndeksyZadan.push_back(j); nBufor = 0; int indeksWektora = 0; //wybieranie przpustowosci malejaco i zapisywanie ich indeksow while (vIndeksyZadan.size() != m_uIloscUni+m_uIloscMulti){ for (unsigned i = 0; i<m_uIloscUni+m_uIloscMulti; i++){ if ((nBufor <= m_psKolejka[i].nPrzepust) and (vPrzepustowosci[indeksWektora] >= nBufor) and (SprawdzCzyJest(vIndeksyZadan, i) == false)){ nBufor = m_psKolejka[i].nPrzepust; j = i; } } vPrzepustowosci.push_back(nBufor); vIndeksyZadan.push_back(j); nBufor = 0; } for (unsigned j = 0; j<vIndeksyZadan.size(); j++) cout << "[" << vIndeksyZadan[j] << "] " << vPrzepustowosci[j] << endl; //teraz sortowanie kolejki malejaco wg przepustowosci for (unsigned k = 0; k<m_uIloscUni+m_uIloscMulti; k++){ m_psBufor[k] = m_psKolejka[vIndeksyZadan[k]]; } for (unsigned k = 0; k<m_uIloscUni+m_uIloscMulti; k++){ m_psKolejka[k] = m_psBufor[k]; } return true; }