2011-07-20 10:33:24 +02:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
* @file CodeView.cpp
|
|
|
|
* @brief Editeur De N'ours : Code Viewer Widget
|
|
|
|
* This is an abstraction
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @date 05/01/2011
|
|
|
|
* @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.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2012-01-11 15:26:53 +01:00
|
|
|
#include <CodeView.h>
|
2011-07-20 10:33:24 +02:00
|
|
|
|
2012-04-23 10:15:43 +02:00
|
|
|
#include <appl/Debug.h>
|
2012-04-24 09:42:14 +02:00
|
|
|
#include <appl/global.h>
|
2012-01-11 15:26:53 +01:00
|
|
|
#include <CodeView.h>
|
|
|
|
#include <BufferManager.h>
|
|
|
|
#include <ColorizeManager.h>
|
2012-04-04 18:18:27 +02:00
|
|
|
#include <ewol/ClipBoard.h>
|
2012-01-11 15:26:53 +01:00
|
|
|
#include <SearchData.h>
|
2011-07-20 10:33:24 +02:00
|
|
|
|
2012-01-15 16:09:32 +01:00
|
|
|
#include <ewol/WidgetManager.h>
|
2012-02-28 18:22:49 +01:00
|
|
|
#include <ewol/EObject.h>
|
2012-01-13 13:06:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
#undef __class__
|
2012-03-14 09:26:14 +01:00
|
|
|
#define __class__ "CodeView"
|
2012-01-13 13:06:15 +01:00
|
|
|
|
|
|
|
|
2012-03-14 09:26:14 +01:00
|
|
|
extern const char * const TYPE_EOBJECT_EDN_CODE_VIEW = "CodeView";
|
|
|
|
|
2012-01-31 18:26:04 +01:00
|
|
|
CodeView::CodeView(void)
|
2012-01-13 13:06:15 +01:00
|
|
|
{
|
|
|
|
m_label = "CodeView is disable ...";
|
2012-02-03 18:14:45 +01:00
|
|
|
m_fontNormal = -1;
|
|
|
|
m_fontBold = -1;
|
|
|
|
m_fontItalic = -1;
|
|
|
|
m_fontBoldItalic = -1;
|
|
|
|
m_fontSize = 15;
|
|
|
|
|
2012-01-13 13:06:15 +01:00
|
|
|
m_bufferID = -1;
|
|
|
|
m_buttunOneSelected = false;
|
|
|
|
|
2012-04-23 17:05:56 +02:00
|
|
|
m_textColorFg = etk::color::color_Black;
|
2012-01-13 13:06:15 +01:00
|
|
|
|
2012-04-23 17:05:56 +02:00
|
|
|
m_textColorBg = etk::color::color_Black;
|
2012-01-13 13:06:15 +01:00
|
|
|
m_textColorBg.alpha = 0.25;
|
|
|
|
SetCanHaveFocus(true);
|
2012-02-29 18:06:08 +01:00
|
|
|
RegisterMultiCast(ednMsgBufferId);
|
2012-04-04 18:18:27 +02:00
|
|
|
RegisterMultiCast(ednMsgGuiCopy);
|
|
|
|
RegisterMultiCast(ednMsgGuiPaste);
|
|
|
|
RegisterMultiCast(ednMsgGuiCut);
|
2012-04-16 09:16:43 +02:00
|
|
|
RegisterMultiCast(ednMsgGuiRedo);
|
|
|
|
RegisterMultiCast(ednMsgGuiUndo);
|
|
|
|
RegisterMultiCast(ednMsgGuiRm);
|
|
|
|
RegisterMultiCast(ednMsgGuiSelect);
|
2012-04-17 11:01:26 +02:00
|
|
|
RegisterMultiCast(ednMsgGuiChangeCharset);
|
2012-01-13 13:06:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeView::~CodeView(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-14 09:26:14 +01:00
|
|
|
/**
|
|
|
|
* @brief Check if the object has the specific type.
|
|
|
|
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
|
|
|
* @param[in] objectType type of the object we want to check
|
|
|
|
* @return true if the object is compatible, otherwise false
|
|
|
|
*/
|
|
|
|
bool CodeView::CheckObjectType(const char * const objectType)
|
|
|
|
{
|
|
|
|
if (NULL == objectType) {
|
2012-04-23 17:05:56 +02:00
|
|
|
APPL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_CODE_VIEW << "\" != NULL(pointer) ");
|
2012-03-14 09:26:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (objectType == TYPE_EOBJECT_EDN_CODE_VIEW) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if(true == ewol::WidgetScrooled::CheckObjectType(objectType)) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-23 17:05:56 +02:00
|
|
|
APPL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_CODE_VIEW << "\" != \"" << objectType << "\"");
|
2012-03-14 09:26:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the current Object type of the EObject
|
|
|
|
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
|
|
|
* @param[in] objectType type description
|
|
|
|
* @return true if the object is compatible, otherwise false
|
|
|
|
*/
|
|
|
|
const char * const CodeView::GetObjectType(void)
|
|
|
|
{
|
|
|
|
return TYPE_EOBJECT_EDN_CODE_VIEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-13 13:06:15 +01:00
|
|
|
bool CodeView::CalculateMinSize(void)
|
|
|
|
{
|
|
|
|
m_minSize.x = 50;
|
|
|
|
m_minSize.y = 50;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-02-07 18:04:15 +01:00
|
|
|
void CodeView::CalculateMaxSize(void)
|
|
|
|
{
|
2012-02-10 18:20:03 +01:00
|
|
|
m_maxSize.x = 2048;
|
2012-02-07 18:04:15 +01:00
|
|
|
int32_t letterHeight = ewol::GetHeight(m_fontNormal);
|
2012-02-20 20:30:26 +01:00
|
|
|
m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight;
|
2012-02-07 18:04:15 +01:00
|
|
|
}
|
2012-02-19 15:48:08 +01:00
|
|
|
|
2012-02-07 18:04:15 +01:00
|
|
|
|
2012-03-09 18:08:08 +01:00
|
|
|
void CodeView::OnDraw(void)
|
2012-02-18 15:56:00 +01:00
|
|
|
{
|
|
|
|
m_OObjectsColored[ m_currentDrawId].Draw();
|
|
|
|
m_OObjectTextNormal[ m_currentDrawId].Draw();
|
|
|
|
m_OObjectTextBold[ m_currentDrawId].Draw();
|
|
|
|
m_OObjectTextItalic[ m_currentDrawId].Draw();
|
|
|
|
m_OObjectTextBoldItalic[m_currentDrawId].Draw();
|
|
|
|
}
|
2012-01-13 13:06:15 +01:00
|
|
|
|
|
|
|
void CodeView::OnRegenerateDisplay(void)
|
|
|
|
{
|
2012-02-07 18:04:15 +01:00
|
|
|
if (true == NeedRedraw()) {
|
2012-02-18 11:50:29 +01:00
|
|
|
int64_t startTime = GetCurrentTime();
|
|
|
|
|
2012-02-07 18:04:15 +01:00
|
|
|
// For the scrooling windows
|
|
|
|
CalculateMaxSize();
|
|
|
|
|
2012-02-18 15:56:00 +01:00
|
|
|
// clean internal elements ...
|
|
|
|
m_OObjectTextNormal[ m_currentCreateId].SetFontID(m_fontNormal);
|
|
|
|
m_OObjectTextBold[ m_currentCreateId].SetFontID(m_fontBold);
|
|
|
|
m_OObjectTextItalic[ m_currentCreateId].SetFontID(m_fontItalic);
|
|
|
|
m_OObjectTextBoldItalic[m_currentCreateId].SetFontID(m_fontBoldItalic);
|
|
|
|
|
|
|
|
m_OObjectTextNormal[ m_currentCreateId].Clear();
|
|
|
|
m_OObjectTextBold[ m_currentCreateId].Clear();
|
|
|
|
m_OObjectTextItalic[ m_currentCreateId].Clear();
|
|
|
|
m_OObjectTextBoldItalic[m_currentCreateId].Clear();
|
|
|
|
m_OObjectsColored[ m_currentCreateId].Clear();
|
|
|
|
|
2012-04-24 13:17:04 +02:00
|
|
|
if (true == BufferManager::Get(m_bufferID)->NeedToUpdateDisplayPosition() ) {
|
|
|
|
coord2D_ts borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
|
|
|
|
bool centerRequested = false;
|
|
|
|
coord2D_ts currentPosition = BufferManager::Get(m_bufferID)->GetPosition(m_OObjectTextNormal[m_currentCreateId].GetFontID(), centerRequested);
|
|
|
|
SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
|
|
|
|
} // else : nothing to do ...
|
2012-02-07 18:04:15 +01:00
|
|
|
|
|
|
|
// generate the objects :
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->Display(m_OObjectTextNormal[m_currentCreateId],
|
2012-02-29 18:06:08 +01:00
|
|
|
m_OObjectTextBold[m_currentCreateId],
|
|
|
|
m_OObjectTextItalic[m_currentCreateId],
|
|
|
|
m_OObjectTextBoldItalic[m_currentCreateId],
|
|
|
|
m_OObjectsColored[m_currentCreateId],
|
|
|
|
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
|
2012-04-24 13:36:25 +02:00
|
|
|
// set the current size of the windows
|
|
|
|
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
|
2012-02-07 18:04:15 +01:00
|
|
|
|
2012-02-18 11:50:29 +01:00
|
|
|
int64_t stopTime = GetCurrentTime();
|
2012-04-24 13:17:04 +02:00
|
|
|
APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " micro-s");
|
2012-02-18 11:50:29 +01:00
|
|
|
|
2012-02-07 18:04:15 +01:00
|
|
|
// call the herited class...
|
|
|
|
WidgetScrooled::OnRegenerateDisplay();
|
2012-02-18 15:56:00 +01:00
|
|
|
m_needFlipFlop = true;
|
2012-02-07 18:04:15 +01:00
|
|
|
}
|
2012-01-13 13:06:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-13 18:03:09 +01:00
|
|
|
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
|
2012-01-13 13:06:15 +01:00
|
|
|
{
|
2012-04-23 10:15:43 +02:00
|
|
|
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
|
2012-01-15 16:09:32 +01:00
|
|
|
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->AddChar(unicodeData);
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-13 13:06:15 +01:00
|
|
|
}
|
2012-01-17 15:35:34 +01:00
|
|
|
return true;
|
2012-01-13 13:06:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-17 15:35:34 +01:00
|
|
|
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
|
|
|
|
{
|
|
|
|
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->cursorMove(moveTypeEvent);
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-17 15:35:34 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-09 18:08:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Event on an input of this Widget
|
|
|
|
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
|
|
|
|
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
|
|
|
|
* @param[in] pos Absolute position of the event
|
|
|
|
* @return true the event is used
|
|
|
|
* @return false the event is not used
|
|
|
|
*/
|
|
|
|
bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-03-09 18:08:08 +01:00
|
|
|
coord2D_ts relativePos = RelativePosition(pos);
|
2012-02-23 13:43:57 +01:00
|
|
|
if (m_bufferID < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, pos)) {
|
2012-02-06 17:59:48 +01:00
|
|
|
ewol::widgetManager::FocusKeep(this);
|
|
|
|
// nothing to do ... done on upper widet ...
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-15 16:09:32 +01:00
|
|
|
if (1 == IdInput) {
|
2012-02-11 11:18:27 +01:00
|
|
|
#ifndef __MODE__Touch
|
|
|
|
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
|
|
|
m_buttunOneSelected = true;
|
|
|
|
ewol::widgetManager::FocusKeep(this);
|
2012-03-09 18:08:08 +01:00
|
|
|
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
2012-02-11 11:18:27 +01:00
|
|
|
MarkToReedraw();
|
|
|
|
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
|
|
|
m_buttunOneSelected = false;
|
2012-04-04 18:18:27 +02:00
|
|
|
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
|
2012-02-11 11:18:27 +01:00
|
|
|
MarkToReedraw();
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
|
|
|
#ifdef __MODE__Touch
|
|
|
|
ewol::widgetManager::FocusKeep(this);
|
2012-03-09 18:08:08 +01:00
|
|
|
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
2012-02-11 11:18:27 +01:00
|
|
|
MarkToReedraw();
|
|
|
|
#else
|
|
|
|
// nothing to do ...
|
|
|
|
#endif
|
2012-01-15 15:42:01 +01:00
|
|
|
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->MouseEventDouble();
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-15 15:42:01 +01:00
|
|
|
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->MouseEventTriple();
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-15 16:09:32 +01:00
|
|
|
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
|
|
|
if (true == m_buttunOneSelected) {
|
|
|
|
int xxx, yyy;
|
2012-03-09 18:08:08 +01:00
|
|
|
xxx = relativePos.x;
|
|
|
|
yyy = relativePos.y;
|
2012-01-15 16:09:32 +01:00
|
|
|
if (xxx<0) {
|
|
|
|
xxx = 0;
|
|
|
|
}
|
|
|
|
if (yyy<0) {
|
|
|
|
yyy = 0;
|
|
|
|
}
|
2012-04-23 10:15:43 +02:00
|
|
|
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
|
2012-04-17 11:01:26 +02:00
|
|
|
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(m_fontNormal, xxx+m_originScrooled.x, yyy+m_originScrooled.y);
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-15 16:09:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (2 == IdInput) {
|
|
|
|
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
2012-03-09 18:08:08 +01:00
|
|
|
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
2012-04-04 18:18:27 +02:00
|
|
|
BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_SELECTION);
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2012-01-15 16:09:32 +01:00
|
|
|
ewol::widgetManager::FocusKeep(this);
|
2012-01-15 15:42:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-29 18:06:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Receive a message from an other EObject with a specific eventId and data
|
|
|
|
* @param[in] CallerObject Pointer on the EObject that information came from
|
|
|
|
* @param[in] eventId Message registered by this class
|
|
|
|
* @param[in] data Data registered by this class
|
|
|
|
* @return ---
|
|
|
|
*/
|
|
|
|
void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-29 18:06:08 +01:00
|
|
|
ewol::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
|
2012-01-31 18:26:04 +01:00
|
|
|
|
2012-02-29 18:06:08 +01:00
|
|
|
if(eventId == ednMsgBufferId) {
|
2012-02-03 18:14:45 +01:00
|
|
|
int32_t bufferID = 0;
|
2012-02-29 18:06:08 +01:00
|
|
|
sscanf(data.Utf8Data(), "%d", &bufferID);
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_INFO("Select a new Buffer ... " << bufferID);
|
2012-02-03 18:14:45 +01:00
|
|
|
m_bufferID = bufferID;
|
|
|
|
// TODO : need to update the state of the file and the filenames ...
|
2012-04-04 18:18:27 +02:00
|
|
|
} else if (eventId == ednMsgGuiCopy) {
|
|
|
|
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_STD);
|
|
|
|
} else if (eventId == ednMsgGuiCut) {
|
|
|
|
BufferManager::Get(m_bufferID)->Cut(ewol::clipBoard::CLIPBOARD_STD);
|
|
|
|
} else if (eventId == ednMsgGuiPaste) {
|
|
|
|
BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_STD);
|
2012-04-16 09:16:43 +02:00
|
|
|
} else if (eventId == ednMsgGuiUndo) {
|
|
|
|
BufferManager::Get(m_bufferID)->Undo();
|
|
|
|
} else if (eventId == ednMsgGuiRedo) {
|
|
|
|
BufferManager::Get(m_bufferID)->Redo();
|
|
|
|
} else if (eventId == ednMsgGuiRm) {
|
|
|
|
// data : "Word" "Line" "Paragraph"
|
|
|
|
if (data == "Word") {
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
2012-04-16 09:16:43 +02:00
|
|
|
} else if (data == "Line") {
|
|
|
|
BufferManager::Get(m_bufferID)->RemoveLine();
|
|
|
|
} else if (data == "Paragraph") {
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
2012-04-16 09:16:43 +02:00
|
|
|
} else {
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
2012-04-16 09:16:43 +02:00
|
|
|
}
|
|
|
|
} else if (eventId == ednMsgGuiSelect) {
|
|
|
|
// data : "ALL" "NONE"
|
|
|
|
if (data == "ALL") {
|
|
|
|
BufferManager::Get(m_bufferID)->SelectAll();
|
|
|
|
} else if (data == "NONE") {
|
|
|
|
BufferManager::Get(m_bufferID)->SelectNone();
|
|
|
|
} else {
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
2012-04-16 09:16:43 +02:00
|
|
|
}
|
2012-04-17 11:01:26 +02:00
|
|
|
} else if (eventId == ednMsgGuiChangeCharset) {
|
|
|
|
// data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
|
|
|
|
if (data == "UTF-8") {
|
|
|
|
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_UTF8);
|
|
|
|
} else if (data == "ISO-8859-1") {
|
|
|
|
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_1);
|
|
|
|
} else if (data == "ISO-8859-15") {
|
|
|
|
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_15);
|
|
|
|
} else {
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
2012-04-17 11:01:26 +02:00
|
|
|
}
|
2012-02-03 18:14:45 +01:00
|
|
|
}
|
2012-01-31 18:26:04 +01:00
|
|
|
/*
|
2011-07-20 10:33:24 +02:00
|
|
|
switch (id)
|
|
|
|
{
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_FIND_PREVIOUS:
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-15 16:23:20 +01:00
|
|
|
etk::UString myDataString;
|
2011-07-20 10:33:24 +02:00
|
|
|
SearchData::GetSearch(myDataString);
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_FIND_NEXT:
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-15 16:23:20 +01:00
|
|
|
etk::UString myDataString;
|
2011-07-20 10:33:24 +02:00
|
|
|
SearchData::GetSearch(myDataString);
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_REPLACE:
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-15 16:23:20 +01:00
|
|
|
etk::UString myDataString;
|
2011-07-20 10:33:24 +02:00
|
|
|
SearchData::GetReplace(myDataString);
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_REPLACE_ALL:
|
2011-07-20 10:33:24 +02:00
|
|
|
break;
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_GOTO_LINE:
|
2011-07-20 10:33:24 +02:00
|
|
|
if (dataID<0) {
|
|
|
|
dataID = 0;
|
|
|
|
}
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->JumpAtLine(dataID);
|
2011-07-20 10:33:24 +02:00
|
|
|
break;
|
2012-04-23 10:15:43 +02:00
|
|
|
case APPL_MSG__CURRENT_SET_CHARSET:
|
2012-02-20 20:30:26 +01:00
|
|
|
BufferManager::Get(m_bufferID)->SetCharset((unicode::charset_te)dataID);
|
2011-07-20 10:33:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2012-01-31 18:26:04 +01:00
|
|
|
*/
|
2011-07-20 10:33:24 +02:00
|
|
|
// Force redraw of the widget
|
2012-02-06 17:59:48 +01:00
|
|
|
MarkToReedraw();
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-17 15:35:34 +01:00
|
|
|
void CodeView::OnGetFocus(void)
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-27 18:15:56 +01:00
|
|
|
/*
|
2012-02-09 17:20:52 +01:00
|
|
|
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
|
2012-02-27 18:15:56 +01:00
|
|
|
*/
|
2012-02-09 17:20:52 +01:00
|
|
|
ewol::KeyboardShow(ewol::KEYBOARD_MODE_CODE);
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_INFO("Focus - In");
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-17 15:35:34 +01:00
|
|
|
void CodeView::OnLostFocus(void)
|
2011-07-20 10:33:24 +02:00
|
|
|
{
|
2012-02-09 17:20:52 +01:00
|
|
|
ewol::KeyboardHide();
|
2012-04-23 10:15:43 +02:00
|
|
|
APPL_INFO("Focus - out");
|
2011-07-20 10:33:24 +02:00
|
|
|
}
|
|
|
|
|
2012-02-03 18:14:45 +01:00
|
|
|
void CodeView::SetFontSize(int32_t size)
|
|
|
|
{
|
|
|
|
m_fontSize = size;
|
2012-04-05 18:28:15 +02:00
|
|
|
SetScrollingSize(m_fontSize*3.0*1.46); // 1.46 is a magic nmber ...
|
2012-02-03 18:14:45 +01:00
|
|
|
}
|
|
|
|
|
2012-02-15 16:23:20 +01:00
|
|
|
void CodeView::SetFontNameNormal(etk::UString fontName)
|
2012-02-03 18:14:45 +01:00
|
|
|
{
|
|
|
|
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
|
|
|
if (fontID >= 0) {
|
|
|
|
m_fontNormal = fontID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-15 16:23:20 +01:00
|
|
|
void CodeView::SetFontNameBold(etk::UString fontName)
|
2012-02-03 18:14:45 +01:00
|
|
|
{
|
|
|
|
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
|
|
|
if (fontID >= 0) {
|
|
|
|
m_fontBold = fontID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-15 16:23:20 +01:00
|
|
|
void CodeView::SetFontNameItalic(etk::UString fontName)
|
2012-02-03 18:14:45 +01:00
|
|
|
{
|
|
|
|
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
|
|
|
if (fontID >= 0) {
|
|
|
|
m_fontItalic = fontID;
|
|
|
|
}
|
|
|
|
}
|
2011-07-20 10:33:24 +02:00
|
|
|
|
2012-02-15 16:23:20 +01:00
|
|
|
void CodeView::SetFontNameBoldItalic(etk::UString fontName)
|
2012-02-03 18:14:45 +01:00
|
|
|
{
|
|
|
|
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
|
|
|
if (fontID >= 0) {
|
|
|
|
m_fontBoldItalic = fontID;
|
|
|
|
}
|
|
|
|
}
|