Add shortcut and management of move event in codeViewer

This commit is contained in:
Edouard Dupin 2012-01-17 15:35:34 +01:00
parent 43d8aaef48
commit 6f6b0a6f7f
7 changed files with 37 additions and 104 deletions

View File

@ -251,7 +251,7 @@ void Buffer::ForceReDraw(bool allElement)
void Buffer::cursorMove(int32_t gtkKey)
void Buffer::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
{
// nothing to do
}

View File

@ -85,7 +85,7 @@ class Buffer {
virtual int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY);
virtual void ForceReDraw(bool allElement);
virtual void AddChar(char * UTF8data);
virtual void cursorMove(int32_t gtkKey);
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
virtual void MouseEvent(int32_t width, int32_t height);
virtual void MouseEventDouble(void);

View File

@ -856,7 +856,7 @@ bool BufferText::TextDMoveDown(int32_t offset)
* @return ---
*
*/
void BufferText::cursorMove(int32_t gtkKey)
void BufferText::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
{
bool needUpdatePosition = true;
// check selection event ...
@ -871,73 +871,41 @@ void BufferText::cursorMove(int32_t gtkKey)
SelectionEnd();
}
*/
switch(gtkKey) {
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Left:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Left:
# endif
switch(moveTypeEvent) {
case ewol::EVENT_KB_MOVE_TYPE_LEFT:
//EDN_INFO("keyEvent : <LEFT>");
if (m_cursorPos > 0) {
SetInsertPosition(m_cursorPos - 1);
}
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Right:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Right:
# endif
case ewol::EVENT_KB_MOVE_TYPE_RIGHT:
//EDN_INFO("keyEvent : <RIGHT>");
if (m_cursorPos < m_EdnBuf.Size() ) {
SetInsertPosition(m_cursorPos + 1);
}
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Up:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Up:
# endif
case ewol::EVENT_KB_MOVE_TYPE_UP:
//EDN_INFO("keyEvent : <UP>");
TextDMoveUp(1);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Down:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Down:
# endif
case ewol::EVENT_KB_MOVE_TYPE_DOWN:
//EDN_INFO("keyEvent : <DOWN>");
// check if we have enought line ...
TextDMoveDown(1);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Page_Up:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Page_Up:
# endif
case ewol::EVENT_KB_MOVE_TYPE_PAGE_UP:
//EDN_INFO("keyEvent : <PAGE-UP>");
TextDMoveUp(m_displaySize.y);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Page_Down:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Page_Down:
# endif
case ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN:
//EDN_INFO("keyEvent : <PAGE-DOWN>");
TextDMoveDown(m_displaySize.y);
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_Begin:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_Begin:
# endif
case ewol::EVENT_KB_MOVE_TYPE_START:
//EDN_INFO("keyEvent : <Start of line>");
SetInsertPosition(m_EdnBuf.StartOfLine(m_cursorPos) );
break;
# ifdef USE_GTK_VERSION_3_0
case GDK_KEY_End:
# elif defined( USE_GTK_VERSION_2_0)
case GDK_End:
# endif
case ewol::EVENT_KB_MOVE_TYPE_END:
//EDN_INFO("keyEvent : <End of line>");
SetInsertPosition(m_EdnBuf.EndOfLine(m_cursorPos) );
break;

View File

@ -49,7 +49,7 @@ class BufferText : public Buffer {
int32_t Display(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY);
void ForceReDraw(bool allElement);
void AddChar(char * UTF8data);
void cursorMove(int32_t gtkKey);
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
void MouseSelectFromCursorTo(int32_t width, int32_t height);
void MouseEvent(int32_t width, int32_t height);
void MouseEventDouble(void);

View File

@ -85,7 +85,7 @@ void CodeView::OnRegenerateDisplay(void)
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
// generate the objects :
m_bufferID = 0;
//m_bufferID = 0;
m_bufferManager->Get(m_bufferID)->Display(myOObjectText, myOObjectsColored, m_size.x, m_size.y);
// clean the object list ...
@ -117,15 +117,26 @@ bool CodeView::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE])
{
EWOL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << typeEvent);
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
m_bufferManager->Get(m_bufferID)->AddChar(UTF8_data);
OnRegenerateDisplay();
}
return false;
return true;
}
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
{
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
m_bufferManager->Get(m_bufferID)->cursorMove(moveTypeEvent);
OnRegenerateDisplay();
}
return true;
}
bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{
x -= m_origin.x;
@ -231,7 +242,7 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
switch (id)
{
case EDN_MSG__CURRENT_CHANGE_BUFFER_ID:
//EDN_INFO("Select a new Buffer ... " << dataID);
EDN_INFO("Select a new Buffer ... " << dataID);
m_bufferID = dataID;
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
// request the display of the curent Editor
@ -317,61 +328,21 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
// Redraw all the display ... Done under ...
break;
}
OnRegenerateDisplay();
// Force redraw of the widget
//gtk_widget_queue_draw(m_widget);
OnRegenerateDisplay();
}
#ifdef SDFGSDFGSDFG_FGSDFG_SDF_G___DSFG_SD_FG__SD_F_G_SD_FG
gint CodeView::CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data)
void CodeView::OnGetFocus(void)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
self->SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, self->m_bufferID);
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
EDN_INFO("Focus - In");
return FALSE;
}
gint CodeView::CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data)
void CodeView::OnLostFocus(void)
{
EDN_INFO("Focus - out");
return FALSE;
}
gint CodeView::CB_keyboardEvent(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
CodeView * self = reinterpret_cast<CodeView*>(data);
char Utf8Out[10];
bool controlKey;
bool moveKey;
int32_t key;
// Convert input key :
ConvertInput(event, Utf8Out, controlKey, moveKey, key);
if(event->type == GDK_KEY_PRESS) {
if(false==controlKey) {
self->m_bufferManager->Get(self->m_bufferID)->AddChar(Utf8Out);
gtk_widget_queue_draw( widget );
} else if (true == moveKey) {
self->m_bufferManager->Get(self->m_bufferID)->cursorMove(key);
gtk_widget_queue_draw( widget );
}
}
return true;
}
#endif

View File

@ -56,6 +56,9 @@ class CodeView :public ewol::Widget, public MsgBroadcast
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent);
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
};

View File

@ -120,13 +120,13 @@ void APP_Init(int argc, char *argv[])
cCurrentPath[FILENAME_MAX - 1] = '\0';
//EDN_INFO("The current working directory is " << cCurrentPath);
basicWindows = new MainWindows();
// add files
EDN_INFO("show list of files : ");
for( int32_t i=1 ; i<argc; i++) {
EDN_INFO("need load file : \"" << argv[i] << "\"" );
etk::File myfile((char *)argv[i], etk::FILE_TYPE_DIRECT);
if (false == myBufferManager->Exist(myfile) ) {
int32_t idBuffOpened = myBufferManager->Open(myfile);
if (1==i) {
@ -134,15 +134,6 @@ void APP_Init(int argc, char *argv[])
}
}
}
{
EDN_INFO("need load file : \"" << "avancement.boo" << "\"" );
etk::File myfile("RegExp.cpp", etk::FILE_TYPE_DIRECT);
if (false == myBufferManager->Exist(myfile) ) {
int32_t idBuffOpened = myBufferManager->Open(myfile);
MsgBroadcastCore::getInstance()->SendMessage(NULL, EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idBuffOpened);
}
}
basicWindows = new MainWindows();
if (NULL == basicWindows) {
EDN_ERROR("Can not allocate the basic windows");
ewol::Stop();