void InsertMenuIntoBrowser(MenuBrowser& brw, Menu mn)
{
    RefPtr<MenuStore> ms = brw.GetMenuStore();
    // * куда
    Gtk::TreeRow row = *InsertByPos(ms, GetCursor(brw));
    OpenPublishMenu(row, ms, mn);
    InvokeOnInsert(mn);

    // * фокус
    GoToPos(brw, ms->get_path(row));
}
// Zeichnet das Stein Array auf die Konsole an der gewuenschten Stelle
void Zeichne_Stein(int sx, int sy)
{
	// Zeichne
	for(int h=0; h<_ITEMARRAYSIZE; h++)
	{
		// GoToPos(sx, sy+h);
		int tempH = sy+h;
		for(int b=0; b<_ITEMARRAYSIZE; b++)
		{
			GoToPos(sx + b, tempH);
			char buchstabe = _CurrentStone[h][b];
			printf("%c", buchstabe);
		}
	}

	ClearCurrentArray();
	GoToPosZero();
}
// Gibt eine beliebige Raute auf der Konsole aus
void AusgabeRaute(int anzahl, char buchstabe, int sx,  int sy)
{
	char printArr[_ITEMARRAYSIZE][_ITEMARRAYSIZE] = {};

    for(int i=1; i<=anzahl; i++)
    {
        if((i%2)!=0)
        {
            for(int j=0; j<i; j++)
            {
				int posLinks = ((anzahl-(i))/2)+1;
				for(int k=0; k<i;k++)
				{
					int hPos = i;
					printArr[hPos][posLinks++] = buchstabe;
				}
            }
        }
    }
    
    for(int k=(anzahl-1); k>=0; k--)
    {
        if((k%2)!=0)
        {
            for (int j=0; j<k; j++)
            {
				int posLinks = ((anzahl-k)/2)+1;
				for(int l=0; l<k;l++)
				{
					int hPos = (anzahl-k) + anzahl;
					printArr[hPos][posLinks++] = buchstabe;
				}
            }
        }
    }

	int increasingFactor = 0;
	for(int m=0; m<_ITEMARRAYSIZE; m++)
	{
		if((m % 2)!=0)
		{
			increasingFactor++;
			for(int n=0; n<_ITEMARRAYSIZE; n++)
			{
				int x = n+sx;
				int y = m+sy;
				if(m==1)
				{
					GoToPos(x, y-1);
				}
				else
				{
					int yCalc = y - increasingFactor;
					GoToPos(x, yCalc);
				}

				char pCh = printArr[m][n];
				if(pCh != NULL)
				{
					printf("%c", pCh);
				}
				else
				{
					printf(" ");
				}
			}
			//printf("\n");
		}
	}
}
Beispiel #4
0
bool SciDoc::DoLoadFromFile(const char*filename,bool insert)
{
  _lasterror="";
  errno=0;
  memset(bom,0,sizeof(bom));
  bool rv=true;
  bool ro=GetReadOnly();
  FXTextCodec *codec=NULL;
  if (ro&&insert) {
    _lasterror=_("Document is marked read-only.");
    return false;
  }
  if (FXStat::isDirectory(filename)) {
    _lasterror=_("is a directory");
    return false;
  }
  bool DefaultToAscii=SettingsBase::instance()->DefaultToAscii;
  bool DefaultToSbcs=SettingsBase::instance()->DefaultToSbcs;
  switch (get_file_encoding(filename)) {
    case 'B': { // Binary file
      if ( !ConfirmOpenBinary(this,filename) ) {
        _lasterror=BinaryFileMessage();
        return false;
      }
      if (!insert) { SetUTF8(!DefaultToSbcs); }
      break;
    }
    case 'T': { // Plain US-ASCII text file
      if (!insert) { SetUTF8(!DefaultToAscii); }
      break;
    }
    case 'H': { // High (extended ASCII) text file.
      if (!insert) { SetUTF8(!DefaultToSbcs); }
      break;
    }
    case 'U': { // UTF-8 encoded text file w/o BOM.
      if (!insert) { SetUTF8(true); }
      break;
    }
    case 'M': { // UTF-8 BOM.
      if (!insert) {
        strcpy(bom,"\0357\0273\0277");
        SetUTF8(true);
      }
      break;
    }
    case 'Z': { // Zero-length (empty) file.
      if (!insert) { SetUTF8(!DefaultToAscii); }
      break;
    }
    case 'e': { // UTF-16LE BOM.
      if (!insert) {
        codec=new FXUTF16LECodec();
        strcpy(bom,"\377\376");
        SetUTF8(false);
      }
      break;
    }
    case 'E': { // UTF-16BE BOM.
      if (!insert) {
        codec=new FXUTF16BECodec();
        strcpy(bom,"\376\377");
        SetUTF8(false);
      }
      break;
    }
    case 'F': { // Failure, could not read the file.
      _lasterror=SystemErrorStr();
      return false;
      break;
    }
  }
  FXFile fh(filename, FXFile::Reading);
  if (fh.isOpen()) {
    if (ro) {
      // This might happen e.g. if we are updating a document that has been modified externally
      sendMessage(SCI_SETREADONLY,0,0);
    }
    static const int BUFSIZE=1025;
    char buf[BUFSIZE];
    fh.position(strlen(bom),FXIO::Begin);
    long p=0;
    _loading=!insert;
    if (insert) {
      p=sendMessage(SCI_GETCURRENTPOS, 0,0);
      sendMessage(SCI_BEGINUNDOACTION, 0, 0);
    } else {
      sendMessage(SCI_CLEARALL,0,0);
    }
    do {
      memset(buf,0,BUFSIZE);
      FXival n=fh.readBlock(buf,BUFSIZE-1);
      if (n<0) {
        _lasterror=SystemErrorStr();
        rv=false;
        break;
      }
      buf[n]='\0';
      if (insert) {
        _dirty=true;
        if (GetSelLength()>0) {
          sendString(SCI_REPLACESEL,0,buf);
          p=sendMessage(SCI_GETCURRENTPOS, 0,0);
        } else {
          sendString(SCI_INSERTTEXT,p,buf);
          p+=n;
        }
      } else {
        sendString(SCI_APPENDTEXT,n,buf);
      }
    } while (!fh.eof());
    fh.close();
    if (rv) {
      if (insert) {
        GoToPos(p);
        sendMessage(SCI_CONVERTEOLS,sendMessage(SCI_GETEOLMODE,0,0),0);
        sendMessage(SCI_ENDUNDOACTION,0,0);
      } else {
        _filename=FXPath::absolute(filename);
        _filetime=FXStat::modified(_filename);
        _dirty=false;
        need_backup=false;
        if (codec) {
          const char *orig=(const char*)sendMessage(SCI_GETCHARACTERPOINTER,0,0);
          FXString recode;
          recode.length(codec->mb2utflen(orig,sendMessage(SCI_GETLENGTH,0,0)));
          codec->mb2utf((char*)recode.text(),recode.length(),orig,sendMessage(SCI_GETLENGTH,0,0));
          delete codec;
          SetUTF8(true);
          sendString(SCI_SETTEXT,0,recode.text());
        }
        SetEolModeFromContent();
        sendMessage(SCI_EMPTYUNDOBUFFER,0,0);
      }
      AdjustHScroll();
    }
    if (ro) { sendMessage(SCI_SETREADONLY,1,0); }
  } else {
    _lasterror=SystemErrorStr();
    rv=false;
  }
  _loading=false;
  return rv;
}