Esempio n. 1
0
bool BackupMgr::SaveBackup(SciDoc*sci)
{
  FXString savename;
  FXString untitled;
  untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
  if (SciDocUtils::Filename(sci).empty()) {
    savename=untitled;
  } else {
    if (FXStat::isFile(untitled)) {
      RemoveBackup(untitled);
    }
#ifdef WIN32
    savename=SciDocUtils::Filename(sci).text();
    savename.substitute(':', '%', true);
    savename.prepend(backupdir.text());
#else
    savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
  }
  if (MakePath(FXPath::directory(savename))) {
    if (SciDocUtils::SaveToFile(sci,savename.text(),false)) {
      SciDocUtils::NeedBackup(sci, false);
      return true;
    } else {
      lasterror=SciDocUtils::GetLastError(sci);
      ErrorMessage(_("Failed to save backup"), savename);
      return false;
    }
  } else {
    return false;
  }
}
Esempio n. 2
0
void recipe_window::setup_config_parameters()
{
    spectral_range *range = &recipe->config->spectr_range;
    FXString text;
    if (range->active) {
        FXString text;
        text.format("%g-%g", range->min, range->max);
        range_textfield->setText(text);
    } else {
        range_textfield->setText("");
    }
    if (recipe->config->threshold_given) {
        text.format("%g", recipe->config->chisq_threshold);
        chisq_textfield->setText(text);
    } else {
        chisq_textfield->setText("");
    }
    text.format("%d", recipe->config->nb_max_iters);
    iter_textfield->setText(text);
    if (recipe->config->subsampling != 1) {
        text.format("%d", recipe->config->subsampling);
        subsamp_textfield->setText(text);
    } else {
        subsamp_textfield->setText("");
    }
}
Esempio n. 3
0
static void update_textfield(fx_numeric_field *tf, fx_disp_window *disp_win, int param_id)
{
    FXString vstr;
    double *pvalue = disp_win->map_parameter(param_id);
    vstr.format("%g", *pvalue);
    tf->setText(vstr);
}
Esempio n. 4
0
void
PlaybackWindow::setPlaybackPacketsProcessed(unsigned int packets)
{
	FXString s;
	s.format("Processed %u of %u", packets_processed, total_packets);
	processedLabel->setText(s);
}
Esempio n. 5
0
void BackupMgr::RemoveBackup(SciDoc*sci)
{
  FXString untitled;
  SciDocUtils::NeedBackup(sci,false);
  untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
  RemoveBackup(untitled);
  if (!SciDocUtils::Filename(sci).empty()) {
    FXString savename;
#ifdef WIN32
    savename=SciDocUtils::Filename(sci).text();
    savename.substitute(':', '%', true);
    savename.prepend(backupdir.text());
#else
    savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
    RemoveBackup(savename);
  }
}
Esempio n. 6
0
void ShortcutList::UpdateListItem(MenuSpec*spec)
{
    FXint n=acclist->findItemByData(spec);
    if (n>=0) {
        FXString txt;
        txt.format("%s\t%s", spec->pref, spec->accel);
        acclist->setItemText(n, txt);
        handle(acclist,FXSEL(SEL_CHANGED,ID_SEL_KEYBIND),(void*)(FXival)n);
    }
}
Esempio n. 7
0
// Update handler for window menus
long FXMDIClient::onUpdWindowSelect(FXObject *sender,FXSelector sel,void*){
  FXint which=FXSELID(sel)-ID_MDI_1;
  FXMDIChild *child=(FXMDIChild*)childAtIndex(which);
  if(child){
    FXString string;
    if(which<9)
      string.format("&%d %s",which+1,child->getTitle().text());
    else
      string.format("1&0 %s",child->getTitle().text());
    sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE),(void*)&string);
    sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SHOW),NULL);
    if(child==active)
      sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_CHECK),NULL);
    else
      sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),NULL);
    }
  else{
    sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_HIDE),NULL);
    }
  return 1;
  }
