diff --git a/data/theme/colorBlack/textViewer.json b/data/theme/colorBlack/textViewer.json index 2469fc1..f08a525 100644 --- a/data/theme/colorBlack/textViewer.json +++ b/data/theme/colorBlack/textViewer.json @@ -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"}, diff --git a/data/theme/colorWhite/textViewer.json b/data/theme/colorWhite/textViewer.json index e32baf6..dd0b0eb 100644 --- a/data/theme/colorWhite/textViewer.json +++ b/data/theme/colorWhite/textViewer.json @@ -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"}, diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index a0fdc0e..f955b5d 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -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; +} \ No newline at end of file diff --git a/sources/appl/Buffer.h b/sources/appl/Buffer.h index 2b32b90..2ef7034 100644 --- a/sources/appl/Buffer.h +++ b/sources/appl/Buffer.h @@ -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 diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 680ec4c..3682d7f 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -18,7 +18,7 @@ appl::BufferManager::BufferManager(void) : ewol::Resource("???BufferManager???"), m_bufferSelected(NULL) { - + addObjectType("appl::BufferManager"); } appl::BufferManager::~BufferManager(void) { diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index a1ab199..2b1dbc8 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -40,6 +40,7 @@ static void SortElementList(std::vector& _list) { } BufferView::BufferView(void) { + addObjectType("appl::BufferView"); setCanHaveFocus(true); registerMultiCast(ednMsgBufferListChange); registerMultiCast(ednMsgBufferState); diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 5bcfdb9..277d3d7 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -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(); diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp index 9fd5118..abc7b30 100644 --- a/sources/appl/Gui/Search.cpp +++ b/sources/appl/Gui/Search.cpp @@ -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 : /* diff --git a/sources/appl/Gui/TagFileList.cpp b/sources/appl/Gui/TagFileList.cpp index 7a368b2..a72f0b5 100644 --- a/sources/appl/Gui/TagFileList.cpp +++ b/sources/appl/Gui/TagFileList.cpp @@ -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); diff --git a/sources/appl/Gui/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index 2ec2e65..fc39cd7 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -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); diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index aeb9d31..7720662 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -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) { iiisetSelectMode(_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 : "); - //TextDMoveUp(m_displaySize.y()); + moveCursorUp(15); // TODO : Set the real number of line ... break; case ewol::keyEvent::keyboardPageDown: //APPL_INFO("keyEvent : "); - //TextDMoveDown(m_displaySize.y()); + moveCursorDown(15); // TODO : Set the real number of line ... break; case ewol::keyEvent::keyboardStart: //APPL_INFO("keyEvent : "); @@ -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; iiigetStartLine(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; } diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index e4264d2..8846938 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -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); diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index 76a8cea..43ff33b 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -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(); diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index d36081f..33f420f 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -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(); diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 0f26263..05d8dab 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -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(); diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index f37dd0f..e33c86d 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -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(); diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp index 8a6332a..a4f5abb 100644 --- a/sources/appl/Highlight.cpp +++ b/sources/appl/Highlight.cpp @@ -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, diff --git a/sources/appl/TextPluginMultiLineTab.cpp b/sources/appl/TextPluginMultiLineTab.cpp index 357e795..2885d61 100644 --- a/sources/appl/TextPluginMultiLineTab.cpp +++ b/sources/appl/TextPluginMultiLineTab.cpp @@ -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 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 diff --git a/sources/lutin_edn.py b/sources/lutin_edn.py index d982f4c..f759530 100755 --- a/sources/lutin_edn.py +++ b/sources/lutin_edn.py @@ -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")