Пример #1
0
void MadEdit::SetSyntax(const wxString &title, bool manual)
{
    if (m_Syntax->GetTitle() == title)
        return;

    delete m_Syntax;
    m_Syntax = MadSyntax::GetSyntaxByTitle(title);
    m_Syntax->SetEncoding(m_Encoding);
    m_Syntax->InitNextWord1(m_Lines, m_WordBuffer, m_WidthBuffer,
        m_TextFont->GetFaceName(), m_TextFont->GetPointSize(), m_TextFont->GetFamily());

    m_Lines->m_Syntax=m_Syntax;
    m_Lines->SetManual(manual);

    if (m_LoadingFile)
        return;

    if (!IsTextFile())
        return;

    // data is text
    ReformatAll();

    DoStatusChanged();
    DoSelectionChanged();

    m_RepaintAll = true;
    Refresh(false);
}
Пример #2
0
void Ide::IdePaste(String& data)
{
	data.Clear();
	if(AcceptFiles(Clipboard())) {
		Vector<String> s = GetFiles(Clipboard());
		for(int i = 0; i < s.GetCount(); i++)
			if(FileExists(s[i]) && IsTextFile(s[i], 10000)) {
				int64 len = GetFileLength(s[i]);
				if(len > 5000000 || data.GetLength() + len < 5000000)
					data.Cat(LoadFile(s[i]));
			}
	}
}
Пример #3
0
void MadEdit::SetEncoding(const wxString &encname)
{
    if(encname.Lower() != m_Encoding->GetName().Lower())
    {
        //delete m_Encoding;
        m_Encoding=wxm::WXMEncodingManager::Instance().GetWxmEncoding(encname);
        m_Lines->SetEncoding(m_Encoding);
        m_Syntax->SetEncoding(m_Encoding);

        wxString fontname;
        m_Config->Read(wxString(wxT("/Fonts/"))+m_Encoding->GetName(), &fontname, m_Encoding->GetFontName());

        bool oldlf=m_LoadingFile;
        m_LoadingFile=true;
        SetTextFont(fontname, m_TextFont->GetPointSize(), false);
        m_LoadingFile=oldlf;

        if(!m_LoadingFile)
        {
            if(IsTextFile())    // data is text
            {
                ReformatAll();
            }
            else // hex data
            {
                AppearCaret();
                UpdateScrollBarPos();

                if(!m_CaretAtHexArea)
                {
                    UpdateTextAreaXPos();
                    m_LastTextAreaXPos = m_TextAreaXPos;
                }
            }

            DoStatusChanged();
            DoSelectionChanged();

            m_RepaintAll = true;
            Refresh(false);
        }
    }
}
Пример #4
0
bool    FlexCopyManager::FileCopy(const char *srcName, const char *destName,
                                  FileContainerIf &src, FileContainerIf &dst)
{
    if (&src == &dst)
    {
        throw FlexException(FERR_COPY_ON_ITSELF, std::string(srcName));
    }

    if (dst.IsWriteProtected())
    {
        FlexContainerInfo info;

        dst.GetInfo(info);
        throw FlexException(FERR_CONTAINER_IS_READONLY, info.GetName());
    }

    auto fileBuffer = src.ReadToBuffer(srcName);

    if ((src.GetContainerType() & TYPE_CONTAINER) &&
        (dst.GetContainerType() & TYPE_DIRECTORY) &&
        fileBuffer.IsFlexTextFile() && autoTextConversion)
    {
        fileBuffer.ConvertToTextFile();
    }

    if ((src.GetContainerType() & TYPE_DIRECTORY) &&
        (dst.GetContainerType() & TYPE_CONTAINER) &&
        fileBuffer.IsTextFile() && autoTextConversion)
    {
        fileBuffer.ConvertToFlexTextFile();
    }

    if (!dst.WriteFromBuffer(fileBuffer, destName))
    {
        FlexContainerInfo info;

        dst.GetInfo(info);
        throw FlexException(FERR_DISK_FULL_WRITING, info.GetPath().c_str(),
                            destName);
    }

    return true;
}
Пример #5
0
/*
 * FormatFileEntry - print a file entry
 */
void FormatFileEntry( direct_ent *file, char *res )
{
    char        *tmp;
    char        buff[11];
    long        size;
    struct tm   *tm;
    time_t      tt;
    size_t      size1;

    size1 = strlen( file->name ) + 4;
    if( size1 < NAMEWIDTH + 1 )
        size1 = NAMEWIDTH + 1;
    tmp = malloc( size1 );

    strcpy( buff, "----------" );
    size = file->fsize;
    if( file->attr & _A_SUBDIR ) {
        MySprintf( tmp, " " FILE_SEP_STR "%S", file->name );
        buff[0] = 'd';
        size = 0;
    } else {
        if( !IsTextFile( file->name ) ) {
            MySprintf( tmp, " *%S", file->name );
        } else {
            MySprintf( tmp, "  %S", file->name );
        }
    }

    /*
     * build attributes
     */
    if( file->st_mode & S_IWUSR ) {
        buff[1] = 'r';
    }
    if( file->st_mode & S_IRUSR ) {
        buff[2] = 'w';
    }
    if( file->st_mode & S_IXUSR ) {
        tmp[1] = '*';
        buff[3] = 'x';
    }
    if( file->st_mode & S_IWGRP ) {
        buff[4] = 'r';
    }
    if( file->st_mode & S_IRGRP ) {
        buff[5] = 'w';
    }
    if( file->st_mode & S_IXGRP ) {
        tmp[1] = '*';
        buff[6] = 'x';
    }
    if( file->st_mode & S_IWOTH ) {
        buff[7] = 'r';
    }
    if( file->st_mode & S_IROTH ) {
        buff[8] = 'w';
    }
    if( file->st_mode & S_IXOTH ) {
        tmp[1] = '*';
        buff[9] = 'x';
    }

    tmp[NAMEWIDTH] = '\0';

    tt = file->time;
    tm = localtime( &tt );

    MySprintf( res, "%s %s %L %D/%D/%d %D:%D",
               tmp,
               buff,
               size,
               (int)tm->tm_mon + 1,
               (int)tm->tm_mday,
               (int)tm->tm_year + 1900,
               (int)tm->tm_hour,
               (int)tm->tm_min );

} /* FormatFileEntry */