Example #1
0
QSPEditor::QSPEditor(QWidget *parent) :
    QsciScintilla(parent)
{
    setUtf8(true);
    QFont m_font(Config().editorFont());
    //m_font.setFamily("Monospace");
    m_font.setFixedPitch(true);
    m_font.setPointSize(Config().editorFontSize());

    QFontMetrics m_fm (m_font);

    this->setFont(m_font);
    this->setMarginsFont(m_font);

    this->setMarginWidth(0, m_fm.width("00000")+ 5);
    this->setMarginLineNumbers(0,true);

    //Clickable margin 1 for showing markers
    this->setMarginSensitivity(1, true);
    connect(this,SIGNAL(marginClicked(int,int,Qt::KeyboardModifiers)),
            this, SLOT(onMarginClicked(int,int,Qt::KeyboardModifiers)));
    this->markerDefine(QsciScintilla::RightArrow, ARROW_MARKER_NUM);
    this->setMarkerBackgroundColor(QColor("#ee1111"),ARROW_MARKER_NUM);

    this->setEdgeMode(QsciScintilla::EdgeLine);
    this->setEdgeColumn(200);
    this->setEdgeColor(QColor("#FF0000"));


    this->setFolding(QsciScintilla::CircledTreeFoldStyle);
    this->setBraceMatching(QsciScintilla::SloppyBraceMatch);
    this->setCaretLineVisible(true);
    this->setCaretLineBackgroundColor(QColor("#F1EFD8"));

    this->setMarginsBackgroundColor(QColor("#333333"));
    this->setMarginsForegroundColor(QColor("#CCCCCC"));

    this->setFoldMarginColors(QColor("#99CC66"),QColor("#333300"));
    this->setAutoIndent(true);
    this->setIndentationWidth(4);

    m_lexer = new QsciLexerPascal();
    m_lexer->setDefaultFont(m_font);
    //m_lexer->setAutoIndentStyle(QsciScintilla::AiOpening | QsciScintilla::AiClosing);
    const char *keywords = m_lexer->keywords(0);
    qDebug() << "Pascal keywords : " << keywords << endl;

    //this->SendScintilla(QsciScintilla::SCI_STYLESETFONT,1,"Courier");
    loadApis(m_lexer);

    this->setLexer(m_lexer);

    //this->setAutoIndent(true);
    this->setBackspaceUnindents(true);
    this->setAutoCompletionThreshold(1);
    this->setAutoCompletionSource(QsciScintilla::AcsAPIs);
    this->setAutoCompletionFillupsEnabled(true);
}
Example #2
0
int main(int argc, char *argv[])
   {
   register int i;
   int xpos = XPOS;
   int ypos = YPOS;
   int font = -1;
   int shape = 1;

   char *getenv();
   char *home = getenv("HOME");
   int clean(), update();

   /* make sure we have a valid environment to run in */

   ckmgrterm( *argv );

   if (home==NULL || *home=='\0') {
      fprintf(stderr,"%s: Can't find your home directory\n",argv[0]);
      exit(1);
      }

   if ((bounds = fopen(BOUNDS,"r")) == NULL) {
      fprintf(stderr,"%s: Can't find a bounds file\n",argv[0]);
      exit(2);
      }

   sprintf(line,"%s/%s",home,RC);
   
   if ((rc = fopen(line,"r")) == NULL) {
      fprintf(stderr,"%s: Can't find %s\n",argv[0],line);
      exit(3);
      }

   /* process arguments */

   for(i=1;i<argc;i++) {
      if (Isflag(argv[i],"-s"))
         shape = 0;
      else if (Isflag(argv[i],"-x"))
         xpos = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-y"))
         ypos = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-f"))
         font = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-p"))
         poll  = Max(atoi(argv[i]+2),10);
      else
         usage(argv[0],argv[i]);
      }

   /* setup mgr stuff */

   m_setup(M_FLUSH);
   m_push(P_MENU|P_EVENT|P_FLAGS);
   m_setmode(M_NOWRAP);
   m_ttyset();

   signal(SIGTERM,clean);
   signal(SIGINT,clean);
   signal(SIGALRM,update);

   menu_load(1,MENU_COUNT,menu);
   m_selectmenu(1);

   old_msg_cnt = MSGS();
   get_msg(line,old_msg_cnt);
   if (shape) {
      m_setmode(M_ACTIVATE);
      m_size(strlen(line)+2,1);
      }
   m_printstr(line);
   m_setevent(REDRAW,"R\n");
   m_setevent(ACTIVATED,"A\n");
   m_clearmode(M_ACTIVATE);
   alarm(poll);

   while(1) {
      char buff[80];
      m_gets(buff);
      alarm(0);

      /* read msgs */

      old_msg_cnt = msg_cnt;
      msg_cnt = MSGS();
      if (msg_cnt > 0 && *buff == 'A') {
         m_push(P_POSITION|P_EVENT|P_FLAGS|P_FONT);
         if (font != -1)
            m_font(font);
         m_sizeall(xpos,ypos,80,24);
         m_printstr("\freading msgs...\r");
         m_ttyreset();
         system(MSGSCMD);
         m_gets(buff);
         m_ttyset();
         m_pop();
         }

      /* wait for window to deactivate */

      else if (*buff == 'A') {
         m_setevent(DEACTIVATED,RESUME);
         do {
            m_printstr("\f Your msgs system here        ");
            m_gets(buff);
            } while(!SCMP(buff,RESUME));
         m_clearevent(DEACTIVATED);
         }
      old_msg_cnt = msg_cnt;
      msg_cnt = MSGS();
      get_msg(line,msg_cnt);
      m_printstr(line);
      m_clearmode(M_ACTIVATE);
      alarm(poll);
      }
      return 0;
   }