[DEV] first good vertion from many time...

This commit is contained in:
Edouard DUPIN 2013-11-20 21:57:00 +01:00
parent 872fde6bc2
commit 4ea4d0dc55
22 changed files with 139 additions and 102 deletions

View File

@ -4,7 +4,7 @@
{ name:"CODE_space", foreground:"#333333" },
{ name:"CODE_tabulation", foreground:"#444444" },
{ name:"CODE_cursor", foreground:"#eadd05" },
{ name:"CODE_lineNumber", foreground:"#fff725" },
{ name:"CODE_lineNumber", foreground:"#fff725", background:"#464646"},
{ name:"normal", foreground:"#EEEEEE"},
{ name:"SelectedText", foreground:"#AAAAAA", background:"#225a09"},
{ name:"error", foreground:"#FF0000"},

View File

@ -4,7 +4,7 @@
{ name:"CODE_space", foreground:"#b7b6b6"},
{ name:"CODE_tabulation", foreground:"#a7a5a5"},
{ name:"CODE_cursor", foreground:"#2a00ff"},
{ name:"CODE_lineNumber", foreground:"#1a00a0"},
{ name:"CODE_lineNumber", foreground:"#1a00a0", background:"#a2a2a2"},
{ name:"normal", foreground:"#000000"},
{ name:"SelectedText", foreground:"#292929", background:"#009ce7"},
{ name:"error", foreground:"#FF0000"},

View File