Esempio n. 8
0
void fx_disp_lookup_window::add_matrix_component(int index, bool create)
{
    FXString istr;
    istr.format("%d", index + 1);
    FXButton *db = new FXButton(matrix, istr, NULL, this, ID_MENU_COMPONENT + index, FRAME_SUNKEN);
    FXTextField *tf1 = new FXTextField(matrix, 24, this, ID_COMPONENT_NAME + index, FRAME_SUNKEN);
    tf1->setText(CSTR(disp->disp.lookup.component[index].disp->name));
    FXTextField *tf2 = create_textfield(matrix, this, ID_PARAM_0 + 1 + index);
    if (create) {
        db->create();
        tf1->create();
        tf2->create();
    }
}
Esempio n. 9
0
// Link file or directory
long FXFileSelector::onCmdLink(FXObject*,FXSelector,void*){
  FXString *filenamelist=getSelectedFiles();
  FXString linkmessage;
  if(filenamelist){
    for(FXint i=0; !filenamelist[i].empty(); i++){
      linkmessage.format(tr("Link file from location:\n\n%s\n\nto location: ").text(),filenamelist[i].text());
      FXInputDialog inputdialog(this,tr("Link File"),linkmessage,NULL,INPUTDIALOG_STRING,0,0,0,0);
      inputdialog.setText(FXPath::absolute(FXPath::directory(filenamelist[i]),"LinkTo"+FXPath::name(filenamelist[i])));
      inputdialog.setNumColumns(60);
      if(inputdialog.execute()){
        FXString newname=inputdialog.getText();
        if(!FXFile::symlink(filenamelist[i],newname)){
          if(FXMessageBox::error(this,MBOX_YES_NO,tr("Error Linking File").text(),tr("Unable to link file:\n\n%s  to:  %s\n\nContinue with operation?").text(),filenamelist[i].text(),newname.text())==MBOX_CLICKED_NO) break;
          }
        }
      }
    delete [] filenamelist;
    }
  return 1;
  }
Esempio n. 10
0
// Move file or directory
long FXFileSelector::onCmdMove(FXObject*,FXSelector,void*){
  FXString *filenamelist=getSelectedFiles();
  FXString movemessage;
  if(filenamelist){
    for(FXint i=0; !filenamelist[i].empty(); i++){
      movemessage.format(tr("Move file from location:\n\n%s\n\nto location: ").text(),filenamelist[i].text());
      FXInputDialog inputdialog(this,tr("Move File"),movemessage,NULL,INPUTDIALOG_STRING,0,0,0,0);
      inputdialog.setText(filenamelist[i]);
      inputdialog.setNumColumns(60);
      if(inputdialog.execute()){
        FXString newname=inputdialog.getText();
        if(!FXFile::moveFiles(filenamelist[i],newname,FALSE)){
          if(FXMessageBox::error(this,MBOX_YES_NO,tr("Error Moving File").text(),tr("Unable to move file:\n\n%s  to:  %s\n\nContinue with operation?").text(),filenamelist[i].text(),newname.text())==MBOX_CLICKED_NO) break;
          }
        }
      }
    delete [] filenamelist;
    }
  return 1;
  }
