bool ProgramsWindow::ReadOnlyEditorX::GetFileLine(string &sFileName, unsigned int &LineNumber) { unsigned int Start, End; char *sText; //Find the filename in this line's message End = Start = pTextBuffer->line_start(insert_position()); while(pStyleBuffer->character(End) != 'F') End = ++Start; while(pStyleBuffer->character(End) == 'F') End++; if(End-Start <= 2) //There was no file name on this line return false; //Create a full-path version of the filename. //All file names in a message should be relative to the project, or absolute. sText = pTextBuffer->text_range(Start+1, End-1); FileName sFile = sFileName = CreateFileNameRelative(TheProject.sWorkingDir, sText); delete [] sText; LineNumber = 0; if(ToLower(sFile.Ext) == "obj" || ToLower(sFile.Ext) == "bin") return false; return true; }
int DerivedText_Editor::handle_key(){ // Call FLTK's rules to try to turn this into a printing character. // This uses the right-hand ctrl key as a "compose prefix" and returns // the changes that should be made to the text, as a number of // bytes to delete and a string to insert: int del = 0; if (Fl::compose(del)) { if (del) { // del is a number of bytes int dp = insert_position() - del; if ( dp < 0 ) dp = 0; buffer()->select(dp, insert_position()); } kill_selection(this); if (Fl::event_length()) { if (insert_mode()) insert(Fl::event_text()); else overstrike(Fl::event_text()); } #ifdef __APPLE__ if (Fl::compose_state) { int pos = this->insert_position(); this->buffer()->select(pos - Fl::compose_state, pos); } #endif show_insert_position(); set_changed(); if (when()&FL_WHEN_CHANGED) do_callback(); return 1; } int key = Fl::event_key(), state = Fl::event_state(), c = Fl::event_text()[0]; state &= FL_SHIFT|FL_CTRL|FL_ALT|FL_META; // only care about these states C_to_Fl_Callback* f; f = bound_key_function(key, state, global_key_bindings); this->curr_callback_context = f; if (!f) f = bound_key_function(key, state, key_bindings); if (f) return C_to_Fl_Callback::intercept(key, this); if (default_key_function_ && !state) return default_key_function_(c, this); return 0; }
bool DisassemblyWindow::ReadOnlyEditorX::GetFileLine(string &sFileName, unsigned int &LineNumber) { unsigned int Start, End; char *sText; //Find the filename in this line's message End = Start = pTextBuffer->line_start(insert_position()); while(pStyleBuffer->character(End) == 'R') End++; if(End == Start) //There was no file name on this line return false; //Create a full-path version of the filename. //All file names in a message should be relative to the project, or absolute. sText = pTextBuffer->text_range(Start, End); FileName sFile = sFileName = CreateFileNameRelative(TheProject.sWorkingDir, sText); delete [] sText; //Find the line number if(pStyleBuffer->character(End) != 'J' || pStyleBuffer->character(End+1) != 'G') { //There was no line number LineNumber = 0; } else { End = Start = End+1; while(pStyleBuffer->character(End) == 'G') End++; sText = pTextBuffer->text_range(Start, End); sscanf(sText, "%u", &LineNumber); delete [] sText; } if(sFile.Name == "NoFile" && LineNumber == 0 || ToLower(sFile.Ext) == "obj" || ToLower(sFile.Ext) == "bin") return false; return true; }
int SchemeEditor::handle(int e) { int ret = Fl_Text_Editor::handle(e); if(!pmatch) return ret; if(e == FL_KEYBOARD || e == FL_PUSH) { if(!buffer()) return ret; buffer()->unhighlight(); int pos = insert_position() - 1; if(pos < 0) return ret; int ch = BUFFER_CHAR_AT(buffer(), pos); if(strchr(EDITOR_PARENS_CLOSE, ch)) { int deep = 0; /* go backward and search matching open one */ for(int p = pos; p >= 0; p--) { if(strchr(EDITOR_PARENS_CLOSE, BUFFER_CHAR_AT(buffer(), p))) { deep++; continue; } if(strchr(EDITOR_PARENS_OPEN, BUFFER_CHAR_AT(buffer(), p))) { deep--; if(deep == 0) { buffer()->highlight(p, pos + 1); return ret; } } } } if(strchr(EDITOR_PARENS_OPEN, ch)) { int deep = 0; /* go forward and search matching one */ for(int p = pos; p < buffer()->length(); p++) { if(strchr(EDITOR_PARENS_OPEN, BUFFER_CHAR_AT(buffer(), p))) { deep++; continue; } if(strchr(EDITOR_PARENS_CLOSE, BUFFER_CHAR_AT(buffer(), p))) { deep--; if(deep == 0) { buffer()->highlight(pos, p + 1); return ret; } } } } } return ret; }