bad day
This commit is contained in:
parent
a9eb976b48
commit
6052df85dc
@ -29,7 +29,7 @@
|
||||
#include <etk/String.h>
|
||||
#include <etk/File.h>
|
||||
#include <Display.h>
|
||||
#include <charset.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ class Buffer {
|
||||
virtual void SelectNone(void);
|
||||
virtual void Undo(void);
|
||||
virtual void Redo(void);
|
||||
virtual void SetCharset(charset_te newCharset) {};
|
||||
virtual void SetCharset(unicode::charset_te newCharset) {};
|
||||
|
||||
//virtual void SelectAll(void);
|
||||
virtual void Copy(int8_t clipboardID);
|
||||
|
@ -341,7 +341,6 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
|
||||
color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE);
|
||||
color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB);
|
||||
Colorize * selectColor = NULL;
|
||||
char displayChar[MAX_EXP_CHAR_LEN];
|
||||
memset(displayChar, 0, sizeof(char)*MAX_EXP_CHAR_LEN);
|
||||
|
||||
int mylen = m_EdnBuf.Size();
|
||||
@ -361,20 +360,97 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DC
|
||||
//g_get_current_time(&timeStart);
|
||||
|
||||
|
||||
#if 0
|
||||
// TODO : change diplay methode :
|
||||
// Extract the entire line on the buffer with all char expended and the data in Unicode
|
||||
// Second parsing of the line ==> to have the syntax highligt
|
||||
// Draw all needed char in the
|
||||
#if 1
|
||||
uniChar_t displayChar[MAX_EXP_CHAR_LEN];
|
||||
// draw the lineNumber :
|
||||
int32_t currentLineID = m_displayStart.y+1;
|
||||
EDN_DEBUG("Start display of text buffer [" << m_displayStartBufferPos<< ".." << mylen << "]");
|
||||
bool ended = false;
|
||||
while (true == ended) {
|
||||
|
||||
currentLineID++;
|
||||
ended = true;
|
||||
EDN_DEBUG("cursor Pos : " << m_cursorPos << "start at pos=" << m_displayStartBufferPos);
|
||||
|
||||
DrawLineNumber(OOText, OOColored, sizeX, sizeY, myPrint, currentLineID, y);
|
||||
int32_t pixelX = x_base;
|
||||
for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
|
||||
//EDN_DEBUG("diplay element=" << iii);
|
||||
int displaywidth;
|
||||
uint32_t currentChar = '\0';
|
||||
new_i = iii;
|
||||
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
|
||||
//EDN_INFO("diplay element=" << new_i);
|
||||
if (currentChar!='\n') {
|
||||
selectColor = myColor;
|
||||
//kwow size to display
|
||||
int32_t widthToDisplay;
|
||||
char * tmpDisplayOfset;
|
||||
HLColor = m_EdnBuf.GetElementColorAtPosition(m_displayLocalSyntax, iii);
|
||||
if (NULL != HLColor) {
|
||||
if (NULL != HLColor->patern) {
|
||||
selectColor = HLColor->patern->GetColor();
|
||||
}
|
||||
}
|
||||
|
||||
if( true == selHave
|
||||
&& selStart <= iii
|
||||
&& selEnd > iii)
|
||||
{
|
||||
selectColor = myColorSel;
|
||||
}
|
||||
OOColored->SetColor(selectColor->GetBG());
|
||||
OOText->SetColor(selectColor->GetFG());
|
||||
if (currentChar <= 0x7F) {
|
||||
int32_t drawSize = OOText->TextAdd(pixelX, y, tmpDisplayOfset, -1);
|
||||
if (true == selectColor->HaveBg() ) {
|
||||
OOColored->Rectangle( pixelX, y, drawSize*strlen(tmpDisplayOfset), letterHeight);
|
||||
}
|
||||
pixelX += drawSize;
|
||||
} else {
|
||||
int32_t drawSize = OOText->TextAdd(pixelX, y, displayChar, -1);
|
||||
if (true == selectColor->HaveBg() ) {
|
||||
OOColored->Rectangle( pixelX, y, drawSize*strlen(tmpDisplayOfset), letterHeight);
|
||||
}
|
||||
pixelX += drawSize;
|
||||
}
|
||||
}
|
||||
xx+=widthToDisplay;
|
||||
idX += displaywidth;
|
||||
|
||||
// display cursor :
|
||||
//EDN_DEBUG(" is equal : " << m_cursorPos << "=" << iii);
|
||||
if (m_cursorPos == iii) {
|
||||
// display the cursor:
|
||||
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
|
||||
/*if (true == m_cursorOn) {
|
||||
//Cursor(OOColored, pixelX, y+letterHeight, letterHeight, letterWidth);
|
||||
//m_cursorOn = false;
|
||||
} else {
|
||||
m_cursorOn = true;
|
||||
}*/
|
||||
}
|
||||
// move to next line ...
|
||||
if (currentChar=='\n') {
|
||||
//drawer.EndOfLine(pixelX, y+letterHeight);
|
||||
//drawer.Flush();
|
||||
xx = 0;
|
||||
idX =0;
|
||||
pixelX = x_base;
|
||||
y += letterHeight;
|
||||
displayLines++;
|
||||
currentLineID++;
|
||||
DrawLineNumber(OOText, OOColored, sizeX, sizeY, myPrint, currentLineID, y);
|
||||
}
|
||||
}
|
||||
// special case : the cursor is at the end of the buffer...
|
||||
if (m_cursorPos == iii) {
|
||||
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
|
||||
// display the cursor:
|
||||
if (true == m_cursorOn) {
|
||||
//Cursor(OOColored, xx*letterWidth + x_base, yy+letterHeight, letterHeight, letterWidth);
|
||||
m_cursorOn = false;
|
||||
} else {
|
||||
m_cursorOn = true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
char displayChar[MAX_EXP_CHAR_LEN];
|
||||
// draw the lineNumber :
|
||||
int32_t currentLineID = m_displayStart.y+1;
|
||||
EDN_DEBUG("Start display of text buffer [" << m_displayStartBufferPos<< ".." << mylen << "]");
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <EdnBuf.h>
|
||||
|
||||
|
||||
@ -488,6 +489,108 @@ int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, char outUTF8[MAX_E
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transform the current caracter in the buffer in a displayable vector of char
|
||||
*
|
||||
* @param[in,out] pos position of the char that might be converted (incremented to the next char (in case of UTF8)
|
||||
* @param[in] indent Curent indentation befor the curent char
|
||||
* @param[out] outUTF8 string of the displayed element
|
||||
* @param[out] currentChar curent unicode output char
|
||||
*
|
||||
* @return number of displayable char (display char width)
|
||||
*
|
||||
*/
|
||||
int32_t EdnBuf::GetExpandedChar(int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t ¤tChar)
|
||||
{
|
||||
int32_t i, nSpaces;
|
||||
char c = m_data.Get(pos);
|
||||
currentChar = (uint32_t)c & 0xFF;
|
||||
/* Convert tabs to spaces */
|
||||
if (c == '\t') {
|
||||
nSpaces = m_tabDist - (indent % m_tabDist);
|
||||
for (i=0; i<nSpaces; i++) {
|
||||
outUnicode[i] = ' ';
|
||||
}
|
||||
outUnicode[i] = '\0';
|
||||
pos++;
|
||||
return nSpaces;
|
||||
}
|
||||
|
||||
// Convert ASCII control codes to readable character sequences
|
||||
if (c == '\0') {
|
||||
outUnicode[0] = '<';
|
||||
outUnicode[1] = 'n';
|
||||
outUnicode[2] = 'u';
|
||||
outUnicode[3] = 'l';
|
||||
outUnicode[4] = '>';
|
||||
outUnicode[5] = '\0';
|
||||
pos++;
|
||||
return 5;
|
||||
}
|
||||
if (((unsigned char)c) == '\n') {
|
||||
outUnicode[0] = (unsigned char)c;
|
||||
outUnicode[1] = '\0';
|
||||
pos++;
|
||||
return 1;
|
||||
}
|
||||
if (((unsigned char)c) <= 31) {
|
||||
const char * tmp = ControlCodeTable[(unsigned char)c];
|
||||
int32_t nbElem = 2;
|
||||
*outUnicode++ = '<';
|
||||
while (*tmp!='\0') {
|
||||
*outUnicode++ = *tmp;
|
||||
tmp++;
|
||||
nbElem++;
|
||||
}
|
||||
*outUnicode++ = '>';
|
||||
*outUnicode++ = '\0';
|
||||
pos++;
|
||||
return nbElem;
|
||||
} else if (c == 127) {
|
||||
outUnicode[0] = '<';
|
||||
outUnicode[1] = 'd';
|
||||
outUnicode[2] = 'e';
|
||||
outUnicode[3] = 'l';
|
||||
outUnicode[4] = '>';
|
||||
outUnicode[5] = '\0';
|
||||
pos++;
|
||||
return 5;
|
||||
}
|
||||
|
||||
// Otherwise, just return the character
|
||||
if (false ==m_isUtf8) {
|
||||
unicode::convertIsoToUnicode(m_charsetType, c, outUnicode[0]);
|
||||
pos++;
|
||||
} else {
|
||||
char tmpString[8];
|
||||
for (int32_t k=0; k<6 && k< m_data.Size() - pos; k++) {
|
||||
tmpString[k] = m_data.Get(pos+k);
|
||||
}
|
||||
tmpString[6] = '\0';
|
||||
uint8_t size;
|
||||
bool baseValid;
|
||||
unicode::Utf8_SizeElement(tmpString, 6 , size, baseValid);
|
||||
currentChar = 0; // TODO : Set UNICODE char ...
|
||||
if (true == baseValid) {
|
||||
char *tmp = outUnicode;
|
||||
for (int32_t k=0; k<size; k++) {
|
||||
*tmp++ = tmpString[k];
|
||||
}
|
||||
*tmp = '\0';
|
||||
unicode::convertIsoToUnicode(m_charsetType, c, outUnicode);
|
||||
|
||||
} else {
|
||||
sprintf(outUTF8, "<? ? ? ?>");
|
||||
}
|
||||
if (0 == size) {
|
||||
EDN_ERROR("plop");
|
||||
}
|
||||
pos+=size;
|
||||
return strlen(outUTF8);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief generate the real display of character of the output (ex : \t ==> 4 spaces or less ...)
|
||||
|
@ -34,7 +34,7 @@ class EdnBuf;
|
||||
#include <EdnVectorBuf.h>
|
||||
#include <EdnBufHistory.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <charset.h>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
/*
|
||||
|
||||
@ -100,9 +100,10 @@ class EdnBuf {
|
||||
int32_t StartOfLine( int32_t pos);
|
||||
int32_t EndOfLine( int32_t pos);
|
||||
|
||||
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t ¤tChar);
|
||||
int32_t ExpandCharacter( char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN]); // TODO : rework this
|
||||
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
|
||||
int32_t GetExpandedChar( int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t ¤tChar);
|
||||
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t ¤tChar);
|
||||
int32_t ExpandCharacter( char c, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN]); // TODO : Remove
|
||||
int32_t CharWidth( char c, int32_t indent); // TODO : rework this
|
||||
int32_t CountDispChars( int32_t lineStartPos, int32_t targetPos);
|
||||
int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars);
|
||||
int32_t CountLines( int32_t startPos, int32_t endPos);
|
||||
@ -178,19 +179,19 @@ class EdnBuf {
|
||||
// Display property and charset ...
|
||||
// -----------------------------------------
|
||||
public:
|
||||
int32_t GetTabDistance(void) { return m_tabDist; } ;
|
||||
void SetTabDistance(int32_t tabDist) { m_tabDist = tabDist; };
|
||||
charset_te GetCharsetType(void) { return m_charsetType; };
|
||||
void SetCharsetType(charset_te newOne) { m_charsetType = newOne; if (EDN_CHARSET_UTF8==newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
|
||||
bool GetUTF8Mode(void) { return m_isUtf8; };
|
||||
void SetUTF8Mode(bool newOne) { m_isUtf8 = newOne; m_charsetType=EDN_CHARSET_UTF8; };
|
||||
int32_t GetTabDistance(void) { return m_tabDist; } ;
|
||||
void SetTabDistance(int32_t tabDist) { m_tabDist = tabDist; };
|
||||
unicode::charset_te GetCharsetType(void) { return m_charsetType; };
|
||||
void SetCharsetType(unicode::charset_te newOne) { m_charsetType = newOne; if (unicode::EDN_CHARSET_UTF8==newOne){m_isUtf8=true;} else {m_isUtf8=false;} };
|
||||
bool GetUTF8Mode(void) { return m_isUtf8; };
|
||||
void SetUTF8Mode(bool newOne) { m_isUtf8 = newOne; m_charsetType=unicode::EDN_CHARSET_UTF8; };
|
||||
private:
|
||||
// Special mode of the buffer :
|
||||
bool m_isUtf8; //!< true if we are in UTF8 mode ==> if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
|
||||
charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
|
||||
bool m_isUtf8; //!< true if we are in UTF8 mode ==> if true the size of a char is 0, otherwise .. 1->4 ( TODO : not now)
|
||||
unicode::charset_te m_charsetType; //!< if UTF8 mode is at false : the charset type of the buffer
|
||||
// Local Tabulation policies
|
||||
int32_t m_tabDist; //!< equiv. number of characters in a tab
|
||||
bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
|
||||
int32_t m_tabDist; //!< equiv. number of characters in a tab
|
||||
bool m_useTabs; //!< True if buffer routines are allowed to use tabs for padding in rectangular operations
|
||||
|
||||
// -----------------------------------------
|
||||
// Local function :
|
||||
|
@ -27,9 +27,7 @@ FILE_LIST+= edn/tools/EdnTemplate/EdnVectorBuf.cpp \
|
||||
FILE_LIST+= edn/tools/Display/Display.cpp \
|
||||
edn/tools/ClipBoard/ClipBoard.cpp \
|
||||
edn/tools/MsgBroadcast/MsgBroadcast.cpp \
|
||||
edn/tools/MsgBroadcast/AccelKey.cpp \
|
||||
edn/tools/charset/charsetTable.cpp \
|
||||
edn/tools/charset/charset.cpp
|
||||
edn/tools/MsgBroadcast/AccelKey.cpp
|
||||
|
||||
# Gui:
|
||||
FILE_LIST+= edn/CustumWidget/BufferView/BufferView.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user