Esempio n. 11
0
void set_numeric_textfield(FXTextField *tf, double value)
{
    FXString text;
    text.format("%g", value);
    tf->setText(text);
}
Esempio n. 12
0
long
PlaybackWindow::onStart(FXObject *, FXSelector sel, void*)
{
	// If we're PAUSED, then just set the state back to playing.
	// There's no need to re-open the socket or anything.
	if (state == PAUSED) {
		state = PLAYING;
		startButton->disable();
		stopButton->enable();
		pauseButton->enable();
		//rewindButton->disable();

		// Fake the playback_start_time, so that the time-based
		// asynchronous playback will pick up where it left off.
		playback_start_time += get_time() - pause_time;

		return 1;
	}

	/* Starting the capture from the beginning. */

	progress->setProgress(0);

	pcap_if_t *devs = NULL;
	char errbuf[PCAP_ERRBUF_SIZE];
	
	// Open the capture file.
	pcap_file = pcap_open_offline(filename.text(), errbuf);
	if (!pcap_file) {
		FXMessageBox::information( this, MBOX_OK, "File Open Error", "Can't open original file %s for reading.\n", filename.text() );

		// Set the GUI and app state to
		// the STOPPED state.
		state = STOPPED;
		progress->setProgress(0);
		startButton->enable();
		stopButton->disable();
		pauseButton->disable();

		return 1;
	}

	// Prompt for the interface if one isn't set, or if called from the Play button click.
	if (FXSELID(sel) == ID_START_BUTTON || pcap_if.length() == 0) {
		// Popup window with list of interfaces in it.
		pcap_findalldevs(&devs, errbuf);
		if (devs) {
			// Show the interface Window.
			FXDialogBox *dlg = new FXDialogBox(this, "Select a device", DECOR_CLOSE|DECOR_TITLE|DECOR_BORDER);
			InterfaceWindow *ifwin = new InterfaceWindow(dlg, devs, "Select Playback Device", "Playback");
			FXuint res = dlg->execute();

			if (res) {
				// User selected an interface. Start capturing.
				pcap_if = ifwin->getSelectedInterface()->name;
				cout << "User selected " << pcap_if << endl;
			}
			else {
				// User pushed cancel from the interface window.
				pcap_if = "";
			}

			delete dlg;
		}
		else {
			// report error.
			cout << "Error finding devices " << errbuf << endl;
		#ifdef WIN32
			const char *privs = "Administrator";
		#else
			const char *privs = "root user";
		#endif
			FXString s;
			s.format("There was an error trying to open the network device.\nThis most likely means that you do not have permission to open raw sockets.\nEnsure that you have %s privileges and try again.\n\nError: %s", privs, errbuf);
			FXMessageBox::error(this, MBOX_OK, "Capture Error", "%s", s.text());
		}

		pcap_freealldevs(devs);
	}

	// Begin playback if an interface was selected.
	if (pcap_if.length() > 0) {
		live_capture = pcap_open_live(pcap_if.c_str(), 9999, 1/*promisc*/, 5/*read_timeout*/, errbuf);
		if (live_capture) {
			int res = pcap_setnonblock(live_capture, 1, errbuf);
			if (res >= 0) {

			}
			else
				cout << "Error setting nonblock: " << errbuf << endl;

			#ifndef WIN32
				send_handle = pcap_get_selectable_fd(live_capture);
			#else
				send_handle = 0;
			#endif
			if (send_handle >= 0) {
				// Set the GUI and app state to
				// the PLAYING state.
				state = PLAYING;
				startButton->disable();
				stopButton->enable();
				pauseButton->enable();
				//rewindButton->disable();
				playback_start_time = get_time();

				// Start the playback thread.
				run_thread = true;
				packets_processed = 0;
				elapsed_time = 0.0;
				pthread_create(&thread, NULL, &thread_function, this);
				// Start the periodic update timer.
				// FOX 1.7 changes the timeouts to all be nanoseconds.
				// Fox 1.6 had all timeouts as milliseconds.
				int timeout_scalar = 1;
			#if (FOX_MINOR >= 7)
				timeout_scalar = 1000*1000;
			#endif
				getApp()->addTimeout(this, ID_CAPTURE_TIMEOUT, 1 * timeout_scalar  /*1ms*/);
			}
			else {
				FXMessageBox::information(this, MBOX_OK, "Networking Error", "Unable to get a write handle for the playback.");
			}
		}
	}

	return 1;
}
Esempio n. 13
0
void MacroRecorder::translate(TranslateFunc callback, void* user_data)
{

  for (FXint i=list.no()-1; i>=0; i--) {
    FXString text;
    MacroMessage* mm=list[i];
    switch (mm->message) {
      case SCI_CUT: {
        text=_LUAMOD_".cut()";
        break;
      }
      case SCI_COPY: {
        text=_LUAMOD_".copy()";
        break;
      }
      case SCI_CLEARALL: {
        text=_LUAMOD_".text(\"\")";
        break;
      }
      case SCI_SELECTALL: {
        text=_LUAMOD_".select(0,"_LUAMOD_".nchars())";
        break;
      }


      case SCI_HOME:
      case SCI_VCHOME:{
        text=_LUAMOD_".go(\"edge\", -1)";
        break;
      }

      case SCI_HOMEEXTEND:
      case SCI_VCHOMEEXTEND:{
        text=_LUAMOD_".go(\"edge\", -1, true)";
        break;
      }


      case SCI_LINEEND: {
        text=_LUAMOD_".go(\"edge\", 1)";
        break;
      }
      case SCI_LINEENDEXTEND: {
        text=_LUAMOD_".go(\"edge\", 1, true)";
        break;
      }
      case SCI_DOCUMENTSTART: {
        text=_LUAMOD_".go(\"body\", -1)";
        break;
      }
      case SCI_DOCUMENTSTARTEXTEND: {
        text=_LUAMOD_".go(\"body\", -1, true)";
        break;
      }
      case SCI_DOCUMENTEND: {
        text=_LUAMOD_".go(\"body\", 1)";
        break;
      }
      case SCI_DOCUMENTENDEXTEND: {
        text=_LUAMOD_".go(\"body\", 1, true)";
        break;
      }
      case SCI_HOMERECTEXTEND:
      case SCI_VCHOMERECTEXTEND: {
        text=_LUAMOD_".go(\"edge\", -1, true, true)";
        break;
      }
      case SCI_LINEENDRECTEXTEND: {
        text=_LUAMOD_".go(\"edge\", 1, true, true)";
        break;
      }
      case SCI_GOTOLINE: {
        text.format(_LUAMOD_".caret(%ld,%ld)", mm->wParam+1, mm->lParam);
        break;
      }
      case SCI_GOTOPOS: {
        if ((i>1)&&(list[i-1]->message==SCI_SEARCHNEXT)&&(list[i-2]->message==SCI_REPLACETARGET)&&(list[i-2]->wParam==2)) {
            // If message was generated inside SciSearch::ReplaceAllInDoc() just ignore it.
        } else {
          text.format(_LUAMOD_".caret(%ld)", mm->wParam);
        }
        break;
      }
      case SCI_REPLACESEL: {
        FXString s=(char*)mm->lParam;
        FXint n=s.contains('\n');
        if ( (n>0) && (s.length()>1) ) { // If multiple lines,  split into lines for playback...
          int p;
          for (p=0; p<n; p++) {
            FXString part=s.section('\n', p);
            requote(part);
            text.format(_LUAMOD_".insert(\"%s\\n\",true)", part.text());
            callback(text.text(), user_data);
          }
          if (!s.section('\n', n).empty()) { // there may still be text beyond the last LF...
            FXString part=s.section('\n', n);
            requote(part);
            text.format(_LUAMOD_".insert(\"%s\",true)", part.text());
            callback(text.text(), user_data);
          }
          continue;
        }
        requote(s);
        text.format(_LUAMOD_".insert(\"%s\",true)", s.text());
        break;
      }

      case SCI_SEARCHNEXT:
      case SCI_SEARCHPREV: {
        FXString what=(char*)mm->lParam;
        requote(what);
        FXString flags="";
        if (mm->wParam & SCFIND_MATCHCASE) { flags.append("\"matchcase\""); }
        if (mm->wParam & SCFIND_WHOLEWORD) { flags.append(",\"wholeword\""); }
        if (mm->wParam & SCFIND_REGEXP)    { flags.append(",\"regexp\""); }
        if (flags[0]==',') { flags.erase(0,1); }
        if ((i>0)&&(list[i-1]->message==SCI_REPLACETARGET)) {
          FXString with=(char*)list[i-1]->lParam;
          requote(with);
          const char*how=NULL;
          switch (list[i-1]->wParam) {
            case 0: { how=mm->message==SCI_SEARCHNEXT?"next":"prev"; break; }
            case 1: { how="sel"; break; }
            case 2: { how="all"; break; }
          }
          text.format(_LUAMOD_".replace(\"%s\",\"%s\", {%s},\"%s\")",
                         what.text(), with.text(), flags.text(), how );

        } else {

          text.format( _LUAMOD_".gofind(\"%s\", {%s}%s)",
                         what.text(), flags.text(), mm->message==SCI_SEARCHNEXT?"":", false"  );
        }
        break;
      }
      case SCI_REPLACETARGET: {
        break;
      }
      case SCI_PASTE: {
        text=_LUAMOD_".paste()";
        break;
      }
      case SCI_LINEDOWN: {
        text.format(_LUAMOD_".go(\"line\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_LINEDOWNEXTEND: {
        text.format(_LUAMOD_".go(\"line\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_PARADOWN: {
        text.format(_LUAMOD_".go(\"para\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_PARADOWNEXTEND: {
        text.format(_LUAMOD_".go(\"para\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_LINEUP: {
        text.format(_LUAMOD_".go(\"line\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_LINEUPEXTEND: {
        text.format(_LUAMOD_".go(\"line\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_PARAUP: {
        text.format(_LUAMOD_".go(\"para\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_PARAUPEXTEND: {
        text.format(_LUAMOD_".go(\"para\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_CHARLEFT: {
        text.format(_LUAMOD_".go(\"char\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_CHARLEFTEXTEND: {
        text.format(_LUAMOD_".go(\"char\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_CHARRIGHT: {
        text.format(_LUAMOD_".go(\"char\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_CHARRIGHTEXTEND: {
        text.format(_LUAMOD_".go(\"char\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_WORDLEFT: {
        text.format(_LUAMOD_".go(\"word\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_WORDLEFTEXTEND: {
        text.format(_LUAMOD_".go(\"word\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_WORDRIGHT: {
        text.format(_LUAMOD_".go(\"word\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_WORDRIGHTEXTEND: {
        text.format(_LUAMOD_".go(\"word\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_WORDPARTLEFT: {
        text.format(_LUAMOD_".go(\"part\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_WORDPARTLEFTEXTEND: {
        text.format(_LUAMOD_".go(\"part\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_WORDPARTRIGHT: {
        text.format(_LUAMOD_".go(\"part\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_WORDPARTRIGHTEXTEND: {
        text.format(_LUAMOD_".go(\"part\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_PAGEUP: {
        text.format(_LUAMOD_".go(\"page\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_PAGEUPEXTEND: {
        text.format(_LUAMOD_".go(\"page\", -%ld, true)", mm->lParam+1);
        break;
      }
      case SCI_PAGEDOWN: {
        text.format(_LUAMOD_".go(\"page\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_PAGEDOWNEXTEND: {
        text.format(_LUAMOD_".go(\"page\", %ld, true)", mm->lParam+1);
        break;
      }
      case SCI_LINEDOWNRECTEXTEND: {
        text.format(_LUAMOD_".go(\"line\", %ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_LINEUPRECTEXTEND: {
        text.format(_LUAMOD_".go(\"line\", -%ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_CHARLEFTRECTEXTEND: {
        text.format(_LUAMOD_".go(\"char\", -%ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_CHARRIGHTRECTEXTEND: {
        text.format(_LUAMOD_".go(\"char\", %ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_PAGEUPRECTEXTEND: {
        text.format(_LUAMOD_".go(\"page\", -%ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_PAGEDOWNRECTEXTEND: {
        text.format(_LUAMOD_".go(\"page\", %ld, true, true)", mm->lParam+1);
        break;
      }
      case SCI_TAB: {
        text.format(_LUAMOD_".indent(%ld)", mm->lParam+1);
        break;
      }
      case SCI_BACKTAB: {
        text.format(_LUAMOD_".indent(-%ld)", mm->lParam+1);
        break;
      }
      case SCI_DELETEBACK: {
        text.format(_LUAMOD_".delete(-%ld)", mm->lParam+1);
        break;
      }
      case SCI_CLEAR: {
        text.format(_LUAMOD_".delete(%ld)", mm->lParam+1);
        break;
      }
      case SCI_UPPERCASE: {
        text.format(_LUAMOD_".uppercase()");
        break;
      }
      case SCI_LOWERCASE: {
        text.format(_LUAMOD_".lowercase()");
        break;
      }
      case SCI_DELWORDLEFT: {
        text.format(_LUAMOD_".delete(\"word\", -%ld)", mm->lParam+1);
        break;
      }
      case SCI_DELWORDRIGHT: {
        text.format(_LUAMOD_".delete(\"word\", %ld)", mm->lParam+1);
        break;
      }
      case SCI_DELLINELEFT: {
        text.format(_LUAMOD_".delete(\"edge\", -1)");
        break;
      }
      case SCI_DELLINERIGHT: {
        text.format(_LUAMOD_".delete(\"edge\", 1)");
        break;
      }
      case SCI_HOMEWRAP:                noimpl("SCI_HOMEWRAP");
      case SCI_HOMEWRAPEXTEND:          noimpl("SCI_HOMEWRAP");
      case SCI_LINEENDWRAP:             noimpl("SCI_LINEENDWRAP");
      case SCI_LINEENDWRAPEXTEND:       noimpl("SCI_LINEENDWRAPEXTEND");
      case SCI_LINECOPY:                noimpl("SCI_LINECOPY");
      case SCI_LINECUT:                 noimpl("SCI_LINECUT");
      case SCI_LINEDELETE:              noimpl("SCI_LINEDELETE");
      case SCI_COPYALLOWLINE:           noimpl("SCI_COPYALLOWLINE");
      case SCI_SEARCHANCHOR:            noimpl("SCI_SEARCHANCHOR");
      case SCI_ADDTEXT:                 noimpl("SCI_ADDTEXT");
      case SCI_INSERTTEXT:              noimpl("SCI_INSERTTEXT");
      case SCI_APPENDTEXT:              noimpl("SCI_APPENDTEXT");
      case SCI_WORDLEFTEND:             noimpl("SCI_WORDLEFTEND");
      case SCI_WORDLEFTENDEXTEND:       noimpl("SCI_WORDLEFTENDEXTEND");
      case SCI_WORDRIGHTEND:            noimpl("SCI_WORDRIGHTEND");
      case SCI_WORDRIGHTENDEXTEND:      noimpl("SCI_WORDRIGHTENDEXTEND");
      case SCI_STUTTEREDPAGEUP:         noimpl("SCI_STUTTEREDPAGEUP");
      case SCI_STUTTEREDPAGEUPEXTEND:   noimpl("SCI_STUTTEREDPAGEUPEXTEND");
      case SCI_STUTTEREDPAGEDOWN:       noimpl("SCI_STUTTEREDPAGEDOWN");
      case SCI_STUTTEREDPAGEDOWNEXTEND: noimpl("SCI_STUTTEREDPAGEDOWNEXTEND");
      case SCI_FORMFEED:                noimpl("SCI_FORMFEED");
      case SCI_EDITTOGGLEOVERTYPE:      noimpl("SCI_EDITTOGGLEOVERTYPE");
      case SCI_CANCEL:                  noimpl("SCI_CANCEL");

      case SCI_VCHOMEWRAP:              noimpl("SCI_VCHOMEWRAP");
      case SCI_VCHOMEWRAPEXTEND:        noimpl("SCI_VCHOMEWRAPEXTEND");
      case SCI_DELWORDRIGHTEND:         noimpl("SCI_DELWORDRIGHTEND");
      case SCI_LINETRANSPOSE:           noimpl("SCI_LINETRANSPOSE");
      case SCI_LINEDUPLICATE:           noimpl("SCI_LINEDUPLICATE");
      case SCI_HOMEDISPLAY:             noimpl("SCI_HOMEDISPLAY");
      case SCI_HOMEDISPLAYEXTEND:       noimpl("SCI_HOMEDISPLAYEXTEND");
      case SCI_LINEENDDISPLAY:          noimpl("SCI_LINEENDDISPLAY");
      case SCI_LINEENDDISPLAYEXTEND:    noimpl("SCI_LINEENDDISPLAYEXTEND");
      case SCI_SELECTIONDUPLICATE:      noimpl("SCI_SELECTIONDUPLICATE");

      case SCI_LINESCROLLDOWN:          noimpl("SCI_LINESCROLLDOWN");
      case SCI_LINESCROLLUP:            noimpl("SCI_LINESCROLLUP");
      case SCI_DELETEBACKNOTLINE:       noimpl("SCI_DELETEBACKNOTLINE");
      case SCI_SETSELECTIONMODE:        noimpl("SCI_SETSELECTIONMODE");
    }
    callback(text.text(), user_data);
  }
}
Esempio n. 14
0
// Fill the list with font sizes
void FontSelector::listFontSizes()
{
    const FXuint sizeint[] =
    {
        60, 80, 90, 100, 110, 120, 140, 160, 200, 240, 300, 360, 420, 480, 640
    };
    FXFontDesc* fonts;
    FXuint      numfonts, f, s, lasts;
    int         selindex = -1;

    sizelist->clearItems();
    size->setText("");
    FXString string;
    if (FXFont::listFonts(fonts, numfonts, selected.face, selected.weight, selected.slant, selected.setwidth, selected.encoding, selected.flags))
    {
        FXASSERT(0 < numfonts);
        lasts = 0;
        if (fonts[0].flags&FXFont::Scalable)
        {
            for (f = 0; f < ARRAYNUMBER(sizeint); f++)
            {
                s = sizeint[f];
                string.format("%.1f", 0.1*s);
                sizelist->appendItem(string, NULL, (void*)(FXuval)s);
                if (selected.size == s)
                {
                    selindex = sizelist->getNumItems()-1;
                }
                lasts = s;
            }
        }
        else
        {
            for (f = 0; f < numfonts; f++)
            {
                s = fonts[f].size;
                if (s != lasts)
                {
                    string.format("%.1f", 0.1*s);
                    sizelist->appendItem(string, NULL, (void*)(FXuval)s);
                    if (selected.size == s)
                    {
                        selindex = sizelist->getNumItems()-1;
                    }
                    lasts = s;
                }
            }
        }
        if (selindex == -1)
        {
            selindex = 0;
        }
        if (0 < sizelist->getNumItems())
        {
            sizelist->setCurrentItem(selindex);
            sizelist->makeItemVisible(selindex);
            size->setText(sizelist->getItemText(selindex));
            selected.size = (FXuint)(FXuval)sizelist->getItemData(selindex);
        }
        FXFREE(&fonts);
    }
}
Esempio n. 15
0
// When BuildClassTree() is called, ctags parses all source files in the directory list.
// This routine is called by the CmdIO object, once for each line of output from ctags.
long TagParserBase::onParseAllSources(FXObject*o, FXSelector sel, void*p)
{
  const FXString* s=(const FXString*)p;
  if (FXSELTYPE(sel)==SEL_IO_EXCEPT) { return 1; }
  LocationIndex dirindex=(LocationIndex)((FXuval)((CmdIO*)o)->getUserData());
  FXString ancestor=FXString::null;
  FXString scopename=FXString::null;
  FXint linenum=ExtractLineNumber(s);
  FXchar kind=s->section('\t', 3)[0];
  FXString tagname=s->section('\t',0);
  FXString filename=s->section('\t',1);
  if (current_filename!=filename) {
    current_filename=filename;
    dirs[dirindex]->append(filename);
  }
  const FXchar ext=Ascii::toLower(FXPath::extension(filename)[0]);

  if ( (kind=='n') ) {
    if (ext=='c') { return 1; } // namespaces are only interesting if they are in a public header
  }
  for (FXint i=4; i<=s->contains('\t'); i++) {
    const FXString sect=s->section('\t', i);
    if (sect.find(':')>0) {
      const FXString key=sect.section(':',0);
      if ((kind=='s')&&(key=="access")) {  // ignore structs defined inside a class
        return 1;
      } else if ((kind=='f')&&((key=="class")||(key=="namespace"))) {
        scopename=sect.section(':',1,1024);
        StripNamespace(scopename);
      } else if (key=="inherits") {
        ancestor=sect.section(':',1);
        if (ancestor.find(',')>0) {
          ancestor=ancestor.section(',',0);  // can't do multiple inheritence
        }
        StripNamespace(ancestor);
      }
    }
  }
  switch (kind) {
    case 'c':
    case 'n':    
    case 's': {
      tag_info_list->append(kind, tagname, ancestor, dirindex, dirs[dirindex]->no()-1, linenum);
      break;
    }
    default: {
      FXString* entry = new FXString();
      entry->format(
        "%c\t%s%s%s\t%d",
        kind,
        scopename.text(),
        scopename.empty()?"":"::",
        tagname.text(),
        linenum
      );
      dirs[dirindex]->tail()->append(entry);
      break;
    }
  }
  return 1;
}
Esempio n. 16
0
// Launch a command and initiate a startup notification
int runcmd(FXString cmd, FXString cmdname, FXString dir, FXString startdir, FXbool usesn = true, FXString snexcepts = "")
{
    int ret;

    // Change to current directory
    ret = chdir(dir.text());
    if (ret < 0)
    {
        int errcode = errno;
        if (errcode)
        {
            fprintf(stderr, _("Error: Can't enter folder %s: %s"), dir.text(), strerror(errcode));
        }
        else
        {
            fprintf(stderr, _("Error: Can't enter folder %s"), dir.text());
        }

        return(-1);
    }

    // Get rid of possible command options
    cmdname = cmdname.before(' ');

    // Check if command is in the startup notification exception list
    FXbool startup_notify = true;
    if (snexcepts != "")
    {
        FXString entry;
        for (int i = 0; ; i++)
        {
            entry = snexcepts.section(':', i);
            if (streq(entry.text(), ""))
            {
                break;
            }
            if (streq(entry.text(), cmdname.text()))
            {
                startup_notify = false;
                break;
            }
        }
    }

    // Run command with startup notification
    if (usesn && startup_notify)
    {
        Display*           xdisplay;
        SnDisplay*         display;
        SnLauncherContext* context;
        Time               timestamp;

        // Open display
        xdisplay = XOpenDisplay(NULL);
        if (xdisplay == NULL)
        {
            fprintf(stderr, _("Error: Can't open display\n"));
            ret = chdir(startdir.text());
            if (ret < 0)
            {
                int errcode = errno;
                if (errcode)
                {
                    fprintf(stderr, _("Error: Can't enter folder %s: %s"), startdir.text(), strerror(errcode));
                }
                else
                {
                    fprintf(stderr, _("Error: Can't enter folder %s"), startdir.text());
                }
            }
            return(-1);
        }

        // Message displayed in the task bar (if any)
        FXString message;
        message.format(_("Start of %s"), cmdname.text());

        // Initiate launcher context
        display = sn_display_new(xdisplay, NULL, NULL);
        context = sn_launcher_context_new(display, DefaultScreen(xdisplay));
        sn_launcher_context_set_name(context, message.text());
        sn_launcher_context_set_binary_name(context, cmdname.text());
        sn_launcher_context_set_description(context, message.text());
        sn_launcher_context_set_icon_name(context, cmdname.text());
        timestamp = gettimestamp();
        sn_launcher_context_initiate(context, "Xfe", cmd.text(), timestamp);

        // Run command in background
        cmd += " &";

        static pid_t child_pid = 0;
        switch ((child_pid = fork()))
        {
        case -1:
            fprintf(stderr, _("Error: Fork failed: %s\n"), strerror(errno));
            break;

        case 0: // Child
            sn_launcher_context_setup_child_process(context);
            execl("/bin/sh", "sh", "-c", cmd.text(), (char*)NULL);
            _exit(EXIT_SUCCESS);
            break;
        }
        sn_launcher_context_unref(context);
    }

    // Run command without startup notification
    else
    {
        // Run command in background
        cmd += " &";
        ret = system(cmd.text());
        if (ret < 0)
        {
            fprintf(stderr, _("Error: Can't execute command %s"), cmd.text());
            return(-1);
        }

        // Just display the wait cursor during a second
        sleep(1);
    }

    // Go back to startup directory
    ret = chdir(startdir.text());
    if (ret < 0)
    {
        int errcode = errno;
        if (errcode)
        {
            fprintf(stderr, _("Error: Can't enter folder %s: %s"), startdir.text(), strerror(errcode));
        }
        else
        {
            fprintf(stderr, _("Error: Can't enter folder %s"), startdir.text());
        }

        return(-1);
    }

    return(0);
}
Esempio n. 17
0
void StatusBar::Running(const char*what, const char*howtokill)
{
  FXString status;
  status.format(_("Running %s (press %s to cancel)"), what, howtokill);
  Mode(status.text());
}
Esempio n. 18
0
static void AppendError(FXString &errors, const char*err, const FXString &filename)
{
  FXString tmp;
  tmp.format("\n%s (%s): %s", err, SystemErrorStr(), filename.text());
  errors+=tmp;
}