/** ******************************************************************************* * @file Buffer.c * @brief Editeur De N'ours : Text Buffer * @author Edouard DUPIN * @date 08/12/2010 * @par Project * Edn * * @par Copyright * Copyright 2010 Edouard DUPIN, all right reserved * * This software is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. * * Licence summary : * You can modify and redistribute the sources code and binaries. * You can send me the bug-fix * You can not earn money with this Software (if the source extract from Edn * represent less than 50% of original Sources) * Term of the licence in in the file licence.txt. * ******************************************************************************* */ #include "tools_debug.h" #include "tools_globals.h" #include "Buffer.h" #include "BufferManager.h" #undef __class__ #define __class__ "Buffer" /** * @brief * * @param[in,out] --- * * @return --- * */ Buffer::Buffer() { static int32_t bufID = 0; m_uniqueID = bufID++; static int32_t fileBasicID = 0; m_fileModify = true; m_haveName = false; Edn::String mString = "Untitle - "; mString += fileBasicID++; SetFileName(mString); m_haveName = false; // Set basic anchor bufferAnchorReference_ts tmpAnchor; tmpAnchor.m_displaySize.x = 0; tmpAnchor.m_displaySize.y = 0; tmpAnchor.m_displayStart.x = 0; tmpAnchor.m_curent = true; tmpAnchor.m_idAnchor = -1; tmpAnchor.m_lineId = 0; tmpAnchor.m_bufferPos = 0; for(int32_t iii=0; iii=0) { EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " already exist !!!"); } else { bufferAnchorReference_ts tmpAnchor = m_AnchorList[0]; m_AnchorList[0].m_curent = false; tmpAnchor.m_idAnchor = anchorID; for(int32_t iii=0; iii Added"); } } void Buffer::AnchorRm(int32_t anchorID) { if (anchorID == -1) { EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " Can not remove this one !!!"); return; } int32_t localID = AnchorRealId(anchorID); if (localID >=0) { if (m_AnchorList.Size() == 2) { m_AnchorList[0] = m_AnchorList[1]; for(int32_t iii=0; iii Remove"); } else { EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " does not exist !!!"); } } bool Buffer::AnchorGet(int32_t anchorID, bufferAnchor_ts & anchor) { EDN_ERROR("[" << m_uniqueID << "] AnchorID="<< anchorID << " Main buffer ==> can not manage Anchor (type buffer specific)"); return false; } bool Buffer::AnchorNext(bufferAnchor_ts & anchor) { EDN_ERROR("[" << m_uniqueID << "] AnchorID=?? Main buffer ==> can not manage Anchor (type buffer specific)"); return false; } void Buffer::AnchorSetSize(int32_t anchorID, int32_t sizePixelX, int32_t sizePixelY) { int32_t localID = AnchorRealId(anchorID); if (localID >=0) { m_AnchorList[localID].m_displaySize.x = sizePixelX / m_lineWidth; m_AnchorList[localID].m_displaySize.y = sizePixelY / m_lineHeight; } } void Buffer::AnchorSetStartOffset(int32_t anchorID, int32_t offsetX, int32_t offsetY) { int32_t localID = AnchorRealId(anchorID); if (localID >=0) { m_AnchorList[localID].m_displayStart.x += offsetX; if (0 set ofset : " << offset); int32_t localID = AnchorCurrentId(); if (localID >=0) { m_AnchorList[localID].m_BufferNumberLineOffset += offset; if (offset < 0) { if (-1 * offset < MAX_LINE_DISPLAYABLE_BY_BUFFER) { for(int32_t iii=-1*offset; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== " << iii+offset << " val=" << m_AnchorList[localID].m_redrawLine[iii+offset]); m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset]; } for(int32_t iii=0; iii < -1*offset; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== true"); m_AnchorList[localID].m_redrawLine[iii] = true; } } else { EDN_WARNING("FORCE a total redraw... 1"); for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== true"); m_AnchorList[localID].m_redrawLine[iii] = true; } } } else { if (offset < MAX_LINE_DISPLAYABLE_BY_BUFFER) { for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER-offset ; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== " << iii+offset << " val=" << m_AnchorList[localID].m_redrawLine[iii+offset]); m_AnchorList[localID].m_redrawLine[iii] = m_AnchorList[localID].m_redrawLine[iii+offset]; } for(int32_t iii=MAX_LINE_DISPLAYABLE_BY_BUFFER-offset+1; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== true"); m_AnchorList[localID].m_redrawLine[iii] = true; } } else { EDN_WARNING("FORCE a total redraw... 2"); for(int32_t iii=0; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== true"); m_AnchorList[localID].m_redrawLine[iii] = true; } } } for(int32_t iii=m_AnchorList[localID].m_displaySize.y; iii < MAX_LINE_DISPLAYABLE_BY_BUFFER; iii++) { //EDN_DEBUG("move redraw request : " << iii << " <== true"); m_AnchorList[localID].m_redrawLine[iii] = true; } } }