Exemplo n.º 1
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string sm(string c)
{
  rc=0;
  if (c=="act")
    return smact();
  if (c=="active")
    return smactive();
  if (c=="close")
    return smclose();
  if (c=="focus")
    return smfocus();
  if (c=="font")
    return smfont();
  if (c=="get")
    return smget();
  if (c=="html")
    return smhtml();
  if (c=="new")
    return smopen();
  if (c=="open")
    return smopen();
  if (c=="profont")
    return smprofont();
  if (c=="replace")
    return smreplace();
  if (c=="save")
    return smsave();
  if (c=="set")
    return smset();
  else if (c=="prompt")
    return smprompt();
  cmd.getparms();
  return smerror("unrecognized sm command: " + c);
}
Exemplo n.º 2
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smopen()
{
  string c=cmd.getid();
  string p=cmd.getparms();

  if (c=="edit")
    term->vieweditor();
  if (c=="edit2") {
    if (note==0)
      return smerror("no edit window open");
    note->on_winotherAct_triggered();
  }
  if (c=="edit" || c=="edit2")
    return "";
  if (c!="tab") {
    return smerror("unrecognized sm command: open " + c);
  }
  term->vieweditor();
  if (p.empty())
    note->newtemp();
  else {
    QString f=s2q(smgetscript(p));
    if (!cfexist(f))
      return smerror("file not found: " + q2s(f));
    note->fileopen(f);
  }
  rc=-1;
  return i2s(note->editIndex());
}
Exemplo n.º 3
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smfocus()
{
  string p=cmd.getparms();
  if (p.empty())
    return smerror("sm focus needs additional parameters");
  if (p=="term")
    term->smact();
  else if (p=="edit") {
    if (note==0)
      return smerror("No active edit window");
    if (note->editIndex()==-1)
      return "";
    note->activateWindow();
    note->raise();
    note->repaint();
  } else if (p=="edit2") {
    if (note2==0 || note2->editIndex()==-1)
      return smerror("No active edit2 window");
    setnote(note2);
    note->activateWindow();
    note->raise();
    note->repaint();
  } else
    return smerror("unrecognized sm command: focus " + p);
  return "";
}
Exemplo n.º 4
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smsave()
{
  string p=cmd.getparms();
  if (note==0)
    return smerror("No active edit window");
  if (p.empty())
    return smerror("sm save parameter not given");
  if (p=="edit")
    return smsaveactive();
  if (p=="tabs")
    return smsaveall();
  return smerror("sm save parameter should be 'edit' or 'tabs': " + p);
}
Exemplo n.º 5
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smactive()
{
  string p=cmd.getparms();
  QStringList opt=qsplit(p);
  if (note==0 || note->editIndex()<0)
    return smerror ("No active edit window");
  if (opt[0]!="tab")
    return smerror ("unrecognized sm command parameters: " + p);
  int ndx=opt[1].toInt();
  if (ndx<0 || ndx>=note->count())
    return smerror ("invalid tab index: " + p);
  note->setindex(ndx);
  return "";
}
Exemplo n.º 6
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smset()
{
  string p=cmd.getid();
  if (p.empty())
    return smerror("sm set parameters not given");

  string c=cmd.getid();
  if (c.empty())
    return smerror("sm set " + p + " parameters not given");
  string q=cmd.getparms();

  if (p=="inputlog")
    return smsetinputlog(c,q);

  if (p=="term") {
    if (c=="text")
      return smsettext(p,q);
    if (c=="xywh")
      return smsetxywh(p,q);
    return smerror("command applies only to an edit window: " + c);
  }

  Bedit *e;

  if (p=="edit") {
    if (note==0)
      return smerror("No active edit window");
    e=(Bedit *)note->editPage();
  } else if (p=="edit2") {
    if (note2==0)
      return smerror("No active edit2 window");
    e=(Bedit *)note2->editPage();
  } else
    return smerror("unrecognized sm command: set " + p);

  if (e==0 && (c=="scroll" || c=="select" || c=="text"))
    return smerror("no edit window for sm command: set " + c);

  if (c=="scroll")
    return smsetscroll(e,q);
  if (c=="select")
    return smsetselect(e,q);
  if (c=="text")
    return smsettext(p,q);
  if (c=="xywh")
    return smsetxywh(p,q);

  return smerror("unrecognized sm command: set " + p + " " + q);
}
Exemplo n.º 7
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smreplace()
{
  string c=cmd.getid();
  string p=cmd.getparms();
  if (note==0 || note->editIndex()<0)
    return smerror ("No active edit window");
  if (c!="edit")
    return smerror("unrecognized sm command: replace " + c);
  if (p.empty())
    return smerror("replace needs 2 parameters: edit filename");
  QString f=s2q(smgetscript(p));
  if (!cfexist(f))
    return smerror("file not found: " + q2s(f));
  note->filereplace(f);
  return"";
}
Exemplo n.º 8
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smprofont()
{
  string p=cmd.getparms();
  if (!p.empty()) {
    Font *fnt = new Font(p);
    if (fnt->error) {
      delete fnt;
      return smerror("unrecognized sm command: font " + p);
    } else {
      QApplication::setFont(fnt->font);
      delete fnt;
    }
  } else
    QApplication::setFont(config.DefProFont);
  return "";
}
Exemplo n.º 9
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smfont()
{
  string p=cmd.getparms();
  if (!p.empty()) {
    Font *fnt = new Font(p);
    if (fnt->error) {
      delete fnt;
      return smerror("unrecognized sm command: font " + p);
    } else {
      config.Font=fnt->font;
      delete fnt;
      fontset(config.Font);
    }
  } else
    fontset(config.DefFont);
  return "";
}
Exemplo n.º 10
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smclose()
{
  string c=cmd.getid();
  string p=cmd.getparms();
  if (c=="tab") {
    if (note==0 || note->editIndex()<0)
      return smerror ("No active edit window");
    int ndx=s2q(p).toInt();
    if (ndx<0 || ndx>=note->count())
      return smerror ("invalid tab index: " + p);
    note->tabclose(ndx);
  } else if (c=="edit") {
    if (note==0)
      return smerror ("No edit window");
    note->close();
  } else if (c=="edit2") {
    if (note2==0)
      return smerror ("No edit2 window");
    note2->close();
  } else
    return smerror ("unrecognized sm command parameters: " + p);
  return "";
}
Exemplo n.º 11
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smget()
{
  string p=cmd.getparms();
  if (p.size()==0)
    return smerror("sm get needs additional parameters");
  if (p=="active")
    return smgetactive();
  if (p=="term" || p=="edit" || p=="edit2")
    return smgetwin(p);
  if (p=="termcwh")
    return smgettermcwh();
  if (p=="inputlog")
    return smgetinputlog();
  if (p=="xywh")
    return smgetxywh();
  QStringList s=qsplit(p);
  if (s[0]=="tabs") {
    if(s.size()<=1)
      return smerror("sm command requires another parameter: get tabs");
    else
      return smgettabs(s[1]);
  }
  return smerror("unrecognized sm command: get " + p);
}
Exemplo n.º 12
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smact()
{
  cmd.getparms();
  term->smact();
  return"";
}
Exemplo n.º 13
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smprompt()
{
  string p=cmd.getparms();
  term->smprompt(s2q(p));
  return"";
}
Exemplo n.º 14
0
Arquivo: sm.cpp Projeto: 0branch/qtide
// ---------------------------------------------------------------------
string smhtml()
{
  string p=cmd.getparms();
  tedit->appendHtml(s2q(p));
  return"";
}