@ -112,6 +112,7 @@ appl::Buffer::Buffer(void) :
m_cursorPreferredCol(-1),
m_nbLines(1),
m_highlight(NULL) {
addObjectType("appl::Buffer");
static int32_t bufferBaseId = 0;
m_fileName = "No Name " + std::to_string(bufferBaseId);
bufferBaseId++;
@ -807,3 +808,17 @@ appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(appl::DisplayHLData
return getElementColorAtPosition(_pos, _MData.posHLPass1);
}
uint32_t appl::Buffer::getCursorLinesId(void) {
if (m_data.size() == 0) {
return 0;
}
uint32_t line = 0;
for (Iterator it = begin();
(bool)it == true && it <= cursor();
++it) {
if (*it == etk::UChar::Return) {
++line;
}
}
return line;
}

View File

@ -526,6 +526,11 @@ namespace appl {
esize_t getNumberOfLines(void) {
return m_nbLines;
}
/**
* @brief Get the cursor line numberin the buffer.
* @return the line id in the Buffer.
*/
uint32_t getCursorLinesId(void);
protected:
/**
* @brief Count the number of line in the buffer

View File

@ -18,7 +18,7 @@
appl::BufferManager::BufferManager(void) :
ewol::Resource("???BufferManager???"),
m_bufferSelected(NULL) {
addObjectType("appl::BufferManager");
}
appl::BufferManager::~BufferManager(void) {

View File

@ -40,6 +40,7 @@ static void SortElementList(std::vector<appl::dataBufferStruct*>& _list) {
}
BufferView::BufferView(void) {
addObjectType("appl::BufferView");
setCanHaveFocus(true);
registerMultiCast(ednMsgBufferListChange);
registerMultiCast(ednMsgBufferState);

View File

@ -121,6 +121,7 @@ const char* l_smoothMax = "tmpEvent_maxChange";
#define __class__ "MainWindows"
MainWindows::MainWindows(void) {
addObjectType("appl::MainWindows");
APPL_DEBUG("CREATE WINDOWS ... ");
widget::Sizer * mySizerVert = NULL;
widget::Sizer * mySizerVert2 = NULL;
@ -232,12 +233,8 @@ MainWindows::MainWindows(void) {
(void)myMenu->add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
(void)myMenu->add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
int32_t idMenugDisplay = myMenu->addTitle("Display");
(void)myMenu->add(idMenugDisplay, "Charset UTF-8", "", ednMsgGuiChangeCharset, "UTF-8");
(void)myMenu->add(idMenugDisplay, "Charset ISO-8859-1", "", ednMsgGuiChangeCharset, "ISO-8859-1");
(void)myMenu->add(idMenugDisplay, "Charset ISO-8859-15", "", ednMsgGuiChangeCharset, "ISO-8859-15");
(void)myMenu->addSpacer();
(void)myMenu->add(idMenugDisplay, "Color Black", "", ednMsgGuiChangeColor, "Black");
(void)myMenu->add(idMenugDisplay, "Color White", "", ednMsgGuiChangeColor, "White");
(void)myMenu->add(idMenugDisplay, "Color Black", "", appl::MsgNameGuiChangeColor, "colorBlack/");
(void)myMenu->add(idMenugDisplay, "Color White", "", appl::MsgNameGuiChangeColor, "colorWhite/");
(void)myMenu->addSpacer();
(void)myMenu->add(idMenugDisplay, "Reload openGl Shader", "", ednMsgGuiReloadShader);
@ -281,6 +278,7 @@ MainWindows::MainWindows(void) {
registerMultiCast(ednMsgBufferState);
registerMultiCast(ednMsgBufferId);
registerMultiCast(ednMsgGuiReloadShader);
registerMultiCast(appl::MsgNameGuiChangeColor);
}
@ -337,6 +335,10 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
tmpSubWidget = new ParameterAboutGui();
tmpWidget->menuAdd("About", "", tmpSubWidget);
}
} else if (_msg.getMessage() == appl::MsgNameGuiChangeColor) {
etk::theme::setName("COLOR", _msg.getData());
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if (_msg.getMessage() == ednMsgGuiReloadShader) {
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();

View File

@ -35,6 +35,7 @@ Search::Search(void) :
widget::Sizer(widget::Sizer::modeHori),
m_searchEntry(NULL),
m_replaceEntry(NULL) {
addObjectType("appl::Search");
m_forward = false;
// TODO : change the mode of creating interface :
/*

View File

@ -17,6 +17,7 @@ extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-
extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate";
appl::TagFileList::TagFileList(void) {
addObjectType("appl::TagFileList");
m_selectedLine = -1;
addEventId(applEventCtagsListSelect);
addEventId(applEventCtagsListValidate);

View File

@ -30,8 +30,8 @@ extern const char * const applEventctagsSelection = "appl-event-ctags-validate";
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel";
appl::TagFileSelection::TagFileSelection(void)
{
appl::TagFileSelection::TagFileSelection(void) {
addObjectType("appl::TagFileSelection");
addEventId(applEventctagsSelection);
addEventId(applEventctagsCancel);

View File

@ -21,15 +21,23 @@
#undef __class__
#define __class__ "TextViewer"
#define tic() \
int64_t startTime = ewol::getTime();
#define toc(comment) \
int64_t endTime = ewol::getTime(); \
int64_t processTimeLocal = (endTime - startTime); \
APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms");
appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
m_buffer(NULL),
m_displayText(_fontName, _fontSize),
m_insertMode(false) {
addObjectType("appl::TextViewer");
setCanHaveFocus(true);
registerMultiCast(ednMsgBufferId);
registerMultiCast(ednMsgGuiRm);
registerMultiCast(ednMsgGuiSelect);
registerMultiCast(ednMsgGuiChangeCharset);
registerMultiCast(ednMsgGuiFind);
registerMultiCast(ednMsgGuiReplace);
registerMultiCast(ednMsgGuiGotoLine);
@ -95,6 +103,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
if (false == needRedraw()) {
return;
}
//tic();
// For the scrooling windows
m_displayDrawing.clear();
m_displayText.clear();
@ -188,7 +197,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
iii<nbLine;
++iii) {
char tmpLineNumber[50];
sprintf(tmpLineNumber, "%*d", nbChar, iii);
sprintf(tmpLineNumber, "%*d", nbChar, iii+1);
m_displayText.print(tmpLineNumber);
m_displayText.forceLineReturn();
if (m_displayText.getPos().y() < -20.0f ) {
@ -282,7 +291,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
m_maxSize.setX(maxSizeX+m_originScrooled.x());
m_maxSize.setY((float)nbLines*tmpLetterSize.y());
}
//toc("Display time : ");
// call the herited class...
WidgetScrooled::onRegenerateDisplay();
}
@ -350,6 +359,8 @@ bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event) {
// move events ...
if (_event.getStatus() == ewol::keyEvent::statusDown) {
bool needUpdatePosition = true;
// selection when shift is set:
m_buffer->setSelectMode(_event.getSpecialKey().isSetShift());
// check selection event ...
switch(_event.getType()) {
case ewol::keyEvent::keyboardLeft:
@ -370,11 +381,11 @@ bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event) {
break;
case ewol::keyEvent::keyboardPageUp:
//APPL_INFO("keyEvent : <PAGE-UP>");
//TextDMoveUp(m_displaySize.y());
moveCursorUp(15); // TODO : Set the real number of line ...
break;
case ewol::keyEvent::keyboardPageDown:
//APPL_INFO("keyEvent : <PAGE-DOWN>");
//TextDMoveDown(m_displaySize.y());
moveCursorDown(15); // TODO : Set the real number of line ...
break;
case ewol::keyEvent::keyboardStart:
//APPL_INFO("keyEvent : <Start of line>");
@ -396,6 +407,7 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
if (_event.getId() != 0) {
keepFocus();
}
//tic();
if (m_buffer == NULL) {
return false;
}
@ -431,17 +443,23 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
// mouse selection :
if (_event.getType() == ewol::keyEvent::typeMouse) {
if (_event.getStatus() == ewol::keyEvent::statusDown) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
m_buffer->setSelectMode(true);
markToRedraw();
return true;
//if (_event.getSpecialKey().isSetShift() == false) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
m_buffer->setSelectMode(true);
markToRedraw();
return true;
//}
} else if (_event.getStatus() == ewol::keyEvent::statusUp) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
m_buffer->setSelectMode(false);
// TODO : Copy selection :
//tmpBuffer->Copy(ewol::clipBoard::clipboardSelection);
// Copy selection :
std::string value;
m_buffer->copy(value);
if (value.size() != 0) {
ewol::clipBoard::set(ewol::clipBoard::clipboardSelection, value);
}
markToRedraw();
return true;
}
@ -518,7 +536,10 @@ appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativeP
m_displayText.forceLineReturn();
countColomn = 0;
} else {
m_displayText.print(stringToDisplay[kkk]);
//note : Without this condithion the time od selection change to 0.6 ms to 8ms ...
if (-_relativePos.y() >= positionCurentDisplay.y()) {
m_displayText.print(stringToDisplay[kkk]);
}
}
}
if (-_relativePos.y() >= positionCurentDisplay.y()) {
@ -548,7 +569,7 @@ void appl::TextViewer::onEventClipboard(enum ewol::clipBoard::clipboardListe _cl
void appl::TextViewer::onReceiveMessage(const ewol::EMessage& _msg) {
widget::WidgetScrooled::onReceiveMessage(_msg);
//APPL_DEBUG("receive msg: " << _msg);
APPL_VERBOSE("receive msg: " << _msg);
// First call plugin
if (appl::textPluginManager::onReceiveMessage(*this, _msg) == true) {
markToRedraw();
@ -614,15 +635,46 @@ void appl::TextViewer::setFontName(const std::string& _fontName) {
m_displayText.setFontName(_fontName);
}
void appl::TextViewer::updateScrolling(void) {
if (m_buffer == NULL) {
return;
}
vec2 realCursorPosition(0,0);
uint32_t lineId = m_buffer->getCursorLinesId();
m_displayText.clear();
m_displayText.forceLineReturn();
float lineSize = -m_displayText.getPos().y();
for (size_t iii=0; iii<lineId; ++iii) {
m_displayText.forceLineReturn();
}
realCursorPosition.setY(-m_displayText.getPos().y());
realCursorPosition.setX(getScreenSize(m_buffer->getStartLine(m_buffer->cursor())+1, m_buffer->cursor())-10);
APPL_VERBOSE("position=" << realCursorPosition << " scrool=" << m_originScrooled << " size" << m_size);
if (realCursorPosition.x() < m_originScrooled.x()-lineSize*2.0f) {
m_originScrooled.setX(realCursorPosition.x()-lineSize*2.0f);
} else if (realCursorPosition.x() > m_originScrooled.x()+m_size.x()-lineSize*2.0f-10) {
m_originScrooled.setX(realCursorPosition.x()-m_size.x()+lineSize*2.0f+10);
}
if (realCursorPosition.y() < m_originScrooled.y()+lineSize*2.0f) {
m_originScrooled.setY(realCursorPosition.y()-lineSize*2.0f);
} else if (realCursorPosition.y() > m_originScrooled.y()+m_size.y()-lineSize*2.0f) {
m_originScrooled.setY(realCursorPosition.y()-m_size.y()+lineSize*2.0f);
}
realCursorPosition.setMin(vec2(0,0));
}
bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
if (m_buffer == NULL) {
return false;
}
markToRedraw();
if (appl::textPluginManager::onCursorMove(*this, _pos) == true) {
updateScrolling();
return true;
}
m_buffer->moveCursor((esize_t)_pos);
updateScrolling();
return true;
}

View File

@ -68,8 +68,11 @@ namespace appl {
private:
bool m_insertMode; //!< the insert mode is enable
public:
public:
/**
* @brief Update the scrolling position from the cursor position,
* it might be be all time in the display screen.
*/
void updateScrolling(void);
// TODO : Doc : write data on buffer
bool moveCursor(const appl::Buffer::Iterator& _pos);
bool write(const std::string& _data);

View File

@ -18,6 +18,7 @@ static const char* s_closeDone = "close-done";
appl::WorkerCloseAllFile::WorkerCloseAllFile(void) :
m_worker(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerCloseAllFile");
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();

View File

@ -26,6 +26,7 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
m_buffer(NULL),
m_worker(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerCloseFile");
addEventId(eventCloseDone);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();

View File

@ -18,6 +18,7 @@ static const char* s_saveAsDone = "save-as-done";
appl::WorkerSaveAllFile::WorkerSaveAllFile(void) :
m_worker(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerSaveAllFile");
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();

View File

@ -21,6 +21,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force
m_bufferName(_bufferName),
m_chooser(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerSaveFile");
addEventId(eventSaveDone);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();

View File

@ -155,8 +155,8 @@ void appl::Highlight::display(void) {
}
}
/* TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas trègrave...
* Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
/* TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas très grave...
* Il suffirait juste de suprimer celui d'avant si il n'est pas terminer...
*/
void appl::Highlight::parse(int32_t start,
int32_t stop,

View File

@ -53,19 +53,20 @@ bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,
// un-indent
data.insert(0, 1, etk::UChar::Return);
for (esize_t iii=1; iii<data.size(); ++iii) {
if (data[iii-1] == etk::UChar::Return) {
if(data[iii] == etk::UChar::Tabulation) {
data.erase(iii);
} else if(data[iii] == etk::UChar::Space) {
for (esize_t jjj=0; jjj<m_tabDist && jjj+iii<data.size() ; jjj++) {
if(data[iii] == etk::UChar::Space) {
data.erase(iii);
} else if(data[iii] == etk::UChar::Tabulation) {
data.erase(iii);
break;
} else {
break;
}
if (data[iii-1] != etk::UChar::Return) {
continue;
}
if(data[iii] == etk::UChar::Tabulation) {
data.erase(iii);
} else if(data[iii] == etk::UChar::Space) {
for (esize_t jjj=0; jjj<m_tabDist && jjj+iii<data.size() ; jjj++) {
if(data[iii] == etk::UChar::Space) {
data.erase(iii);
} else if(data[iii] == etk::UChar::Tabulation) {
data.erase(iii);
break;
} else {
break;
}
}
}
@ -75,14 +76,15 @@ bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,
// indent
data.insert(0, 1, etk::UChar::Return);
for (esize_t iii=1; iii<data.size(); iii++) {
if (data[iii-1] == etk::UChar::Return) {
if (true == _event.getSpecialKey().isSetCtrl() ) {
data.insert(iii, 1, etk::UChar::Space);
} else if (true == m_useTabs) {
data.insert(iii, 1, etk::UChar::Tabulation);
} else {
data.insert(iii, m_tabDist, etk::UChar::Space);
}
if (data[iii-1] != etk::UChar::Return) {
continue;
}
if (true == _event.getSpecialKey().isSetCtrl() ) {
data.insert(iii, 1, etk::UChar::Space);
} else if (true == m_useTabs) {
data.insert(iii, 1, etk::UChar::Tabulation);
} else {
data.insert(iii, m_tabDist, etk::UChar::Space);
}
}
data.erase(0);

View File

@ -33,8 +33,6 @@ extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search";
extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace";
extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find";
extern const char* const ednMsgGuiChangeColor = "edn-Msg-Gui-ChangeColor";
extern const char* const ednMsgGuiChangeCharset = "edn-Msg-Gui-ChangeCharset";
extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces";
extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine";
@ -61,5 +59,6 @@ extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";
extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file";
extern const char* const appl::MsgSelectChange = "edn-msg-select-change";
extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change";
extern const char* const appl::MsgNameGuiChangeColor = "edn-Msg-Gui-Change-color";

View File

@ -33,8 +33,6 @@
extern const char* const ednMsgGuiReplace; // data : "Normal" "All"
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
extern const char* const ednMsgGuiChangeCharset; // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable"
extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable"
@ -61,6 +59,7 @@ namespace appl {
extern const char* const MsgSelectNewFile; // data : "buffer/name"
extern const char* const MsgSelectChange; // data : ""
extern const char* const MsgNameChange; // data : ""
extern const char* const MsgNameGuiChangeColor; // data : "Black" "White"
};
#endif

View File

@ -57,59 +57,12 @@ etk::CCout& operator <<(etk::CCout& _os, const std::u32string& _obj) {
return _os;
}
etk::CCout& operator <<(etk::CCout& _os, const std::regex_error& _e) {
int32_t val = _e.code();
switch(val) {
case std::regex_constants::error_collate:
_os << "{ error_collate = The expression contained an invalid collating element name.}";
break;
case std::regex_constants::error_ctype:
_os << "{ error_ctype = The expression contained an invalid character class name.}";
break;
case std::regex_constants::error_escape:
_os << "{ error_escape = The expression contained an invalid escaped character, or a trailing escape.}";
break;
case std::regex_constants::error_backref:
_os << "{ error_backref = The expression contained an invalid back reference.}";
break;
case std::regex_constants::error_brack:
_os << "{ error_brack = The expression contained mismatched brackets ([ and ]).}";
break;
case std::regex_constants::error_paren:
_os << "{ error_paren = The expression contained mismatched parentheses (( and )).}";
break;
case std::regex_constants::error_brace:
_os << "{ error_brace = The expression contained mismatched braces ({ and }).}";
break;
case std::regex_constants::error_badbrace:
_os << "{ error_badbrace = The expression contained an invalid range between braces ({ and }).}";
break;
case std::regex_constants::error_range:
_os << "{ error_range = The expression contained an invalid character range.}";
break;
case std::regex_constants::error_space:
_os << "{ error_space = There was insufficient memory to convert the expression into a finite state machine.}";
break;
case std::regex_constants::error_badrepeat:
_os << "{ error_badrepeat = The expression contained a repeat specifier (one of *?+{) that was not preceded by a valid regular expression.}";
break;
case std::regex_constants::error_complexity:
_os << "{ error_complexity = The complexity of an attempted match against a regular expression exceeded a pre-set level.}";
break;
case std::regex_constants::error_stack:
_os << "{ error_stack = There was insufficient memory to determine whether the regular expression could match the specified character sequence.}";
break;
}
return _os;
}
/**
* @brief main application function initialisation
*/
bool APP_Init(ewol::eContext& _context) {
APPL_INFO(" == > init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
//etk::theme::setName("COLOR", "colorBlack/");
etk::theme::setName("COLOR", "colorWhite/");
// TODO : remove this : Move if in the windows properties

View File

@ -77,7 +77,7 @@ def Create(target):
myModule.CopyFolder('../data/languages/python/*.xml','languages/python/')
myModule.CopyFolder('../data/theme/default/*.svg','theme/default/')
myModule.CopyFolder('../data/theme/colorWhite/*.json','theme/colorWhite/')
myModule.CopyFolder('../data/theme/colorClack/*.json','theme/colorBlack/')
myModule.CopyFolder('../data/theme/colorBlack/*.json','theme/colorBlack/')
myModule.AddPath(lutinTools.GetCurrentPath(__file__))
myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl")