115 Commits
0.3.9 ... 1.1.0

Author SHA1 Message Date
803e2dbc82 Update version tag : 1.1.0 2013-11-28 22:41:47 +01:00
c86a5d89a3 [DEBUG] tag creation error correction 2013-11-28 22:23:42 +01:00
bb0003170b [DEV] add a real stable tag 2013-11-28 21:56:35 +01:00
02c6e75822 [DEV] Update position on undo/redo & write char 2013-11-27 21:45:56 +01:00
14419a521b [DEV] correction of the insert cursor mode 2013-11-27 21:33:42 +01:00
b78455c8fd [DEBUG] Remove some unused element of c++11 in MacOs 2013-11-28 00:52:51 +01:00
357a8baa9a [DEV] add extra compilation flags & correct warning 2013-11-27 21:33:34 +01:00
cb20c0af2d [DEBUG] correction of the first char selection 2013-11-26 21:33:45 +01:00
48260131d3 [DEV] Add ctags jumping 2013-11-26 21:22:06 +01:00
cc5afe2d55 [DEV] debug history manager 2013-11-26 21:06:01 +01:00
4d999bbb67 [DEV] add ctags and select all plugin and correct the undo/redo plugin 2013-11-25 22:18:06 +01:00
b79578b7e1 [DEBUG] remove open folder 2013-11-25 21:20:13 +01:00
9c4d936d76 [DEBUG] Change the title name when rename and status change of a buffer 2013-11-25 21:09:23 +01:00
771a8826c4 [DEV] Reorder BufferView 2013-11-25 21:03:21 +01:00
b3ffe8c212 [DEBUG] Indentation error 2013-11-25 21:03:02 +01:00
aa05234752 [DEV] add std hl of c++ 2013-11-25 21:02:24 +01:00
d3440c153b [DEV] remove dependency of frend in the text viewer 2013-11-24 16:07:43 +01:00
157bd7bcd2 [DEV] add ctrl+w in plgin list (with no frend dependency 2013-11-24 15:27:57 +01:00
16bf6e7648 [DEBUG] correction of the mouse position adter TAB 2013-11-24 15:26:47 +01:00
60903845c1 [DEV] review all the search bar 2013-11-23 18:30:52 +01:00
a95a1e8033 [DEBUG] correction of the end cursor position 2013-11-23 12:25:42 +01:00
26d206caae [DEV] some display update 2013-11-22 21:48:05 +01:00
e15cb8e4b6 [DEV] many small correction 2013-11-21 21:56:22 +01:00
069c457407 [DEBUG] correction of the scrolling wrong position 2013-11-21 21:22:38 +01:00
4efed97130 [DEV] remember multiple last lene in a buffer when change it 2013-11-21 21:18:30 +01:00
0bef90462b [DEBUG] correction of the tabulation error 2013-11-21 21:13:54 +01:00
50579a93a0 [DEBUG] assertion correction 2013-11-20 21:57:00 +01:00
4ea4d0dc55 [DEV] first good vertion from many time... 2013-11-20 21:57:00 +01:00
872fde6bc2 [DEV] sava and close multiple file done 2013-11-19 21:43:43 +01:00
9ca83d1718 [DEV] multiple save and close start to work 2013-11-17 20:37:06 +01:00
e32253cd98 [DEV] start creating worker for display multiple saving 2013-11-15 23:42:00 +01:00
dc652a6237 [DEV] add control before closing buffer not saved... (not ended) 2013-11-14 23:44:55 +01:00
101f77dc3d [DEV] work with std::string 2013-11-14 21:57:10 +01:00
a5b44ae974 [DEV] integarate std x11 2013-11-11 20:20:25 +01:00
4731dae6e4 [DEV] add store 2013-11-07 21:08:57 +01:00
4693119e7d [DEV] test multiple display of one buffer 2013-10-30 21:16:38 +01:00
50c1830696 [DEV] buffer manager better work 2013-10-29 21:13:45 +01:00
7ddaa68bb0 [DEV] start rework buffer manager in resource 2013-10-28 21:47:51 +01:00
01692bdd13 [DEV] correct display with highlight ==> maybe rework the highlight 2013-10-27 20:36:54 +01:00
4d35830559 [DEV] add highlight parsing file 2013-10-27 11:34:45 +01:00
49649329eb [DEV] Add buffer iterator out of bounds control 2013-10-26 13:16:30 +02:00
925fed77f1 [DEV] update Debug in debug 2013-10-25 20:49:26 +02:00
8eb4aff266 [DEV] work on highlight 2013-10-25 22:12:34 +02:00
6f4a67b47b [DEV] glyph pattern might be ended 2013-10-24 21:09:58 +02:00
79b8f594d6 [DEV] think paintin glyph api 2013-10-24 07:46:24 +02:00
8c57b28d73 [DEV] start rework color and highlight 2013-10-23 21:19:30 +02:00
c8fd4183cd [DEV] add missing history plugin 2013-10-22 22:01:31 +02:00
c76f396526 [DEV] add indent one space by one space 2013-10-22 21:44:33 +02:00
29815eb46d [DEV] undo & redo implemented 2013-10-22 21:34:13 +02:00
4c9fb8a74e [DEV] start dev of smart indent 2013-10-21 22:11:16 +02:00
e6480b8cac [DEV] add scrolling and multiline indent module 2013-10-21 21:47:28 +02:00
4704eca027 [DEV] add plugin and rewrite to support the plugin 2013-10-20 18:14:22 +02:00
408a22015c [DEV] simplyfy accec of element with adding iterator 2013-10-18 22:23:52 +02:00
cf8a720924 [DEV] UniChar ==> UChar & Hach ==> Hash 2013-10-18 21:15:02 +02:00
16f78eaef2 [DEV] add copy/cut/paste in std clipboard 2013-10-18 21:01:11 +02:00
0b022d62fc [DEV] add replace of element when selection availlable 2013-10-17 22:23:11 +02:00
8e6d0cc379 [DEV] corect up and down line moving and selection double and triple 2013-10-17 21:57:31 +02:00
171014c86a [DEV] add mouse event 2013-10-16 21:55:45 +02:00
730f637695 [DEV] coding style review 2013-10-09 22:00:24 +02:00
d677075e16 [DEV] code style step 1 2013-10-07 22:04:21 +02:00
211c253116 [DEV] Add the replace mode 2013-09-30 22:32:36 +02:00
7643f5a736 [DEV] display element utf8 and up-down cursor 2013-09-30 00:08:52 +02:00
bd066da738 [DEV] move in the text view widget 2013-09-27 23:02:30 +02:00
1a56f4c49c [DEV] add element availlable ==> bug when adding special char 2013-09-26 22:16:40 +02:00
19d3750f01 [DEV] first display of the cursor 2013-09-26 22:15:39 +02:00
40bf24a095 [DEV] start rework buffer display 2013-09-19 22:23:31 +02:00
b98ee05d2a [DEV] add line at 80 char limitation and set tab at 8 char (not configurable for now) 2013-09-19 09:21:58 +02:00
c1ab16ec1f [DEV] add color at the /* TODO : */ 2013-09-17 17:48:04 +02:00
4d7f4d8531 [DEV] remove the end error 2013-09-02 21:06:50 +02:00
ad12b68ead [DEV] update to the new ewol system 2013-09-02 06:45:12 +02:00
b5371c4d13 [DEV] add json parsing 2013-08-01 23:22:58 +02:00
0240bced14 [DEV] update at the new color class 2013-07-09 15:18:53 +02:00
3747bffa2f [DEV] update last exml 2013-06-30 17:01:02 +02:00
1864f9aa75 [DEV] a little change in the exml lib 2013-06-28 22:13:21 +02:00
0a12bd17ed [DEV] add multiple font request 2013-06-27 21:40:48 +02:00
757a9a49ee [DEV] update for debian 2013-06-27 07:26:31 +02:00
6422d91883 [DEV] aupdate at exml api ==> tested and validate 2013-06-26 23:48:23 +02:00
24bb4f515c [DEV] start move to exml 2013-06-24 21:17:45 +02:00
86552172d7 [DEV] do not open folder like file (not open at all) 2013-06-12 22:58:11 +02:00
dcdfbe3647 [DEV] Save configuration of the user 2013-05-28 22:09:53 +02:00
421dc0c404 [DEV] revove dependency of the build date (use external lib) 2013-05-25 10:59:50 +02:00
9678d46cb1 [DISPLAY] english correction 2013-05-23 21:24:44 +02:00
1724955f67 [DEV] display code correction 2013-05-22 21:28:26 +02:00
543cd8ddf1 [DEV] editork work again like as previous 2013-05-21 09:50:19 +02:00
7b456f1cdb [DEV] change color of member 2013-05-21 09:11:50 +02:00
cd8b5772e9 Revert "[DEV] BROKEN-gitcc start dev of a naw mode of display for the Internal system"
This reverts commit 0633355169.
2013-05-21 09:11:14 +02:00
0633355169 [DEV] BROKEN-gitcc start dev of a naw mode of display for the Internal system 2013-05-14 23:20:17 +02:00
52ac167872 [DEV] update the system interface 2013-05-12 21:08:31 +02:00
b55be0aeca [DEV] change the input and entry event function 2013-05-08 12:13:49 +02:00
e325bffc5e [RM] remove some deprecated files 2013-04-26 22:49:49 +02:00
b47d6f359d [DEV] remove old maker ==> replace by lutin 2013-04-24 21:33:38 +02:00
7d3e8d4d26 [DEBUG] date correction in maker 2013-04-24 21:33:38 +02:00
e85a34c988 [DEV] change date and time in only date to prevent multiple rebuild in one day 2013-04-24 12:48:28 +02:00
9f7af89567 [DEV] add the package property ok 2013-04-23 21:44:49 +02:00
8c241ef106 [DEV] add the package properties of the edn package 2013-04-22 21:57:24 +02:00
73c2e6a547 [DEV] change build to lutin mode 2013-04-21 22:15:45 +02:00
c5b6519dc6 [DEV] build the soft with the new builder 2013-04-18 18:02:27 +02:00
df24216dac [DEV] First file compiled with new python maker 2013-04-18 01:56:40 +02:00
b8c819936e [DEV] add python parser and start work on the python makefile 2013-04-17 21:40:05 +02:00
91c1201f69 [DEV] mac : missing font 2013-04-16 22:41:03 +02:00
3aac9ab9a7 [DEV] seems to work not so bak with the new ewol rework 2013-04-15 21:12:13 +02:00
e6d078e0c9 [DEV] add capacity od C highlight 2013-04-15 09:11:18 +02:00
af417b44f0 [DEV] work better than previously but this is the start of rework 2013-04-14 13:58:59 +02:00
aabc92f309 [DEV] base rework 2013-04-10 22:04:54 +02:00
46969e15b1 [DEV] mac dev ... 2013-04-07 23:40:49 +02:00
e1d2c2a3c7 [DEV] adapte to the EWOL modification of Sizer and const string callback 2013-03-25 21:30:16 +01:00
4139e88a6c [DEV] update config 2013-03-11 21:10:19 +01:00
dd6f05540f (DEV) add MacOs config and makefile 2013-03-09 17:33:28 +01:00
d2f2afd129 update android config 2013-03-03 20:58:59 +01:00
e97f6a77d4 [DEV] find the init bug 2013-03-03 20:43:00 +01:00
e56ade0856 [dev] add element on the glsl highlight 2013-03-02 12:03:26 +01:00
ed462a3b36 [DEV] better init of vec 2/3 2013-03-01 09:14:53 +01:00
c767266dfe [DEV] update to the new vector 3d 2013-01-28 22:46:48 +01:00
4f09da0f0f [DEV] update configs 2013-01-18 22:13:44 +01:00
50addbecbb [DEV] add the icon on X11 system 2013-01-11 23:14:15 +01:00
131 changed files with 8921 additions and 8517 deletions

View File

@@ -1,57 +0,0 @@
#############################################################################"
# main makefile for a basic application
# this is minimal application main makefile
#############################################################################"
# Project name ==> generate the application name [a-z] <== make attention at the case this generate error on Android compilation
PROJECT_NAME=edn
#Can be manny things, but limit whith no space no special char and no Maj ... [a-z]
# com : Commercial
# net : Network??
# org : Organisation
# gov : Governement
# mil : Military
# edu : Education
# pri : Private
# museum : ...
PROJECT_COMPAGNY_TYPE=org
# Compagny name of the project [a-zA-Z0-9 \-]
PROJECT_COMPAGNY_NAME=Edouard DUPIN
# List of mainainer that might be contact in problem case : "Mr NAME Surname<mail@host.com>" "second ..."
PROJECT_MAINTAINER="Mr DUPIN Edouard <yui.heero@gmail.com>"
# the icon of the project is all time needed ... if it is not present the ewol icon might be set (must be a .png file) (and no space in the fileName and filePath)
PROJECT_ICON=$(shell pwd)/data/icon.png
# project section : (must be separate by coma
# refer to : http://packages.debian.org/sid/
# admin cli-mono comm database debian-installer
# debug doc editors electronics devel embedded
# fonts games gnome gnu-r gnustep graphics
# hamradio haskell httpd interpreters java
# kde kernel libdevel libs lisp localization
# mail math misc net news ocaml oldlibs otherosfs
# perl php python ruby science shells sound tex
# text utils vcs video virtual web x11 xfce zope ...
PROJECT_SECTION=Development,Editors
# project prority
# required : Packages which are necessary for the proper functioning of the system (usually, this means that dpkg functionality depends on these packages). Removing a required package may cause your system to become totally broken and you may not even be able to use dpkg to put things back, so only do so if you know what you are doing. Systems with only the required packages are probably unusable, but they do have enough functionality to allow the sysadmin to boot and install more software.
# important : Important programs, including those which one would expect to find on any Unix-like system. If the expectation is that an experienced Unix person who found it missing would say "What on earth is going on, where is foo?", it must be an important package.[6] Other packages without which the system will not run well or be usable must also have priority important. This does not include Emacs, the X Window System, TeX or any other large applications. The important packages are just a bare minimum of commonly-expected and necessary tools.
# standard : These packages provide a reasonably small but not too limited character-mode system. This is what will be installed by default if the user doesn't select anything else. It doesn't include many large applications.
# optional : (In a sense everything that isn't required is optional, but that's not what is meant here.) This is all the software that you might reasonably want to install if you didn't know what it was and don't have specialized requirements. This is a much larger system and includes the X Window System, a full TeX distribution, and many applications. Note that optional packages should not conflict with each other.
# extra : This contains all packages that conflict with others with required, important, standard or optional priorities, or are only likely to be useful if you already know what they are or have specialized requirements (such as packages containing only detached debugging symbols).
PROJECT_PRIORITY=optional
# description of the current project inside quote and no \n
PROJECT_DESCRIPTION="Text editor for sources code with ctags management"
# Add package needed :
# current user packages
USER_PACKAGES =$(shell pwd)/sources/
# include the basic makefile of ewol :
include $(shell pwd)/../ewol/Makefile.mk

View File

@@ -20,25 +20,23 @@ download the software :
git clone git://github.com/HeeroYui/edn.git
cd edn
(debug) Compile software & Run debug version:
make DEBUG=1
../ewol/build/lutin.py --color --mode=debug
or
make CLANG=1 DEBUG=1
./out/Linux/debug/staging/edn/usr/bin/edn -l6 yourFile.txt
../ewol/build/lutin.py --color --compilator=clang --mode=debug
./out/Linux/debug/staging/edn//usr/bin/edn -l6 yourFile.txt
Note : -l6 corespond at the LOG level to display.
Note : If you not compile in debug mode, you must install it to execure it.
(release) Compile software & install & run:
# generate binary and tree
make
# generate .deb packages
make final
# install .deb packages
make install
# generate binary, tree, package and install it ...
../ewol/build/lutin.py -c edn-install
edn exemple.txt
(Android) Compile software & install
cd yourDevFolder
@@ -50,26 +48,35 @@ download the software :
==> you need to download sub package of the NDK (refer to the NDK doccumentation) but only supported android version >4.0
cd ../edn
# generate .so
make PLATFORM=Android
# generate .apk
make PLATFORM=Android final
# To send it on the board :
make PLATFORM=Android install
../ewol/build/lutin.py --color --target=Android --mode=debug edn-install
# to show the log :
make PLATFORM=Android log
../ewol/build/lutin.py --target=Android edn-log
(Windows) Compile software & install
cd yourDevFolder/edn
make PLATFORM=Windows
# generate ...
make PLATFORM=Windows final
../ewol/build/lutin.py --color --target=Windows --mode=debug
(MAC) All needed and some useful packages
- Git access (client you want or : http://code.google.com/p/git-osx-installer/ ==>need a ctrl+click to remove the normal installation control)
- Xcode ==> for all developement packages
- in Xcode : XCode->Setting->Download and install component: "Command Line Tools"
cd yourDevFolder/edn
../ewol/build/lutin.py --color --mode=debug
On linux you can generate 3 board in one time
=============================================
cd yourDevFolder/edn
../ewol/build/lutin.py --color --target=Linux --mode=debug edn --target=Windows --mode=debug edn --target=Android --mode=debug edn
Dependency packages
===================
sudo apt-get install g++ libgl1-mesa-dev zlib1g-dev libasound2-dev
# if you want to compile with clang :
sudo apt-get install clang
@@ -77,7 +84,7 @@ Dependency packages
sudo apt-get install mingw32
License (GPL)
License (GPLv3)
==================
Edn (Editeur De N'ours) : Source code editor
@@ -95,3 +102,7 @@ License (GPL)
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Annexe
==================
sudo cp data/edn.desktop /usr/share/applications/

View File

@@ -1,64 +1,25 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
#
# Modules
#
BUILD_EDN=y
# BUILD_AGG is not set
# BUILD_ETK is not set
# BUILD_EWOL is not set
# BUILD_FREETYPE is not set
# BUILD_LUA is not set
# BUILD_OGG is not set
# BUILD_PARSERSVG is not set
# BUILD_LIBPNG is not set
# BUILD_PORTAUDIO is not set
# BUILD_TINYXML is not set
# BUILD_ZLIB is not set
# BUILD_LIBZIP is not set
#
# edn
#
#
# General
#
APPL_BUFFER_FONT_NORMAL=y
# APPL_BUFFER_FONT_DISTANCE_FIELD is not set
#
# Android
#
__EWOL_ANDROID_MINIMUM_SDK_VERSION__=9
# __EWOL_ANDROID_SHOW_TITLE__ is not set
__EWOL_ANDROID_ORIENTATION_AUTO__=y
# __EWOL_ANDROID_ORIENTATION_LANDSCAPE__ is not set
# __EWOL_ANDROID_ORIENTATION_PORTRAIT__ is not set
#
# Permissions
#
__ANDROID_PERMISSION__WRITE_EXTERNAL_STORAGE__=y
# __ANDROID_PERMISSION__CAMERA__ is not set
# __ANDROID_PERMISSION__INTERNET__ is not set
# __ANDROID_PERMISSION__MODIFY_AUDIO_SETTINGS__ is not set
# __ANDROID_PERMISSION__READ_CALENDAR__ is not set
# __ANDROID_PERMISSION__READ_CONTACTS__ is not set
# __ANDROID_PERMISSION__READ_FRAME_BUFFER__ is not set
# __ANDROID_PERMISSION__READ_PROFILE__ is not set
# __ANDROID_PERMISSION__RECORD_AUDIO__ is not set
# __ANDROID_PERMISSION__SET_ORIENTATION__ is not set
# __ANDROID_PERMISSION__VIBRATE__ is not set
# __ANDROID_PERMISSION__ACCESS_COARSE_LOCATION__ is not set
# __ANDROID_PERMISSION__ACCESS_FINE_LOCATION__ is not set
# __VIDEO__OPENGL_ES_1 is not set
# CONFIG_BUILD_AGG is not set
# CONFIG_BUILD_LINEARMATH is not set
# CONFIG_BUILD_BULLET is not set
# CONFIG_BUILD_ETK is not set
# CONFIG_BUILD_FREETYPE is not set
# CONFIG_BUILD_LUA is not set
# CONFIG_BUILD_OGG is not set
# CONFIG_BUILD_PARSERSVG is not set
# CONFIG_BUILD_LIBPNG is not set
# CONFIG_BUILD_TINYXML is not set
# CONFIG_BUILD_ZLIB is not set
# CONFIG_BUILD_LIBZIP is not set
# CONFIG_BUILD_EWOL is not set
CONFIG_BUILD_EDN=y
#
# ewol
@@ -67,5 +28,41 @@ __ANDROID_PERMISSION__WRITE_EXTERNAL_STORAGE__=y
#
# General
#
__EWOL_INTEGRATED_FONT__=y
__EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
CONFIG___EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
CONFIG___EWOL_INTEGRATED_FONT__=y
#
# Android
#
CONFIG___EWOL_ANDROID_MINIMUM_SDK_VERSION__=9
# CONFIG___EWOL_ANDROID_SHOW_TITLE__ is not set
CONFIG___EWOL_ANDROID_ORIENTATION_AUTO__=y
# CONFIG___EWOL_ANDROID_ORIENTATION_LANDSCAPE__ is not set
# CONFIG___EWOL_ANDROID_ORIENTATION_PORTRAIT__ is not set
#
# Permissions
#
CONFIG___ANDROID_PERMISSION__WRITE_EXTERNAL_STORAGE__=y
# CONFIG___ANDROID_PERMISSION__CAMERA__ is not set
# CONFIG___ANDROID_PERMISSION__INTERNET__ is not set
# CONFIG___ANDROID_PERMISSION__MODIFY_AUDIO_SETTINGS__ is not set
# CONFIG___ANDROID_PERMISSION__READ_CALENDAR__ is not set
# CONFIG___ANDROID_PERMISSION__READ_CONTACTS__ is not set
# CONFIG___ANDROID_PERMISSION__READ_FRAME_BUFFER__ is not set
# CONFIG___ANDROID_PERMISSION__READ_PROFILE__ is not set
# CONFIG___ANDROID_PERMISSION__RECORD_AUDIO__ is not set
# CONFIG___ANDROID_PERMISSION__SET_ORIENTATION__ is not set
# CONFIG___ANDROID_PERMISSION__VIBRATE__ is not set
# CONFIG___ANDROID_PERMISSION__ACCESS_COARSE_LOCATION__ is not set
# CONFIG___ANDROID_PERMISSION__ACCESS_FINE_LOCATION__ is not set
#
# edn
#
#
# General
#
CONFIG_APPL_BUFFER_FONT_NORMAL=y
# CONFIG_APPL_BUFFER_FONT_DISTANCE_FIELD is not set

View File

@@ -1,34 +1,26 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
#
# Modules
#
BUILD_EDN=y
# BUILD_AGG is not set
# BUILD_ETK is not set
# BUILD_EWOL is not set
# BUILD_FREETYPE is not set
# BUILD_LUA is not set
# BUILD_OGG is not set
# BUILD_PARSERSVG is not set
# BUILD_LIBPNG is not set
# BUILD_PORTAUDIO is not set
# BUILD_TINYXML is not set
# BUILD_ZLIB is not set
# BUILD_LIBZIP is not set
#
# edn
#
#
# General
#
APPL_BUFFER_FONT_NORMAL=y
# APPL_BUFFER_FONT_DISTANCE_FIELD is not set
# CONFIG_BUILD_AGG is not set
# CONFIG_BUILD_LINEARMATH is not set
# CONFIG_BUILD_BULLET is not set
# CONFIG_BUILD_ETK is not set
# CONFIG_BUILD_FREETYPE is not set
# CONFIG_BUILD_LUA is not set
# CONFIG_BUILD_OGG is not set
# CONFIG_BUILD_PARSERSVG is not set
# CONFIG_BUILD_LIBPNG is not set
# CONFIG_BUILD_PORTAUDIO is not set
# CONFIG_BUILD_TINYXML is not set
# CONFIG_BUILD_ZLIB is not set
# CONFIG_BUILD_LIBZIP is not set
# CONFIG_BUILD_EWOL is not set
CONFIG_BUILD_EDN=y
#
# ewol
@@ -37,5 +29,21 @@ APPL_BUFFER_FONT_NORMAL=y
#
# General
#
# __EWOL_INTEGRATED_FONT__ is not set
__EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
CONFIG___EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
# CONFIG___EWOL_INTEGRATED_FONT__ is not set
#
# Linux
#
CONFIG___EWOL_LINUX_GUI_MODE_X11__=y
# CONFIG___EWOL_LINUX_GUI_MODE_DIRECT_FB__ is not set
#
# edn
#
#
# General
#
CONFIG_APPL_BUFFER_FONT_NORMAL=y
# CONFIG_APPL_BUFFER_FONT_DISTANCE_FIELD is not set

48
config/MacOs.config Normal file
View File

@@ -0,0 +1,48 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
#
# Modules
#
# CONFIG_BUILD_AGG is not set
# CONFIG_BUILD_LINEARMATH is not set
# CONFIG_BUILD_BULLET is not set
# CONFIG_BUILD_ETK is not set
# CONFIG_BUILD_FREETYPE is not set
# CONFIG_BUILD_LUA is not set
# CONFIG_BUILD_OGG is not set
# CONFIG_BUILD_PARSERSVG is not set
# CONFIG_BUILD_LIBPNG is not set
# CONFIG_BUILD_TINYXML is not set
# CONFIG_BUILD_ZLIB is not set
# CONFIG_BUILD_LIBZIP is not set
# CONFIG_BUILD_EWOL is not set
CONFIG_BUILD_EDN=y
#
# ewol
#
#
# General
#
CONFIG___EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
CONFIG___EWOL_INTEGRATED_FONT__=y
#
# Linux
#
CONFIG___EWOL_LINUX_GUI_MODE_X11__=y
# CONFIG___EWOL_LINUX_GUI_MODE_DIRECT_FB__ is not set
#
# edn
#
#
# General
#
CONFIG_APPL_BUFFER_FONT_NORMAL=y
# CONFIG_APPL_BUFFER_FONT_DISTANCE_FIELD is not set

View File

@@ -1,33 +1,26 @@
#
# Automatically generated make config: don't edit
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
#
# Modules
#
BUILD_EDN=y
# BUILD_AGG is not set
# BUILD_ETK is not set
# BUILD_FREETYPE is not set
BUILD_GLEW=y
# BUILD_LUA is not set
# BUILD_OGG is not set
# BUILD_PARSERSVG is not set
# BUILD_LIBPNG is not set
# BUILD_TINYXML is not set
# BUILD_ZLIB is not set
# BUILD_LIBZIP is not set
# BUILD_EWOL is not set
#
# edn
#
#
# General
#
APPL_BUFFER_FONT_NORMAL=y
# APPL_BUFFER_FONT_DISTANCE_FIELD is not set
# CONFIG_BUILD_AGG is not set
# CONFIG_BUILD_LINEARMATH is not set
# CONFIG_BUILD_BULLET is not set
# CONFIG_BUILD_ETK is not set
# CONFIG_BUILD_FREETYPE is not set
# CONFIG_BUILD_GLEW is not set
# CONFIG_BUILD_LUA is not set
# CONFIG_BUILD_OGG is not set
# CONFIG_BUILD_PARSERSVG is not set
# CONFIG_BUILD_LIBPNG is not set
# CONFIG_BUILD_TINYXML is not set
# CONFIG_BUILD_ZLIB is not set
# CONFIG_BUILD_LIBZIP is not set
# CONFIG_BUILD_EWOL is not set
CONFIG_BUILD_EDN=y
#
# ewol
@@ -36,5 +29,15 @@ APPL_BUFFER_FONT_NORMAL=y
#
# General
#
__EWOL_APPL_BASIC_TITLE__="Ewol Basic Title"
__EWOL_INTEGRATED_FONT__=y
CONFIG___EWOL_APPL_BASIC_TITLE__="Ewol Basic Title"
CONFIG___EWOL_INTEGRATED_FONT__=y
#
# edn
#
#
# General
#
CONFIG_APPL_BUFFER_FONT_NORMAL=y
# CONFIG_APPL_BUFFER_FONT_DISTANCE_FIELD is not set

28
data/GUI-Search.xml Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<composer>
<sizer mode="hori" expand="true,false" fill="true" lock="true">
<button name="SEARCH:close">
<image src="THEME:GUI:Remove.svg" fill="true" size="7,7mm"/>
</button>
<entry name="SEARCH:search-entry" expand="true" fill="true"/>
<button name="SEARCH:search">
<image src="THEME:GUI:Search.svg" fill="true" size="7,7mm"/>
</button>
<entry name="SEARCH:replace-entry" expand="true" fill="true"/>
<button name="SEARCH:replace">
<image src="THEME:GUI:Replace.svg" fill="true" size="7,7mm"/>
</button>
<button name="SEARCH:case">
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
<button name="SEARCH:wrap">
<image src="THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
<button name="SEARCH:up-down">
<image src="THEME:GUI:Up.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:Down.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
</sizer>
</composer>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnColor version="0.1">
<gui> <!-- Doivent tous y <20>tre de prf<72>rence ... global system acces -->
<color name="CODE_basicBackgroung" val="#151515"/>
<color name="CODE_space" val="#333333"/>
<color name="CODE_tabulation" val="#444444"/>
<color name="CODE_cursor" val="#eadd05"/>
<color name="CODE_lineNumber" val="#fff725"/>
<!-- Buffer list property -->
<color name="LIST_backgroung1" val="#202020"/>
<color name="LIST_backgroung2" val="#000000"/>
<color name="LIST_backgroungSelected" val="#2f0ba4"/>
<color name="LIST_textNormal" val="#EEEEEE"/>
<color name="LIST_textModify" val="#FF0000"/>
</gui>
<syntax>
<color name="normal" FG="#EEEEEE"/>
<color name="SelectedText" FG="#AAAAAA" BG="#225a09"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#00fF00"/>
<!-- hightline description : -->
<color name="type" FG="#56bf10" bold="yes"/>
<color name="storageKeyword" FG="#5c8fed"/>
<color name="number" FG="#00ff00"/>
<color name="systemFunction" FG="#ffff00"/>
<color name="commonDefine" FG="#56bf10"/>
<color name="boolean" FG="#214cf1"/>
<color name="preprocesseur" FG="#FF0000"/>
<color name="comment" FG="#ef4def" italic="yes"/>
<color name="commentDoxygen" FG="#ef4d00" bold="yes" italic="yes"/>
<color name="keyword" FG="#5c8fed" bold="yes"/>
<color name="macro" FG="#6c09c8" bold="yes"/>
<color name="SYNTAX_ERROR" FG="#000000" BG="#FF0000" bold="yes"/>
<color name="functionName" FG="#24d1e0" bold="yes"/>
<color name="TestResultOK" FG="#000000" BG="#00FF00" bold="yes"/>
<color name="TestResultERROR" FG="#000000" BG="#FF0000" bold="yes"/>
</syntax>
</EdnColor>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnColor version="0.1">
<gui> <!-- Doivent tous y <20>tre de prf<72>rence ... global system acces -->
<color name="CODE_basicBackgroung" val="#d9d7d7"/>
<color name="CODE_space" val="#b7b6b6"/>
<color name="CODE_tabulation" val="#a7a5a5"/>
<color name="CODE_cursor" val="#2a00ff"/>
<color name="CODE_lineNumber" val="#1a00a0"/>
<!-- Buffer list property -->
<color name="LIST_backgroung1" val="#d9d7d7"/>
<color name="LIST_backgroung2" val="#b7b6b6"/>
<color name="LIST_backgroungSelected" val="#3da3f9"/>
<color name="LIST_textNormal" val="#000000"/>
<color name="LIST_textModify" val="#FF0000"/>
</gui>
<syntax>
<color name="normal" FG="#000000"/>
<color name="SelectedText" FG="#292929" BG="#009ce7"/>
<color name="error" FG="#FF0000"/>
<color name="doubleQuoteText" FG="#008e00"/>
<!-- hightline description : -->
<color name="type" FG="#376d0a" bold="yes"/>
<color name="storageKeyword" FG="#466cb4"/>
<color name="number" FG="#007b00"/>
<color name="systemFunction" FG="#acaa00"/>
<color name="commonDefine" FG="#3c850b"/>
<color name="boolean" FG="#1633a3"/>
<color name="preprocesseur" FG="#ac0000"/>
<color name="comment" FG="#b704b5" italic="yes"/>
<color name="commentDoxygen" FG="#bf3e00" bold="yes" italic="yes"/>
<color name="keyword" FG="#215eb8" bold="yes"/>
<color name="macro" FG="#571793" bold="yes"/>
<color name="SYNTAX_ERROR" FG="#000000" BG="#c20000" bold="yes"/>
<color name="functionName" FG="#09857e" bold="yes"/>
<color name="TestResultOK" FG="#000000" BG="#009c00" bold="yes"/>
<color name="TestResultERROR" FG="#000000" BG="#c20000" bold="yes"/>
</syntax>
</EdnColor>

14
data/edn.desktop Normal file
View File

@@ -0,0 +1,14 @@
[Desktop Entry]
Version=0.3.0
Name=Edn : Editeur de N'ours
Exec=edn
Icon=Edn
Terminal=false
Type=Application
Categories=Development;Utility;TextEditor;
GenericName=Text editor
GenericName[en]=Text editor
GenericName[nl]=Tekst verwerker
GenericName[fr]=éditeur de text
Comment=Code editor for c, c++, php, bash, xml ...
Comment[fr]=éditeur de text pour les language c, c++, php, bash, xml ...

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="boulou log">
<EdnLang version="0.1" lang="Boulou log">
<ext>*.boo</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="comment ##">

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="c">
<EdnLang version="0.1" lang="C/C++">
<ext>*.c</ext>
<ext>*.cpp</ext>
<ext>*.cc</ext>
<ext>*.h</ext>
<ext>*.hpp</ext>
<ext>*.mm</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen">
<color>commentDoxygen</color>
@@ -23,7 +24,7 @@
</rule>
<rule name="code Review">
<color>SYNTAX_ERROR</color>
<start>/\*[ \t]*@review</start>
<start>/\*[ \t]*TODO :</start>
<end>\*/</end>
</rule>
<rule name="my comment multiline">
@@ -84,11 +85,15 @@
</rule>
<rule name="my type">
<color>type</color>
<start>\@bool|BOOL|char|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128)\@</start>
<start>\@bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128)\@</start>
</rule>
<rule name="std type">
<color>type</color>
<start>\@std::(vector|(u16|u32|w)?string|codecvt_utf(16|8_utf16|8)+|complex|iterator(_traits)?|tuple(_element|_size)?|pair)\@</start>
</rule>
<rule name="my storage keyword">
<color>storageKeyword</color>
<start>\@const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum\@</start>
<start>\@inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum\@</start>
</rule>
<rule name="my common Define">
<color>commonDefine</color>
@@ -106,6 +111,14 @@
<color>macro</color>
<start>\@[A-Z_][A-Z_0-9]{3,500}\@</start>
</rule>
<rule name="CPP member">
<color>memberClass</color>
<start>\@m_[A-Za-z_0-9]*\@</start>
</rule>
<rule name="function input">
<color>inputFunction</color>
<start>\@_[A-Za-z_0-9]*\@</start>
</rule>
<rule name="Function name">
<color>functionName</color>
<start>\@(\w|_)+[ \t]*\(</start>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="glsl">
<EdnLang version="0.1" lang="Glsl">
<ext>*.glsl</ext>
<ext>*.vert</ext>
<ext>*.frag</ext>
@@ -52,11 +52,11 @@
</rule>
<rule name="my type">
<color>type</color>
<start>\@bool|float|int|(vec|mat|ivect|bvect)[2-4]\@</start>
<start>\@void|bool|float|int|(vec|mat|ivect|bvect)[2-4]\@</start>
</rule>
<rule name="my storage keyword">
<color>storageKeyword</color>
<start>\@varying|uniform|attribute\@</start>
<start>\@varying|uniform|attribute|precision|mediump\@</start>
</rule>
<rule name="numeric constant">
<color>number</color>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="qconf configuration file">
<EdnLang version="0.1" lang="Kernel conf file">
<ext>*.in</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my preprocesseur">

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="java">
<EdnLang version="0.1" lang="Java">
<ext>*.java</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen">

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Json">
<ext>*.json</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>\{|\}|\[|\]</start>
</rule>
<rule name="separator">
<color>error</color>
<start>:|,</start>
</rule>
<rule name="names">
<color>functionName</color>
<start>([a-zA-Z0-9]|-|_)*</start>
</rule>
<rule name="numeric constant">
<color>number</color>
<start>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</start>
</rule>
<rule name="my boolean">
<color>boolean</color>
<start>\@true|false\@</start>
</rule>
</pass2>
</EdnLang>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="c">
<EdnLang version="0.1" lang="Lua">
<ext>*.lua</ext>
<pass1>
<rule name="Comment multiline">

View File

@@ -25,7 +25,7 @@
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="confition">
<color>type</color>
<start>\@if|ifed|ifneq|else|endif\@</start>
<start>\@if|ifeq|ifneq|else|endif|define|endef\@</start>
</rule>
<rule name="my keyword">
<color>keyword</color>
@@ -33,7 +33,7 @@
</rule>
<rule name="function call">
<color>functionName</color>
<start>\$\((call|info|error|warning|shell|patsubst|lastword|wildcard|addprefix|foreach|subst|if|word|eval)</start>
<start>\$\((call|info|error|warning|shell|patsubst|lastword|wildcard|addprefix|foreach|subst|word|eval)</start>
</rule>
<rule name="condition">
<color>boolean</color>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="matlab">
<EdnLang version="0.1" lang="Matlab">
<ext>*.m</ext>
<ext>*.M</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="php: pretty home page">
<EdnLang version="0.1" lang="Php: pretty home page">
<ext>*.php</ext>
<ext>*.php3</ext>
<ext>*.php4</ext>

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<EdnLang version="0.1" lang="Python">
<ext>*.py</ext>
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline">
<color>comment</color>
<start>"""</start>
<end>"""</end>
</rule>
<rule name="my comment doxygen">
<color>commentDoxygen</color>
<start>##</start>
<end>\n</end>
</rule>
<rule name="my comment">
<color>comment</color>
<start>#</start>
<end>\n</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="doubleQuteText">
<color>doubleQuoteText</color>
<start>"</start>
<end>"</end>
<EscapeChar>\</EscapeChar>
</rule>
<rule name="simpleQuteText">
<color>doubleQuoteText</color>
<start>'</start>
<end>'</end>
</rule>
</pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->
<rule name="my keyword">
<color>keyword</color>
<start>\@if|else|elif|break|pass|continue|while|do|for|in|return\@</start>
</rule>
<rule name="my function keyword">
<color>systemFunction</color>
<start>\@print|len|range|del|__init__|self|os\.|sys\.|path\.\@</start>
</rule>
<rule name="my type">
<color>type</color>
<start>\@bool|BOOL|char|double|float\@</start>
</rule>
<rule name="my storage keyword">
<color>storageKeyword</color>
<start>\@def|class|import|from|as|try|except\@</start>
</rule>
<rule name="numeric constant">
<color>number</color>
<start>\@((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?\@</start>
</rule>
<rule name="my boolean">
<color>boolean</color>
<start>\@True|False\@</start>
</rule>
<rule name="BIG LETTER">
<color>macro</color>
<start>\@[A-Z_][A-Z_0-9]{3,500}\@</start>
</rule>
<rule name="Function name">
<color>functionName</color>
<start>\@(\w|_)+[ \t]*\(</start>
</rule>
<rule name="condition">
<color>boolean</color>
<start>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</start>
</rule>
<!-- With all elementes : -->
<rule name="BIG LETTER">
<color>macro</color>
<start>([A-Z]|_){4,500}</start>
<elemSubColor id="1">doxElem</elemSubColor>
</rule>
</pass2>
</EdnLang>

View File

@@ -28,7 +28,7 @@
</rule>
<rule name="normale Balise">
<color>functionName</color>
<start>&lt;/[0-9a-fA-F_]*|&lt;[0-9a-fA-F_]*|/&gt;|&gt;</start>
<start>&lt;/[0-9a-zA-Z_]+|&lt;[0-9a-zA-Z_]+|/&gt;|&gt;</start>
</rule>
</pass2>
</EdnLang>

View File

@@ -0,0 +1,9 @@
{
"ednColor": [
{ name:"backgroung1", foreground:"#202020" },
{ name:"backgroung2", foreground:"#000000" },
{ name:"backgroungSelected", foreground:"#2f0ba4" },
{ name:"textNormal", foreground:"#EEEEEE" },
{ name:"textModify", foreground:"#FF0000" },
]
}

View File

@@ -0,0 +1,31 @@
{
"ednColor": [
{ name:"CODE_basicBackgroung", foreground:"#151515" },
{ name:"CODE_space", foreground:"#333333" },
{ name:"CODE_tabulation", foreground:"#444444" },
{ name:"CODE_cursor", foreground:"#eadd05" },
{ name:"CODE_lineNumber", foreground:"#fff725", background:"#464646"},
{ name:"normal", foreground:"#EEEEEE"},
{ name:"SelectedText", foreground:"#AAAAAA", background:"#225a09"},
{ name:"error", foreground:"#FF0000"},
{ name:"doubleQuoteText", foreground:"#00FF00"},
{ name:"type", foreground:"#56bf10", bold:true},
{ name:"storageKeyword", foreground:"#5c8fed"},
{ name:"inputFunction", foreground:"#B80000", bold:true, italic:true},
{ name:"memberClass", foreground:"#7c5406", bold:true},
{ name:"number", foreground:"#00ff00"},
{ name:"systemFunction", foreground:"#ffff00"},
{ name:"commonDefine", foreground:"#56bf10"},
{ name:"boolean", foreground:"#214cf1"},
{ name:"preprocesseur", foreground:"#FF0000"},
{ name:"comment", foreground:"#ef4def", italic:true},
{ name:"commentDoxygen", foreground:"#ef4d00", bold:true, italic:true},
{ name:"keyword", foreground:"#5c8fed", bold:true},
{ name:"macro", foreground:"#6c09c8", bold:true},
{ name:"SYNTAX_ERROR", foreground:"#000000", background:"#FF0000", bold:true},
{ name:"functionName", foreground:"#24d1e0", bold:true},
{ name:"TestResultOK", foreground:"#000000", background:"#00FF00", bold:true},
{ name:"TestResultERROR", FG:"#000000", background:"#FF0000", bold:true}
]
}

View File

@@ -0,0 +1,9 @@
{
"ednColor": [
{ name:"backgroung1", foreground:"#d9d7d7"},
{ name:"backgroung2", foreground:"#b7b6b6"},
{ name:"backgroungSelected", foreground:"#3da3f9"},
{ name:"textNormal", foreground:"#000000"},
{ name:"textModify", foreground:"#FF0000"}
]
}

View File

@@ -0,0 +1,31 @@
{
"ednColor": [
{ name:"CODE_basicBackgroung", foreground:"#d9d7d7"},
{ name:"CODE_space", foreground:"#b7b6b6"},
{ name:"CODE_tabulation", foreground:"#a7a5a5"},
{ name:"CODE_cursor", foreground:"#2a00ff"},
{ name:"CODE_lineNumber", foreground:"#1a00a0", background:"#a2a2a2"},
{ name:"normal", foreground:"#000000"},
{ name:"SelectedText", foreground:"#292929", background:"#009ce7"},
{ name:"error", foreground:"#FF0000"},
{ name:"doubleQuoteText", foreground:"#008e00"},
{ name:"type", foreground:"#376d0a", bold:true},
{ name:"memberClass", foreground:"#7c5406", bold:true},
{ name:"inputFunction", foreground:"#B80000", bold:true, italic:true},
{ name:"storageKeyword", foreground:"#466cb4"},
{ name:"number", foreground:"#007b00"},
{ name:"systemFunction", foreground:"#acaa00"},
{ name:"commonDefine", foreground:"#3c850b"},
{ name:"boolean", foreground:"#1633a3"},
{ name:"preprocesseur", foreground:"#ac0000"},
{ name:"comment", foreground:"#b704b5", italic:true},
{ name:"commentDoxygen", foreground:"#bf3e00", bold:true, italic:true},
{ name:"keyword", foreground:"#215eb8", bold:true},
{ name:"macro", foreground:"#571793", bold:true},
{ name:"SYNTAX_ERROR", foreground:"#000000", background:"#c20000", bold:true},
{ name:"functionName", foreground:"#09857e", bold:true},
{ name:"TestResultOK", foreground:"#000000", background:"#009c00", bold:true},
{ name:"TestResultERROR", foreground:"#000000", background:"#c20000", bold:true}
]
}

Binary file not shown.

View File

@@ -1,9 +0,0 @@
#!/bin/bash
#really simple to install
echo "- copy binary /usr/bin/edn"
sudo cp -vf out/Linux/release/staging/edn/usr/bin/edn /usr/bin/edn
sudo mkdir -p /usr/share/edn
echo "- Remove the folder /usr/share/edn/*"
sudo rm -rf /usr/share/edn/*
sudo cp -rfv out/Linux/release/staging/edn/usr/share/* /usr/share/

6
lutinBase.py Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/python
import lutinModule
import lutinTools
lutinModule.ImportPath(lutinTools.GetCurrentPath(__file__) + "/sources/")
lutinModule.ImportPath(lutinTools.GetCurrentPath(__file__) + "/../ewol/")

View File

@@ -1,31 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
LOCAL_MODULE := edn
# get the tag of the current project :
LOCAL_VERSION=$(shell cat $(LOCAL_PATH)/../tag)
$(info [TAG:$(LOCAL_MODULE)] $(LOCAL_VERSION))
# name of the dependency
LOCAL_LIBRARIES := ewol freetype libpng parsersvg tinyxml lua etk libzip
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS := -llog -landroid
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION)-$(BUILD_DIRECTORY_MODE)\""
include $(BUILD_SHARED_LIBRARY)

View File

@@ -1,16 +0,0 @@
menu "General"
choice
prompt "Buffer text configuration"
default APPL_BUFFER_FONT_NORMAL
help
Buffer display mode :
0 : Basic Sprite font mode.
==> Old standard mode fast but need to reaload distint font for every size
1 : Distance Field.
==> New theoric mode for the display of the font ==> really slow but insteresting ...
config APPL_BUFFER_FONT_NORMAL
bool "0: Basic Sprite font mode"
config APPL_BUFFER_FONT_DISTANCE_FIELD
bool "1: Distance Field"
endchoice
endmenu

View File

@@ -1,30 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
LOCAL_MODULE := edn
# get the tag of the current project :
LOCAL_VERSION=$(shell cat $(LOCAL_PATH)/../tag)
$(info [TAG:$(LOCAL_MODULE)] $(LOCAL_VERSION))
# name of the dependency
LOCAL_STATIC_LIBRARIES := ewol
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION)-$(BUILD_DIRECTORY_MODE)\""
include $(BUILD_EXECUTABLE)

View File

@@ -1,30 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_CONFIG_FILES := Config.in
# name of the librairy
LOCAL_MODULE := edn
# get the tag of the current project :
LOCAL_VERSION=$(shell cat $(LOCAL_PATH)/../tag)
$(info [TAG:$(LOCAL_MODULE)] $(LOCAL_VERSION))
# name of the dependency
LOCAL_STATIC_LIBRARIES := ewol
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(addprefix $(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST))))
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\"" \
-DAPPL_VERSION_TAG_NAME="\"$(LOCAL_VERSION)-$(BUILD_DIRECTORY_MODE)\""
include $(BUILD_EXECUTABLE)

987
sources/appl/Buffer.cpp Normal file
View File

@@ -0,0 +1,987 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Buffer.h>
#include <appl/debug.h>
#include <ewol/clipBoard.h>
#include <appl/HighlightManager.h>
const char* const appl::Buffer::eventIsModify = "edn-is-modify";
const char* const appl::Buffer::eventIsSave = "edn-is-save";
const char* const appl::Buffer::eventSelectChange = "edn-select-change";
const char* const appl::Buffer::eventChangeName = "edn-buffer-name-change";
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
m_value = etk::UChar::Null;
if (m_current < 0) {
m_current = 0;
return *this;
}
if (m_data != NULL) {
if (m_current < m_data->m_data.size() ) {
int8_t nbChar = etk::UChar::theoricUTF8Len(m_data->m_data[m_current]);
if (nbChar != 0) {
m_current+=nbChar;
} else {
m_current++;
}
}
if (m_current >= m_data->m_data.size()) {
m_current = m_data->m_data.size();
}
}
return *this;
}
appl::Buffer::Iterator& appl::Buffer::Iterator::operator-- (void) {
m_value = etk::UChar::Null;
if (m_data != NULL) {
if (m_current > 0) {
int32_t iii = -1;
while( etk::UChar::theoricUTF8First(m_data->m_data[m_current+iii]) == false
&& iii >= -6
&& m_current-iii>0) {
--iii;
};
m_current += iii;
} else {
m_current = -1;
}
return *this;
} else {
m_current = -1;
}
return *this;
}
char32_t appl::Buffer::Iterator::operator* (void) {
if (m_value != etk::UChar::Null) {
return m_value;
}
if (m_data == NULL) {
APPL_ERROR("request an element that iterator not link");
return m_value;
}
if ( m_current < 0
|| m_current >= m_data->m_data.size()) {
APPL_ERROR("request an element out of bounding !!! 0 <= " << m_current << " < " << m_data->m_data.size());
return m_value;
}
char tmpVal[5];
memset(tmpVal, 0, sizeof(tmpVal));
tmpVal[0] = m_data->m_data[m_current];
int8_t nbChar = etk::UChar::theoricUTF8Len(tmpVal[0]);
for (int32_t iii=1; iii<nbChar && m_current+iii<m_data->m_data.size(); ++iii) {
tmpVal[iii] = m_data->m_data[m_current+iii];
}
// transform ...
m_value = etk::setUtf8(tmpVal);
return m_value;
}
appl::Buffer::Iterator appl::Buffer::position(int64_t _pos) {
return appl::Buffer::Iterator(this, _pos);
}
appl::Buffer::Iterator appl::Buffer::begin(void) {
return position(0);
}
appl::Buffer::Iterator appl::Buffer::end(void) {
// TODO : chek the validity of the char ...
return position( m_data.size() );
}
appl::Buffer::Iterator appl::Buffer::cursor(void) {
if (m_cursorPos<= 0) {
return begin();
}
return position( m_cursorPos );
}
appl::Buffer::Iterator appl::Buffer::selectStart(void) {
return position( getStartSelectionPos() );
}
appl::Buffer::Iterator appl::Buffer::selectStop(void) {
return position( getStopSelectionPos() );
}
appl::Buffer::Buffer(void) :
m_hasFileName(false),
m_fileName(""),
m_isModify(false),
m_cursorPos(0),
m_cursorSelectPos(-1),
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++;
addEventId(eventIsModify);
addEventId(eventIsSave);
addEventId(eventSelectChange);
addEventId(eventChangeName);
}
appl::Buffer::~Buffer(void) {
if (m_highlight == NULL) {
appl::Highlight::release(m_highlight);
}
}
bool appl::Buffer::loadFile(const std::string& _name) {
APPL_DEBUG("Load file : '" << _name << "'");
m_fileName = _name;
m_hasFileName = true;
m_isModify = true;
m_cursorPos = 0;
setHighlightType("");
etk::FSNode file(m_fileName);
if (file.exist() == false) {
APPL_INFO("File doesn not exist !!! " << file);
return false;
}
m_nbLines = 0;
if (true == m_data.dumpFrom(file) ) {
countNumberofLine();
tryFindHighlightType();
m_isModify = false;
return true;
}
return false;
}
void appl::Buffer::setFileName(const std::string& _name) {
if (m_fileName == _name) {
return;
}
m_fileName = _name;
m_hasFileName = true;
generateEventId(eventChangeName);
setModification(true);
}
bool appl::Buffer::storeFile(void) {
etk::FSNode file(m_fileName);
if (true == m_data.dumpIn(file) ) {
APPL_INFO("saving file : " << file);
setModification(false);
return true;
}
return false;
}
void appl::Buffer::setModification(bool _status) {
if (m_isModify == _status) {
return;
}
m_isModify = _status;
if (m_isModify == true) {
generateEventId(eventIsModify);
} else {
generateEventId(eventIsSave);
}
}
// TODO : Naming error
void appl::Buffer::countNumberofLine(void) {
m_nbLines = 1;
for (Iterator it = begin();
(bool)it == true;
++it) {
if (*it == etk::UChar::Return) {
++m_nbLines;
}
}
}
appl::Buffer::Iterator appl::Buffer::getStartLine(const appl::Buffer::Iterator& _pos) {
appl::Buffer::Iterator startPos;
if (false == searchBack(_pos, etk::UChar::Return, startPos)) {
return begin();
}
// note search will return the position of \n ==> the lione start just after ...
return startPos+1;
}
appl::Buffer::Iterator appl::Buffer::getEndLine(const appl::Buffer::Iterator& _pos) {
appl::Buffer::Iterator endPos;
if (false == search(_pos, etk::UChar::Return, endPos)) {
endPos = end();
}
// Note the line end at the \n
return endPos;
}
bool appl::Buffer::search(const appl::Buffer::Iterator& _pos, const char32_t& _search, appl::Buffer::Iterator& _result) {
// move in the string
for (Iterator it = _pos;
(bool)it == true;
++it) {
if (*it == _search) {
_result = it;
return true;
}
}
_result = end();
return false;
}
bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos, const char32_t& _search, appl::Buffer::Iterator& _result) {
// move in the string
for (Iterator it = _pos - 1;
(bool)it == true;
--it) {
//APPL_DEBUG("compare : " << *it << " ?= " << _search);
if (*it == _search) {
//APPL_DEBUG("find : " << (int32_t)it);
_result = it;
return true;
}
}
_result = begin();
return false;
}
bool appl::Buffer::search(const appl::Buffer::Iterator& _pos,
const std::u32string& _search,
appl::Buffer::Iterator& _result,
bool _caseSensitive) {
if (_search.size() <= 0 ) {
return false;
}
if (_caseSensitive == true) {
// move in the string
for (Iterator it = _pos;
(bool)it == true;
++it) {
if (*it == _search[0]) {
// find the first char ==> check next...
bool find = true;
Iterator tmp = it;
for (size_t iii=0; iii<_search.size(); ++iii) {
if (*tmp != _search[iii]) {
find = false;
break;
}
++tmp;
if ((bool)tmp == false) {
if (iii != _search.size()-1) {
find = false;
}
break;
}
}
if (find == true) {
_result = it;
return true;
}
}
}
} else {
char32_t firstElement = tolower(_search[0]);
// move in the string
for (Iterator it = _pos;
(bool)it == true;
++it) {
if (tolower(*it) == firstElement) {
// find the first char ==> check next...
bool find = true;
Iterator tmp = it;
for (size_t iii=0; iii<_search.size(); ++iii) {
if (tolower(*tmp) != tolower(_search[iii])) {
find = false;
break;
}
++tmp;
if ((bool)tmp == false) {
if (iii != _search.size()-1) {
find = false;
}
break;
}
}
if (find == true) {
_result = it;
return true;
}
}
}
}
_result = end();
return false;
}
bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos,
const std::u32string& _search,
appl::Buffer::Iterator& _result,
bool _caseSensitive) {
if (_search.size() <= 0 ) {
return false;
}
char32_t lastElement = _search[_search.size()-1];
if (_caseSensitive == true) {
// move in the string
for (Iterator it = _pos - 1;
(bool)it == true;
--it) {
//APPL_DEBUG("compare : " << *it << " ?= " << _search);
if (*it == lastElement) {
// find the last char ==> check previous...
bool find = true;
_result = it;
for (int64_t iii=_search.size()-1; iii>=0; --iii) {
if (*_result != _search[iii]) {
find = false;
break;
}
--_result;
if ((bool)_result == false) {
if (iii != 0) {
find = false;
}
break;
}
}
if (find == true) {
_result++;
return true;
}
}
}
} else {
lastElement = tolower(lastElement);
// move in the string
for (Iterator it = _pos - 1;
(bool)it == true;
--it) {
//APPL_DEBUG("compare : " << *it << " ?= " << _search);
if (tolower(*it) == lastElement) {
// find the last char ==> check previous...
bool find = true;
_result = it;
for (int64_t iii=_search.size()-1; iii>=0; --iii) {
if (tolower(*_result) != tolower(_search[iii])) {
find = false;
break;
}
--_result;
if ((bool)_result == false) {
if (iii != 0) {
find = false;
}
break;
}
}
if (find == true) {
_result++;
return true;
}
}
}
}
_result = begin();
return false;
}
void appl::Buffer::moveCursor(int64_t _pos) {
m_cursorPreferredCol = -1;
APPL_VERBOSE("move cursor : " << _pos << "/" << m_data.size());
// selecting mode ...
if (m_selectMode == true) {
if (m_cursorSelectPos == -1) {
m_cursorSelectPos = m_cursorPos;
if (m_cursorSelectPos < 0) {
m_cursorSelectPos = 0;
}
}
//APPL_DEBUG("Select : " << m_cursorSelectPos << " ==> " << _pos);
m_cursorPos = _pos;
if (m_cursorPos == m_cursorSelectPos) {
m_cursorSelectPos = -1;
}
generateEventId(eventSelectChange);
return;
}
// move mode
m_cursorPos = _pos;
m_cursorSelectPos = -1;
generateEventId(eventSelectChange);
}
bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos,
appl::Buffer::Iterator &_beginPos,
appl::Buffer::Iterator &_endPos) {
char32_t currentValue = *position(_startPos);
_beginPos = begin();
_endPos = end();
if ( currentValue == etk::UChar::Tabulation
|| currentValue == etk::UChar::Space) {
APPL_DEBUG("select spacer");
// Search back
for (Iterator it = --position(_startPos);
(bool)it == true;
--it) {
currentValue = *it;
if ( currentValue != etk::UChar::Tabulation
&& currentValue != etk::UChar::Space) {
_beginPos = ++it;
break;
}
}
// Search forward
for (Iterator it = position(_startPos);
(bool)it == true;
++it) {
currentValue = *it;
if ( currentValue != etk::UChar::Tabulation
&& currentValue != etk::UChar::Space) {
_endPos = it;
break;
}
}
return true;
} else if( etk::isSpecialChar(currentValue) == false
|| currentValue == '_') {
APPL_DEBUG("select normal Char");
// Search back
for (Iterator it = --position(_startPos);
(bool)it == true;
--it) {
currentValue = *it;
if ( currentValue != '_'
&& true == etk::isSpecialChar(currentValue)) {
_beginPos = ++it;
break;
}
}
// Search forward
for (Iterator it = position(_startPos);
(bool)it == true;
++it) {
currentValue = *it;
if ( currentValue != '_'
&& true == etk::isSpecialChar(currentValue)) {
_endPos = it;
break;
}
}
return true;
} else {
APPL_DEBUG("select same char");
char32_t comparechar = currentValue;
// Search back
for (Iterator it = --position(_startPos);
(bool)it == true;
--it) {
currentValue = *it;
if (comparechar != currentValue) {
_beginPos = ++it;
break;
}
}
// Search forward
for (Iterator it = position(_startPos);
(bool)it == true;
++it) {
currentValue = *it;
if (comparechar != currentValue) {
_endPos = it;
break;
}
}
return true;
}
_beginPos = begin();
_endPos = begin();
return false;
}
void appl::Buffer::setSelectionPos(const appl::Buffer::Iterator& _pos) {
m_cursorSelectPos = _pos;
generateEventId(eventSelectChange);
}
void appl::Buffer::unSelect(void) {
m_cursorSelectPos = -1;
generateEventId(eventSelectChange);
}
static const char *ControlCodeTable[32] = {
"NUL", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "nl", "vt", "np", "cr", "so", "si",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", "us"};
void appl::Buffer::expand(int32_t& _indent, const char32_t& _value, std::u32string& _out) const {
_out.clear();
int32_t tabDist = 4;
if (_value == etk::UChar::Tabulation) {
int32_t nSpaces = tabDist - (_indent % tabDist);
for (int32_t iii=0; iii<nSpaces; iii++) {
_out += etk::UChar::Space;
}
return;
}
// convert ASCII control codes to readable character sequences
if (_value == etk::UChar::Null) {
_out += U"<nul>";
return;
}
if (_value == etk::UChar::Return) {
// nothing to display...
_out += etk::UChar::Return;
return;
}
if (_value <= 31) {
_out += '<';
const char * tmp = ControlCodeTable[_value];
while (*tmp!='\0') {
_out += *tmp;
tmp++;
}
_out += '>';
return;
}
if (_value == etk::UChar::Delete) {
_out += U"<del>";
return;
}
// nothing to do ...
_out += _value;
//APPL_DEBUG("plop : " << _out);
}
appl::Buffer::Iterator appl::Buffer::countForwardNLines(const appl::Buffer::Iterator& _startPos, int32_t _nLines) {
char32_t value;
int32_t lineCount = 0;
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
for (Iterator it = position(_startPos);
(bool)it == true;
++it) {
value = *it;
if (value == etk::UChar::Return) {
lineCount++;
if (lineCount == _nLines) {
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
return ++it;
}
}
}
//APPL_INFO(" == > (2) at position=" << myPosIt.Position() );
return end();
}
appl::Buffer::Iterator appl::Buffer::countBackwardNLines(const appl::Buffer::Iterator& _startPos, int32_t _nLines) {
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
char32_t value;
int32_t lineCount = 0;
for (Iterator it = --position(_startPos);
(bool)it == true;
--it) {
value = *it;
if (value == etk::UChar::Return) {
lineCount++;
if (lineCount >= _nLines) {
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
return ++it;
}
}
}
//APPL_INFO(" == > (2) at position=0");
return begin();
}
bool appl::Buffer::copy(std::string& _data) {
_data.clear();
if (hasTextSelected() == true) {
int32_t startPos = getStartSelectionPos();
int32_t endPos = getStopSelectionPos();
for (Iterator it = position(startPos);
it != position(endPos) &&
(bool)it == true;
++it) {
_data += *it;
}
return true;
}
return false;
}
void appl::Buffer::copy(std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
_data.clear();
int64_t startPos = getStartSelectionPos();
int64_t endPos = getStopSelectionPos();
for (Iterator it = _pos;
it != _posEnd &&
(bool)it == true;
++it) {
_data += *it;
}
}
bool appl::Buffer::write(const std::string& _data, const appl::Buffer::Iterator& _pos) {
int64_t position = (int64_t)_pos;
if (position < 0){
position = 0;
}
APPL_ERROR("writye at pos: " << (int64_t)_pos << " ==> " << position);
m_data.insert(position, (int8_t*)(_data.c_str()), _data.size());
if (m_cursorPos < 0) {
m_cursorPos = 0;
}
regenerateHighLightAt(position, 0, _data.size());
m_selectMode = false;
moveCursor(position+_data.size());
countNumberofLine(); // TODO : use more intelligent counter
setModification(true);
return true;
}
bool appl::Buffer::replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
int64_t position = (int64_t)_pos;
if (position < 0){
position = 0;
}
m_data.replace(position, (int64_t)_posEnd-(int64_t)_pos, (int8_t*)(_data.c_str()), _data.size());
regenerateHighLightAt(position, (int64_t)_posEnd-(int64_t)_pos, _data.size());
m_selectMode = false;
moveCursor(position+_data.size());
countNumberofLine(); // TODO : use more intelligent counter
setModification(true);
return true;
}
void appl::Buffer::removeSelection(void) {
if (hasTextSelected() == false) {
return;
}
int64_t startPos = getStartSelectionPos();
int64_t endPos = getStopSelectionPos();
m_data.remove(startPos, endPos-startPos);
regenerateHighLightAt(startPos, endPos-startPos, 0);
m_selectMode = false;
moveCursor(startPos);
countNumberofLine(); // TODO : use more intelligent counter
setModification(true);
}
void appl::Buffer::tryFindHighlightType(void) {
etk::FSNode file(m_fileName);
std::string type = appl::highlightManager::getTypeExtention(file.fileGetExtention());
if (type.size() == 0) {
return;
}
APPL_DEBUG("Find extention type: " << type);
setHighlightType(type);
}
void appl::Buffer::setHighlightType(const std::string& _type) {
m_highlightType = "";
cleanHighLight();
if (m_highlight == NULL) {
appl::Highlight::release(m_highlight);
}
std::string resourceName = appl::highlightManager::getFileWithTypeType(_type);
if (resourceName == "") {
return;
}
m_highlightType = _type;
m_highlight = appl::Highlight::keep(resourceName);
generateHighLightAt(0, m_data.size());
}
void appl::Buffer::regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64_t _nbAdded) {
// prevent ERROR...
if (NULL == m_highlight) {
return;
}
// prevent No data Call
if ( _nbDeleted == 0
&& _nbAdded == 0) {
return;
}
// normal case
//APPL_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
int64_t posEnd = _pos + _nbDeleted;
// search position of the old element to reparse IT...
int64_t startId;
int64_t stopId;
// clean data if needed
if (m_HLDataPass1.size() == 0) {
// Parse the new element ...
generateHighLightAt(0, m_data.size());
return;
}
// find element previous
findMainHighLightPosition(_pos, posEnd, startId, stopId, true);
// remove deprecated element
if ( startId == -1
&& stopId == -1) {
m_HLDataPass1.clear();
} else if (startId == -1) {
if (stopId == 0){
m_HLDataPass1.erase(m_HLDataPass1.begin());
//APPL_DEBUG("1 * Erase 0");
} else {
m_HLDataPass1.erase(m_HLDataPass1.begin(), m_HLDataPass1.begin()+stopId);
//APPL_DEBUG("2 * Erase 0->" << stopId);
}
} else if (stopId == -1) {
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.end());
stopId = -1;
} else {
int32_t currentSize = m_HLDataPass1.size();
//APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
m_HLDataPass1.erase(m_HLDataPass1.begin()+startId+1, m_HLDataPass1.begin()+stopId);
if (stopId == currentSize-1) {
stopId = -1;
}
}
//APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.size()-1);
// update position after the range position :
int64_t elemStart;
if (startId == -1) {
elemStart = 0;
} else {
elemStart = startId+1;
}
for (int64_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
//APPL_DEBUG("move element=" << i);
m_HLDataPass1[iii].beginStart += _nbAdded - _nbDeleted;
m_HLDataPass1[iii].beginStop += _nbAdded - _nbDeleted;
m_HLDataPass1[iii].endStart += _nbAdded - _nbDeleted;
m_HLDataPass1[iii].endStop += _nbAdded - _nbDeleted;
}
//Regenerate Element inside range
if ( startId == -1
&& stopId == -1) {
//APPL_DEBUG("******* Regenerate ALL");
generateHighLightAt(0, m_data.size());
} else if(-1 == startId) {
//APPL_DEBUG("******* Regenerate START");
generateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
} else if(-1 == stopId) {
//APPL_DEBUG("******* Regenerate STOP");
generateHighLightAt(m_HLDataPass1[m_HLDataPass1.size() -1].endStop, m_data.size(), m_HLDataPass1.size());
} else {
//APPL_DEBUG("******* Regenerate RANGE");
generateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
}
}
void appl::Buffer::findMainHighLightPosition(int64_t _startPos,
int64_t _endPos,
int64_t& _startId,
int64_t& _stopId,
bool _backPreviousNotEnded) {
_startId = -1;
_stopId = -1;
/* rules to start stop:
HighLight data ----
remove area ****
Start pos S
End pos E
Some Case :
----------- ------------ ------------- ----------
S **** E
----------- ------------ ------------- ----------
S ********** E
----------- ------------ ------------- ----------
S **** E
----------- ------------ ------------- ----------
S ********* E
----------- ------------ ------------- ----------
S ********************* E
----------- ------------ ------------- ----------
S ************************ E
----------- ------------ ------------- ----------
S ***************** E
----------- ------------ ------------- ----------
S *************** E
----------- ------------
S *************** E=-1
------------ ------------- ----------
S=-1 *************** E
*/
for (int32_t iii = 0; iii < m_HLDataPass1.size(); ++iii) {
if (m_HLDataPass1[iii].endStop > _startPos) {
break;
}
_startId = iii;
}
// go back while the previous element is not eneded
if (_backPreviousNotEnded == true) {
for (int64_t iii = _startId; iii >= 0; --iii) {
if (m_HLDataPass1[iii].notEnded == false) {
break;
}
_startId = iii-1;
}
}
int64_t elemStart;
if(_startId == -1) {
elemStart = 0;
} else {
elemStart = _startId+1;
}
for (int32_t iii = elemStart; iii < m_HLDataPass1.size(); ++iii) {
if (m_HLDataPass1[iii].beginStart > _endPos) {
_stopId = iii;
break;
}
}
}
void appl::Buffer::generateHighLightAt(int64_t _pos, int64_t _endPos, int64_t _addingPos) {
if (NULL == m_highlight) {
return;
}
//APPL_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addingPos);
m_highlight->parse(_pos, _endPos, m_HLDataPass1, _addingPos, m_data);
}
void appl::Buffer::cleanHighLight(void) {
// remove all element in the list...
m_HLDataPass1.clear();
}
appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(int64_t _pos, int64_t &_starPos) {
int32_t start = etk_max(0, _starPos-1);
for (int32_t iii = start; iii < m_HLDataPass1.size(); ++iii) {
_starPos = iii;
if ( m_HLDataPass1[iii].beginStart <= _pos
&& m_HLDataPass1[iii].endStop > _pos) {
return &m_HLDataPass1[iii];
}
if(m_HLDataPass1[iii].beginStart > _pos) {
return NULL;
}
}
return NULL;
}
void appl::Buffer::hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t _HLStart, int64_t _nbLines) {
_MData.posHLPass1 = 0;
_MData.posHLPass2 = 0;
if (NULL == m_highlight) {
return;
}
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
_HLStart = (int32_t)getStartLine(position(_HLStart));
_MData.HLData.clear();
int64_t HLStop = countForwardNLines(position(_HLStart), _nbLines);
int64_t startId = 0;
int64_t stopId = 0;
// find element previous
findMainHighLightPosition(_HLStart, HLStop, startId, stopId, true);
//APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
int64_t endSearch = stopId+1;
if (stopId == -1) {
endSearch = m_HLDataPass1.size();
}
int64_t kkk;
for (kkk = etk_max(startId, 0); kkk < endSearch; ++kkk) {
// empty section :
if (kkk == 0) {
if (_HLStart < m_HLDataPass1[kkk].beginStart) {
//APPL_DEBUG(" == > (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
m_highlight->parse2(_HLStart,
m_HLDataPass1[kkk].beginStart,
_MData.HLData,
m_data);
} // else : nothing to do ...
} else {
//APPL_DEBUG(" == > (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
m_HLDataPass1[kkk].beginStart,
_MData.HLData,
m_data);
}
// under section :
//APPL_DEBUG(" == > (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ...
}
if (endSearch == (int32_t)m_HLDataPass1.size() ){
//if( k < (int32_t)m_HLDataPass1.size()) {
if (m_HLDataPass1.size() != 0) {
//APPL_DEBUG(" == > (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_highlight->parse2(m_HLDataPass1[kkk-1].endStop,
HLStop,
_MData.HLData,
m_data);
} else {
//APPL_DEBUG(" == > (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_highlight->parse2(0,
HLStop,
_MData.HLData,
m_data);
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
appl::HighlightInfo* appl::Buffer::getElementColorAtPosition(appl::DisplayHLData& _MData, int64_t _pos) {
int64_t start = etk_max(0, _MData.posHLPass2-1);
for (int64_t iii=start; iii<(int32_t)_MData.HLData.size(); iii++) {
_MData.posHLPass2 = iii;
if( _MData.HLData[iii].beginStart <= _pos
&& _MData.HLData[iii].endStop > _pos)
{
return &_MData.HLData[iii];
}
if(_MData.HLData[iii].beginStart > _pos) {
return getElementColorAtPosition(_pos, _MData.posHLPass1);
}
}
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;
}

627
sources/appl/Buffer.h Normal file
View File

@@ -0,0 +1,627 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_BUFFER_H__
#define __APPL_BUFFER_H__
#include <etk/UString.h>
#include <etk/os/FSNode.h>
#include <etk/unicode.h>
#include <ewol/ewol.h>
#include <etk/Buffer.h>
#include <ewol/renderer/EObject.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Text.h>
#include <appl/Highlight.h>
namespace appl {
class DisplayHLData {
public:
std::vector<appl::HighlightInfo> HLData;
int64_t posHLPass1;
int64_t posHLPass2;
};
class Buffer : public ewol::EObject {
public:
class Iterator {
// Private data :
private:
int64_t m_current; //!< curent Id in the Buffer
appl::Buffer* m_data; //!< Pointer on the curent Buffer
char32_t m_value; //!< store vlue to prevent multiple calcule of getting the data
public:
/**
* @brief Basic itarator constructor with no link.
*/
Iterator(void):
m_current(0),
m_data(NULL),
m_value(etk::UChar::Null) {
// nothing to do ...
};
/**
* @brief Recopy constructor.
* @param[in] _obj The Iterator that might be copy
*/
Iterator(const Iterator & _obj):
m_current(_obj.m_current),
m_data(_obj.m_data),
m_value(etk::UChar::Null) {
// nothing to do ...
};
/**
* @brief Asignation operator.
* @param[in] _otherIterator The Iterator that might be copy
* @return reference on the curent Iterator
*/
Iterator& operator=(const Iterator & _obj) {
m_current = _obj.m_current;
m_data = _obj.m_data;
m_value = etk::UChar::Null;
return *this;
};
/**
* @brief Basic destructor
*/
~Iterator(void) {
m_current = 0;
m_data = NULL;
m_value = etk::UChar::Null;
};
/**
* @brief basic boolean cast
* @return true if the element is present in buffer
*/
operator bool (void) const {
if (m_data == NULL) {
return false;
}
if (m_current >= m_data->m_data.size()) {
return false;
}
if (m_current < 0) {
return false;
}
return true;
};
/**
* @brief basic boolean cast
* @return true if the element is present in buffer
*/
operator int64_t (void) const {
if (m_data == NULL) {
return 0;
}
if (m_current < 0) {
return 0;
}
if (m_current > m_data->m_data.size()) {
return m_data->m_data.size();
}
return m_current;
};
/**
* @brief Incremental operator
* @return Reference on the current iterator incremented
*/
Iterator& operator++ (void);
/**
* @brief Decremental operator
* @return Reference on the current iterator decremented
*/
Iterator& operator-- (void);
/**
* @brief Incremental operator
* @return Reference on a new iterator and increment the other one
*/
Iterator operator++ (int32_t) {
Iterator it(*this);
++(*this);
return it;
};
/**
* @brief Decremental operator
* @return Reference on a new iterator and decrement the other one
*/
Iterator operator-- (int32_t) {
Iterator it(*this);
--(*this);
return it;
};
/**
* @brief egality iterator
* @return true if the iterator is identical pos
*/
bool operator== (const Iterator& _obj) const {
if ( m_current == _obj.m_current
&& m_data == _obj.m_data) {
return true;
}
return false;
};
/**
* @brief egality iterator
* @return true if the iterator is identical pos
*/
bool operator!= (const Iterator& _obj) const {
if ( m_current != _obj.m_current
|| m_data != _obj.m_data) {
return true;
}
return false;
};
/**
* @brief <= iterator
* @return true if the iterator is identical pos
*/
bool operator<= (const Iterator& _obj) const {
if (m_data != _obj.m_data) {
return false;
}
if (m_current <= _obj.m_current) {
return true;
}
return false;
};
/**
* @brief >= iterator
* @return true if the iterator is identical pos
*/
bool operator>= (const Iterator& _obj) const {
if (m_data != _obj.m_data) {
return false;
}
if (m_current >= _obj.m_current) {
return true;
}
return false;
};
/**
* @brief < iterator
* @return true if the iterator is identical pos
*/
bool operator< (const Iterator& _obj) const {
if (m_data != _obj.m_data) {
return false;
}
if (m_current < _obj.m_current) {
return true;
}
return false;
};
/**
* @brief > iterator
* @return true if the iterator is identical pos
*/
bool operator> (const Iterator& _obj) const {
if (m_data != _obj.m_data) {
return false;
}
if (m_current > _obj.m_current) {
return true;
}
return false;
};
/**
* @brief Get the value on the current element
* @return The request element value
*/
char32_t operator* (void);
/**
* @brief Get the position in the buffer
* @return The requested position.
*/
int64_t getPos(void) const {
if (m_data == NULL) {
return 0;
}
if (m_current < 0) {
return 0;
}
if (m_current >= m_data->m_data.size()) {
return m_data->m_data.size()-1;
}
return m_current;
};
/**
* @brief move the element position
* @return a new iterator.
*/
Iterator operator+ (const int64_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
++tmpp;
}
return tmpp;
};
Iterator operator+ (const int32_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
++tmpp;
}
return tmpp;
};
Iterator operator+ (const size_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
++tmpp;
}
return tmpp;
};
/**
* @brief move the element position
* @return a new iterator.
*/
Iterator operator- (const int64_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
--tmpp;
}
return tmpp;
};
Iterator operator- (const int32_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
--tmpp;
}
return tmpp;
};
Iterator operator- (const size_t _val) const {
Iterator tmpp(*this);
for (int64_t iii=0; iii<_val; ++iii) {
--tmpp;
}
return tmpp;
};
private:
Iterator(Buffer* _obj, int64_t _pos) :
m_current(_pos),
m_data(_obj),
m_value(etk::UChar::Null) {
// nothing to do ...
};
friend class Buffer;
};
public:
static const char* const eventIsModify;
static const char* const eventIsSave;
static const char* const eventSelectChange;
static const char* const eventChangeName;
public:
Buffer(void);
~Buffer(void);
private:
bool m_hasFileName; //!< when new file, the buffer has no name ==> but it might be reference with a single name ...
std::string m_fileName; //!< name of the file (with his path)
public:
/**
* @brief get the curent filename of the Buffer
*/
const std::string& getFileName(void) {
return m_fileName;
}
/**
* @brief Check if the buffer has a real filename.
* @return the status of the existance of a name.
*/
bool hasFileName(void) {
return m_hasFileName;
}
/**
* @brief Load A specific file in this buffer.
* @param[in] _name name of the file.
* @return true if file corectly opened.
*/
bool loadFile(const std::string& _name);
/**
* @brief Set a file name at this buffer (no saving ...)
* @param[in] _name name of the file.
*/
void setFileName(const std::string& _name);
/**
* @brief save the file in the specify path.
* @return true is saving well done
*/
bool storeFile(void);
protected:
bool m_isModify; //!< true if the file is modify
public:
/**
* @breif get the status of file modification.
* @return true if file is modify.
*/
bool isModify(void) {
return m_isModify;
}
/**
* @brief Set the file modification status.
* @param[in] _status New modification status.
*/
void setModification(bool _status);
protected:
etk::Buffer m_data; //!< copy of the file buffer
public:
etk::Buffer& getData(void) {
return m_data;
};
protected:
int64_t m_cursorPos; //!< cursor position.
public:
void moveCursor(int64_t _pos);
protected:
int64_t m_cursorSelectPos; //!< cursor position.
public:
/**
* @brief Set the selection position in the buffer.
* @param[in] _pos Position of the selection.
*/
void setSelectionPos(const Iterator& _pos);
/**
* @brief Remove Selection of the buffer.
*/
void unSelect(void);
/**
* @brief Remove the selection of the buffer. (do nothing if no secection)
*/
void removeSelection(void);
/**
* @brief Get the status of selection.
* @return true if we have a curent selection, false otherwise.
*/
bool hasTextSelected(void) {
return m_cursorSelectPos >= 0;
}
/**
* @brief Get the Start position of the selection.
* @return position of the start selection.
*/
int64_t getStartSelectionPos(void) {
return etk_min(m_cursorPos, m_cursorSelectPos);
}
/**
* @brief Get the Stop position of the selection.
* @return position of the stop selection.
*/
int64_t getStopSelectionPos(void) {
return etk_max(m_cursorPos, m_cursorSelectPos);
}
protected:
float m_cursorPreferredCol; //!< position of the cursor when up and down is done.
public:
/**
* @brief Set the favorite up and down position (distance from the left of the screen.
* @param[in] _val New distance (in pixels).
*/
void setFavoriteUpDownPos(float _val) {
m_cursorPreferredCol = _val;
}
/**
* @brief Get the favorite distance from the left screen (For up and down moving).
* @return The distance in pixels.
*/
float getFavoriteUpDownPos(void) {
return m_cursorPreferredCol;
}
protected:
bool m_selectMode; //!< when true, the select mode keep the moving selecting
public:
/**
* @brief Set the selection mode (if true, the move event creata a selection)
* @param[in] _status New status of the section.
*/
void setSelectMode(bool _status) {
m_selectMode = _status;
}
/**
* @brief Get the selection mode (if true, the move event creata a selection)
* @return The selecting mode.
*/
bool getSelectMode(void) {
return m_selectMode;
}
public:
/**
* @brief Get the position of selection around (select word).
* @param[in] _startPos Position to start the selection.
* @param[out] _beginPos Position where the element start.
* @param[out] _endPos Position where the element stop.
* @return true if we find a selection around.
*/
bool getPosAround(const Iterator& _startPos, Iterator &_beginPos, Iterator &_endPos);
/**
* @brief Expand the specify char to have a user frendly display for special char and tabs
* @param[in] _indent Curent indentation in the line
* @param[in] _value Current value to transform
* @param[out] _out String that represent the curent value to display
*/
void expand(int32_t& _indent, const char32_t& _value, std::u32string& _out) const;
/**
* @brief get the start of a line with the position in the buffer.
* @param[in] _pos position in the buffer.
* @return The position in the buffer of the start of the line.
*/
Iterator getStartLine(const Iterator& _pos);
/**
* @brief get the end of a line with the position in the buffer.
* @param[in] _pos position in the buffer.
* @return The position in the buffer of the end of the line.
*/
Iterator getEndLine(const Iterator& _pos);
/**
* @brief Search a character in the buffer.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search Character to search.
* @param[out] _result Research position.
* @return true if pos if fined.
*/
// TODO : rename find
bool search(const Iterator& _pos, const char32_t& _search, Iterator& _result);
/**
* @brief Search a character in the buffer in back mode.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search Character to search.
* @param[out] _result Research position.
* @return true if pos if fined.
*/
// TODO : rename rfind
bool searchBack(const Iterator& _pos, const char32_t& _search, Iterator& _result);
/**
* @brief Search a string in the buffer.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search String to search.
* @param[out] _result Research position.
* @param[in] _caseSensitive (optional) Search making attention of the case [default true]
* @return true if pos if fined.
*/
// TODO : rename find
bool search(const Iterator& _pos, const std::u32string& _search, Iterator& _result, bool _caseSensitive = true);
/**
* @brief Search a string in the buffer in back mode.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search String to search.
* @param[out] _result Research position.
* @param[in] _caseSensitive (optional) Search making attention of the case [default true]
* @return true if pos if fined.
*/
// TODO : rename rfind
bool searchBack(const Iterator& _pos, const std::u32string& _search, Iterator& _result, bool _caseSensitive = true);
/**
* @brief find the first character of the line "nLines" forward
* @param[in] _startPos Start position.
* @param[in] _nLines Number of line to count.
* @return position of the starting the line.
*/
Iterator countForwardNLines(const Iterator& _startPos, int32_t _nLines);
/**
* @brief find the first character of the line "nLines" backwards
* @param[in] _startPos Start position to count (this caracter is not counted)
* @param[in] _nLines Number of line to count (if == 0 means find the beginning of the line)
* @return position of the starting the line
*/
Iterator countBackwardNLines(const Iterator& _startPos, int32_t _nLines);
public:
/**
* @brief copy data in the _data ref value.
* @param[out] _data Output stream to copy.
* @return true of no error occured.
*/
bool copy(std::string& _data);
/**
* @brief copy data in the _data ref value.
* @param[out] _data Output stream to copy.
* @param[in] _pos Position to add the data.
* @param[in] _posEnd End position to end replace the data.
*/
void copy(std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
/**
* @brief Write data at a specific position
* @param[in] _data Data to insert in the buffer
* @param[in] _pos Position to add the data.
* @return true if the write is done corectly
*/
bool write(const std::string& _data, const appl::Buffer::Iterator& _pos);
/**
* @brief Write data at a specific position
* @param[in] _data Data to insert in the buffer
* @param[in] _pos Position to add the data.
* @param[in] _posEnd End position to end replace the data.
* @return true if the write is done corectly
*/
bool replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
public: // iterator section :
/**
* @brief Get an iterator an an specific position
* @param[in] _pos Requested position of the iterator.
* @return The Iterator
*/
Iterator position(int64_t _pos);
/**
* @brief Get an Iterator on the start position.
* @return The Iterator
*/
Iterator begin(void);
/**
* @brief Get an Iterator on the end position.
* @return The Iterator
*/
Iterator end(void);
/**
* @brief Get an Iterator on the cursor position.
* @return The Iterator
*/
Iterator cursor(void);
/**
* @brief Get an Iterator on the start selection.
* @return The Iterator
*/
Iterator selectStart(void);
/**
* @brief Get an Iterator on the stop selection.
* @return The Iterator
*/
Iterator selectStop(void);
protected:
int32_t m_nbLines; //!< number of line in the buffer
public:
/**
* @brief Get the number of line in the buffer.
* @return number of line in the Buffer.
*/
int32_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
*/
void countNumberofLine(void);
protected:
std::string m_highlightType; //!< Name of the highlight type
appl::Highlight* m_highlight; //!< internal link with the Highlight system
std::vector<appl::HighlightInfo> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
public:
/**
* @brief Find the Highligh capability
*/
void tryFindHighlightType(void);
/**
* @brief Set type of highlight
* @param[in] _type type of the highlight
*/
void setHighlightType(const std::string& _type);
/**
* @brief Get type of highlight
* @return Type of the highlight
*/
const std::string& setHighlightType(void) {
return m_highlightType;
};
void regenerateHighLightAt(int64_t _pos, int64_t _nbDeleted, int64_t _nbAdded);
void findMainHighLightPosition(int64_t _startPos,
int64_t _endPos,
int64_t& _startId,
int64_t& _stopId,
bool _backPreviousNotEnded);
void generateHighLightAt(int64_t _pos, int64_t _endPos, int64_t _addingPos=0);
void cleanHighLight(void);
appl::HighlightInfo* getElementColorAtPosition(int64_t _pos, int64_t &_starPos);
void hightlightGenerateLines(appl::DisplayHLData& _MData, int64_t _HLStart, int64_t _nbLines);
appl::HighlightInfo* getElementColorAtPosition(appl::DisplayHLData& _MData, int64_t _pos);
};
};
#endif

View File

@@ -1,586 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <BufferManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#undef __class__
#define __class__ "classBufferManager"
class classBufferManager: public ewol::EObject
{
public:
// Constructeur
classBufferManager(void);
~classBufferManager(void);
/**
* @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 GetObjectType(void)
{
return "ApplBufferManager";
}
public:
/**
* @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 ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
private:
// return the ID of the buffer allocated
// create a buffer with no element
int32_t Create(void);
// open curent filename
int32_t Open(etk::FSNode &myFile);
bool Remove(int32_t BufferID);
public:
int32_t GetSelected(void) { return m_idSelected;};
//void SetSelected(int32_t id) {m_idSelected = id;};
BufferText* Get(int32_t BufferID);
bool Exist(int32_t BufferID);
bool Exist(etk::FSNode &myFile);
int32_t GetId(etk::FSNode &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void);
uint32_t SizeOpen(void);
int32_t WitchBuffer(int32_t iEmeElement);
private:
etk::Vector<BufferText*> listBuffer; //!< element List of the char Elements
void RemoveAll(void); //!< remove all buffer
int32_t m_idSelected;
};
// Constructeur
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
classBufferManager::classBufferManager(void)
{
m_idSelected = -1;
RegisterMultiCast(ednMsgGuiNew);
RegisterMultiCast(ednMsgOpenFile);
RegisterMultiCast(ednMsgGuiClose);
RegisterMultiCast(ednMsgGuiSave);
RegisterMultiCast(ednMsgCodeViewSelectedId);
RegisterMultiCast(ednMsgBufferId);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
classBufferManager::~classBufferManager(void)
{
//clean All Buffer
APPL_INFO("~classBufferManager::RemoveAll();");
RemoveAll();
// clear The list of Buffer
APPL_INFO("~classBufferManager::listBuffer.Clear();");
listBuffer.Clear();
}
/**
* @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 classBufferManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::EObject::OnReceiveMessage(CallerObject, eventId, data);
if (eventId == ednMsgBufferId) {
// select a new buffer ID :
if (data == "") {
APPL_ERROR("Request select buffer ID = \"\" ");
} else {
int32_t newID = -1;
sscanf(data.c_str(), "%d", &newID);
if(true == Exist(newID)) {
m_idSelected = newID;
} else {
m_idSelected = -1;
APPL_ERROR("Request a non existant ID : " << newID << " reset to -1...");
}
}
} else if (eventId == ednMsgGuiNew) {
int32_t newOne = Create();
if (-1 != newOne) {
m_idSelected = newOne;
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
}
} else if (eventId == ednMsgOpenFile) {
if (data != "" ) {
etk::FSNode myFile(data);
APPL_DEBUG("request open file = \"" <<data << "\" ?= \"" << myFile << "\"");
int32_t newOne = Open(myFile);
if (-1 != newOne) {
m_idSelected = newOne;
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
} else {
// TODO : notify user that we can not open the request file...
APPL_ERROR("Can not open the file : \"" << myFile << "\"");
}
}
} else if (eventId == ednMsgGuiSave) {
if (data == "") {
APPL_ERROR("Null data for close file ... ");
} else {
if (data == "current") {
// Check buffer existence
if(true == Exist(m_idSelected)) {
// If no name ==> request a Gui display ...
if (Get(m_idSelected)->HaveName() == false) {
SendMultiCast(ednMsgGuiSaveAs, "current");
} else {
Get(m_idSelected)->Save();
}
}
} else {
int32_t newId;
sscanf(data.c_str(), "%d", &newId);
if (false == Exist(newId)) {
APPL_ERROR("Request a save As with a non existant ID=" << newId);
} else {
// If no name ==> request a Gui display ...
if (Get(newId)->HaveName() == false) {
SendMultiCast(ednMsgGuiSaveAs, newId);
} else {
Get(m_idSelected)->Save();
}
}
SendMultiCast(ednMsgBufferState, "saved");
}
}
} else if (eventId == ednMsgGuiClose) {
if (data == "") {
APPL_ERROR("Null data for close file ... ");
} else {
if (data == "All") {
} else {
int32_t closeID = -1;
if (data == "current") {
closeID = m_idSelected;
APPL_DEBUG("Close specific buffer ID" << closeID);
} else {
// close specific buffer ...
sscanf(data.c_str(), "%d", &closeID);
APPL_DEBUG("Close specific buffer ID="<< closeID);
}
if(true == Exist(closeID)) {
// Get the new display buffer
if (m_idSelected == closeID) {
// Try previous buffer
int32_t destBuffer = -1;
for(int32_t ii=closeID-1; ii >= 0; ii--) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
// try next buffer
if (-1 == destBuffer) {
for(int32_t ii=closeID+1; ii < listBuffer.Size(); ii++) {
if (true == Exist(ii) ) {
destBuffer = ii;
break;
}
}
}
// set it to the currect display
m_idSelected = destBuffer;
SendMultiCast(ednMsgBufferId, destBuffer);
}
// Remove requested buffer
Remove(closeID);
SendMultiCast(ednMsgBufferListChange);
} else {
APPL_ERROR("Request Close of a non existant ID : " << closeID);
}
}
}
} else if (eventId == ednMsgCodeViewSelectedId) {
//Change the selected buffer
if (data == "") {
APPL_ERROR("Null data for changing buffer ID file ... ");
} else {
int32_t newId;
sscanf(data.c_str(), "%d", &newId);
if (true == Exist(newId)) {
m_idSelected = newId;
} else {
APPL_ERROR("code biew request the selection of an non -existant buffer ==> reset to -1");
m_idSelected = -1;
}
SendMultiCast(ednMsgBufferId, m_idSelected);
SendMultiCast(ednMsgBufferListChange);
}
}
/*
switch (id)
{
// Check buffer existence
if(true == Exist(dataID)) {
// If no name ==> request a Gui display ...
if (Get(dataID)->HaveName() == false) {
SendMessage(APPL_MSG__GUI_SHOW_SAVE_AS, dataID);
} else {
Get(dataID)->Save();
}
}
break;
}
*/
}
/**
* @brief Remove all buffer opened
*
* @param[in,out] ---
*
* @return ---
*
*/
void classBufferManager::RemoveAll(void)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
Remove(i);
}
SendMultiCast(ednMsgGuiClose, "All");
}
/**
* @brief Create a new buffer with no name and empty
*
* @param[in,out] ---
*
* @return The ID of the curent buffer where the file is loaded
*
*/
int32_t classBufferManager::Create(void)
{
// allocate a new Buffer
BufferText *myBuffer = new BufferText();
// Add at the list of element
listBuffer.PushBack(myBuffer);
int32_t basicID = listBuffer.Size() - 1;
return basicID;
}
/**
* @brief open a file with the name set in parameters
*
* @param[in] filename curent filename
*
* @return The ID of the curent buffer where the file is loaded
*
* @todo : check if this file is not curently open and return the old ID
*
*/
int32_t classBufferManager::Open(etk::FSNode &myFile)
{
if (false == Exist(myFile)) {
// allocate a new Buffer
BufferText *myBuffer = new BufferText(myFile);
// Add at the list of element
listBuffer.PushBack(myBuffer);
return listBuffer.Size() - 1;
} else {
// the buffer already existed ==> we open it ...
return GetId(myFile);
}
}
BufferText * classBufferManager::Get(int32_t BufferID)
{
// possible special case : -1;
if (-1 >= BufferID) {
return NULL;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return listBuffer[BufferID];
} else {
APPL_ERROR("non existing Buffer " << BufferID);
}
} else {
APPL_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
}
return NULL;
}
bool classBufferManager::Exist(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
return true;
}
}
return false;
}
bool classBufferManager::Exist(etk::FSNode &myFile )
{
if (-1 == GetId(myFile)) {
return false;
}
return true;
}
int32_t classBufferManager::GetId(etk::FSNode &myFile)
{
int32_t iii;
// check if the Buffer existed
for (iii=0; iii < listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
if ( listBuffer[iii]->GetFileName() == myFile) {
return iii;
}
}
}
return -1;
}
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t classBufferManager::Size(void)
{
return listBuffer.Size();
}
// nb of opens file Now ...
uint32_t classBufferManager::SizeOpen(void)
{
uint32_t jjj = 0;
// check if the Buffer existed
for (int32_t iii=0; iii<listBuffer.Size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
jjj++;
}
}
return jjj;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool classBufferManager::Remove(int32_t BufferID)
{
if (-1 >= BufferID) {
return false;
}
// check if the Buffer existed
if (BufferID < listBuffer.Size()) {
// check if the buffer already existed
if (NULL != listBuffer[BufferID]) {
// TODO : Check if it saved...
/*
if (false == IsSaved(BufferID) ) {
APPL_INFO("Buffer " << BufferID << " : Not Saved", BufferID);
}
*/
// Delete the Buffer
delete( listBuffer[BufferID] );
listBuffer[BufferID] = NULL;
/*
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
*/
return true;
} else {
APPL_INFO("non existing Buffer " << BufferID);
return false;
}
} else {
APPL_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.Size());
return false;
}
}
/**
* @brief to get the element 14 in the buffer
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t classBufferManager::WitchBuffer(int32_t iEmeElement)
{
int32_t i;
for (i=0; i<listBuffer.Size(); i++) {
if (NULL != listBuffer[i]) {
iEmeElement--;
// find the element :
if (0 == iEmeElement) {
return i;
}
}
}
return -1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace part :
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static classBufferManager * localManager = NULL;
void BufferManager::Init(void)
{
if (NULL != localManager) {
EWOL_ERROR("classBufferManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new classBufferManager();
if (NULL == localManager) {
EWOL_CRITICAL("Allocation of classBufferManager not done ...");
}
}
void BufferManager::UnInit(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
int32_t BufferManager::GetSelected(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->GetSelected();
}
BufferText * BufferManager::Get(int32_t BufferID)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return NULL;
}
return localManager->Get(BufferID);
}
bool BufferManager::Exist(int32_t BufferID)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return false;
}
return localManager->Exist(BufferID);
}
bool BufferManager::Exist(etk::FSNode &myFile)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return false;
}
return localManager->Exist(myFile);
}
int32_t BufferManager::GetId(etk::FSNode &myFile)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->GetId(myFile);
}
uint32_t BufferManager::Size(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return 0;
}
return localManager->Size();
}
uint32_t BufferManager::SizeOpen(void)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return 0;
}
return localManager->SizeOpen();
}
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
{
if (NULL == localManager) {
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
return -1;
}
return localManager->WitchBuffer(iEmeElement);
}

View File

@@ -1,32 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __BUFFER_MANAGER_H__
#define __BUFFER_MANAGER_H__
#include <BufferText.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
namespace BufferManager
{
void Init(void);
void UnInit(void);
int32_t GetSelected(void);
BufferText* Get(int32_t BufferID);
bool Exist(int32_t BufferID);
bool Exist(etk::FSNode &myFile);
int32_t GetId(etk::FSNode &myFile);
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
uint32_t Size(void);
uint32_t SizeOpen(void);
int32_t WitchBuffer(int32_t iEmeElement);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,159 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __BUFFER_TEXT_H__
#define __BUFFER_TEXT_H__
#include <etk/UString.h>
#include <etk/os/FSNode.h>
#include <etk/unicode.h>
#include <ewol/ewol.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/compositing/Text.h>
#include "ColorizeManager.h"
#include "EdnBuf.h"
typedef enum {
CURSOR_DISPLAY_MODE_NORMAL = 259,
CURSOR_DISPLAY_MODE_INSERT,
CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te;
class CharElement
{
public:
float m_LineOffset; // TODO : DEPRECATED ...
int16_t m_yOffset;
int16_t m_xOffset;
int16_t m_ySize;
int32_t m_bufferPos;
};
typedef struct{
uint32_t nbTotalLine; //!< Number of line in the buffer
uint32_t nbTotalColomn; //!< Number of line in the buffer
uint32_t startLineDisplay; //!< First line display.
uint32_t startColomnDisplay; //!< First Colomn displayed
uint32_t diplayableColomn; //!< NB colomn that can be displayed
uint32_t diplayableLine; //!< NB Line that can be displayed
}infoStatBuffer_ts;
class BufferText
{
private:
bool m_fileModify; //!<
// naming
etk::FSNode m_fileName; //!< filename of the curent buffer
bool m_haveName; //!< to know if the file have a name or NOT
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
vec2 m_maximumSize; //!< current maxSize of the buffer
public:
void SetModify(bool status);
virtual vec2 GetBorderSize(void);
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
void SetMaximumSize(vec2 maxSize) { m_maximumSize = maxSize; };
bool NeedToUpdateDisplayPosition(void);
vec2 GetMaxSize(void) { return m_maximumSize; };
bool IsModify(void);
public:
etk::FSNode GetFileName(void)
{
return m_fileName;
};
void SetFileName(etk::FSNode &newName)
{
m_fileName = newName;
m_haveName = true;
NameChange();
};
void SetFileName(etk::UString &newName)
{
m_fileName.SetName(newName);
m_haveName = true;
NameChange();
};
bool HaveName(void)
{
return m_haveName;
}
public:
BufferText(void);
BufferText(etk::FSNode &fileName);
virtual ~BufferText(void);
void Save(void);
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
int32_t Display(ewol::Text& OOText,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
void AddChar(uniChar_t unicodeData);
void cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent);
void MouseSelectFromCursorTo(vec2 pos);
void MouseEvent(vec2 pos);
void MouseEventDouble(void);
void MouseEventTriple(void);
void Copy(ewol::clipBoard::clipboardListe_te clipboardID);
void Cut(ewol::clipBoard::clipboardListe_te clipboardID);
void Paste(ewol::clipBoard::clipboardListe_te clipboardID);
void Search(etk::UString &data, bool back, bool caseSensitive, bool wrap, bool regExp);
void Replace(etk::UString &data);
int32_t FindLine(etk::UString &data);
void JumpAtLine(int32_t newLine);
int32_t GetCurrentLine(void);
void RemoveLine(void);
void SelectAll(void);
void SelectNone(void);
void Undo(void);
void Redo(void);
void SetCharset(unicode::charset_te newCharset);
int32_t GetNumberOfLine(void);
protected:
void NameChange(void);
private:
int32_t GetLineNumberNumberOfElement(void);
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
vec2 m_displaySize; //!< number of char displayable in the screan
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
etk::Vector<CharElement> m_elmentList; //!< Elemnt position for every char displayed
// internal function
void BasicInit(void);
private:
bool m_centerRequested;
public:
virtual vec2 GetPosition(int32_t fontId, bool& centerRequested);
private:
bool TextDMoveUp(int32_t offset);
bool TextDMoveDown(int32_t offset);
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
int32_t GetMousePosition(vec2 pos);
void DrawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,193 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __EDN_BUF_H__
#define __EDN_BUF_H__
/* Maximum length in characters of a tab or control character expansion
of a single buffer character */
#define MAX_EXP_CHAR_LEN 20*4
class EdnBuf;
#include <etk/Buffer.h>
#include <EdnBufHistory.h>
#include <HighlightManager.h>
#include <etk/unicode.h>
/*
rectStart rectStart
start ************* *************
********** * xxxx*xxxxxx *
* ******** xxxx*xxxxxxxxxxx*xxxxx
end *************** *************
rectEnd rectEnd
*/
typedef struct {
bool selected; //!< True if the selection is active
bool rectangular; //!< True if the selection is rectangular
bool zeroWidth; //!< Width 0 selections aren't "real" selections, but they can be useful when creating rectangular selections from the keyboard.
int32_t start; //!< Pos. of start of selection, or if rectangular start of line containing it.
int32_t end; //!< Pos. of end of selection, or if rectangular end of line containing it.
int32_t rectStart; //!< Indent of left edge of rect. selection
int32_t rectEnd; //!< Indent of right edge of rect. selection
} selection;
typedef struct {
etk::Vector<colorInformation_ts> HLData;
int32_t posHLPass1;
int32_t posHLPass2;
}displayHLData_ts;
class EdnBuf {
// TODO : Set an iterator to acces at every data without knowin the system ...
public:
// constructer
EdnBuf(void);
// destructer
~EdnBuf(void);
// public function :
void GetAll( etk::Vector<int8_t> &text);
void SetAll( etk::Vector<int8_t> &text);
void GetRange( int32_t start, int32_t end, etk::Vector<int8_t> &output);
void GetRange( int32_t start, int32_t end, etk::UString &output);
bool DumpIn( etk::FSNode &file);
bool DumpFrom( etk::FSNode &file);
// replace with operator [] ...
int8_t operator[] (int32_t);
int32_t Insert( int32_t pos, etk::Vector<int8_t> &insertText);
int32_t Insert( int32_t pos, etk::UString &insertText);
int32_t Replace( int32_t start, int32_t end, etk::Vector<int8_t> &insertText);
int32_t Replace( int32_t start, int32_t end, etk::UString &insertText);
void Remove( int32_t start, int32_t end);
int32_t Indent( void);
int32_t UnIndent( void);
void GetLineText( int32_t pos, etk::Vector<int8_t> &text);
int32_t StartOfLine( int32_t pos);
int32_t EndOfLine( int32_t pos);
int32_t GetExpandedChar( int32_t &pos, int32_t indent, uniChar_t outUnicode[MAX_EXP_CHAR_LEN], uint32_t &currentChar);
int32_t GetExpandedChar( int32_t &pos, int32_t indent, char outUTF8[MAX_EXP_CHAR_LEN], uint32_t &currentChar);
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);
int32_t CountLines( void);
int32_t CountLines( etk::Vector<int8_t> &data);
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
bool SearchForward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
bool SearchBackward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
// Buffer Size system :
int32_t Size(void) { return m_data.Size(); };
int32_t NumberOfLines(void) { return m_nbLine; };
// -----------------------------------------
// selection remember...
// -----------------------------------------
public:
bool SelectHasSelection(void);
void Select( int32_t start, int32_t end);
void Unselect( void);
void RectSelect( int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd);
bool GetSelectionPos( int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd);
void GetSelectionText( etk::Vector<int8_t> &text);
void GetSelectionText( etk::UString &text);
void RemoveSelected( void);
int32_t ReplaceSelected( etk::Vector<int8_t> &text);
int32_t ReplaceSelected( etk::UString &text);
private:
// current selection of the buffer
selection m_selectionList; //!< Selection area of the buffer
void UpdateSelection( int32_t pos, int32_t nDeleted, int32_t nInserted);
// -----------------------------------------
// History section :
// -----------------------------------------
public:
int32_t Undo(void);
int32_t Redo(void);
private:
bool m_isUndoProcessing;
bool m_isRedoProcessing;
etk::Vector<EdnBufHistory*> m_historyUndo;
etk::Vector<EdnBufHistory*> m_historyRedo;
// -----------------------------------------
// hightlight section :
// -----------------------------------------
private:
Highlight * m_Highlight; //!< internal link with the Highlight system
etk::Vector<colorInformation_ts> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded);
void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0);
void CleanHighLight(void);
void FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded);
public:
void SetHLSystem( Highlight * newHLSystem);
void HightlightGenerateLines(displayHLData_ts & MData, int32_t startPos, int32_t nbLines);
colorInformation_ts * GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos);
private:
colorInformation_ts * GetElementColorAtPosition(int32_t pos, int32_t &starPos);
private:
etk::Buffer m_data; //!< buffer of the data in the mode int8_t
void CountNumberOfLines(void);
int32_t m_nbLine; //!< Number of line in the biffer
// -----------------------------------------
// Display property and charset ...
// -----------------------------------------
public:
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)
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
// -----------------------------------------
// Local function :
// -----------------------------------------
private:
void findRectSelBoundariesForCopy( int32_t lineStartPos, int32_t rectStart, int32_t rectEnd, int32_t *selStart, int32_t *selEnd);
char * getSelectionText( selection &sel);
void removeSelected( selection &sel);
void replaceSelected( selection &sel, const char *text);
void eventModification( int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
int32_t LocalInsert( int32_t pos, etk::Vector<int8_t> &insertText);
int32_t LocalInsert( int32_t pos, etk::UString &insertText);
bool charMatch( char first, char second, bool caseSensitive = true);
};
#endif

View File

@@ -1,64 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBufHistory.h>
#undef __class__
#define __class__ "EdnBufHistory"
EdnBufHistory::EdnBufHistory(void)
{
//APPL_INFO("EdnBufHistory new");
m_pos = 0;
m_nInserted = 0;
}
EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
{
//APPL_INFO("EdnBufHistory new + data");
m_pos = pos;
m_nInserted = nInserted;
m_deletedText = deletedText;
}
void EdnBufHistory::Set(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText)
{
//APPL_INFO("EdnBufHistory new + data");
m_pos = pos;
m_nInserted = nInserted;
m_deletedText = deletedText;
}
EdnBufHistory::~EdnBufHistory(void)
{
// nothing to do ...
}
int32_t EdnBufHistory::getPos(void)
{
return m_pos;
}
int32_t EdnBufHistory::getnbDeleted(void)
{
return m_deletedText.Size();
}
int32_t EdnBufHistory::getnbInserted(void)
{
return m_nInserted;
}
void EdnBufHistory::getData(etk::Vector<int8_t> &deletedText)
{
deletedText = m_deletedText;
}

View File

@@ -1,32 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __EDN_BUFFER_HISTORY_H__
#define __EDN_BUFFER_HISTORY_H__
#include <etk/Vector.h>
class EdnBufHistory{
public:
EdnBufHistory(void);
EdnBufHistory(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
~EdnBufHistory(void);
void Set(int32_t pos, int32_t nInserted, etk::Vector<int8_t> &deletedText);
int32_t getPos(void);
int32_t getnbDeleted(void);
int32_t getnbInserted(void);
void getData(etk::Vector<int8_t> &deletedText);
private:
int32_t m_pos;
int32_t m_nInserted;
etk::Vector<int8_t> m_deletedText;
};
#endif

View File

@@ -1,353 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
#define __class__ "EdnBuf{HighLight}"
void EdnBuf::SetHLSystem(Highlight * newHLSystem)
{
if (m_Highlight != newHLSystem) {
m_Highlight = newHLSystem;
m_HLDataPass1.Clear();
RegenerateHighLightAt(0, 0, m_data.Size());
}
}
// TODO : Check this fuction it have too many conditionnal inside ==> can do a better algo
void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded)
{
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
// prevent ERROR...
if (NULL == m_Highlight) {
return;
}
// prevent No data Call
if( 0 == nbDeleted
&& 0 == nbAdded)
{
return;
}
// normal case
//APPL_INFO("(pos="<<pos<<", nbDeleted="<<nbDeleted<<", nbAdded=" << nbAdded << "\");");
int32_t i;
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
APPL_DEBUG("HighLight (previous) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
int32_t posEnd = pos + nbDeleted;
// search position of the old element to reparse IT...
int32_t startId;
int32_t stopId;
// clean data if needed
if (0 != m_HLDataPass1.Size()) {
// find element previous
FindMainHighLightPosition(pos, posEnd, startId, stopId, true);
// Remove deprecated element
if( -1 == startId
&& -1 == stopId)
{
m_HLDataPass1.Clear();
} else if(-1 == startId) {
if (0 == stopId){
m_HLDataPass1.Erase(0);
//APPL_DEBUG("1 * Erase 0");
} else {
m_HLDataPass1.EraseLen(0,stopId);
//APPL_DEBUG("2 * Erase 0->" << stopId);
}
} else if(-1 == stopId) {
//APPL_DEBUG("3 * Erase " << startId+1 << "-> end");
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.Size() - startId);
stopId = -1;
} else {
int32_t currentSize = m_HLDataPass1.Size();
//APPL_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
m_HLDataPass1.EraseLen(startId+1, stopId - startId);
if (stopId == currentSize-1) {
stopId = -1;
}
}
//APPL_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1);
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
APPL_DEBUG("HighLight (Middle) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
// update position after the range position :
int32_t elemStart;
if(-1 == startId) {
elemStart = 0;
} else {
elemStart = startId+1;
}
for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
//APPL_DEBUG("move element=" << i);
m_HLDataPass1[i].beginStart += nbAdded - nbDeleted;
m_HLDataPass1[i].beginStop += nbAdded - nbDeleted;
m_HLDataPass1[i].endStart += nbAdded - nbDeleted;
m_HLDataPass1[i].endStop += nbAdded - nbDeleted;
}
//Regenerate Element inside range
if( -1 == startId
&& -1 == stopId)
{
//APPL_DEBUG("******* Regenerate ALL");
GenerateHighLightAt(0, m_data.Size());
} else if(-1 == startId) {
//APPL_DEBUG("******* Regenerate START");
GenerateHighLightAt(0, m_HLDataPass1[0].beginStart, 0);
} else if(-1 == stopId) {
//APPL_DEBUG("******* Regenerate STOP");
GenerateHighLightAt(m_HLDataPass1[m_HLDataPass1.Size() -1].endStop, m_data.Size(), m_HLDataPass1.Size());
} else {
//APPL_DEBUG("******* Regenerate RANGE");
GenerateHighLightAt(m_HLDataPass1[startId].endStop, m_HLDataPass1[startId+1].beginStart, startId+1);
}
} else {
// Parse the new element ...
GenerateHighLightAt(0, m_data.Size());
}
/*
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
etk::UString ploppp;
if (NULL != m_HLDataPass1[i].patern ) {
ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName();
}
APPL_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp );
}
*/
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//APPL_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded)
{
startId = -1;
stopId = -1;
/* rules to start stop:
HighLight data ----
Remove area ****
Start pos S
End pos E
Some Case :
----------- ------------ ------------- ----------
S **** E
----------- ------------ ------------- ----------
S ********** E
----------- ------------ ------------- ----------
S **** E
----------- ------------ ------------- ----------
S ********* E
----------- ------------ ------------- ----------
S ********************* E
----------- ------------ ------------- ----------
S ************************ E
----------- ------------ ------------- ----------
S ***************** E
----------- ------------ ------------- ----------
S *************** E
----------- ------------
S *************** E=-1
------------ ------------- ----------
S=-1 *************** E
*/
int32_t i;
for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) {
if (m_HLDataPass1[i].endStop > startPos) {
break;
}
startId = i;
}
// go back while the previous element is not eneded
if (true == backPreviousNotEnded) {
for (i=startId; i>=0; i--) {
if (m_HLDataPass1[i].notEnded == false) {
break;
}
startId = i-1;
}
}
int32_t elemStart;
if(-1 == startId) {
elemStart = 0;
} else {
elemStart = startId+1;
}
for (i=elemStart; i< (int32_t)m_HLDataPass1.Size(); i++) {
if (m_HLDataPass1[i].beginStart > endPos)
{
stopId = i;
break;
}
}
/*
if (-1 != startId && startId < (int32_t)m_HLDataPass1.Size()) {
APPL_DEBUG("==> BEGIN : start="<<m_HLDataPass1[startId].beginStart<<", stop="<<m_HLDataPass1[startId].endStop<<" id=" << startId << "/" << (int32_t)m_HLDataPass1.Size()-1);
} else {
APPL_DEBUG("==> BEGIN : start=???, stop=??? id=" << startId);
}
if (-1 != stopId && stopId < (int32_t)m_HLDataPass1.Size()) {
APPL_DEBUG("==> END : start="<<m_HLDataPass1[stopId].beginStart<<", stop="<<m_HLDataPass1[stopId].endStop<<" id=" << stopId<< "/" << (int32_t)m_HLDataPass1.Size()-1);
} else {
APPL_DEBUG("==> END : start=???, stop=??? id=" << stopId);
}
*/
}
void EdnBuf::GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos)
{
if (NULL == m_Highlight) {
return;
}
//APPL_DEBUG("area : ("<<pos<<","<<endPos<<") insert at : " << addinPos);
m_Highlight->Parse(pos, endPos, m_HLDataPass1, addinPos, m_data);
}
void EdnBuf::CleanHighLight(void)
{
// Remove all element in the list...
m_HLDataPass1.Clear();
}
colorInformation_ts *EdnBuf::GetElementColorAtPosition(int32_t pos, int32_t &starPos)
{
int32_t i;
int32_t start = etk_max(0, starPos-1);
for (i=start; i<(int32_t)m_HLDataPass1.Size(); i++) {
starPos = i;
if( m_HLDataPass1[i].beginStart <= pos
&& m_HLDataPass1[i].endStop > pos)
{
return &m_HLDataPass1[i];
}
if(m_HLDataPass1[i].beginStart > pos) {
return NULL;
}
}
return NULL;
}
void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, int32_t nbLines)
{
MData.posHLPass1 = 0;
MData.posHLPass2 = 0;
if (NULL == m_Highlight) {
return;
}
//GTimeVal timeStart;
//g_get_current_time(&timeStart);
HLStart = StartOfLine(HLStart);
MData.HLData.Clear();
int32_t HLStop = CountForwardNLines(HLStart, nbLines);
int32_t startId, stopId;
// find element previous
FindMainHighLightPosition(HLStart, HLStop, startId, stopId, true);
int32_t k;
//APPL_DEBUG("List of section between : "<< startId << " & " << stopId);
int32_t endSearch = stopId+1;
if (-1 == stopId) {
endSearch = m_HLDataPass1.Size();
}
for (k=etk_max(startId, 0); k<endSearch; k++) {
// empty section :
if (0==k) {
if (HLStart < m_HLDataPass1[k].beginStart) {
//APPL_DEBUG(" ==> (empty section 1 ) k="<<k<<" start="<<HLStart<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(HLStart,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
} // else : nothing to do ...
} else {
//APPL_DEBUG(" ==> (empty section 2 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<m_HLDataPass1[k].beginStart );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
m_HLDataPass1[k].beginStart,
MData.HLData,
m_data);
}
// under section :
//APPL_DEBUG(" ==> (under section ) k="<<k<<" start="<<m_HLDataPass1[k].beginStart<<" stop="<<m_HLDataPass1[k].endStop << " subSectionOfID=" << 99999999);
// TODO : ...
}
if (endSearch == (int32_t)m_HLDataPass1.Size() ){
//if( k < (int32_t)m_HLDataPass1.Size()) {
if (m_HLDataPass1.Size() != 0) {
//APPL_DEBUG(" ==> (empty section 3 ) k="<<k<<" start="<<m_HLDataPass1[k-1].endStop<<" stop="<<HLStop );
m_Highlight->Parse2(m_HLDataPass1[k-1].endStop,
HLStop,
MData.HLData,
m_data);
} else {
//APPL_DEBUG(" ==> (empty section 4 ) k="<<k<<" start=0 stop="<<HLStop );
m_Highlight->Parse2(0,
HLStop,
MData.HLData,
m_data);
}
}
//GTimeVal timeStop;
//g_get_current_time(&timeStop);
//APPL_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
}
colorInformation_ts * EdnBuf::GetElementColorAtPosition(displayHLData_ts & MData, int32_t pos)
{
int32_t i;
int32_t start = etk_max(0, MData.posHLPass2-1);
for (i=start; i<(int32_t)MData.HLData.Size(); i++) {
MData.posHLPass2 = i;
if( MData.HLData[i].beginStart <= pos
&& MData.HLData[i].endStop > pos)
{
return &MData.HLData[i];
}
if(MData.HLData[i].beginStart > pos) {
return GetElementColorAtPosition(pos, MData.posHLPass1);
}
}
return GetElementColorAtPosition(pos, MData.posHLPass1);
}

View File

@@ -1,116 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
#define __class__ "EdnBuf{History}"
int32_t EdnBuf::Undo(void)
{
int32_t nbElement = m_historyUndo.Size();
//APPL_DEBUG("EdnBuf::Undo Request id="<<nbElement);
int32_t posDest = -1;
if (0 == nbElement) {
// nothing to do ...
APPL_ERROR("EdnBuf::Undo No more History");
return -1;
}
nbElement--;
if (m_historyUndo[nbElement] == NULL) {
APPL_ERROR("EdnBuf::Undo Find empty history ==> remove it");
m_historyUndo.PopBack();
return -1;
}
int32_t pos = m_historyUndo[nbElement]->getPos();
int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted();
etk::Vector<int8_t> deletedText;
m_historyUndo[nbElement]->getData(deletedText);
m_isUndoProcessing = true;
if (0 == nbInserted) {
// just add data at position ...
if (0 == nbDeleted) {
APPL_DEBUG("EdnBuf::Undo nothing to do in UNDO");
} else {
Insert(pos, deletedText);
posDest = pos + nbDeleted;
}
} else {
if (0 == nbDeleted) {
// only remove data
Remove(pos, pos+nbInserted);
posDest = pos;
} else {
// replace data
Replace(pos, pos+nbInserted, deletedText);
posDest = pos + nbDeleted;
}
}
// remove element in the list :
delete(m_historyUndo[nbElement]);
m_historyUndo.PopBack();
m_isUndoProcessing = false;
return posDest;
}
int32_t EdnBuf::Redo(void)
{
int32_t nbElement = m_historyRedo.Size();
//APPL_DEBUG("EdnBuf::Redo Request id="<<nbElement);
int32_t posDest = -1;
if (0 == nbElement) {
// nothing to do ...
APPL_DEBUG("EdnBuf::Redo No more History");
return -1;
}
nbElement--;
if (m_historyRedo[nbElement] == NULL) {
APPL_ERROR("EdnBuf::Redo Find empty history ==> remove it");
m_historyRedo.PopBack();
return -1;
}
int32_t pos = m_historyRedo[nbElement]->getPos();
int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted();
int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted();
etk::Vector<int8_t> deletedText;
m_historyRedo[nbElement]->getData(deletedText);
m_isRedoProcessing = true;
if (0 == nbInserted) {
// just add data at position ...
if (0 == nbDeleted) {
APPL_ERROR("EdnBuf::Redo nothing to do in REDO");
} else {
Insert(pos, deletedText);
posDest = pos + nbDeleted;
}
} else {
if (0 == nbDeleted) {
// only remove data
Remove(pos, pos+nbInserted);
posDest = pos;
} else {
// replace data
Replace(pos, pos+nbInserted, deletedText);
posDest = pos + nbDeleted;
}
}
// remove element in the list :
delete(m_historyRedo[nbElement]);
m_historyRedo.PopBack();
m_isRedoProcessing = false;
return posDest;
}

View File

@@ -1,293 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <EdnBuf.h>
#undef __class__
#define __class__ "EdnBuf{Selection}"
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::SelectHasSelection(void)
{
return m_selectionList.selected;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Select(int32_t start, int32_t end)
{
//selection oldSelection = m_selectionList[select];
m_selectionList.selected = start != end;
m_selectionList.zeroWidth = (start == end) ? true : false;
m_selectionList.rectangular = false;
m_selectionList.start = etk_min(start, end);
m_selectionList.end = etk_max(start, end);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::Unselect(void)
{
//selection oldSelection = m_selectionList[select];
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
}
/**
* @brief
*
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RectSelect(int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd)
{
m_selectionList.selected = rectStart < rectEnd;
m_selectionList.zeroWidth = (rectStart == rectEnd) ? false : true;
m_selectionList.rectangular = true;
m_selectionList.start = start;
m_selectionList.end = end;
m_selectionList.rectStart = rectStart;
m_selectionList.rectEnd = rectEnd;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool EdnBuf::GetSelectionPos(int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd)
{
/* Always fill in the parameters (zero-width can be requested too). */
isRect = m_selectionList.rectangular;
start = m_selectionList.start;
end = m_selectionList.end;
if (m_selectionList.rectangular) {
rectStart = m_selectionList.rectStart;
rectEnd = m_selectionList.rectEnd;
}
return m_selectionList.selected;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::GetSelectionText(etk::Vector<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text.Clear();
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
void EdnBuf::GetSelectionText(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
// remove output data
text = "";
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//GetTextInRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
GetRange(start, end, text);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::RemoveSelected(void)
{
int32_t start, end;
int32_t rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return;
}
// Rectangular selection
if (true == isRect) {
//RemoveRect(start, end, rectStart, rectEnd);
// TODO : ...
} else {
Remove(start, end);
}
Unselect();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t EdnBuf::ReplaceSelected(etk::Vector<int8_t> &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return 0;
}
int32_t returnSize = 0;
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList.selected = false;
return returnSize;
}
int32_t EdnBuf::ReplaceSelected(etk::UString &text)
{
int32_t start, end, rectStart, rectEnd;
bool isRect;
bool isSelected = GetSelectionPos(start, end, isRect, rectStart, rectEnd);
// No data selected ...
if (false == isSelected) {
return 0;
}
int32_t returnSize = 0;
// Rectangular selection
if (true == isRect) {
//ReplaceRect(start, end, rectStart, rectEnd, text);
// TODO : ...
} else {
returnSize = Replace(start, end, text);
}
// Clean selection
m_selectionList.selected = false;
return returnSize;
}
/*
** Update an individual selection for changes in the corresponding text
*/
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void EdnBuf::UpdateSelection(int32_t pos, int32_t nDeleted, int32_t nInserted)
{
if( ( false == m_selectionList.selected
&& false == m_selectionList.zeroWidth)
|| pos > m_selectionList.end )
{
return;
}
if (pos+nDeleted <= m_selectionList.start) {
m_selectionList.start += nInserted - nDeleted;
m_selectionList.end += nInserted - nDeleted;
} else if( pos <= m_selectionList.start
&& pos+nDeleted >= m_selectionList.end)
{
m_selectionList.start = pos;
m_selectionList.end = pos;
m_selectionList.selected = false;
m_selectionList.zeroWidth = false;
} else if( pos <= m_selectionList.start
&& pos+nDeleted < m_selectionList.end)
{
m_selectionList.start = pos;
m_selectionList.end = nInserted + m_selectionList.end - nDeleted;
} else if(pos < m_selectionList.end) {
m_selectionList.end += nInserted - nDeleted;
if (m_selectionList.end <= m_selectionList.start) {
m_selectionList.selected = false;
}
}
}

View File

@@ -0,0 +1,145 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/BufferManager.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/EObjectManager.h>
#undef __class__
#define __class__ "BufferManager"
appl::BufferManager::BufferManager(void) :
ewol::Resource("???BufferManager???"),
m_bufferSelected(NULL) {
addObjectType("appl::BufferManager");
}
appl::BufferManager::~BufferManager(void) {
int32_t previousCount = m_list.size();
for (int32_t iii = m_list.size()-1; iii >= 0 ; --iii) {
if (m_list[iii] == NULL) {
continue;
}
delete(m_list[iii]);
if (previousCount == m_list.size()) {
APPL_ERROR("Error in removing buffer !! ");
}
previousCount = m_list.size();
}
m_list.clear();
}
appl::Buffer* appl::BufferManager::createNewBuffer(void) {
appl::Buffer* tmp = new appl::Buffer();
if (tmp == NULL) {
APPL_ERROR("Can not allocate the Buffer (empty).");
return NULL;
}
m_list.push_back(tmp);
sendMultiCast(appl::MsgSelectNewFile, tmp->getFileName());
return tmp;
}
appl::Buffer* appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) {
for (int32_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii] == NULL) {
continue;
}
if (m_list[iii]->getFileName() == _fileName) {
return m_list[iii];
}
}
if (_createIfNeeded == true) {
if (etk::FSNodeGetType(_fileName) == etk::FSN_FOLDER) {
APPL_INFO("try open a folder : " << _fileName);
return NULL;
}
appl::Buffer* tmp = new appl::Buffer();
if (tmp == NULL) {
APPL_ERROR("Can not allocate the Buffer class : " << _fileName);
return NULL;
}
tmp->loadFile(_fileName);
m_list.push_back(tmp);
return tmp;
}
return NULL;
}
void appl::BufferManager::setBufferSelected(appl::Buffer* _bufferSelected) {
m_bufferSelected = _bufferSelected;
sendMultiCast(appl::MsgSelectChange, "");
}
void appl::BufferManager::onObjectRemove(ewol::EObject * _removeObject) {
if (m_bufferSelected == _removeObject) {
setBufferSelected(NULL);
}
for (int32_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii] != _removeObject) {
continue;
}
m_list[iii] = NULL;
m_list.erase(m_list.begin()+iii);
return;
}
}
bool appl::BufferManager::exist(const std::string& _fileName) {
for (int32_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii] == NULL) {
continue;
}
if (m_list[iii]->getFileName() == _fileName) {
return true;
}
}
return false;
}
void appl::BufferManager::open(const std::string& _fileName) {
if (exist(_fileName) == true) {
return;
}
if (get(_fileName, true) == NULL) {
return;
}
sendMultiCast(appl::MsgSelectNewFile, _fileName);
}
void appl::BufferManager::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_DEBUG("receive message !!! " << _msg);
}
appl::BufferManager* appl::BufferManager::keep(void) {
//EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
appl::BufferManager* object = static_cast<appl::BufferManager*>(getManager().localKeep("???BufferManager???"));
if (NULL != object) {
return object;
}
// this element create a new one every time ....
EWOL_INFO("CREATE : appl::BufferManager: ???BufferManager???");
object = new appl::BufferManager();
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ???BufferManager???");
return NULL;
}
getManager().localAdd(object);
return object;
}
void appl::BufferManager::release(appl::BufferManager*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@@ -0,0 +1,98 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __BUFFER_MANAGER_H__
#define __BUFFER_MANAGER_H__
#include <appl/Buffer.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
#include <ewol/resources/Resource.h>
namespace appl {
class BufferManager : public ewol::Resource {
protected:
BufferManager(void);
~BufferManager(void);
private:
std::vector<appl::Buffer*> m_list; // list of all buffer curently open
public:
/**
* @brief Get a specific buffer with his name (can create a new buffer).
* @param[in] _fileName Name of the file to open.
* @param[in] _createIfNeeded Create the buffer if not existed.
* @return a pointer on the buffer
*/
appl::Buffer* get(const std::string& _fileName, bool _createIfNeeded=false);
/**
* @brief Load a specific file, event if it not existed:
* @param[in] _fileName Name of the file to open or create.
*/
void open(const std::string& _fileName);
/**
* @brief Check if a buffer is already open.
* @param[in] _fileName name of the file.
* @return true if the buffer is already open.
*/
bool exist(const std::string& _fileName);
/**
* @brief Get count of all buffer availlable.
* @return Number of buffer
*/
int32_t size(void) const {
return m_list.size();
}
/**
* @brief Get a pointer on a buffer Id (never remember this ID!!!).
* @param[in] _id Number of buffer
* @return pointer on the buffer
*/
appl::Buffer* get(int32_t _id) {
return m_list[_id];
}
/**
* @brief Create a new buffer empty.
* @return Created buffer or NULL.
*/
appl::Buffer* createNewBuffer(void);
private:
appl::Buffer* m_bufferSelected;
public:
/**
* @brief Set the current buffer selected
* @param[in] _bufferSelected Pointer on the buffer selected
*/
void setBufferSelected(appl::Buffer* _bufferSelected);
/**
* @brief Get the current buffer selected
* @return Pointer on the buffer selected
*/
appl::Buffer* getBufferSelected(void) {
return m_bufferSelected;
};
public: // herited function
void onReceiveMessage(const ewol::EMessage& _msg);
void onObjectRemove(ewol::EObject * _removeObject);
public: // resource manager
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static appl::BufferManager* keep(void);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(appl::BufferManager*& _object);
};
};
#endif

View File

@@ -1,122 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <Colorize.h>
#undef __class__
#define __class__ "Colorize"
Colorize::Colorize( etk::UString &newColorName)
{
m_colorFG = draw::color::black;
m_colorBG = draw::color::none;
italic = false;
bold = false;
SetName(newColorName);
APPL_VERBOSE("New(Colorise)");
}
Colorize::Colorize(void)
{
ColorName = "no_name";
m_colorFG = draw::color::black;
m_colorBG = draw::color::none;
italic = false;
bold = false;
APPL_VERBOSE("New(Colorise)");
}
Colorize::~Colorize(void)
{
// nothing to do ...
}
void Colorize::SetName(const char *newColorName)
{
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
ColorName = newColorName;
}
void Colorize::SetName(etk::UString &newColorName)
{
APPL_VERBOSE("color change name : \"" << ColorName << "\" ==> \"" << newColorName << "\"");
ColorName = newColorName;
}
etk::UString Colorize::GetName(void)
{
return ColorName;
}
void Colorize::SetFgColor(const char *myColor)
{
m_colorFG = myColor;
APPL_VERBOSE(myColor << " ==> "<< m_colorFG );
}
void Colorize::SetBgColor(const char *myColor)
{
m_colorBG = myColor;
APPL_VERBOSE(myColor << " ==> "<< m_colorBG );
}
bool Colorize::HaveBg(void)
{
return m_colorBG.a!=0;
}
void Colorize::SetItalic(bool enable)
{
italic = enable;
if (true == enable) {
APPL_VERBOSE("color : \"" << ColorName << "\" enable italic");
} else {
APPL_VERBOSE("color : \"" << ColorName << "\" disable italic");
}
}
bool Colorize::GetItalic(void)
{
return italic;
}
void Colorize::SetBold(bool enable)
{
bold = enable;
if (true == enable) {
APPL_VERBOSE("color : \"" << ColorName << "\" enable bold");
} else {
APPL_VERBOSE("color : \"" << ColorName << "\" disable bold");
}
}
bool Colorize::GetBold(void)
{
return bold;
}

View File

@@ -1,51 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __COLORIZE_H__
#define __COLORIZE_H__
#include <draw/Color.h>
#include <etk/UString.h>
class Colorize {
public:
// Constructeur
Colorize(void);
Colorize(etk::UString &newColorName);
~Colorize(void);
void SetName(etk::UString &newColorName);
void SetName(const char *newColorName);
etk::UString GetName(void);
void SetFgColor(const char *myColor);
void SetBgColor(const char *myColor);
draw::Color & GetFG(void) { return m_colorFG; };
draw::Color & GetBG(void) { return m_colorBG; };
bool HaveBg(void);
void SetItalic(bool enable);
void SetBold(bool enable);
bool GetItalic(void);
bool GetBold(void);
void Display(int32_t i) { APPL_INFO(" " << i << " : \"" << ColorName << "\"" << " fg="<< m_colorFG); };
private:
etk::UString ColorName; //!< curent color Name
draw::Color m_colorFG;
draw::Color m_colorBG;
bool italic;
bool bold;
};
#endif

View File

@@ -1,439 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <ColorizeManager.h>
#include <tinyXML/tinyxml.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#include <etk/os/FSNode.h>
#define PFX "ColorizeManager "
class classColorManager: public ewol::EObject
{
public:
// Constructeur
classColorManager(void);
~classColorManager(void);
/**
* @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 GetObjectType(void)
{
return "ApplColorManager";
}
/**
* @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 ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
public:
void LoadFile(etk::UString &xmlFilename);
void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName);
Colorize * Get(etk::UString &colorName);
draw::Color& Get(basicColor_te myColor);
bool Exist(etk::UString &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void);
private:
etk::UString m_fileColor;
etk::Vector<Colorize*> listMyColor; //!< List of ALL Color
Colorize * errorColor;
draw::Color basicColors[COLOR_NUMBER_MAX];
};
classColorManager::classColorManager(void)
{
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
}
classColorManager::~classColorManager(void)
{
delete(errorColor);
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
}
void classColorManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
/*
switch (id)
{
case APPL_MSG__RELOAD_COLOR_FILE:
{
// Reaload File
// TODO : Check this : Pb in the recopy etk::UString element
etk::UString plop = m_fileColor;
LoadFile(plop);
}
break;
}
*/
}
void classColorManager::LoadFile(etk::UString &xmlFilename)
{
// TODO : Remove this
LoadFile(xmlFilename.c_str());
}
// TODO : Remove this ...
void classColorManager::LoadFile(const char * xmlFilename)
{
// Remove all old color :
int32_t i;
// clean all Element
for (i=0; i< listMyColor.Size(); i++) {
if (NULL != listMyColor[i]) {
delete(listMyColor[i]);
listMyColor[i] = NULL;
}
}
// clear the compleate list
listMyColor.Clear();
m_fileColor = xmlFilename;
APPL_DEBUG("open file (COLOR) \"" << xmlFilename << "\" ? = \"" << m_fileColor << "\"");
errorColor = new Colorize();
errorColor->SetBgColor("#00FF00FF");
errorColor->SetFgColor("#FF00FFFF");
// allocate the document in the stack
TiXmlDocument XmlDocument;
// open the curent File
etk::FSNode fileName(etk::UString("DATA:color/") + xmlFilename + etk::UString(".xml"));
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
APPL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.FileClose();
// load the XML from the memory
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnColor" );
if (NULL == root ) {
APPL_ERROR(PFX"(l ?) main node not find: \"EdnColor\" in \"" << xmlFilename << "\"");
return;
} else {
TiXmlNode * pNode = root->FirstChild();
while(NULL != pNode) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pNode->Value(), "gui")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode) {
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" val="#000000"/>
//--------------------------------------------------------------------------------------------
const char *colorName = pGuiNode->ToElement()->Attribute("name");
int32_t id = 0;
if (NULL == colorName) {
APPL_ERROR("(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
if (!strcmp(colorName, "CODE_space")) {
id = COLOR_CODE_SPACE;
} else if (!strcmp(colorName, "CODE_tabulation")) {
id = COLOR_CODE_TAB;
} else if (!strcmp(colorName, "CODE_basicBackgroung")) {
id = COLOR_CODE_BASIC_BG;
} else if (!strcmp(colorName, "CODE_cursor")) {
id = COLOR_CODE_CURSOR;
} else if (!strcmp(colorName, "CODE_lineNumber")) {
id = COLOR_CODE_LINE_NUMBER;
} else if (!strcmp(colorName, "LIST_backgroung1")) {
id = COLOR_LIST_BG_1;
} else if (!strcmp(colorName, "LIST_backgroung2")) {
id = COLOR_LIST_BG_2;
} else if (!strcmp(colorName, "LIST_backgroungSelected")) {
id = COLOR_LIST_BG_SELECTED;
} else if (!strcmp(colorName, "LIST_textNormal")) {
id = COLOR_LIST_TEXT_NORMAL;
} else if (!strcmp(colorName, "LIST_textModify")) {
id = COLOR_LIST_TEXT_MODIFY;
} else {
APPL_ERROR("(l "<<pGuiNode->Row()<<") Unknown basic gui color : \"" << colorName << "\"" );
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
}
const char *color = pGuiNode->ToElement()->Attribute("val");
if (NULL != color) {
basicColors[id] = color;
}
} else {
APPL_ERROR("(l "<<pGuiNode->Row()<<") node not suported : \""<<pGuiNode->Value()<<"\" must be [color]");
}
// get next node element
pGuiNode = pGuiNode->NextSibling();
}
} else if (!strcmp(pNode->Value(), "syntax")) {
TiXmlNode * pGuiNode = pNode->FirstChild();
while(NULL != pGuiNode)
{
if (pGuiNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
} else if (!strcmp(pGuiNode->Value(), "color")) {
Colorize *myNewColor = new Colorize();
//--------------------------------------------------------------------------------------------
//<color name="basicBackground" FG="#000000" BG="#000000" bold="no" italic="no"/>
//--------------------------------------------------------------------------------------------
// get the name of the Chaine
const char *colorName = pGuiNode->ToElement()->Attribute("name");
if (NULL == colorName) {
APPL_ERROR(PFX"(l "<< pGuiNode->Row() <<") node with no name");
// get next node element
pGuiNode = pGuiNode->NextSibling();
continue;
} else {
myNewColor->SetName(colorName);
//APPL_INFO(PFX"Add a new color in the panel : \"%s\"", colorName);
}
const char *colorBG = pGuiNode->ToElement()->Attribute("BG");
if (NULL != colorBG) {
myNewColor->SetBgColor(colorBG);
}
const char *colorFG = pGuiNode->ToElement()->Attribute("FG");
if (NULL != colorFG) {
myNewColor->SetFgColor(colorFG);
}
const char *bold = pGuiNode->ToElement()->Attribute("bold");
if (NULL != bold) {
if(0 == strcmp(bold, "yes") ) {
myNewColor->SetBold(true);
}
}
const char *italic = pGuiNode->ToElement()->Attribute("italic");
if (NULL != italic) {
if(0 == strcmp(italic, "yes") ) {
myNewColor->SetItalic(true);
}
}
listMyColor.PushBack(myNewColor);
} else {
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [color]");
}
pGuiNode = pGuiNode->NextSibling();
}
} else {
APPL_ERROR(PFX"(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value()<<"\" must be [gui,syntax]");
}
// get next node element
pNode = pNode->NextSibling();
}
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
//SendMessage(APPL_MSG__COLOR_HAS_CHANGE);
//SendMessage(APPL_MSG__USER_DISPLAY_CHANGE);
}
// TODO : Remove this ...
Colorize *classColorManager::Get(const char *colorName)
{
int32_t i;
for (i=0; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return listMyColor[i];
}
}
APPL_ERROR(PFX"Color does not Existed ["<< colorName<<"]" );
// an error
return errorColor;
}
Colorize *classColorManager::Get(etk::UString &colorName)
{
// TODO : Remove this
return Get(colorName.c_str());
}
draw::Color & classColorManager::Get(basicColor_te myColor)
{
if (myColor < COLOR_NUMBER_MAX) {
return basicColors[myColor];
} else {
return basicColors[0];
}
}
// TODO : Remove this ...
bool classColorManager::Exist(const char *colorName)
{
int32_t i;
for (i=0; i<listMyColor.Size(); i++) {
etk::UString elementName = listMyColor[i]->GetName();
if (elementName == colorName) {
return true;
}
}
return false;
}
bool classColorManager::Exist(etk::UString &colorName)
{
// TODO : Remove this
return Exist(colorName.c_str());
}
void classColorManager::DisplayListOfColor(void)
{
int32_t i;
APPL_INFO(PFX"List of ALL COLOR : ");
for (i=0; i<listMyColor.Size(); i++) {
//etk::UString elementName = listMyColor[i]->GetName();
//APPL_INFO(i << " : \"" << elementName.c_str() << "\"" );
listMyColor[i]->Display(i);
}
}
static classColorManager * localManager = NULL;
void ColorizeManager::Init(void)
{
if (NULL != localManager) {
EWOL_ERROR("ColorizeManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new classColorManager();
if (NULL == localManager) {
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void ColorizeManager::UnInit(void)
{
if (NULL == localManager) {
EWOL_ERROR("ColorizeManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void ColorizeManager::LoadFile(etk::UString &xmlFilename)
{
if (NULL == localManager) {
return;
}
localManager->LoadFile(xmlFilename);
}
void ColorizeManager::LoadFile(const char * xmlFilename)
{
if (NULL == localManager) {
return;
}
localManager->LoadFile(xmlFilename);
}
Colorize* ColorizeManager::Get(const char *colorName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(colorName);
}
Colorize* ColorizeManager::Get(etk::UString &colorName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(colorName);
}
draw::Color errorColor;
draw::Color& ColorizeManager::Get(basicColor_te myColor)
{
if (NULL == localManager) {
return errorColor;
}
return localManager->Get(myColor);
}
bool ColorizeManager::Exist(etk::UString &colorName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(colorName);
}
bool ColorizeManager::Exist(const char *colorName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(colorName);
}
void ColorizeManager::DisplayListOfColor(void)
{
if (NULL == localManager) {
return;
}
localManager->DisplayListOfColor();
}

View File

@@ -1,51 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __COLORIZE_MANAGER_H__
#define __COLORIZE_MANAGER_H__
#include <Colorize.h>
#include <appl/globalMsg.h>
#include <draw/Color.h>
#include <ewol/widget/Widget.h>
typedef enum {
// BASIC color for codeViewer
COLOR_CODE_SPACE,
COLOR_CODE_TAB,
COLOR_CODE_BASIC_BG,
COLOR_CODE_CURSOR,
COLOR_CODE_LINE_NUMBER,
// Basic color for list viewer
COLOR_LIST_BG_1,
COLOR_LIST_BG_2,
COLOR_LIST_BG_SELECTED,
COLOR_LIST_TEXT_NORMAL,
COLOR_LIST_TEXT_MODIFY,
// KNOW the number of BASIC color
COLOR_NUMBER_MAX,
}basicColor_te;
namespace ColorizeManager
{
void Init(void);
void UnInit(void);
void LoadFile(etk::UString &xmlFilename);
void LoadFile(const char * xmlFilename);
Colorize * Get(const char *colorName);
Colorize * Get(etk::UString &colorName);
draw::Color& Get(basicColor_te myColor);
bool Exist(etk::UString &colorName);
bool Exist(const char *colorName);
void DisplayListOfColor(void);
};
#endif

View File

@@ -0,0 +1,55 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/GlyphDecoration.h>
#undef __class__
#define __class__ "GlyphDecoration"
appl::GlyphDecoration::GlyphDecoration(const std::string &_newColorName) :
m_colorName(_newColorName),
m_colorFG(etk::color::black),
m_colorBG(etk::color::none),
m_italic(false),
m_bold(false)
{
APPL_VERBOSE("New(" << __class__ << ")");
}
void appl::GlyphDecoration::setItalic(bool _enable)
{
m_italic = _enable;
if (true == _enable) {
APPL_VERBOSE("color : \"" << m_colorName << "\" enable italic");
} else {
APPL_VERBOSE("color : \"" << m_colorName << "\" disable italic");
}
}
void appl::GlyphDecoration::setBold(bool _enable)
{
m_bold = _enable;
if (true == _enable) {
APPL_VERBOSE("color : \"" << m_colorName << "\" enable bold");
} else {
APPL_VERBOSE("color : \"" << m_colorName << "\" disable bold");
}
}
etk::CCout& appl::operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj)
{
_os << "{fg=" << _obj.getForeground();
_os << ",bg=" << _obj.getBackground();
_os << ",italic=" << _obj.getItalic();
_os << ",bold=" << _obj.getBold();
_os << "name='" << _obj.getName() << "'}";
return _os;
}

View File

@@ -0,0 +1,124 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __GLYPH_DECORATION_H__
#define __GLYPH_DECORATION_H__
#include <etk/Color.h>
#include <etk/UString.h>
namespace appl {
class GlyphDecoration {
public:
// Constructeur
GlyphDecoration(const std::string& _newColorName = "no_name");
~GlyphDecoration(void) {
// nothing to do ...
};
private:
std::string m_colorName; //!< curent color Name
public:
/**
* @brief Set color name of the element.
* @param[in] _newColorName new color name.
*/
void setName(const std::string& _newColorName) {
m_colorName = _newColorName;
};
/**
* @brief Get the color name.
* @return The name of the color.
*/
const std::string& getName(void) const {
return m_colorName;
};
private:
etk::Color<> m_colorFG; //!< Foreground color
public:
/**
* @brief Set foreground color.
* @param[in] _myColor new color description.
*/
void setForeground(const std::string& _myColor) {
m_colorFG = _myColor;
};
/**
* @brief Get the foreground color.
* @return The color.
*/
const etk::Color<>& getForeground(void) const {
return m_colorFG;
};
/**
* @brief Get the foreground color status.
* @return true if the color is visible.
*/
bool haveFg(void) const {
return m_colorFG.a() != 0;
};
private:
etk::Color<> m_colorBG; //!< Background color
public:
/**
* @brief Set background color.
* @param[in] _myColor new color description.
*/
void setBackground(const std::string& _myColor) {
m_colorBG = _myColor;
};
/**
* @brief Get the background color.
* @return The color.
*/
const etk::Color<>& getBackground(void) const {
return m_colorBG;
};
/**
* @brief Get the background color status.
* @return true if the color is visible.
*/
bool haveBackground(void) const {
return m_colorBG.a()!=0;
};
private:
bool m_italic; //!< the gryph might be italic.
public:
/**
* @brief Set the italic status.
* @param[in] _enable new status of italic request.
*/
void setItalic(bool _enable);
/**
* @brief Get the italic status.
* @return true if the glyph might be display in italic.
*/
bool getItalic(void) const {
return m_italic;
};
private:
bool m_bold; //!< the gryph might be bold.
public:
/**
* @brief Set the bold status.
* @param[in] _enable new status of bold request.
*/
void setBold(bool _enable);
/**
* @brief Get the bold status.
* @return true if the glyph might be display in bold.
*/
bool getBold(void) const {
return m_bold;
};
};
etk::CCout& operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj);
}
#endif

View File

@@ -0,0 +1,123 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/GlyphPainting.h>
#include <ejson/ejson.h>
#include <etk/os/FSNode.h>
#include <ewol/resources/ResourceManager.h>
#undef __class__
#define __class__ "GlyphPainting"
appl::GlyphPainting::GlyphPainting(const std::string& _filename) :
ewol::Resource(_filename) {
addObjectType("appl::GlyphPainting");
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload();
}
appl::GlyphPainting::~GlyphPainting(void) {
}
void appl::GlyphPainting::reload(void) {
ejson::Document doc;
if (false == doc.load(m_name)) {
APPL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
return;
}
// for debug only :
/*
APPL_WARNING("Load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
std::string tmppppp;
doc.generate(tmppppp);
APPL_DEBUG(tmppppp);
*/
ejson::Array* baseArray = doc.getArray("ednColor");
if (baseArray == NULL) {
APPL_ERROR("Can not get basic array : 'ednColor'");
return;
}
for (int32_t iii = 0; iii < baseArray->size(); ++iii) {
ejson::Object* tmpObj = baseArray->getObject(iii);
if (tmpObj == NULL) {
APPL_DEBUG(" can not get object in 'ednColor' id=" << iii);
continue;
}
std::string name = tmpObj->getStringValue("name", "");
std::string background = tmpObj->getStringValue("background", "#FFF0");
std::string foreground = tmpObj->getStringValue("foreground", "#000F");
bool italic = tmpObj->getBooleanValue("italic", false);
bool bold = tmpObj->getBooleanValue("bold", false);
APPL_VERBOSE("find new color : '" << name << "' fg='" << foreground << "' bg='" << background << "' italic='" << italic << "' bold='" << bold << "'");
bool findElement = false;
for (int32_t jjj=0; jjj<m_list.size(); ++jjj) {
if (m_list[jjj].getName() != name) {
continue;
}
m_list[jjj].setForeground(foreground);
m_list[jjj].setBackground(background);
m_list[jjj].setItalic(italic);
m_list[jjj].setBold(bold);
findElement = true;
}
if (findElement == true) {
continue;
}
appl::GlyphDecoration tmpDeco(name);
tmpDeco.setForeground(foreground);
tmpDeco.setBackground(background);
tmpDeco.setItalic(italic);
tmpDeco.setBold(bold);
m_list.push_back(tmpDeco);
}
}
int32_t appl::GlyphPainting::request(const std::string& _name) {
for (int32_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii].getName() == _name) {
return iii;
}
}
// create an empty deco ...
appl::GlyphDecoration tmpDeco(_name);
m_list.push_back(tmpDeco);
return m_list.size()-1;
}
appl::GlyphPainting* appl::GlyphPainting::keep(const std::string& _filename) {
//EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
appl::GlyphPainting* object = static_cast<appl::GlyphPainting*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
// this element create a new one every time ....
EWOL_INFO("CREATE : appl::GlyphPainting : file : \"" << _filename << "\"");
object = new appl::GlyphPainting(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??GlyphPainting??");
return NULL;
}
getManager().localAdd(object);
return object;
}
void appl::GlyphPainting::release(appl::GlyphPainting*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@@ -0,0 +1,68 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_GLYPH_PAINTING_H__
#define __APPL_GLYPH_PAINTING_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resources/Resource.h>
#include <appl/GlyphDecoration.h>
namespace appl {
class GlyphPainting : public ewol::Resource {
private:
std::vector<appl::GlyphDecoration> m_list;
protected:
GlyphPainting(const std::string& _filename);
virtual ~GlyphPainting(void);
public:
/**
* @brief Load or reload data from config
*/
void reload(void);
/**
* @brief Register a decoration with his name and get the ref id.
* @param[in] _name Name of the deco.
* @return id of the deco.
*/
int32_t request(const std::string& _name);
/**
* @brief Get Decoration handle.
* @param[in] _id Id of the decoration.
* @return reference on deco.
*/
const appl::GlyphDecoration& get(int32_t _id) const {
return m_list[_id];
};
/**
* @brief Operator to get decoration handle.
* @param[in] _pos Id of the decoration.
* @return reference on deco.
*/
const appl::GlyphDecoration& operator[] (int32_t _pos) const {
return m_list[_pos];
}
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static appl::GlyphPainting* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(appl::GlyphPainting*& _object);
};
};
#endif

View File

@@ -6,191 +6,296 @@
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/debug.h>
#include <appl/global.h>
#include <BufferView.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <MainWindows.h>
#include <ewol/eObject/EObject.h>
#include <appl/Gui/BufferView.h>
#include <appl/BufferManager.h>
//#include <ColorizeManager.h>
#include <appl/Gui/MainWindows.h>
#include <ewol/renderer/EObject.h>
#undef __class__
#define __class__ "BufferView"
#define __class__ "BufferView"
static void SortElementList(etk::Vector<appl::dataBufferStruct *> &list)
{
etk::Vector<appl::dataBufferStruct *> tmpList = list;
list.Clear();
for(int32_t iii=0; iii<tmpList.Size(); iii++) {
if (NULL != tmpList[iii]) {
int32_t findPos = 0;
for(int32_t jjj=0; jjj<list.Size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (list[jjj]!=NULL) {
if (tmpList[iii]->m_bufferName.GetNameFile() > list[jjj]->m_bufferName.GetNameFile()) {
findPos = jjj+1;
}
}
}
//EWOL_DEBUG("position="<<findPos);
list.Insert(findPos, tmpList[iii]);
static void SortElementList(std::vector<appl::dataBufferStruct*>& _list) {
std::vector<appl::dataBufferStruct *> tmpList = _list;
_list.clear();
for(int32_t iii=0; iii<tmpList.size(); iii++) {
if (NULL == tmpList[iii]) {
continue;
}
int32_t findPos = 0;
for(int32_t jjj=0; jjj<_list.size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (_list[jjj] == NULL) {
continue;
}
if (tmpList[iii]->m_bufferName.getNameFile() > _list[jjj]->m_bufferName.getNameFile()) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
BufferView::BufferView(void)
{
SetCanHaveFocus(true);
RegisterMultiCast(ednMsgBufferListChange);
RegisterMultiCast(ednMsgBufferState);
RegisterMultiCast(ednMsgBufferId);
BufferView::BufferView(void) :
m_openOrderMode(false) {
addObjectType("appl::BufferView");
setCanHaveFocus(true);
registerMultiCast(ednMsgBufferListChange);
registerMultiCast(ednMsgBufferState);
registerMultiCast(ednMsgBufferId);
registerMultiCast(appl::MsgSelectNewFile);
registerMultiCast(appl::MsgSelectChange);
registerMultiCast(appl::MsgNameChange);
m_selectedID = -1;
m_selectedIdRequested = -1;
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
// load color properties
m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:bufferList.json");
// get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2");
m_colorBackgroundSelect = m_paintingProperties->request("backgroungSelected");
m_colorTextNormal = m_paintingProperties->request("textNormal");
m_colorTextModify = m_paintingProperties->request("textModify");
}
BufferView::~BufferView(void)
{
RemoveAllElement();
BufferView::~BufferView(void) {
removeAllElement();
}
void BufferView::RemoveAllElement(void)
{
for(int32_t iii=0; iii<m_list.Size(); iii++) {
void BufferView::removeAllElement(void) {
for(int32_t iii=0; iii<m_list.size(); iii++) {
if (NULL!=m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
}
}
m_list.Clear();
m_list.clear();
if (m_bufferManager != NULL) {
appl::BufferManager::release(m_bufferManager);
}
}
/**
* @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 BufferView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
widget::List::OnReceiveMessage(CallerObject, eventId, data);
if (eventId == ednMsgBufferListChange) {
void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition) {
if (_dataStruct == NULL) {
return;
}
// alphabetical order:
for (size_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii] == NULL) {
continue;
}
if (to_lower(m_list[iii]->m_bufferName.getNameFile()) > to_lower(_dataStruct->m_bufferName.getNameFile())) {
m_list.insert(m_list.begin() + iii, _dataStruct);
_dataStruct = NULL;
if (_selectNewPosition == true) {
m_selectedID = iii;
}
break;
}
}
if (_dataStruct != NULL) {
m_list.push_back(_dataStruct);
if (_selectNewPosition == true) {
m_selectedID = m_list.size()-1;
}
}
}
void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
widget::List::onReceiveMessage(_msg);
if (_msg.getMessage() == appl::MsgSelectNewFile) {
appl::Buffer* buffer = m_bufferManager->get(_msg.getData());
if (buffer == NULL) {
APPL_ERROR("event on element nor exist : " << _msg.getData());
return;
}
buffer->registerOnEvent(this, appl::Buffer::eventIsSave);
buffer->registerOnEvent(this, appl::Buffer::eventIsModify);
buffer->registerOnEvent(this, appl::Buffer::eventChangeName);
appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer);
if (tmp == NULL) {
APPL_ERROR("Allocation error of the tmp buffer list element");
return;
}
if (m_openOrderMode == true) {
m_list.push_back(tmp);
} else {
insertAlphabetic(tmp);
}
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventChangeName) {
for (size_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii] == NULL) {
continue;
}
if (m_list[iii]->m_bufferName != m_list[iii]->m_buffer->getFileName()) {
m_list[iii]->m_bufferName = m_list[iii]->m_buffer->getFileName();
if (m_openOrderMode == false) {
// re-order the fine in the correct position
appl::dataBufferStruct* tmp = m_list[iii];
m_list[iii] = NULL;
m_list.erase(m_list.begin() + iii);
insertAlphabetic(tmp, (iii == m_selectedID));
break;
}
}
}
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventIsSave) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventIsModify) {
markToRedraw();
return;
}
APPL_DEBUG("message : " << _msg);
if (_msg.getMessage() == appl::MsgSelectChange) {
m_selectedID = -1;
appl::Buffer* tmpBuffer = NULL;
if (m_bufferManager != NULL) {
tmpBuffer = m_bufferManager->getBufferSelected();
}
if (tmpBuffer != NULL) {
for (int32_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii] == NULL) {
continue;
}
if (m_list[iii]->m_buffer != tmpBuffer) {
continue;
}
m_selectedID = iii;
break;
}
}
markToRedraw();
return;
}
if (_msg.getMessage() == ednMsgBufferListChange) {
// clean The list
RemoveAllElement();
// Get all the buffer name and properties:
int32_t nbBufferOpen = BufferManager::Size();
removeAllElement();
// get all the buffer name and properties:
int32_t nbBufferOpen = 0; // BufferManager::size();
for (int32_t iii=0; iii<nbBufferOpen; iii++) {
if (BufferManager::Exist(iii)) {
BufferText* tmpBuffer = BufferManager::Get(iii);
/*
if (BufferManager::exist(iii)) {
BufferText* tmpBuffer = BufferManager::get(iii);
if (NULL != tmpBuffer) {
bool isModify = tmpBuffer->IsModify();
etk::FSNode name = tmpBuffer->GetFileName();
bool isModify = tmpBuffer->isModify();
etk::FSNode name = tmpBuffer->getFileName();
appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify);
if (NULL != tmpElement) {
m_list.PushBack(tmpElement);
m_list.push_back(tmpElement);
} else {
APPL_ERROR("Allocation error of the tmp buffer list element");
}
}
}
*/
}
if (true == globals::OrderTheBufferList() ) {
SortElementList(m_list);
}
MarkToRedraw();
}else if (eventId == ednMsgBufferId) {
m_selectedIdRequested = BufferManager::GetSelected();
MarkToRedraw();
}else if (eventId == ednMsgBufferState) {
// Update list of modify section ...
for (int32_t iii=0; iii<m_list.Size(); iii++) {
markToRedraw();
}else if (_msg.getMessage() == ednMsgBufferId) {
m_selectedIdRequested = 0; //BufferManager::getSelected();
markToRedraw();
}else if (_msg.getMessage() == ednMsgBufferState) {
// update list of modify section ...
for (int32_t iii=0; iii<m_list.size(); iii++) {
if (NULL!=m_list[iii]) {
m_list[iii]->m_isModify = BufferManager::Get(m_list[iii]->m_bufferID)->IsModify();
//m_list[iii]->m_isModify = BufferManager::get(m_list[iii]->m_bufferID)->isModify();
}
}
MarkToRedraw();
markToRedraw();
}
}
void BufferView::onObjectRemove(ewol::EObject* _removeObject) {
widget::List::onObjectRemove(_removeObject);
for (int32_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii] == NULL) {
continue;
}
if (m_list[iii]->m_buffer != _removeObject) {
continue;
}
m_list.erase(m_list.begin()+iii);
markToRedraw();
return;
}
}
draw::Color BufferView::GetBasicBG(void)
{
return ColorizeManager::Get(COLOR_LIST_BG_1);
etk::Color<> BufferView::getBasicBG(void) {
return (*m_paintingProperties)[m_colorBackground1].getForeground();
}
uint32_t BufferView::GetNuberOfColomn(void)
{
uint32_t BufferView::getNuberOfColomn(void) {
return 1;
}
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg)
{
myTitle = "Buffers : ";
bool BufferView::getTitle(int32_t _colomn, std::string &_myTitle, etk::Color<> &_fg, etk::Color<> &_bg) {
_myTitle = "Buffers : ";
return true;
}
uint32_t BufferView::GetNuberOfRaw(void)
{
return m_list.Size();
uint32_t BufferView::getNuberOfRaw(void) {
return m_list.size();
}
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg)
{
bool isModify;
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
basicColor_te selectBG = COLOR_LIST_BG_1;
// when requested a new display selection ==> reset the previous one ...
if (m_selectedIdRequested != -1) {
m_selectedID = -1;
}
if( raw>=0
&& raw<m_list.Size()
&& NULL != m_list[raw]) {
myTextToWrite = m_list[raw]->m_bufferName.GetNameFile();
bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
if( _raw >= 0
&& _raw<m_list.size()
&& NULL != m_list[_raw]) {
_myTextToWrite = m_list[_raw]->m_bufferName.getNameFile();
if (true == m_list[raw]->m_isModify) {
selectFG = COLOR_LIST_TEXT_MODIFY;
if ( m_list[_raw]->m_buffer != NULL
&& m_list[_raw]->m_buffer->isModify() == false) {
_fg = (*m_paintingProperties)[m_colorTextNormal].getForeground();
} else {
selectFG = COLOR_LIST_TEXT_NORMAL;
_fg = (*m_paintingProperties)[m_colorTextModify].getForeground();
}
if (raw%2==0) {
selectBG = COLOR_LIST_BG_1;
if (_raw%2 == 0) {
_bg = (*m_paintingProperties)[m_colorBackground1].getForeground();
} else {
selectBG = COLOR_LIST_BG_2;
_bg = (*m_paintingProperties)[m_colorBackground2].getForeground();
}
// the buffer change of selection ...
if (m_selectedIdRequested == m_list[raw]->m_bufferID) {
m_selectedID = raw;
// stop searching
m_selectedIdRequested = -1;
}
if (m_selectedID == raw) {
selectBG = COLOR_LIST_BG_SELECTED;
if (m_selectedID == _raw) {
_bg = (*m_paintingProperties)[m_colorBackgroundSelect].getForeground();
}
} else {
myTextToWrite = "ERROR";
_myTextToWrite = "ERROR";
}
fg = ColorizeManager::Get(selectFG);
bg = ColorizeManager::Get(selectBG);
return true;
}
bool BufferView::OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y)
{
if (1 == IdInput && typeEvent == ewol::keyEvent::statusSingle) {
APPL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if( raw>=0
&& raw<m_list.Size()
&& NULL != m_list[raw]) {
m_selectedID = raw;
SendMultiCast(ednMsgBufferId, m_list[raw]->m_bufferID);
if (1 == _IdInput && _typeEvent == ewol::keyEvent::statusSingle) {
APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
if( _raw >= 0
&& _raw<m_list.size()
&& NULL != m_list[_raw]) {
if (m_list[_raw]->m_buffer != NULL) {
sendMultiCast(appl::MsgSelectNewFile, m_list[_raw]->m_buffer->getFileName());
m_selectedID = _raw;
markToRedraw();
return true;
}
}
}
MarkToRedraw();
return false;
}

View File

@@ -9,11 +9,11 @@
#ifndef __BUFFER_VIEW_H__
#define __BUFFER_VIEW_H__
#include <appl/Debug.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <appl/debug.h>
#include <appl/BufferManager.h>
#include <appl/globalMsg.h>
#include <ewol/widget/List.h>
#include <ewol/widget/Windows.h>
namespace appl
{
@@ -21,13 +21,10 @@ namespace appl
{
public:
etk::FSNode m_bufferName;
uint32_t m_bufferID;
bool m_isModify;
dataBufferStruct(etk::FSNode& bufferName, int32_t bufferID, bool isModify) :
m_bufferName(bufferName),
m_bufferID(bufferID),
m_isModify(isModify)
{
appl::Buffer* m_buffer;
dataBufferStruct(const std::string& _bufferName, appl::Buffer* _buffer) :
m_bufferName(_bufferName),
m_buffer(_buffer) {
};
~dataBufferStruct(void) { };
@@ -37,31 +34,42 @@ namespace appl
class BufferView : public widget::List
{
private:
int32_t m_selectedIdRequested;
int32_t m_selectedID;
etk::Vector<appl::dataBufferStruct*> m_list;
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
private:
appl::GlyphPainting* m_paintingProperties; //!< element painting property
int32_t m_colorBackground1;
int32_t m_colorBackground2;
int32_t m_colorBackgroundSelect;
int32_t m_colorTextNormal;
int32_t m_colorTextModify;
private:
int32_t m_selectedIdRequested;
int32_t m_selectedID;
std::vector<appl::dataBufferStruct*> m_list;
/**
* @brief Insert the element in the alphabetic order.
* @param[in] _dataStruct element to add.
*/
void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false);
public:
// Constructeur
BufferView(void);
~BufferView(void);
// Derived function
const char * const GetObjectType(void) { return "ApplBufferView"; };
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject* _removeObject);
private:
bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order
protected:
// function call to display the list :
virtual draw::Color GetBasicBG(void);
virtual etk::Color<> getBasicBG(void);
void removeAllElement(void);
// Derived function
virtual uint32_t GetNuberOfColomn(void);
// Derived function
virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
// Derived function
virtual uint32_t GetNuberOfRaw(void);
// Derived function
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
// Derived function
virtual bool OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
void RemoveAllElement(void);
virtual uint32_t getNuberOfColomn(void);
virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
virtual uint32_t getNuberOfRaw(void);
virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
virtual bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
};

View File

@@ -1,508 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <CodeView.h>
#include <appl/Debug.h>
#include <appl/global.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <ColorizeManager.h>
#include <ewol/clipBoard.h>
#include <SearchData.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "CodeView"
void CodeView::Init(void)
{
m_label = "CodeView is disable ...";
m_bufferID = -1;
m_buttunOneSelected = false;
m_lineNumberList.Clear();
m_textColorFg = draw::color::black;
m_textColorBg = draw::color::black;
m_textColorBg.a = 0x40;
SetCanHaveFocus(true);
RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgGuiCopy);
RegisterMultiCast(ednMsgGuiPaste);
RegisterMultiCast(ednMsgGuiCut);
RegisterMultiCast(ednMsgGuiRedo);
RegisterMultiCast(ednMsgGuiUndo);
RegisterMultiCast(ednMsgGuiRm);
RegisterMultiCast(ednMsgGuiSelect);
RegisterMultiCast(ednMsgGuiChangeCharset);
RegisterMultiCast(ednMsgGuiFind);
RegisterMultiCast(ednMsgGuiReplace);
RegisterMultiCast(ednMsgGuiGotoLine);
SetLimitScrolling(0.2);
ShortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
ShortCutAdd("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
ShortCutAdd("ctrl+x", ednMsgGuiCut, "STD");
ShortCutAdd("ctrl+c", ednMsgGuiCopy, "STD");
ShortCutAdd("ctrl+v", ednMsgGuiPaste, "STD");
ShortCutAdd("ctrl+a", ednMsgGuiSelect, "ALL");
ShortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE");
}
CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
m_displayText(fontName, fontSize)
{
Init();
}
CodeView::CodeView(void)
{
Init();
}
CodeView::~CodeView(void)
{
}
/**
* @brief Check if the number of reference buffer is good or not ...
* @param[in] bufferID id of the current Buffer that needed to have a reference
* @return ---
*/
void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
{
vec2 tmpCoord;
tmpCoord.x = 0;
tmpCoord.y = 0;
if (m_lineNumberList.Size()<=bufferID) {
// update the number of elements :
for (int32_t iii=m_lineNumberList.Size(); iii <= bufferID; iii++) {
// add start line at 0 :
m_lineNumberList.PushBack(tmpCoord);
}
}
}
bool CodeView::CalculateMinSize(void)
{
m_minSize.x = 50;
m_minSize.y = 50;
return true;
}
void CodeView::CalculateMaxSize(void)
{
m_maxSize.x = 2048;
int32_t letterHeight = m_displayText.CalculateSize('A').y;
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
m_maxSize.y = tmpBuffer->GetNumberOfLine() * letterHeight;
} else {
m_maxSize.y = 50;
}
}
void CodeView::OnDraw(ewol::DrawProperty& displayProp)
{
m_displayDrawing.Draw();
m_displayText.Draw();
WidgetScrooled::OnDraw(displayProp);
}
void CodeView::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
int64_t startTime = ewol::GetTime();
// For the scrooling windows
CalculateMaxSize();
m_displayDrawing.Clear();
m_displayText.Clear();
// Reset the background :
m_displayDrawing.SetPos(vec3(-2048, -2048, 0));
m_displayDrawing.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
m_displayDrawing.RectangleWidth(vec3(4096, 4096, 0) );
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if( NULL != tmpBuffer
&& true == tmpBuffer->NeedToUpdateDisplayPosition() ) {
vec2 borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
bool centerRequested = false;
// TODO : set it back ...
vec2 currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested);
SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
} // else : nothing to do ...
// generate the objects :
if (-1 == m_bufferID) {
m_displayText.SetTextAlignement(10, m_size.x-20, ewol::Text::alignLeft);
m_displayDrawing.SetColor(0x00000022);
m_displayDrawing.SetPos(vec3(10, 0, 0));
m_displayDrawing.Rectangle(vec3((int32_t)m_size.x-20, 1500, 0) );
m_displayText.SetRelPos(vec3(10, 0, 0));
// nothing to display :
etk::UString tmpString("<br/>\n"
"<font color=\"red\">\n"
" <b>\n"
" edn - Editeur De N'ours\n"
" </b>\n"
"</font>\n"
"<br/>\n"
"<br/>\n"
"<font color=\"indigo\">\n"
" <i>\n"
" No Buffer Availlable to display\n"
" </i>\n"
"</font>\n");
m_displayText.SetPos(vec3(0.0f, m_size.y, 0.0f) );
m_displayText.ForceLineReturn();
m_displayText.PrintDecorated(tmpString);
} else {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Display(m_displayText, m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
}
// set the current size of the windows
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
}
int64_t stopTime = ewol::GetTime();
APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " micro-s");
// call the herited class...
WidgetScrooled::OnRegenerateDisplay();
}
}
bool CodeView::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData)
{
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
if (typeEvent == ewol::keyEvent::statusDown) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->AddChar(unicodeData);
}
MarkToRedraw();
}
return true;
}
bool CodeView::OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent)
{
if (typeEvent == ewol::keyEvent::statusDown) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->cursorMove(moveTypeEvent);
}
MarkToRedraw();
}
return true;
}
/**
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
* @note : need to have focus ...
* @param[in] mode Mode of data requested
* @return ---
*/
void CodeView::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
{
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Paste(clipboardID);
}
MarkToRedraw();
}
/**
* @brief Event on an input of this Widget
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @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(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos)
{
vec2 relativePos = RelativePosition(pos);
// corection for the openGl abstraction
//relativePos.y = m_size.y - relativePos.y;
vec2 limitedPos = relativePos;
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1);
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1);
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widget ...
return true;
}
if (m_bufferID < 0) {
return false;
}
if (1 == IdInput) {
#ifndef __MODE__Touch
if (ewol::keyEvent::statusDown == typeEvent) {
m_buttunOneSelected = true;
ewol::widgetManager::FocusKeep(this);
// TODO : Set something good
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseEvent(limitedPos);
}
MarkToRedraw();
} else if (ewol::keyEvent::statusUp == typeEvent) {
m_buttunOneSelected = false;
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Copy(ewol::clipBoard::clipboardSelection);
}
MarkToRedraw();
} else
#endif
if (ewol::keyEvent::statusSingle == typeEvent) {
#ifdef __MODE__Touch
ewol::widgetManager::FocusKeep(this);
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseEvent(limitedPos);
}
MarkToRedraw();
#else
// nothing to do ...
#endif
} else if (ewol::keyEvent::statusDouble == typeEvent) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseEventDouble();
}
MarkToRedraw();
} else if (ewol::keyEvent::statusTriple == typeEvent) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseEventTriple();
}
MarkToRedraw();
} else if (ewol::keyEvent::statusMove == typeEvent) {
if (true == m_buttunOneSelected) {
int xxx, yyy;
xxx = relativePos.x;
yyy = relativePos.y;
if (xxx<0) {
xxx = 0;
}
if (yyy<0) {
yyy = 0;
}
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
// TODO : Set something good
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseSelectFromCursorTo(limitedPos);
}
MarkToRedraw();
}
}
} else if (2 == IdInput) {
if (ewol::keyEvent::statusSingle == typeEvent) {
// TODO : Set something good
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->MouseEvent(limitedPos);
}
ewol::clipBoard::Request(ewol::clipBoard::clipboardSelection);
ewol::widgetManager::FocusKeep(this);
}
}
return true;
}
/**
* @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)
{
widget::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
APPL_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
if(eventId == ednMsgBufferId) {
//keep the reference of the display offset :
if( m_bufferID >=0
&& m_bufferID < m_lineNumberList.Size()) {
m_lineNumberList[m_bufferID] = m_originScrooled;
}
int32_t bufferID = 0;
sscanf(data.c_str(), "%d", &bufferID);
APPL_INFO("Select a new Buffer ... " << bufferID);
// set the new buffer ID
m_bufferID = bufferID;
// update the start display position...
UpdateNumberOfLineReference(m_bufferID);
// set back if needed the display position ...
if( m_bufferID >=0
&& m_bufferID < m_lineNumberList.Size()) {
m_originScrooled = m_lineNumberList[m_bufferID];
}
} else if (eventId == ednMsgGuiCopy) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Copy(ewol::clipBoard::clipboardStd);
}
} else if (eventId == ednMsgGuiCut) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Cut(ewol::clipBoard::clipboardStd);
}
} else if (eventId == ednMsgGuiPaste) {
ewol::clipBoard::Request(ewol::clipBoard::clipboardStd);
} else if (eventId == ednMsgGuiUndo) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Undo();
}
} else if (eventId == ednMsgGuiRedo) {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Redo();
}
} else if (eventId == ednMsgGuiRm) {
// data : "Word" "Line" "Paragraph"
if (data == "Word") {
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
} else if (data == "Line") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->RemoveLine();
}
} else if (data == "Paragraph") {
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiSelect) {
// data : "ALL" "NONE"
if (data == "ALL") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->SelectAll();
}
} else if (data == "NONE") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->SelectNone();
}
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiChangeCharset) {
// data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
if (data == "UTF-8") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->SetCharset(unicode::EDN_CHARSET_UTF8);
}
} else if (data == "ISO-8859-1") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->SetCharset(unicode::EDN_CHARSET_ISO_8859_1);
}
} else if (data == "ISO-8859-15") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->SetCharset(unicode::EDN_CHARSET_ISO_8859_15);
}
} else {
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
}
} else if (eventId == ednMsgGuiFind) {
etk::UString myDataString;
SearchData::GetSearch(myDataString);
if (data == "Next") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
}
} else if (data == "Previous") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
}
}
} else if (eventId == ednMsgGuiReplace) {
etk::UString myDataString;
SearchData::GetReplace(myDataString);
if (data == "Normal") {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->Replace(myDataString);
}
} else if (data == "All") {
}
} else if (eventId == ednMsgGuiGotoLine) {
int32_t lineID = 0;
sscanf(data.c_str(), "%d", &lineID);
APPL_INFO("Goto line : " << lineID);
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) {
tmpBuffer->JumpAtLine(lineID);
}
}
// Force redraw of the widget
MarkToRedraw();
}
void CodeView::OnGetFocus(void)
{
/*
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
*/
ewol::Keyboard(true);
APPL_INFO("Focus - In");
}
void CodeView::OnLostFocus(void)
{
ewol::Keyboard(false);
APPL_INFO("Focus - out");
}
void CodeView::SetFontSize(int32_t size)
{
m_displayText.SetFontSize(size);
SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ...
}
void CodeView::SetFontName(etk::UString fontName)
{
m_displayText.SetFontName(fontName);
}

View File

@@ -1,71 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __CODE_VIEW_H__
#define __CODE_VIEW_H__
#include <appl/Debug.h>
#include <CodeView.h>
#include <BufferManager.h>
#include <appl/globalMsg.h>
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
class CodeView :public widget::WidgetScrooled
{
public:
void Init(void);
CodeView(etk::UString fontName, int32_t fontSize);
CodeView(void);
virtual ~CodeView(void);
// Derived function
const char * const GetObjectType(void) { return "ApplCodeView"; };
// Derived function
virtual bool CalculateMinSize(void);
private:
etk::UString m_label;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
int32_t m_bufferID;
bool m_buttunOneSelected;
etk::Vector<vec2 > m_lineNumberList;
void UpdateNumberOfLineReference(int32_t bufferID);
// drawing elements :
ewol::Text m_displayText;
ewol::Drawing m_displayDrawing;
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
public:
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
// Derived function
virtual bool OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent);
// Derived function
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
// Derived function
virtual void OnGetFocus(void);
// Derived function
virtual void OnLostFocus(void);
public:
void SetFontSize(int32_t size);
void SetFontName(etk::UString fontName);
private:
void CalculateMaxSize(void);
protected:
virtual void OnDraw(ewol::DrawProperty& displayProp);
};
#endif

View File

@@ -7,17 +7,16 @@
*/
#include <appl/Debug.h>
#include <appl/debug.h>
#include <appl/global.h>
#include <MainWindows.h>
#include <CodeView.h>
#include <BufferView.h>
#include <Search.h>
#include <appl/Gui/MainWindows.h>
#include <appl/Gui/BufferView.h>
#include <appl/Gui/TextViewer.h>
#include <appl/Gui/Search.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/SizerVert.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/List.h>
@@ -29,9 +28,27 @@
#include <ewol/widget/meta/FileChooser.h>
#include <ewol/widget/meta/Parameter.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/eContext.h>
#include <date/date.h>
#include <ewol/widget/meta/StdPopUp.h>
#include <appl/Gui/WorkerSaveFile.h>
#include <appl/Gui/WorkerSaveAllFile.h>
#include <appl/Gui/WorkerCloseFile.h>
#include <appl/Gui/WorkerCloseAllFile.h>
namespace appl {
std::string getVersion(void) {
#define FIRST_YEAR (2010)
std::string tmpOutput = std::to_string(date::getYear()-FIRST_YEAR);
tmpOutput += ".";
tmpOutput += std::to_string(date::getMonth());
tmpOutput += ".";
tmpOutput += std::to_string(date::getDay());
return tmpOutput;
}
}
#undef __class__
@@ -40,27 +57,33 @@
#include <ewol/widget/Label.h>
#include <ewol/widget/Spacer.h>
class ParameterAboutGui : public widget::SizerVert
{
class ParameterAboutGui : public widget::Sizer {
public :
ParameterAboutGui(void)
{
ParameterAboutGui(void) :
widget::Sizer(widget::Sizer::modeVert) {
widget::Spacer* mySpacer = NULL;
mySpacer = new widget::Spacer();
if (NULL == mySpacer) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
APPL_ERROR("Can not allocate widget == > display might be in error");
} else {
mySpacer->SetExpendX(true);
mySpacer->SetExpendY(true);
SubWidgetAdd(mySpacer);
mySpacer->setExpand(bvec2(true,true));
subWidgetAdd(mySpacer);
}
etk::UString tmpLabel = "<left>";
tmpLabel += " <b>Editeur De N'ours</b> : v";
tmpLabel += APPL_VERSION_TAG_NAME;
std::string tmpLabel = "<left>";
tmpLabel += " <b>Editeur De N'ours</b> : v:";
tmpLabel += appl::getVersion();
tmpLabel += "<br/>";
tmpLabel += " <b>Build Time</b> : ";
tmpLabel += BUILD_TIME;
tmpLabel += date::getYear();
tmpLabel += "/";
tmpLabel += date::getMonth();
tmpLabel += "/";
tmpLabel += date::getDay();
tmpLabel += " ";
tmpLabel += date::getHour();
tmpLabel += "h";
tmpLabel += date::getMinute();
tmpLabel += "<br/>";
tmpLabel += " <b>Website</b> : https://github.com/HeeroYui/edn<br/>";
tmpLabel += " <b>License</b> : GPL v3<br/>";
@@ -72,323 +95,404 @@ class ParameterAboutGui : public widget::SizerVert
tmpLabel += "</left>";
widget::Label* myLabel = new widget::Label(tmpLabel);
if (NULL == myLabel) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
APPL_ERROR("Can not allocate widget == > display might be in error");
} else {
myLabel->SetExpendX(true);
SubWidgetAdd(myLabel);
myLabel->setExpand(bvec2(true,false));
subWidgetAdd(myLabel);
}
};
~ParameterAboutGui(void) { };
~ParameterAboutGui(void) {
};
};
// Local main windows event :
static const char* mainWindowsRequestSaveFile = "appl-event-main-windows-save-file";
static const char* mainWindowsRequestSaveFileAs = "appl-event-main-windows-save-file-as";
static const char* mainWindowsRequestcloseFileNoCheck = "appl-event-main-windows-close-file-no-check";
const char * l_smoothChick = "tmpEvent_smooth";
const char * l_smoothMin = "tmpEvent_minChange";
const char * l_smoothMax = "tmpEvent_maxChange";
const char* l_smoothChick = "tmpEvent_smooth";
const char* l_smoothMin = "tmpEvent_minChange";
const char* l_smoothMax = "tmpEvent_maxChange";
#undef __class__
#define __class__ "MainWindows"
#define __class__ "MainWindows"
MainWindows::MainWindows(void)
{
MainWindows::MainWindows(void) {
addObjectType("appl::MainWindows");
APPL_DEBUG("CREATE WINDOWS ... ");
widget::SizerVert * mySizerVert = NULL;
widget::SizerVert * mySizerVert2 = NULL;
widget::SizerHori * mySizerHori = NULL;
widget::Sizer * mySizerVert = NULL;
widget::Sizer * mySizerVert2 = NULL;
widget::Sizer * mySizerHori = NULL;
//ewol::Button * myButton = NULL;
CodeView * myCodeView = NULL;
appl::TextViewer * myTextView = NULL;
BufferView * myBufferView = NULL;
widget::Menu * myMenu = NULL;
mySizerVert = new widget::SizerVert();
SetSubWidget(mySizerVert);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
mySizerHori = new widget::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
mySizerVert = new widget::Sizer(widget::Sizer::modeVert);
setSubWidget(mySizerVert);
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
mySizerVert->subWidgetAdd(mySizerHori);
myBufferView = new BufferView();
myBufferView->SetExpendX(false);
myBufferView->SetExpendY(true);
myBufferView->SetFillX(true);
myBufferView->SetFillY(true);
mySizerHori->SubWidgetAdd(myBufferView);
myBufferView->setExpand(bvec2(false,true));
myBufferView->setFill(bvec2(true,true));
mySizerHori->subWidgetAdd(myBufferView);
mySizerVert2 = new widget::SizerVert();
mySizerHori->SubWidgetAdd(mySizerVert2);
mySizerVert2 = new widget::Sizer(widget::Sizer::modeVert);
mySizerHori->subWidgetAdd(mySizerVert2);
// main buffer Area :
myCodeView = new CodeView("FreeMono", 11);
myCodeView->SetExpendX(true);
myCodeView->SetExpendY(true);
myCodeView->SetFillX(true);
myCodeView->SetFillY(true);
mySizerVert2->SubWidgetAdd(myCodeView);
myTextView = new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11);
myTextView->setExpand(bvec2(true,true));
myTextView->setFill(bvec2(true,true));
mySizerVert2->subWidgetAdd(myTextView);
/*
myTextView = new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11);
myTextView->setExpand(bvec2(true,true));
myTextView->setFill(bvec2(true,true));
mySizerVert2->subWidgetAdd(myTextView);
*/
// search area :
Search * mySearch = new Search();
mySizerVert2->SubWidgetAdd(mySearch);
mySizerVert2->subWidgetAdd(mySearch);
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
{
widget::SizerHori * mySizerHori2 = new widget::SizerHori();
mySizerVert2->SubWidgetAdd(mySizerHori2);
widget::Sizer * mySizerHori2 = new widget::Sizer(widget::Sizer::modeHori);
mySizerVert2->subWidgetAdd(mySizerHori2);
widget::CheckBox* tmpCheck = new widget::CheckBox("smooth");
mySizerHori2->SubWidgetAdd(tmpCheck);
tmpCheck->RegisterOnEvent(this, ewolEventCheckBoxClicked, l_smoothChick);
mySizerHori2->subWidgetAdd(tmpCheck);
tmpCheck->registerOnEvent(this, ewolEventCheckBoxClicked, l_smoothChick);
widget::Slider* tmpSlider = new widget::Slider();
mySizerHori2->SubWidgetAdd(tmpSlider);
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMin);
tmpSlider->SetExpendX(true);
tmpSlider->SetMin(0);
tmpSlider->SetMax(1000);
tmpSlider->SetValue(0450);
mySizerHori2->subWidgetAdd(tmpSlider);
tmpSlider->registerOnEvent(this, ewolEventSliderChange, l_smoothMin);
tmpSlider->setExpand(bvec2(true,false));
tmpSlider->setMin(0);
tmpSlider->setMax(1000);
tmpSlider->setValue(0450);
tmpSliderMin = tmpSlider;
tmpSlider = new widget::Slider();
mySizerHori2->SubWidgetAdd(tmpSlider);
tmpSlider->RegisterOnEvent(this, ewolEventSliderChange, l_smoothMax);
tmpSlider->SetExpendX(true);
tmpSlider->SetMin(0);
tmpSlider->SetMax(1000);
tmpSlider->SetValue(0550);
mySizerHori2->subWidgetAdd(tmpSlider);
tmpSlider->registerOnEvent(this, ewolEventSliderChange, l_smoothMax);
tmpSlider->setExpand(bvec2(true,false));
tmpSlider->setMin(0);
tmpSlider->setMax(1000);
tmpSlider->setValue(0550);
tmpSliderMax = tmpSlider;
}
#endif
mySizerHori = new widget::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
mySizerVert->subWidgetAdd(mySizerHori);
myMenu = new widget::Menu();
mySizerHori->SubWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->AddTitle("File");
(void)myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuFile, "Open", "THEME:GUI:Load.svg", ednMsgGuiOpen);
(void)myMenu->Add(idMenuFile, "Close", "THEME:GUI:Close.svg", ednMsgGuiClose, "current");
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
(void)myMenu->Add(idMenuFile, "Save", "THEME:GUI:Save.svg", ednMsgGuiSave, "current");
(void)myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
(void)myMenu->AddSpacer();
//(void)myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuFile, "Properties", "THEME:GUI:Parameter.svg", ednMsgProperties);
int32_t idMenuEdit = myMenu->AddTitle("Edit");
(void)myMenu->Add(idMenuEdit, "Undo", "THEME:GUI:Undo.svg", ednMsgGuiUndo);
(void)myMenu->Add(idMenuEdit, "Redo", "THEME:GUI:Redo.svg", ednMsgGuiRedo);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
(void)myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
(void)myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
(void)myMenu->Add(idMenuEdit, "Remove", "", ednMsgGuiRm);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
(void)myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
(void)myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
int32_t idMenuSearch = myMenu->AddTitle("Search");
(void)myMenu->Add(idMenuSearch, "Search", "THEME:GUI:Search.svg", ednMsgGuiSearch);
(void)myMenu->Add(idMenuSearch, "Replace", "THEME:GUI:Replace.svg", ednMsgGuiReplace);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
(void)myMenu->Add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
(void)myMenu->Add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
(void)myMenu->Add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
int32_t idMenuCTags = myMenu->AddTitle("C-tags");
(void)myMenu->Add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
(void)myMenu->Add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
(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->AddSpacer();
(void)myMenu->Add(idMenugDisplay, "Reload OpenGl Shader", "", ednMsgGuiReloadShader);
mySizerHori->subWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->addTitle("File");
(void)myMenu->add(idMenuFile, "New", "", ednMsgGuiNew);
(void)myMenu->addSpacer();
(void)myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.svg", ednMsgGuiOpen);
(void)myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.svg", ednMsgGuiClose, "current");
(void)myMenu->add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
(void)myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.svg", ednMsgGuiSave, "current");
(void)myMenu->add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
(void)myMenu->addSpacer();
//(void)myMenu->add(idMenuFile, "Exit", "", ednMsgGuiExit);
(void)myMenu->addSpacer();
(void)myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.svg", ednMsgProperties);
int32_t idMenuEdit = myMenu->addTitle("Edit");
(void)myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.svg", ednMsgGuiUndo);
(void)myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.svg", ednMsgGuiRedo);
(void)myMenu->addSpacer();
(void)myMenu->add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
(void)myMenu->add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
(void)myMenu->add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
(void)myMenu->add(idMenuEdit, "Remove", "", ednMsgGuiRm);
(void)myMenu->addSpacer();
(void)myMenu->add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
(void)myMenu->add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
(void)myMenu->add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
int32_t idMenuSearch = myMenu->addTitle("Search");
(void)myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.svg", ednMsgGuiSearch);
(void)myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.svg", ednMsgGuiReplace);
(void)myMenu->addSpacer();
(void)myMenu->add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
(void)myMenu->add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
(void)myMenu->add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
(void)myMenu->add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
/* ==> must be in the pluggin list control ...
int32_t idMenuCTags = myMenu->addTitle("C-tags");
(void)myMenu->add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
(void)myMenu->add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
(void)myMenu->add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
(void)myMenu->add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
*/
int32_t idMenugDisplay = myMenu->addTitle("Display");
(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);
m_widgetLabelFileName = new widget::Label("<left>FileName</left>");
m_widgetLabelFileName->SetExpendX(true);
m_widgetLabelFileName->SetFillY(true);
mySizerHori->SubWidgetAdd(m_widgetLabelFileName);
m_widgetLabelFileName = new widget::Label("FileName");
m_widgetLabelFileName->setExpand(bvec2(true,false));
m_widgetLabelFileName->setFill(bvec2(true,false));;
mySizerHori->subWidgetAdd(m_widgetLabelFileName);
// add generic shortcut ...
// (shift, control, alt, meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
ShortCutAdd("ctrl+o", ednMsgGuiOpen, "", true);
ShortCutAdd("ctrl+n", ednMsgGuiNew, "", true);
// (shift, control, alt, meta, char32_t unicodeValue, const char * generateEventId, std::string& data)
shortCutAdd("ctrl+o", ednMsgGuiOpen, "", true);
shortCutAdd("ctrl+n", ednMsgGuiNew, "", true);
ShortCutAdd("ctrl+s", ednMsgGuiSave, "current", true);
ShortCutAdd("ctrl+shift+s", ednMsgGuiSave, "All", true);
shortCutAdd("ctrl+s", ednMsgGuiSave, "current", true);
shortCutAdd("ctrl+shift+s", ednMsgGuiSave, "All", true);
ShortCutAdd("ctrl+q", ednMsgGuiClose, "current", true);
ShortCutAdd("ctrl+shift+q", ednMsgGuiClose, "All", true);
shortCutAdd("ctrl+q", ednMsgGuiClose, "current", true);
shortCutAdd("ctrl+shift+q", ednMsgGuiClose, "All", true);
ShortCutAdd("ctrl+z", ednMsgGuiUndo, "", true);
ShortCutAdd("ctrl+shift+z", ednMsgGuiRedo, "", true);
shortCutAdd("ctrl+z", ednMsgGuiUndo, "", true);
shortCutAdd("ctrl+shift+z", ednMsgGuiRedo, "", true);
ShortCutAdd("ctrl+l", ednMsgGuiGotoLine, "???", true);
shortCutAdd("ctrl+l", ednMsgGuiGotoLine, "???", true);
ShortCutAdd("ctrl+f", ednMsgGuiSearch, "", true);
ShortCutAdd("F12", ednMsgGuiReloadShader, "", true);
shortCutAdd("ctrl+f", ednMsgGuiSearch, "", true);
shortCutAdd("F12", ednMsgGuiReloadShader, "", true);
ShortCutAdd("ctrl+d", ednMsgGuiCtags, "Jump", true);
//shortCutAdd("ctrl+d", ednMsgGuiCtags, "Jump", true);
// Generic event ...
RegisterMultiCast(ednMsgGuiSaveAs);
RegisterMultiCast(ednMsgProperties);
RegisterMultiCast(ednMsgGuiOpen);
registerMultiCast(ednMsgGuiSave);
registerMultiCast(ednMsgGuiSaveAs);
registerMultiCast(ednMsgProperties);
registerMultiCast(ednMsgGuiNew);
registerMultiCast(ednMsgGuiOpen);
registerMultiCast(ednMsgGuiClose);
// to update the title ...
RegisterMultiCast(ednMsgBufferState);
RegisterMultiCast(ednMsgBufferId);
RegisterMultiCast(ednMsgGuiReloadShader);
registerMultiCast(ednMsgBufferState);
registerMultiCast(ednMsgBufferId);
registerMultiCast(ednMsgGuiReloadShader);
registerMultiCast(appl::MsgNameGuiChangeColor);
registerMultiCast(appl::MsgSelectNewFile);
}
MainWindows::~MainWindows(void)
{
MainWindows::~MainWindows(void) {
appl::BufferManager::release(m_bufferManager);
}
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
/**
* @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 MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
ewol::Windows::onReceiveMessage(_msg);
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
// Open file Section ...
if (eventId == ednMsgGuiOpen) {
APPL_VERBOSE("Receive Event from the main windows: " << _msg );
// open file Section ...
if (_msg.getMessage() == ednMsgGuiOpen) {
widget::FileChooser* tmpWidget = new widget::FileChooser();
tmpWidget->SetTitle("Open Files ...");
tmpWidget->SetValidateLabel("Open");
if (BufferManager::GetSelected()!=-1) {
BufferText * myBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL!=myBuffer) {
etk::FSNode tmpFile = myBuffer->GetFileName();
tmpWidget->SetFolder(tmpFile.GetNameFolder());
}
}
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
} else if (eventId == ednEventPopUpFileSelected) {
APPL_DEBUG("Request opening the file : " << data);
SendMultiCast(ednMsgOpenFile, data);
} else if (eventId == ednMsgGuiSaveAs) {
if (data == "") {
APPL_ERROR("Null data for Save As file ... ");
} else {
m_currentSavingAsIdBuffer = -1;
if (data == "current") {
m_currentSavingAsIdBuffer = BufferManager::GetSelected();
} else {
sscanf(data.c_str(), "%d", &m_currentSavingAsIdBuffer);
}
if (false == BufferManager::Exist(m_currentSavingAsIdBuffer)) {
APPL_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
} else {
BufferText* myBuffer = BufferManager::Get(m_currentSavingAsIdBuffer);
widget::FileChooser* tmpWidget = new widget::FileChooser();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->SetTitle("Save Files As...");
tmpWidget->SetValidateLabel("Save");
etk::UString folder = "/home/";
etk::UString fileName = "";
if (true == myBuffer->HaveName()) {
etk::FSNode tmpName = myBuffer->GetFileName();
folder = tmpName.GetNameFolder();
fileName = tmpName.GetNameFile();
}
tmpWidget->SetFolder(folder);
tmpWidget->SetFileName(fileName);
PopUpWidgetPush(tmpWidget);
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
}
}
}
} else if (eventId == ednEventPopUpFileSaveAs) {
// get the filename :
etk::UString tmpData = data;
APPL_DEBUG("Request Saving As file : " << tmpData);
BufferManager::Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
SendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
} else if( eventId == ednMsgBufferState
|| eventId == ednMsgBufferId) {
// the buffer change we need to update the widget string
BufferText* tmpBuffer = BufferManager::Get(BufferManager::GetSelected());
if (NULL != tmpBuffer) {
etk::FSNode compleateName = tmpBuffer->GetFileName();
bool isModify = tmpBuffer->IsModify();
etk::UString directName = compleateName.GetName();
if (true == isModify) {
directName += " *";
}
if (NULL != m_widgetLabelFileName) {
m_widgetLabelFileName->SetLabel(etk::UString("<left>") + directName + "</left>");
}
etk::UString windowsTitle = "edn - ";
windowsTitle += directName;
ewol::SetTitle(windowsTitle);
if (tmpWidget == NULL) {
APPL_ERROR("Can not open File chooser !!! ");
return;
} else {
m_widgetLabelFileName->SetLabel("");
ewol::SetTitle("edn");
}
return;
// TODO : Set the Title ....
} else if (eventId == ednMsgProperties) {
tmpWidget->setTitle("Open files ...");
tmpWidget->setValidateLabel("Open");
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
// Get a ref on the buffer selected (if null, no buffer was selected ...)
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != NULL) {
etk::FSNode tmpFile = tmpBuffer->getFileName();
tmpWidget->setFolder(tmpFile.getNameFolder());
}
// apply widget pop-up ...
popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, widget::FileChooser::eventValidate, ednEventPopUpFileSelected);
} else if (_msg.getMessage() == ednMsgProperties) {
// Request the parameter GUI
widget::Parameter* tmpWidget = new widget::Parameter();
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
APPL_ERROR("Can not allocate widget == > display might be in error");
} else {
tmpWidget->SetTitle("Properties");
PopUpWidgetPush(tmpWidget);
tmpWidget->MenuAddGroup("Editor");
tmpWidget->setTitle("Properties");
popUpWidgetPush(tmpWidget);
tmpWidget->menuAddGroup("Editor");
ewol::Widget* tmpSubWidget = new globals::ParameterGlobalsGui();
tmpWidget->MenuAdd("Editor", "", tmpSubWidget);
tmpWidget->MenuAdd("Polices & Color", "", NULL);
tmpWidget->MenuAdd("Highlight", "", NULL);
tmpWidget->MenuAddGroup("Genral");
tmpWidget->MenuAdd("Affichage", "", NULL);
tmpWidget->menuAdd("Editor", "", tmpSubWidget);
tmpWidget->menuAdd("Font & Color", "", NULL);
tmpWidget->menuAdd("Highlight", "", NULL);
tmpWidget->menuAddGroup("General");
tmpWidget->menuAdd("Display", "", NULL);
tmpSubWidget = new ParameterAboutGui();
tmpWidget->MenuAdd("About", "", tmpSubWidget);
tmpWidget->menuAdd("About", "", tmpSubWidget);
}
} else if (eventId == ednMsgGuiReloadShader) {
ewol::resource::ReLoadResources();
ewol::ForceRedrawAll();
} 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();
} else if (_msg.getMessage() == ednMsgGuiExit) {
// TODO : ...
}
// Note : Fore all next message we need to acces to the buffer manager ==> just check one time ...
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
if ( _msg.getMessage() == appl::MsgSelectNewFile
|| _msg.getMessage() == appl::Buffer::eventIsModify
|| _msg.getMessage() == appl::Buffer::eventIsSave
|| _msg.getMessage() == appl::Buffer::eventChangeName) {
// select a new Buffer ==> change title:
appl::Buffer* tmpp = m_bufferManager->getBufferSelected();
if (tmpp == NULL) {
setTitle("Edn");
if (m_widgetLabelFileName != NULL) {
m_widgetLabelFileName->setLabel("");
}
} else {
if (_msg.getMessage() == appl::MsgSelectNewFile) {
tmpp->registerOnEvent(this, appl::Buffer::eventIsModify);
tmpp->registerOnEvent(this, appl::Buffer::eventIsSave);
tmpp->registerOnEvent(this, appl::Buffer::eventChangeName);
}
setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + tmpp->getFileName());
if (m_widgetLabelFileName != NULL) {
m_widgetLabelFileName->setLabel(tmpp->getFileName() + (tmpp->isModify()==true?" *":""));
}
}
} else if (_msg.getMessage() == ednMsgGuiNew) {
(void)m_bufferManager->createNewBuffer();
} else if (_msg.getMessage() == ednEventPopUpFileSelected) {
APPL_DEBUG("Request opening the file : " << _msg.getData());
m_bufferManager->open(_msg.getData());
} else if (_msg.getMessage() == ednMsgGuiSave) {
APPL_DEBUG("Request saving the file : " << _msg.getData());
if (to_lower(_msg.getData()) == "current") {
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", false);
return;
} else if (to_lower(_msg.getData()) == "all") {
appl::WorkerSaveAllFile* tmpWorker = new appl::WorkerSaveAllFile();
return;
} else {
APPL_ERROR("UNKNOW request : " << _msg);
}
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", true);
} else if (_msg.getMessage() == ednMsgGuiClose) {
// Get a ref on the buffer selected (if null, no buffer was selected ...)
if (_msg.getData() == "current") {
appl::WorkerCloseFile* tmpWorker = new appl::WorkerCloseFile("");
} else {
appl::WorkerCloseAllFile* tmpWorker = new appl::WorkerCloseAllFile();
}
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
appl::Buffer* tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == NULL) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
if (tmpBuffer->hasFileName() == false) {
APPL_ERROR("Will never arrive");
saveAsPopUp(tmpBuffer);
} else {
if (tmpBuffer->storeFile() == false) {
APPL_ERROR("Error when loading the file " << _msg.getData());
displayErrorMessage("Error when loading the file <br/><i>" + _msg.getData() + "</i>");
}
}
} else if (_msg.getMessage() == mainWindowsRequestSaveFileAs) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
appl::Buffer* tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == NULL) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
saveAsPopUp(tmpBuffer);
} else if (_msg.getMessage() == mainWindowsRequestcloseFileNoCheck) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
appl::Buffer* tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == NULL) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
// note: just remove ==> no check : normal case ...
tmpBuffer->removeObject();
}
return;
}
void MainWindows::saveAsPopUp(appl::Buffer* _buffer) {
if (_buffer == NULL) {
APPL_ERROR("Call With NULL input...");
return;
}
appl::WorkerSaveFile* tmpObject = new appl::WorkerSaveFile(_buffer->getFileName());
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void MainWindows::OnObjectRemove(ewol::EObject * removeObject)
{
ewol::Windows::OnObjectRemove(removeObject);
if (m_widgetLabelFileName == removeObject) {
void MainWindows::closeNotSavedFile(appl::Buffer* _buffer) {
if (_buffer == NULL) {
APPL_ERROR("Call With NULL input...");
return;
}
widget::StdPopUp* tmpPopUp = new widget::StdPopUp();
if (tmpPopUp == NULL) {
APPL_ERROR("Can not create a simple pop-up");
return;
}
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
ewol::Widget* bt = NULL;
if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true);
if (bt != NULL) {
// TODO : The element is removed before beeing pressed
bt->registerOnEvent(this, widget::Button::eventPressed, mainWindowsRequestSaveFile, _buffer->getFileName());
bt->registerOnEvent(this, widget::Button::eventPressed, mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
}
}
bt = tmpPopUp->addButton("Save As", true);
if (bt != NULL) {
bt->registerOnEvent(this, widget::Button::eventPressed, mainWindowsRequestSaveFileAs, _buffer->getFileName());
//bt->registerOnEvent(this, widget::Button::eventPressed, mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
// TODO : Request the close when saved ...
}
bt = tmpPopUp->addButton("Close", true);
if (bt != NULL) {
bt->registerOnEvent(this, widget::Button::eventPressed, mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
}
tmpPopUp->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true);
popUpWidgetPush(tmpPopUp);
}
void MainWindows::onObjectRemove(ewol::EObject* _removeObject) {
ewol::Windows::onObjectRemove(_removeObject);
if (m_widgetLabelFileName == _removeObject) {
m_widgetLabelFileName = NULL;
}
}

View File

@@ -9,16 +9,15 @@
#ifndef __MAIN_WINDOWS_H__
#define __MAIN_WINDOWS_H__
#include <appl/Debug.h>
#include <appl/debug.h>
#include <appl/globalMsg.h>
#include <CodeView.h>
#include <BufferView.h>
#include <BufferManager.h>
#include <appl/Gui/BufferView.h>
#include <appl/BufferManager.h>
#include <ewol/widget/Label.h>
#include <appl/BufferManager.h>
class MainWindows : public ewol::Windows
{
class MainWindows : public ewol::Windows {
private:
int32_t m_currentSavingAsIdBuffer;
widget::Label* m_widgetLabelFileName;
@@ -26,15 +25,23 @@ class MainWindows : public ewol::Windows
// Constructeur
MainWindows(void);
~MainWindows(void);
// Derived function
const char * const GetObjectType(void) { return "MainWindows"; };
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
/**
* @brief Display a pop-up to the select the name of the file.
* @param[in] _buffer Buffer that might be saved with a new name.
*/
void saveAsPopUp(appl::Buffer* _buffer);
/**
* @brief Display a pop-up to the user to confirm wat he want to do when he close a file not saved.
* @param[in] _buffer Buffer that might be close.
*/
void closeNotSavedFile(appl::Buffer* _buffer);
public: // Derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
#define EDN_CAST_MAIN_WINDOWS(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_MAIN_WINDOWS,MainWindows,curentPointer)
#endif

View File

@@ -7,234 +7,171 @@
*/
#include "appl/global.h"
#include "Search.h"
#include "SearchData.h"
#include "BufferManager.h"
#include "MainWindows.h"
#include "appl/Gui/Search.h"
#include "appl/BufferManager.h"
#include "appl/Gui/TextViewer.h"
#include "appl/Gui/MainWindows.h"
#include "appl/globalMsg.h"
#include <ewol/widget/Button.h>
#undef __class__
#define __class__ "Search"
#define __class__ "Search"
const char* const l_eventSearchEntry = "appl-search-entry";
const char* const l_eventSearchEntryEnter = "appl-search-entry-enter";
const char* const l_eventReplaceEntry = "appl-replace-entry";
const char* const l_eventReplaceEntryEnter = "appl-replace-entry-enter";
const char* const l_eventSearchBt = "appl-search-button";
const char* const l_eventReplaceBt = "appl-replace-button";
const char* const l_eventCaseCb = "appl-case-sensitive-CheckBox";
const char* const l_eventWrapCb = "appl-wrap-CheckBox";
const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button";
const char* const l_eventSearchEntry = "appl-search-entry";
const char* const l_eventSearchEntryEnter = "appl-search-entry-enter";
const char* const l_eventReplaceEntry = "appl-replace-entry";
const char* const l_eventReplaceEntryEnter = "appl-replace-entry-enter";
const char* const l_eventSearchBt = "appl-search-button";
const char* const l_eventReplaceBt = "appl-replace-button";
const char* const l_eventCaseCb = "appl-case-sensitive-CheckBox";
const char* const l_eventWrapCb = "appl-wrap-CheckBox";
const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button";
Search::Search(void) :
m_searchEntry(NULL),
m_replaceEntry(NULL)
{
m_forward = false;
widget::Button * myButtonImage = NULL;
myButtonImage = new widget::Button("", "");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:Remove.svg");
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventHideBt);
SubWidgetAdd(myButtonImage);
}
m_searchEntry = new widget::Entry();
if (NULL == m_searchEntry) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
m_searchEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventSearchEntry);
m_searchEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventSearchEntryEnter);
m_searchEntry->SetExpendX(true);
m_searchEntry->SetFillX(true);
SubWidgetAdd(m_searchEntry);
}
myButtonImage = new widget::Button("","");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:Search.svg");
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventSearchBt);
SubWidgetAdd(myButtonImage);
}
m_replaceEntry = new widget::Entry();
if (NULL == m_replaceEntry) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryModify, l_eventReplaceEntry);
m_replaceEntry->RegisterOnEvent(this, ewolEventEntryEnter, l_eventReplaceEntryEnter);
m_replaceEntry->SetExpendX(true);
m_replaceEntry->SetFillX(true);
SubWidgetAdd(m_replaceEntry);
}
myButtonImage = new widget::Button("","");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:Replace.svg");
myButtonImage->SetMinSize(32,32);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventReplaceBt);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new widget::Button("","");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:CaseSensitive.svg");
myButtonImage->SetImageToggle("THEME:GUI:CaseSensitive.svg", 0xFFFFFF5F);
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(!SearchData::GetCase());
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventCaseCb);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new widget::Button("","");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:WrapAround.svg");
myButtonImage->SetImageToggle("THEME:GUI:WrapAround.svg", 0xFFFFFF5F);
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(!SearchData::GetWrap());
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventWrapCb);
SubWidgetAdd(myButtonImage);
}
myButtonImage = new widget::Button("","");
if (NULL == myButtonImage) {
APPL_ERROR("Widget allocation error ==> it will missing in the display");
} else {
myButtonImage->SetImage("THEME:GUI:Up.svg");
myButtonImage->SetImageToggle("THEME:GUI:Down.svg");
myButtonImage->SetMinSize(32,32);
myButtonImage->SetToggleMode(true);
myButtonImage->SetValue(!m_forward);
myButtonImage->RegisterOnEvent(this, ewolEventButtonPressed, l_eventForwardCb);
SubWidgetAdd(myButtonImage);
}
RegisterMultiCast(ednMsgGuiSearch);
widget::Composer(widget::Composer::file, "DATA:GUI-Search.xml"),
m_viewerManager(NULL),
m_forward(true),
m_caseSensitive(false),
m_wrap(true),
m_searchEntry(NULL),
m_replaceEntry(NULL) {
addObjectType("appl::Search");
// load buffer manager:
m_viewerManager = appl::ViewerManager::keep();
// link event
registerOnEventNameWidget(this, "SEARCH:close", "pressed", l_eventHideBt);
registerOnEventNameWidget(this, "SEARCH:search-entry", "modify", l_eventSearchEntry);
registerOnEventNameWidget(this, "SEARCH:search-entry", "enter", l_eventSearchEntryEnter);
registerOnEventNameWidget(this, "SEARCH:search", "pressed", l_eventSearchBt);
registerOnEventNameWidget(this, "SEARCH:replace-entry", "modify", l_eventReplaceEntry);
registerOnEventNameWidget(this, "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter);
registerOnEventNameWidget(this, "SEARCH:replace", "pressed", l_eventReplaceBt);
registerOnEventNameWidget(this, "SEARCH:case", "value", l_eventCaseCb);
registerOnEventNameWidget(this, "SEARCH:wrap", "value", l_eventWrapCb);
registerOnEventNameWidget(this, "SEARCH:up-down", "value", l_eventForwardCb);
// set default properties
setConfigNamed("SEARCH:case", "value", std::to_string(m_caseSensitive));
setConfigNamed("SEARCH:wrap", "value", std::to_string(m_wrap));
setConfigNamed("SEARCH:up-down", "value", std::to_string(m_forward));
// get widget
m_searchEntry = dynamic_cast<widget::Entry*>(getWidgetNamed("SEARCH:search-entry"));
m_replaceEntry = dynamic_cast<widget::Entry*>(getWidgetNamed("SEARCH:replace-entry"));
// Display and hide event:
registerMultiCast(ednMsgGuiSearch);
// basicly hiden ...
Hide();
hide();
}
Search::~Search(void)
{
Search::~Search(void) {
appl::ViewerManager::release(m_viewerManager);
}
void Search::find(void) {
if (m_viewerManager == NULL) {
APPL_WARNING("No viewer manager selected!!!");
return;
}
appl::TextViewer* viewer = m_viewerManager->getViewerSelected();
if (viewer == NULL) {
APPL_INFO("No viewer selected!!!");
return;
}
viewer->unSelect();
appl::Buffer::Iterator resultStart;
appl::Buffer::Iterator resultStop;
if (m_forward == true) {
if (viewer->find(viewer->cursor(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
if ( m_wrap == false
|| viewer->find(viewer->begin(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
// TODO : Display an IHM pop-up
APPL_WARNING("No element find ...");
return;
}
}
viewer->select(resultStart, resultStop);
} else {
if (viewer->rfind(viewer->cursor(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
if ( m_wrap == false
|| viewer->rfind(viewer->end(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
// TODO : Display an IHM pop-up
APPL_WARNING("No element find ...");
return;
}
}
viewer->select(resultStop, resultStart);
}
}
void Search::replace(void) {
if (m_viewerManager == NULL) {
APPL_WARNING("No viewer manager selected!!!");
return;
}
appl::TextViewer* viewer = m_viewerManager->getViewerSelected();
if (viewer == NULL) {
APPL_INFO("No viewer selected!!!");
return;
}
if (viewer->hasTextSelected() == false) {
// nothing to replace ...
return;
}
viewer->replace(m_replaceData);
}
/**
* @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 Search::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
widget::SizerHori::OnReceiveMessage(CallerObject, eventId, data);
//APPL_INFO("Search receive message : \"" << eventId << "\" data=\"" << data << "\"");
if ( eventId == l_eventSearchEntry) {
SearchData::SetSearch(data);
} else if ( eventId == l_eventSearchEntryEnter) {
SearchData::SetSearch(data);
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventReplaceEntry) {
SearchData::SetReplace(data);
} else if ( eventId == l_eventReplaceEntryEnter) {
SearchData::SetReplace(data);
SendMultiCast(ednMsgGuiReplace, "Normal");
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventSearchBt) {
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventReplaceBt) {
SendMultiCast(ednMsgGuiReplace, "Normal");
if (true==m_forward) {
SendMultiCast(ednMsgGuiFind, "Previous");
} else {
SendMultiCast(ednMsgGuiFind, "Next");
}
} else if ( eventId == l_eventCaseCb) {
if (data == "1") {
SearchData::SetCase(false);
} else {
SearchData::SetCase(true);
}
} else if ( eventId == l_eventWrapCb) {
if (data == "1") {
SearchData::SetWrap(false);
} else {
SearchData::SetWrap(true);
}
} else if ( eventId == l_eventForwardCb) {
if (data == "1") {
m_forward = false;
} else {
m_forward = true;
}
} else if ( eventId == l_eventHideBt) {
Hide();
} else if ( eventId == ednMsgGuiSearch) {
if (true == IsHide()) {
Show();
void Search::onReceiveMessage(const ewol::EMessage& _msg) {
widget::Composer::onReceiveMessage(_msg);
APPL_INFO("Search receive message : " << _msg);
if ( _msg.getMessage() == l_eventSearchEntry) {
m_searchData = to_u32string(_msg.getData());
} else if ( _msg.getMessage() == l_eventSearchEntryEnter
|| _msg.getMessage() == l_eventSearchBt) {
find();
} else if ( _msg.getMessage() == l_eventReplaceEntry) {
m_replaceData = to_u32string(_msg.getData());
} else if ( _msg.getMessage() == l_eventReplaceEntryEnter
|| _msg.getMessage() == l_eventReplaceBt) {
replace();
find();
} else if ( _msg.getMessage() == l_eventCaseCb) {
m_caseSensitive = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventWrapCb) {
m_wrap = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventForwardCb) {
m_forward = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventHideBt) {
hide();
} else if ( _msg.getMessage() == ednMsgGuiSearch) {
if (true == isHide()) {
show();
if (m_searchEntry!= NULL) {
m_searchEntry->KeepFocus();
m_searchEntry->keepFocus();
}
} else {
if( (m_searchEntry!=NULL && true==m_searchEntry->GetFocus())
|| (m_replaceEntry!=NULL && true==m_replaceEntry->GetFocus()) ) {
Hide();
if( (m_searchEntry!=NULL && true == m_searchEntry->getFocus())
|| (m_replaceEntry!=NULL && true == m_replaceEntry->getFocus()) ) {
hide();
} else if (m_searchEntry!= NULL) {
m_searchEntry->KeepFocus();
m_searchEntry->keepFocus();
} else {
Hide();
hide();
}
}
}
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void Search::OnObjectRemove(ewol::EObject * removeObject)
{
widget::SizerHori::OnObjectRemove(removeObject);
if (removeObject == m_searchEntry) {
void Search::onObjectRemove(ewol::EObject * _removeObject) {
widget::Composer::onObjectRemove(_removeObject);
if (_removeObject == m_searchEntry) {
m_searchEntry = NULL;
}
if (removeObject == m_replaceEntry) {
if (_removeObject == m_replaceEntry) {
m_replaceEntry = NULL;
}
if (_removeObject == m_viewerManager) {
m_viewerManager = NULL;
}
}

View File

@@ -9,42 +9,38 @@
#ifndef __SEARCH_H__
#define __SEARCH_H__
#include <appl/Debug.h>
#include <ewol/widget/SizerHori.h>
#include <appl/debug.h>
#include <ewol/widget/Composer.h>
#include <ewol/widget/Entry.h>
#include <appl/Buffer.h>
#include <appl/Gui/ViewerManager.h>
class Search : public widget::SizerHori
{
class Search : public widget::Composer {
private:
appl::ViewerManager* m_viewerManager; //!< handle on the buffer manager
bool m_forward;
bool m_caseSensitive;
bool m_wrap;
widget::Entry* m_searchEntry;
widget::Entry* m_replaceEntry;
std::u32string m_searchData;
std::u32string m_replaceData;
public:
// Constructeur
Search(void);
~Search(void);
/**
* @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 GetObjectType(void) { return "ApplSearch"; };
/**
* @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 ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
private:
bool m_forward;
widget::Entry * m_searchEntry;
widget::Entry * m_replaceEntry;
/**
* @brief Find the next element that corespond at the search
*/
void find(void);
/**
* @brief Replace the current selected text.
*/
void replace(void);
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
#endif

View File

@@ -1,85 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/global.h>
#include <SearchData.h>
#undef __class__
#define __class__ "SearchData"
static etk::UString m_findRequest = "";
void SearchData::SetSearch(etk::UString &myData)
{
m_findRequest = myData;
}
void SearchData::GetSearch(etk::UString &myData)
{
myData = m_findRequest;
}
bool SearchData::IsSearchEmpty(void)
{
if(m_findRequest.Size() > 0) {
return false;
}
return true;
}
static etk::UString m_replaceRequest = "";
void SearchData::SetReplace(etk::UString &myData)
{
m_replaceRequest = myData;
}
void SearchData::GetReplace(etk::UString &myData)
{
myData = m_replaceRequest;
}
bool SearchData::IsReplaceEmpty(void)
{
if(m_replaceRequest.Size() > 0) {
return false;
}
return true;
}
static bool m_case = false;
void SearchData::SetCase(bool value)
{
m_case = value;
}
bool SearchData::GetCase(void)
{
return m_case;
}
static bool m_wrap = true;
void SearchData::SetWrap(bool value)
{
m_wrap = value;
}
bool SearchData::GetWrap(void)
{
return m_wrap;
}
static bool m_RegExp = false;
void SearchData::SetRegExp(bool value)
{
m_RegExp = value;
}
bool SearchData::GetRegExp(void)
{
return m_RegExp;
}

View File

@@ -1,32 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __SEARCH_DATA_H__
#define __SEARCH_DATA_H__
#include <etk/UString.h>
#include <appl/Debug.h>
namespace SearchData
{
void SetSearch(etk::UString &myData);
void GetSearch(etk::UString &myData);
bool IsSearchEmpty(void);
void SetReplace(etk::UString &myData);
void GetReplace(etk::UString &myData);
bool IsReplaceEmpty(void);
void SetCase(bool value);
bool GetCase(void);
void SetWrap(bool value);
bool GetWrap(void);
void SetRegExp(bool value);
bool GetRegExp(void);
}
#endif

View File

@@ -10,25 +10,23 @@
#include <appl/Gui/TagFileList.h>
#undef __class__
#define __class__ "TagFileList"
#define __class__ "TagFileList"
extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-select";
extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-select";
extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate";
appl::TagFileList::TagFileList(void)
{
appl::TagFileList::TagFileList(void) {
addObjectType("appl::TagFileList");
m_selectedLine = -1;
AddEventId(applEventCtagsListSelect);
AddEventId(applEventCtagsListValidate);
SetMouseLimit(1);
addEventId(applEventCtagsListSelect);
addEventId(applEventCtagsListValidate);
setMouseLimit(1);
}
appl::TagFileList::~TagFileList(void)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
appl::TagFileList::~TagFileList(void) {
for (int32_t iii=0; iii<m_list.size(); iii++) {
if (NULL != m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
@@ -36,83 +34,81 @@ appl::TagFileList::~TagFileList(void)
}
}
draw::Color appl::TagFileList::GetBasicBG(void) {
draw::Color bg(0x00000010);
return bg;
etk::Color<> appl::TagFileList::getBasicBG(void) {
return 0x00000010;
}
uint32_t appl::TagFileList::GetNuberOfColomn(void) {
uint32_t appl::TagFileList::getNuberOfColomn(void) {
return 2;
}
bool appl::TagFileList::GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg) {
myTitle = "title";
bool appl::TagFileList::getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg) {
_myTitle = "title";
return true;
}
uint32_t appl::TagFileList::GetNuberOfRaw(void) {
return m_list.Size();
uint32_t appl::TagFileList::getNuberOfRaw(void) {
return m_list.size();
}
bool appl::TagFileList::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg) {
if (raw >= 0 && raw < m_list.Size() && NULL != m_list[raw]) {
if (0==colomn) {
myTextToWrite = etk::UString(m_list[raw]->fileLine);
bool appl::TagFileList::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
if (_raw >= 0 && _raw < m_list.size() && NULL != m_list[_raw]) {
if (0 == _colomn) {
_myTextToWrite = std::to_string(m_list[_raw]->fileLine);
} else {
myTextToWrite = m_list[raw]->filename;
_myTextToWrite = m_list[_raw]->filename;
}
} else {
myTextToWrite = "ERROR";
_myTextToWrite = "ERROR";
}
fg = draw::color::black;
if (raw % 2) {
if (colomn%2==0) {
bg = 0xFFFFFF00;
_fg = etk::color::black;
if (_raw % 2) {
if (_colomn%2 == 0) {
_bg = 0xFFFFFF00;
} else {
bg = 0xFFFFFF10;
_bg = 0xFFFFFF10;
}
} else {
if (colomn%2==0) {
bg = 0xBFBFBFFF;
if (_colomn%2 == 0) {
_bg = 0xBFBFBFFF;
} else {
bg = 0xCFCFCFFF;
_bg = 0xCFCFCFFF;
}
}
if (m_selectedLine == raw) {
if (colomn%2==0) {
bg = 0x8F8FFFFF;
if (m_selectedLine == _raw) {
if (_colomn%2 == 0) {
_bg = 0x8F8FFFFF;
} else {
bg = 0x7F7FFFFF;
_bg = 0x7F7FFFFF;
}
}
return true;
};
bool appl::TagFileList::OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
{
if (typeEvent == ewol::keyEvent::statusSingle) {
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if (1 == IdInput) {
bool appl::TagFileList::onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
if (_typeEvent == ewol::keyEvent::statusSingle) {
EWOL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
if (_IdInput == 1) {
int32_t previousRaw = m_selectedLine;
if (raw > m_list.Size() ) {
if (_raw > m_list.size() ) {
m_selectedLine = -1;
} else {
m_selectedLine = raw;
m_selectedLine = _raw;
}
const char * event = applEventCtagsListValidate;
if (previousRaw != m_selectedLine) {
event = applEventCtagsListSelect;
}
if( m_selectedLine >=0
&& m_selectedLine < m_list.Size()
if( m_selectedLine >= 0
&& m_selectedLine < m_list.size()
&& NULL != m_list[m_selectedLine] ) {
GenerateEventId(event, etk::UString(m_list[raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
generateEventId(event, std::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
} else {
GenerateEventId(applEventCtagsListUnSelect);
generateEventId(applEventCtagsListUnSelect);
}
// need to regenerate the display of the list :
MarkToRedraw();
markToRedraw();
return true;
}
}
@@ -121,18 +117,16 @@ bool appl::TagFileList::OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te t
/**
* @brief Add a Ctags item on the curent list
* @brief add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void appl::TagFileList::Add(etk::UString& file, int32_t line)
{
appl::TagListElement *tmpFile = new appl::TagListElement(file, line);
void appl::TagFileList::add(std::string& _file, int32_t _line) {
appl::TagListElement *tmpFile = new appl::TagListElement(_file, _line);
if (NULL != tmpFile) {
m_list.PushBack(tmpFile);
m_list.push_back(tmpFile);
}
MarkToRedraw();
markToRedraw();
}

View File

@@ -9,7 +9,7 @@
#ifndef __APPL_CTAGS_LIST_H__
#define __APPL_CTAGS_LIST_H__
#include <appl/Debug.h>
#include <appl/debug.h>
#include <ewol/widget/List.h>
@@ -20,41 +20,38 @@ extern const char * const applEventCtagsListUnSelect;
namespace appl {
class TagListElement {
public:
etk::UString filename;
std::string filename;
int32_t fileLine;
TagListElement(etk::UString& file, int32_t line) : filename(file), fileLine(line) {};
~TagListElement(void) {};
TagListElement(std::string& _file, int32_t _line) :
filename(_file),
fileLine(_line) {
};
~TagListElement(void) {
};
};
class TagFileList : public widget::List
{
class TagFileList : public widget::List {
private:
int32_t m_selectedLine;
etk::Vector<appl::TagListElement*> m_list;
int32_t m_selectedLine;
std::vector<appl::TagListElement*> m_list;
public:
TagFileList(void);
~TagFileList(void);
// display API :
virtual draw::Color GetBasicBG(void);
uint32_t GetNuberOfColomn(void);
bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg);
uint32_t GetNuberOfRaw(void);
bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, draw::Color &fg, draw::Color &bg);
bool OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te typeEvent, int32_t colomn, int32_t raw, float x, float y);
/**
* @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 GetObjectType(void) { return "TagFileList"; };
virtual etk::Color<> getBasicBG(void);
uint32_t getNuberOfColomn(void);
bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
uint32_t getNuberOfRaw(void);
bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
public:
/**
* @brief Add a Ctags item on the curent list
* @brief add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void Add(etk::UString& file, int32_t line);
void add(std::string& _file, int32_t _line);
};
};

View File

@@ -7,176 +7,147 @@
*/
#include <appl/Gui/TagFileSelection.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/SizerVert.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/List.h>
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Image.h>
#include <ewol/widget/WidgetManager.h>
#include <etk/Vector.h>
#include <vector>
#include <etk/tool.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Composer.h>
#include <ewol/ewol.h>
#undef __class__
#define __class__ "TagFileSelection"
#define __class__ "TagFileSelection"
extern const char * const applEventctagsSelection = "appl-event-ctags-validate";
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel";
extern const char * const applEventctagsSelection = "appl-event-ctags-validate";
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel";
appl::TagFileSelection::TagFileSelection(void)
{
AddEventId(applEventctagsSelection);
AddEventId(applEventctagsCancel);
appl::TagFileSelection::TagFileSelection(void) {
addObjectType("appl::TagFileSelection");
addEventId(applEventctagsSelection);
addEventId(applEventctagsCancel);
widget::Label* myWidgetTitle = NULL;
widget::Button* myWidgetValidate = NULL;
widget::Button* myWidgetCancel = NULL;
widget::SizerVert * mySizerVert = NULL;
widget::SizerHori * mySizerHori = NULL;
widget::Sizer * mySizerVert = NULL;
widget::Sizer * mySizerHori = NULL;
widget::Spacer * mySpacer = NULL;
#if defined(__TARGET_OS__Android)
SetDisplayRatio(0.90);
setMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent));
#elif defined(__TARGET_OS__Windows)
SetDisplayRatio(0.80);
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
#else
SetDisplayRatio(0.80);
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
#endif
mySizerVert = new widget::SizerVert();
mySizerVert = new widget::Sizer(widget::Sizer::modeVert);
if (NULL == mySizerVert) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
EWOL_ERROR("Can not allocate widget == > display might be in error");
} else {
mySizerVert->LockExpendContamination(true);
mySizerVert->lockExpand(bvec2(true,true));
mySizerVert->setExpand(bvec2(true,true));
// set it in the pop-up-system :
SubWidgetSet(mySizerVert);
mySizerHori = new widget::SizerHori();
if (NULL == mySizerHori) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->SubWidgetAdd(mySizerHori);
mySpacer = new widget::Spacer();
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpendX(true);
mySizerHori->SubWidgetAdd(mySpacer);
}
myWidgetValidate = new widget::Button("Jump");
if (NULL == myWidgetValidate) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myWidgetValidate->SetImage("icon/Load.svg");
myWidgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsSelection);
mySizerHori->SubWidgetAdd(myWidgetValidate);
}
myWidgetCancel = new widget::Button("Cancel");
if (NULL == myWidgetCancel) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
myWidgetCancel->SetImage("icon/Remove.svg");
myWidgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, applEventctagsCancel);
mySizerHori->SubWidgetAdd(myWidgetCancel);
}
}
setSubWidget(mySizerVert);
widget::Composer* compose = new widget::Composer(widget::Composer::String,
"<sizer mode=\"hori\" expand=\"true,false\" lock=\"false,true\">\n"
" <spacer expand=\"true,false\"/>\n"
" <button name=\"PLUGIN-CTAGS-jump\" expand=\"false\" fill=\"true\">"
" <sizer mode=\"hori\">\n"
" <image src=\"THEME:GUI:Load.svg\" fill=\"true\" size=\"10,10mm\"/>\n"
" <label>Jump</label>\n"
" </sizer>\n"
" </button>\n"
" <button name=\"PLUGIN-CTAGS-cancel\" expand=\"false\" fill=\"true\">"
" <sizer mode=\"hori\">\n"
" <image src=\"THEME:GUI:Remove.svg\" fill=\"true\" size=\"10,10mm\"/>\n"
" <label>Cancel</label>\n"
" </sizer>\n"
" </button>\n"
"</sizer>\n");
compose->setExpand(bvec2(true,false));
compose->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(compose);
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection);
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel);
m_listTag = new appl::TagFileList();
if (NULL == m_listTag) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
EWOL_ERROR("Can not allocate widget == > display might be in error");
} else {
m_listTag->RegisterOnEvent(this, applEventCtagsListValidate);
m_listTag->RegisterOnEvent(this, applEventCtagsListSelect);
m_listTag->RegisterOnEvent(this, applEventCtagsListUnSelect);
m_listTag->SetExpendX(true);
m_listTag->SetExpendY(true);
m_listTag->SetFillX(true);
m_listTag->SetFillY(true);
mySizerVert->SubWidgetAdd(m_listTag);
m_listTag->registerOnEvent(this, applEventCtagsListValidate);
m_listTag->registerOnEvent(this, applEventCtagsListSelect);
m_listTag->registerOnEvent(this, applEventCtagsListUnSelect);
m_listTag->setExpand(bvec2(true,true));
m_listTag->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(m_listTag);
}
myWidgetTitle = new widget::Label("Ctags Jump Selection ...");
if (NULL == myWidgetTitle) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
EWOL_ERROR("Can not allocate widget == > display might be in error");
} else {
mySizerVert->SubWidgetAdd(myWidgetTitle);
mySizerVert->subWidgetAdd(myWidgetTitle);
}
}
}
appl::TagFileSelection::~TagFileSelection(void)
{
appl::TagFileSelection::~TagFileSelection(void) {
}
/**
* @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 appl::TagFileSelection::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
EWOL_INFO("ctags LIST ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventId == applEventctagsSelection) {
void appl::TagFileSelection::onReceiveMessage(const ewol::EMessage& _msg) {
EWOL_INFO("ctags LIST ... : " << _msg );
if (_msg.getMessage() == applEventctagsSelection) {
if (m_eventNamed!="") {
GenerateEventId(applEventctagsSelection, m_eventNamed);
//==> Auto remove ...
AutoDestroy();
generateEventId(applEventctagsSelection, m_eventNamed);
// == > Auto remove ...
autoDestroy();
}
} else if (eventId == applEventCtagsListSelect) {
m_eventNamed = data;
} else if (_msg.getMessage() == applEventCtagsListSelect) {
m_eventNamed = _msg.getData();
} else if (eventId == applEventCtagsListUnSelect) {
} else if (_msg.getMessage() == applEventCtagsListUnSelect) {
m_eventNamed = "";
} else if (eventId == applEventCtagsListValidate) {
GenerateEventId(applEventctagsSelection, data);
//==> Auto remove ...
AutoDestroy();
} else if (eventId == applEventctagsCancel) {
GenerateEventId(applEventctagsCancel, "");
//==> Auto remove ...
AutoDestroy();
} else if (_msg.getMessage() == applEventCtagsListValidate) {
generateEventId(applEventctagsSelection, _msg.getData());
// == > Auto remove ...
autoDestroy();
} else if (_msg.getMessage() == applEventctagsCancel) {
generateEventId(applEventctagsCancel, "");
// == > Auto remove ...
autoDestroy();
}
return;
};
/**
* @brief Add a Ctags item on the curent list
* @brief add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void appl::TagFileSelection::AddCtagsNewItem(etk::UString file, int32_t line)
{
void appl::TagFileSelection::addCtagsNewItem(std::string _file, int32_t _line) {
if (NULL != m_listTag) {
m_listTag->Add(file, line);
m_listTag->add(_file, _line);
}
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void appl::TagFileSelection::OnObjectRemove(ewol::EObject * removeObject)
{
void appl::TagFileSelection::onObjectRemove(ewol::EObject * _removeObject) {
// First step call parrent :
widget::PopUp::OnObjectRemove(m_listTag);
widget::PopUp::onObjectRemove(_removeObject);
// second step find if in all the elements ...
if(removeObject == m_listTag) {
if(_removeObject == m_listTag) {
m_listTag = NULL;
}
}

View File

@@ -9,7 +9,7 @@
#ifndef __APPL_CTAGS_SELECTION_H__
#define __APPL_CTAGS_SELECTION_H__
#include <appl/Debug.h>
#include <appl/debug.h>
#include <ewol/widget/PopUp.h>
#include <appl/Gui/TagFileList.h>
@@ -17,44 +17,22 @@ extern const char * const applEventctagsSelection;
extern const char * const applEventctagsCancel;
namespace appl {
class TagFileSelection : public widget::PopUp
{
class TagFileSelection : public widget::PopUp {
private:
appl::TagFileList* m_listTag;
etk::UString m_eventNamed;
appl::TagFileList* m_listTag;
std::string m_eventNamed;
public:
TagFileSelection(void);
virtual ~TagFileSelection(void);
/**
* @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 GetObjectType(void) { return "EwolFileChooser"; };
/**
* @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 OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void OnObjectRemove(ewol::EObject * removeObject);
/**
* @brief Add a Ctags item on the curent list
* @brief add a Ctags item on the curent list
* @param[in] file Compleate file name
* @param[in] jump line id
* @return ---
*/
void AddCtagsNewItem(etk::UString file, int32_t line);
void addCtagsNewItem(std::string file, int32_t line);
public: // herited function
void onReceiveMessage(const ewol::EMessage& _msg);
void onObjectRemove(ewol::EObject * _removeObject);
};
};

View File

@@ -0,0 +1,976 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/Gui/TextViewer.h>
#include <appl/BufferManager.h>
#include <ewol/clipBoard.h>
#include <ewol/widget/WidgetManager.h>
#include <appl/Gui/ViewerManager.h>
#include <ewol/renderer/EObject.h>
#include <appl/TextPluginManager.h>
#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(ednMsgGuiFind);
registerMultiCast(ednMsgGuiReplace);
registerMultiCast(appl::MsgSelectGotoLine);
registerMultiCast(appl::MsgSelectNewFile);
registerMultiCast(appl::MsgSelectGotoLineSelect);
setLimitScrolling(0.2);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
m_viewerManager = appl::ViewerManager::keep();
// load color properties
m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:textViewer.json");
// get all id properties ...
m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung");
m_colorSpace = m_paintingProperties->request("CODE_space");
m_colorTabulation = m_paintingProperties->request("CODE_tabulation");
m_colorCursor = m_paintingProperties->request("CODE_cursor");
m_colorLineNumber = m_paintingProperties->request("CODE_lineNumber");
m_colorSelection = m_paintingProperties->request("SelectedText");
m_colorNormal = m_paintingProperties->request("normal");
appl::textPluginManager::connect(*this);
// last created has focus ...
setCurrentSelect();
}
appl::TextViewer::~TextViewer(void) {
appl::textPluginManager::disconnect(*this);
appl::GlyphPainting::release(m_paintingProperties);
appl::BufferManager::release(m_bufferManager);
appl::ViewerManager::release(m_viewerManager);
}
bool appl::TextViewer::calculateMinSize(void) {
m_minSize.setValue(50,50);
return true;
}
void appl::TextViewer::onDraw(void) {
m_displayDrawing.draw();
m_displayText.draw();
WidgetScrooled::onDraw();
}
void appl::TextViewer::onRegenerateDisplay(void) {
if (false == needRedraw()) {
return;
}
//tic();
// For the scrooling windows
m_displayDrawing.clear();
m_displayText.clear();
// reset the background :
m_displayDrawing.setPos(vec3(0, 0, 0));
m_displayDrawing.setColor((*m_paintingProperties)[m_colorBackground].getForeground());
m_displayDrawing.rectangleWidth(m_size);
if (m_buffer == NULL) {
m_maxSize.setX(256);
m_maxSize.setY(256);
m_displayText.setTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
m_displayText.setRelPos(vec3(10, 0, 0));
std::string tmpString("<br/>\n"
"<font color=\"red\">\n"
" <b>\n"
" edn - Editeur De N'ours\n"
" </b>\n"
"</font>\n"
"<br/>\n"
"<br/>\n"
"<font color=\"indigo\">\n"
" <i>\n"
" No Buffer Availlable to display\n"
" </i>\n"
"</font>\n");
m_displayText.setPos(vec3(0.0f, m_size.y(), 0.0f) );
m_displayText.forceLineReturn();
m_displayText.printDecorated(tmpString);
// call the herited class...
WidgetScrooled::onRegenerateDisplay();
return;
}
// normal displa of the buffer :
vec3 tmpCursorPosition(0, 0, -1);
float tmpCursorLenght = -1.0;
// real display ...
etk::Buffer& buf = m_buffer->getData();
m_displayText.setColor(etk::Color<>(0, 0, 0, 256));
float countNbLine = 1;
int32_t countColomn = 0;
// the siplay string :
std::u32string stringToDisplay;
int64_t bufferElementSize = 0;
bool isSelect = false;
appl::Buffer::Iterator selectPosStart = m_buffer->begin();
appl::Buffer::Iterator selectPosStop = m_buffer->begin();
if (m_buffer->hasTextSelected() == true) {
selectPosStart = m_buffer->selectStart();
selectPosStop = m_buffer->selectStop();
}
m_displayText.setPos(vec3(-m_originScrooled.x(), m_size.y()+m_originScrooled.y(), 0));
m_displayText.forceLineReturn();
appl::Buffer::Iterator startingIt = m_buffer->begin();
int64_t startLineId = 0;
if (m_size.y() < m_displayText.getPos().y()) {
for (startingIt = m_buffer->begin();
(bool)startingIt == true;
++startingIt) {
if (*startingIt == etk::UChar::Return) {
++startLineId;
m_displayText.forceLineReturn();
if (m_size.y() >= m_displayText.getPos().y()) {
++startingIt;
break;
}
}
}
}
// Display line number :
m_lastOffsetDisplay = 0;
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
{
int32_t nbLine = m_buffer->getNumberOfLines();
float nbLineCalc = nbLine;
int32_t nbChar = 0;
while (nbLineCalc >= 1.0f) {
++nbChar;
nbLineCalc /= 10.0f;
}
m_lastOffsetDisplay = tmpLetterSize.x() * (float)nbChar + 1.0f;
m_displayText.setFontItalic((*m_paintingProperties)[m_colorLineNumber].getItalic());
m_displayText.setFontBold((*m_paintingProperties)[m_colorLineNumber].getBold());
m_displayText.setColorBg((*m_paintingProperties)[m_colorLineNumber].getBackground());
m_displayText.setColor((*m_paintingProperties)[m_colorLineNumber].getForeground());
m_displayText.setClippingMode(false);
vec3 startWriteRealPosition = m_displayText.getPos();
m_displayText.setPos(vec3(0.0f, startWriteRealPosition.y(), 0.0f));
for (int32_t iii=startLineId;
iii<nbLine;
++iii) {
char tmpLineNumber[50];
sprintf(tmpLineNumber, "%*d", nbChar, iii+1);
m_displayText.print(tmpLineNumber);
m_displayText.forceLineReturn();
if (m_displayText.getPos().y() < -20.0f ) {
break;
}
}
m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, startWriteRealPosition.y(), 0.0f));
m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size);
}
appl::DisplayHLData displayLocalSyntax;
m_buffer->hightlightGenerateLines(displayLocalSyntax, (int64_t)startingIt, m_size.y());
float maxSizeX = 0;
appl::HighlightInfo * HLColor = NULL;
bool DisplayCursorAndSelection = isSelectedLast();
appl::Buffer::Iterator it;
for (it = startingIt;
(bool)it == true;
++it) {
if (it == m_buffer->cursor()) {
// need to display the cursor :
tmpCursorPosition = m_displayText.getPos();
tmpCursorLenght = 0.0f;
}
//APPL_DEBUG("display element '" << currentValue << "'at pos : " << m_displayText.getPos() );
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
if (*it == etk::UChar::Return) {
countNbLine += 1;
countColomn = 0;
maxSizeX = etk_max(m_displayText.getPos().x(), maxSizeX);
// Display the end line position only if we have the focus ...
if (DisplayCursorAndSelection == true) {
if (it >= selectPosStart && it < selectPosStop) {
ewol::Drawing& draw = m_displayText.getDrawing();
draw.setColor(etk::Color<>(0xFF0000FF));
draw.setPos(m_displayText.getPos() + tmpLetterSize/4.0f);
draw.rectangle(m_displayText.getPos() + tmpLetterSize*3.0f/4.0f);
}
}
if (tmpCursorLenght == 0.0f) {
tmpCursorLenght = tmpLetterSize.x();
}
m_displayText.forceLineReturn();
m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, m_displayText.getPos().y(), 0.0f));
if (m_displayText.getPos().y() < -20.0f ) {
break;
}
continue;
}
HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, (int64_t)it);
bool haveBackground = false;
if ( HLColor != NULL
&& HLColor->patern != NULL) {
m_displayText.setColor(HLColor->patern->getColorGlyph().getForeground());
m_displayText.setColorBg(HLColor->patern->getColorGlyph().getBackground());
haveBackground = HLColor->patern->getColorGlyph().haveBackground();
m_displayText.setFontItalic(HLColor->patern->getColorGlyph().getItalic());
m_displayText.setFontBold(HLColor->patern->getColorGlyph().getBold());
} else {
m_displayText.setFontItalic((*m_paintingProperties)[m_colorNormal].getItalic());
m_displayText.setFontBold((*m_paintingProperties)[m_colorNormal].getBold());
m_displayText.setColorBg((*m_paintingProperties)[m_colorNormal].getBackground());
m_displayText.setColor((*m_paintingProperties)[m_colorNormal].getForeground());
}
if (haveBackground == false) {
if (*it == etk::UChar::Space) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorSpace].getForeground());
} else if (*it == etk::UChar::Tabulation) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorTabulation].getForeground());
}
}
m_buffer->expand(countColomn, *it, stringToDisplay);
// Display selection only if we have the focus ...
if (DisplayCursorAndSelection == true) {
if (it >= selectPosStart && it < selectPosStop) {
m_displayText.setColor((*m_paintingProperties)[m_colorSelection].getForeground());
m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
}
}
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
m_displayText.print(stringToDisplay);
if (tmpCursorLenght == 0.0f) {
tmpCursorLenght = m_displayText.getPos().x()-tmpCursorPosition.x();
}
countColomn += stringToDisplay.size();
}
if (it == m_buffer->cursor()) {
tmpCursorPosition = m_displayText.getPos();
tmpCursorLenght = 5;
}
maxSizeX = etk_max(m_displayText.getPos().x(), maxSizeX);
// Display cursor only if we have the focus ...
if ( tmpCursorPosition.z() != -1
&& getFocus() == true) {
// display the cursor:
//APPL_DEBUG("display cursor at position : " << tmpCursorPosition);
m_displayText.setPos(tmpCursorPosition);
if (m_buffer->hasTextSelected() == true) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground());
m_displayText.printCursor(false);
} else {
if (m_insertMode == true) {
m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
} else {
m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground());
}
m_displayText.printCursor(m_insertMode, tmpCursorLenght);
}
}
// set maximum size (X&Y) :
{
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
int64_t nbLines = m_buffer->getNumberOfLines();
m_maxSize.setX(maxSizeX+m_originScrooled.x());
m_maxSize.setY((float)nbLines*tmpLetterSize.y());
}
//toc("Display time : ");
// call the herited class...
WidgetScrooled::onRegenerateDisplay();
}
bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event) {
if (m_buffer == NULL) {
return false;
}
// First call plugin
if (appl::textPluginManager::onEventEntry(*this, _event) == true) {
markToRedraw();
return true;
}
// just forward event == > manage directly in the buffer
if (_event.getType() == ewol::keyEvent::keyboardChar) {
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
if (_event.getStatus() != ewol::keyEvent::statusDown) {
return false;
}
char32_t localValue = _event.getChar();
if (localValue == etk::UChar::Return) {
if (true == _event.getSpecialKey().isSetShift()) {
localValue = etk::UChar::CarrierReturn;
}
} else if (localValue == etk::UChar::Suppress ) {
//APPL_INFO("keyEvent : <suppr> pos=" << m_cursorPos);
if (m_buffer->hasTextSelected()) {
remove();
} else {
appl::Buffer::Iterator pos = m_buffer->cursor();
appl::Buffer::Iterator posEnd = pos;
++posEnd;
replace("", pos, posEnd);
}
return true;
} else if (localValue == etk::UChar::Delete) {
//APPL_INFO("keyEvent : <del> pos=" << m_cursorPos);
if (m_buffer->hasTextSelected()) {
remove();
} else {
appl::Buffer::Iterator pos = m_buffer->cursor();
appl::Buffer::Iterator posEnd = pos;
--pos;
replace("", pos, posEnd);
}
return true;
}
m_buffer->setSelectMode(false);
// normal adding char ...
char output[5];
int32_t nbElement = etk::getUtf8(localValue, output);
if ( m_buffer->hasTextSelected() == false
&& _event.getSpecialKey().isSetInsert() == true) {
appl::Buffer::Iterator pos = m_buffer->cursor();
appl::Buffer::Iterator posEnd = pos;
++posEnd;
replace(output, pos, posEnd);
//TODO : choisce UTF ... replace(localValue, pos, posEnd);
} else {
std::string myString = output;
write(myString);
}
return true;
}
// 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::keyboardInsert:
m_insertMode = m_insertMode==true?false:true;
markToRedraw();
break;
case ewol::keyEvent::keyboardLeft:
//APPL_INFO("keyEvent : <LEFT>");
moveCursorLeft();
break;
case ewol::keyEvent::keyboardRight:
//APPL_INFO("keyEvent : <RIGHT>");
moveCursorRight();
break;
case ewol::keyEvent::keyboardUp:
//APPL_INFO("keyEvent : <UP>");
moveCursorUp(1);
break;
case ewol::keyEvent::keyboardDown:
//APPL_INFO("keyEvent : <DOWN>");
moveCursorDown(1);
break;
case ewol::keyEvent::keyboardPageUp:
//APPL_INFO("keyEvent : <PAGE-UP>");
moveCursorUp(15); // TODO : Set the real number of line ...
break;
case ewol::keyEvent::keyboardPageDown:
//APPL_INFO("keyEvent : <PAGE-DOWN>");
moveCursorDown(15); // TODO : Set the real number of line ...
break;
case ewol::keyEvent::keyboardStart:
//APPL_INFO("keyEvent : <Start of line>");
moveCursorLeft(moveEnd);
break;
case ewol::keyEvent::keyboardEnd:
//APPL_INFO("keyEvent : <End of line>");
moveCursorRight(moveEnd);
break;
default:
break;
}
return true;
}
return false;
}
bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
if (_event.getId() != 0) {
keepFocus();
}
//tic();
if (m_buffer == NULL) {
return false;
}
// First call the scrolling widget :
if (WidgetScrooled::onEventInput(_event) == true) {
markToRedraw();
return true;
}
// Second call plugin
if (appl::textPluginManager::onEventInput(*this, _event) == true) {
markToRedraw();
return true;
}
vec2 relativePos = relativePosition(_event.getPos());
// offset for the lineNumber:
relativePos -= vec2(m_lastOffsetDisplay, 0);
// offset for the scrolling:
relativePos += vec2(m_originScrooled.x(), -m_originScrooled.y());
// invert for the buffer event ...
relativePos.setY(m_size.y()-relativePos.y());
if (relativePos.x()<0) {
relativePos.setX(0);
}
if ( _event.getId() == 12
&& _event.getStatus() == ewol::keyEvent::statusSingle) {
APPL_DEBUG("kjhkjhkjh");
// Rat5 save event
sendMultiCast(ednMsgGuiSave, "current");
return true;
}
// just forward event == > manage directly in the buffer
if (_event.getId() == 1) {
// mouse selection :
if (_event.getType() == ewol::keyEvent::typeMouse) {
if (_event.getStatus() == ewol::keyEvent::statusDown) {
//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);
// Copy selection :
std::string value;
m_buffer->copy(value);
if (value.size() != 0) {
ewol::clipBoard::set(ewol::clipBoard::clipboardSelection, value);
}
markToRedraw();
return true;
}
}
if (_event.getStatus() == ewol::keyEvent::statusSingle) {
if (_event.getType() == ewol::keyEvent::typeMouse) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
markToRedraw();
return true;
}
} else if (_event.getStatus() == ewol::keyEvent::statusDouble) {
mouseEventDouble();
// Copy selection :
std::string value;
m_buffer->copy(value);
if (value.size() != 0) {
ewol::clipBoard::set(ewol::clipBoard::clipboardSelection, value);
}
markToRedraw();
return true;
} else if (_event.getStatus() == ewol::keyEvent::statusTriple) {
mouseEventTriple();
// Copy selection :
std::string value;
m_buffer->copy(value);
if (value.size() != 0) {
ewol::clipBoard::set(ewol::clipBoard::clipboardSelection, value);
}
markToRedraw();
return true;
} else if (_event.getStatus() == ewol::keyEvent::statusMove) {
if (m_buffer->getSelectMode() == true) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
markToRedraw();
return true;
}
}
} else if (2 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) {
appl::Buffer::Iterator newPos = getMousePosition(relativePos);
moveCursor(newPos);
ewol::clipBoard::request(ewol::clipBoard::clipboardSelection);
markToRedraw();
return true;
}
}
return false;
}
void appl::TextViewer::mouseEventDouble(void) {
//m_selectMode = false;
appl::Buffer::Iterator beginPos, endPos;
if (true == m_buffer->getPosAround(m_buffer->cursor(), beginPos, endPos)) {
moveCursor(endPos);
m_buffer->setSelectionPos(beginPos);
}
}
void appl::TextViewer::mouseEventTriple(void) {
//m_selectMode = false;
moveCursor(m_buffer->getEndLine(m_buffer->cursor()));
m_buffer->setSelectionPos(m_buffer->getStartLine(m_buffer->cursor()));
}
appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativePos) {
char32_t currentValue;
vec3 positionCurentDisplay(0,0,0);
vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
int32_t countColomn = 0;
std::u32string stringToDisplay;
m_displayText.clear();
m_displayText.forceLineReturn();
positionCurentDisplay = m_displayText.getPos();
for (appl::Buffer::Iterator it = m_buffer->begin();
(bool)it == true;
++it) {
currentValue = *it;
m_buffer->expand(countColomn, currentValue, stringToDisplay);
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
if (stringToDisplay[kkk] == etk::UChar::Return) {
m_displayText.forceLineReturn();
countColomn = 0;
} else {
//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]);
}
++countColomn;
}
}
if (-_relativePos.y() >= positionCurentDisplay.y()) {
if (-_relativePos.y() < positionCurentDisplay.y()+tmpLetterSize.y()) {
APPL_VERBOSE("line position : '" << (char)(*it) << "' = '" << stringToDisplay << "' n=" << countColomn << " " <<positionCurentDisplay.x() << " < " << _relativePos.x() << " < " << m_displayText.getPos().x() );
if ( _relativePos.x() >= positionCurentDisplay.x()
&& _relativePos.x() < m_displayText.getPos().x() ) {
APPL_VERBOSE("find ...");
return it;
}
} else {
// previous line ...
return --it;
}
}
positionCurentDisplay = m_displayText.getPos();
}
return m_buffer->end();
}
void appl::TextViewer::onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID) {
if (m_buffer != NULL) {
std::string data = ewol::clipBoard::get(_clipboardID);
write(data);
}
markToRedraw();
}
void appl::TextViewer::onReceiveMessage(const ewol::EMessage& _msg) {
widget::WidgetScrooled::onReceiveMessage(_msg);
APPL_VERBOSE("receive msg: " << _msg);
// First call plugin
if (appl::textPluginManager::onReceiveMessage(*this, _msg) == true) {
markToRedraw();
return;
}
// event needed even if selection of buffer is not done ...
if (_msg.getMessage() == appl::Buffer::eventIsModify) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventSelectChange) {
markToRedraw();
return;
}
// If not the last buffer selected, then no event parsing ...
if (isSelectedLast() == false) {
return;
}
if (_msg.getMessage() == appl::MsgSelectGotoLineSelect) {
if (m_buffer == NULL) {
return;
}
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), std::stoi(_msg.getData()));
select(it, m_buffer->getEndLine(it));
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectGotoLine) {
if (m_buffer == NULL) {
return;
}
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), std::stoi(_msg.getData()));
moveCursor(it);
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectNewFile) {
// reset scroll:
if (m_buffer != NULL) {
m_buffer->unRegisterOnEvent(this);
bool needAdd = true;
for (size_t iii=0; iii<m_drawingRemenber.size(); ++iii) {
if (m_drawingRemenber[iii].first == m_buffer) {
m_drawingRemenber[iii].second = m_originScrooled;
APPL_VERBOSE("store origin : " << m_originScrooled);
needAdd = false;
break;
}
}
if (needAdd == true) {
m_drawingRemenber.push_back(std::make_pair(m_buffer, m_originScrooled));
APPL_VERBOSE("Push origin : " << m_originScrooled);
}
}
m_originScrooled = vec2(0,0);
if (m_bufferManager != NULL) {
m_buffer = m_bufferManager->get(_msg.getData());
m_bufferManager->setBufferSelected(m_buffer);
if (m_buffer != NULL) {
m_buffer->registerOnEvent(this, appl::Buffer::eventIsModify);
m_buffer->registerOnEvent(this, appl::Buffer::eventSelectChange);
for (auto element : m_drawingRemenber) {
if (element.first == m_buffer) {
m_originScrooled = element.second;
APPL_VERBOSE("retrive origin : " << m_originScrooled);
// TODO : Check if this element is not out of the display text ...
break;
}
}
}
}
markToRedraw();
return;
}
}
void appl::TextViewer::onObjectRemove(ewol::EObject* _removeObject) {
widget::WidgetScrooled::onObjectRemove(_removeObject);
if (m_buffer == _removeObject) {
m_buffer = NULL;
markToRedraw();
}
}
void appl::TextViewer::onGetFocus(void) {
showKeyboard();
APPL_INFO("Focus - In");
setCurrentSelect();
markToRedraw();
}
void appl::TextViewer::onLostFocus(void) {
hideKeyboard();
APPL_INFO("Focus - out");
markToRedraw();
}
void appl::TextViewer::setFontSize(int32_t _size) {
m_displayText.setFontSize(_size);
setScrollingSize(_size*3.0*1.46); // 1.46 is a magic number ...
}
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()), m_buffer->cursor()));
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()-m_lastOffsetDisplay)-lineSize*2.0f-10) {
m_originScrooled.setX(realCursorPosition.x()-(m_size.x()-m_lastOffsetDisplay)+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);
}
m_originScrooled.setMax(vec2(0,0));
// TODO : Limit min position too ...
}
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((int64_t)_pos);
updateScrolling();
return true;
}
bool appl::TextViewer::write(const std::string& _data) {
if (m_buffer == NULL) {
return false;
}
if (m_buffer->hasTextSelected() == true) {
return replace(_data);
}
return write(_data, m_buffer->cursor());
}
bool appl::TextViewer::write(const std::string& _data, const appl::Buffer::Iterator& _pos) {
if (m_buffer == NULL) {
return false;
}
markToRedraw();
if (appl::textPluginManager::onWrite(*this, _pos, _data) == true) {
// no call of the move cursor, because pluging might call theses function to copy and cut data...
updateScrolling();
return true;
}
bool ret = m_buffer->write(_data, _pos);
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
updateScrolling();
return ret;
}
bool appl::TextViewer::replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
if (m_buffer == NULL) {
return false;
}
markToRedraw();
if (appl::textPluginManager::onReplace(*this, _pos, _data, _posEnd) == true) {
// no call of the move cursor, because pluging might call theses function to copy and cut data...
updateScrolling();
return true;
}
bool ret = m_buffer->replace(_data, _pos, _posEnd);
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
updateScrolling();
return ret;
}
bool appl::TextViewer::replace(const std::string& _data) {
if (m_buffer == NULL) {
return false;
}
if (m_buffer->hasTextSelected() == false) {
return write(_data);
}
return replace(_data, m_buffer->selectStart(), m_buffer->selectStop());
}
void appl::TextViewer::remove(void) {
if (m_buffer == NULL) {
return;
}
if (m_buffer->hasTextSelected() == false) {
// nothing to do ...
return;
}
markToRedraw();
if (appl::textPluginManager::onRemove(*this, m_buffer->selectStart(), m_buffer->selectStop()) == true) {
return;
}
m_buffer->removeSelection();
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
}
void appl::TextViewer::moveCursorRight(appl::TextViewer::moveMode _mode) {
if (m_buffer == NULL) {
return;
}
markToRedraw();
appl::Buffer::Iterator it;
switch (_mode) {
default:
case moveLetter:
it = m_buffer->cursor();
++it;
moveCursor(it);
break;
case moveWord:
// TODO : ...
break;
case moveEnd:
it = m_buffer->getEndLine(m_buffer->cursor());
moveCursor(it);
break;
}
}
void appl::TextViewer::moveCursorLeft(appl::TextViewer::moveMode _mode) {
if (m_buffer == NULL) {
return;
}
markToRedraw();
appl::Buffer::Iterator it;
switch (_mode) {
default:
case moveLetter:
it = m_buffer->cursor();
--it;
moveCursor(it);
break;
case moveWord:
// TODO : ...
break;
case moveEnd:
it = m_buffer->getStartLine(m_buffer->cursor());
moveCursor(it);
break;
}
}
void appl::TextViewer::moveCursorUp(uint32_t _nbLine) {
if (m_buffer == NULL) {
return;
}
markToRedraw();
// find the position of the start of the line.
appl::Buffer::Iterator lineStartPos = m_buffer->getStartLine(m_buffer->cursor());
// check if we can go up ...
if (lineStartPos == m_buffer->begin()) {
return;
}
// Decide what column to move to, if there's a preferred column use that
if (m_buffer->getFavoriteUpDownPos() < 0) {
m_buffer->setFavoriteUpDownPos(getScreenSize(lineStartPos, m_buffer->cursor()));
}
// get the previous line
appl::Buffer::Iterator prevLineStartPos = m_buffer->countBackwardNLines(lineStartPos-1, _nbLine);
//APPL_INFO("Move line UP result : prevLineStartPos=" << prevLineStartPos);
// get the display char position
appl::Buffer::Iterator newPos = getPosSize(prevLineStartPos, m_buffer->getFavoriteUpDownPos());
//APPL_INFO("Move to colomn : column=" << column << " newPos=" << newPos);
float posStore = m_buffer->getFavoriteUpDownPos();
moveCursor(newPos);
m_buffer->setFavoriteUpDownPos(posStore);
}
void appl::TextViewer::moveCursorDown(uint32_t _nbLine) {
if (m_buffer == NULL) {
return;
}
markToRedraw();
// check if we are not at the end of Buffer
if (m_buffer->cursor() == m_buffer->end() ) {
return;
}
// find the position of the start of the line.
appl::Buffer::Iterator lineStartPos = m_buffer->getStartLine(m_buffer->cursor());
if (m_buffer->getFavoriteUpDownPos() < 0) {
m_buffer->setFavoriteUpDownPos(getScreenSize(lineStartPos, m_buffer->cursor()));
}
// get the next line :
appl::Buffer::Iterator nextLineStartPos = m_buffer->countForwardNLines(lineStartPos, _nbLine);
//APPL_INFO("Move line DOWN result : nextLineStartPos=" << nextLineStartPos);
// get the display char position
appl::Buffer::Iterator newPos = getPosSize(nextLineStartPos, m_buffer->getFavoriteUpDownPos());
//APPL_INFO("Move to colomn : column=" << column << " newPos=" << newPos);
float posStore = m_buffer->getFavoriteUpDownPos();
moveCursor(newPos);
m_buffer->setFavoriteUpDownPos(posStore);
}
// TODO : Rename ...
appl::Buffer::Iterator appl::TextViewer::getPosSize(const appl::Buffer::Iterator& _startLinePos, float _distance) {
char32_t currentValue;
int32_t countColomn = 0;
std::u32string stringToDisplay;
m_displayText.clear();
m_displayText.forceLineReturn();
for (appl::Buffer::Iterator it = _startLinePos;
(bool)it == true;
++it) {
currentValue = *it;
m_buffer->expand(countColomn, currentValue, stringToDisplay);
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
if (stringToDisplay[kkk] == etk::UChar::Return) {
return it;
} else {
m_displayText.print(stringToDisplay[kkk]);
}
}
if (m_displayText.getPos().x() >= _distance) {
return it;
}
countColomn += stringToDisplay.size();
}
return m_buffer->end();
}
// TODO : Rename ...
float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePos, const appl::Buffer::Iterator& _stopPos) {
float ret = 0;
char32_t currentValue;
int32_t countColomn = 0;
std::u32string stringToDisplay;
m_displayText.clear();
for (appl::Buffer::Iterator it = _startLinePos;
(bool)it == true && it <= _stopPos;
++it) {
currentValue = *it;
//APPL_DEBUG("parse : " << currentValue);
m_buffer->expand(countColomn, currentValue, stringToDisplay);
for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
if (stringToDisplay[kkk] == etk::UChar::Return) {
return m_displayText.getPos().x() + 2; // TODO : Add the +2 for the end of line ...
} else {
m_displayText.print(stringToDisplay[kkk]);
}
}
ret = m_displayText.getPos().x();
countColomn += stringToDisplay.size();
}
return ret;
}
void appl::TextViewer::setCurrentSelect(void) {
if (m_viewerManager != NULL) {
m_viewerManager->setViewerSelected(this, m_buffer);
}
}
bool appl::TextViewer::isSelectedLast(void) {
if (m_viewerManager != NULL) {
return m_viewerManager->isLastSelected(this);
}
return false;
}

View File

@@ -0,0 +1,404 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_TEXT_VIEWER_H__
#define __APPL_TEXT_VIEWER_H__
#include <appl/debug.h>
#include <appl/Buffer.h>
#include <appl/globalMsg.h>
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
#include <appl/BufferManager.h>
#include <appl/Gui/ViewerManager.h>
#include <utility>
namespace appl {
class TextViewer : public widget::WidgetScrooled {
private:
appl::GlyphPainting* m_paintingProperties; //!< element painting property
int32_t m_colorBackground;
int32_t m_colorSpace;
int32_t m_colorTabulation;
int32_t m_colorCursor;
int32_t m_colorLineNumber;
int32_t m_colorSelection;
int32_t m_colorNormal;
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
appl::ViewerManager* m_viewerManager; //!< handle on the buffer manager
public:
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);
private:
appl::Buffer* m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
public:
/**
* @brief Get the buffer property (only for the class : template <typename TYPE> class TextViewerPluginData)
* @return pointer on buffer
*/
appl::Buffer* internalGetBuffer(void) {
return m_buffer;
}
private:
ewol::Text m_displayText; //!< Text display properties.
ewol::Drawing m_displayDrawing; //!< Other diaplay requested.
std::vector<std::pair<appl::Buffer*, vec2>> m_drawingRemenber;
public:
void setFontSize(int32_t _size);
void setFontName(const std::string& _fontName);
protected: // derived function
virtual void onDraw(void);
public: // Derived function
virtual bool calculateMinSize(void);
virtual void onRegenerateDisplay(void);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID);
virtual void onGetFocus(void);
virtual void onLostFocus(void);
private:
float m_lastOffsetDisplay; //!< Line number ofssed in the display
private:
bool m_insertMode; //!< the insert mode is enable
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);
bool write(const std::string& _data, const appl::Buffer::Iterator& _pos);
bool replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
bool replace(const std::string& _data);
bool replace(const std::u32string& _data) {
return replace(to_u8string(_data));
}
/**
* @brief Remove selected data ...
*/
void remove(void);
/**
* @brief Remove selected data ... (No plugin call)
*/
void removeDirect(void) {
if (m_buffer==NULL) {
return;
}
m_buffer->removeSelection();
updateScrolling();
}
/**
* @brief copy data in the _data ref value.
* @param[out] _data Output stream to copy.
* @return true of no error occured.
*/
bool copy(std::string& _data) {
if (m_buffer==NULL) {
return false;
}
return m_buffer->copy(_data);
}
/**
* @brief copy data in the _data ref value.
* @param[out] _data Output stream to copy.
* @param[in] _pos Position to add the data.
* @param[in] _posEnd End position to end replace the data.
*/
void copy(std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
if (m_buffer==NULL) {
return;
}
m_buffer->copy(_data, _pos, _posEnd);
}
/**
* @brief Write data at a specific position (No plugin call)
* @param[in] _data Data to insert in the buffer
* @param[in] _pos Position to add the data.
* @return true if the write is done corectly
*/
bool writeDirect(const std::string& _data, const appl::Buffer::Iterator& _pos) {
if (m_buffer==NULL) {
return false;
}
bool ret = m_buffer->write(_data, _pos);
updateScrolling();
return ret;
}
/**
* @brief Write data at a specific position (No plugin call)
* @param[in] _data Data to insert in the buffer
* @param[in] _pos Position to add the data.
* @param[in] _posEnd End position to end replace the data.
* @return true if the write is done corectly
*/
bool replaceDirect(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) {
if (m_buffer==NULL) {
return false;
}
bool ret = m_buffer->replace(_data, _pos, _posEnd);
updateScrolling();
return ret;
}
appl::Buffer::Iterator getMousePosition(const vec2& _relativePos);
void mouseEventDouble(void);
void mouseEventTriple(void);
private:
enum moveMode {
moveLetter,
moveWord,
moveEnd
};
/**
* Move the cursor right in the line (no stop of a new line)
* @param[in] _mode Moving mode char, word, ...
*/
void moveCursorRight(moveMode _mode = moveLetter);
/**
* Move the cursor left in the line (no stop of a new line)
* @param[in] _mode Moving mode char, word, ...
*/
void moveCursorLeft(moveMode _mode = moveLetter);
/**
* @brief Move the cursor at an other position upper.
* @param[in] _nbLine number of up line that might be moved
*/
void moveCursorUp(uint32_t _nbLine);
/**
* @brief Move the cursor at an other position under.
* @param[in] _nbLine number of down line that might be moved
*/
void moveCursorDown(uint32_t _nbLine);
appl::Buffer::Iterator getPosSize(const appl::Buffer::Iterator& _startLinePos, float _distance);
float getScreenSize(const appl::Buffer::Iterator& _startLinePos, const appl::Buffer::Iterator& _stopPos);
private:
/**
* @brief Set the current buffer selected
*/
void setCurrentSelect(void);
/**
* @brief Check if the current buffer is last selected
* @return true if selected last
*/
bool isSelectedLast(void);
public:
/**
* @brief Check if the buffer is availlable
* @return true if a display buffer is present, false otherwise.
*/
virtual bool hasBuffer(void) {
return m_buffer != NULL;
}
/**
* @brief Get the status of selection.
* @return true if we have a current selection, false otherwise.
*/
virtual bool hasTextSelected(void) {
if (m_buffer==NULL) {
return false;
}
return m_buffer->hasTextSelected();
}
/**
* @brief Remove Selection of the buffer.
*/
virtual void unSelect(void) {
if (m_buffer==NULL) {
return;
}
m_buffer->unSelect();
}
/**
* @brief Select a section of text.
* @param[in] _start Start position of the selection
* @param[in] _stop Stop position of the selection (the curor is set at this position)
*/
virtual void select(const appl::Buffer::Iterator& _start, const appl::Buffer::Iterator& _stop) {
if (m_buffer==NULL) {
return;
}
moveCursor(_stop);
m_buffer->setSelectionPos(_start);
}
/**
* @brief Find a string in the buffer.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search String to search.
* @param[out] _resultStart Find element start position.
* @param[out] _resultStop Find element end position.
* @param[in] _caseSensitive (optional) Search making attention of the case [default true]
* @return true if pos if fined.
*/
virtual bool find(const appl::Buffer::Iterator& _pos,
const std::u32string& _search,
appl::Buffer::Iterator& _resultStart,
appl::Buffer::Iterator& _resultStop,
bool _caseSensitive = true) {
if (m_buffer==NULL) {
return false;
}
bool ret = m_buffer->search(_pos, _search, _resultStart, _caseSensitive);
if (ret == true) {
_resultStop = _resultStart + _search.size();
}
return ret;
}
/**
* @brief revers find a string in the buffer.
* @param[in] _pos Position to start the search of the element.
* @param[in] _search String to search.
* @param[out] _resultStart Find element start position.
* @param[out] _resultStop Find element end position.
* @param[in] _caseSensitive (optional) Search making attention of the case [default true]
* @return true if pos if fined.
*/
virtual bool rfind(const appl::Buffer::Iterator& _pos,
const std::u32string& _search,
appl::Buffer::Iterator& _resultStart,
appl::Buffer::Iterator& _resultStop,
bool _caseSensitive = true) {
if (m_buffer==NULL) {
return false;
}
bool ret = m_buffer->searchBack(_pos, _search, _resultStart, _caseSensitive);
if (ret == true) {
_resultStop = _resultStart + _search.size();
}
return ret;
}
/**
* @brief Get the position of selection around (select word).
* @param[in] _pos Position to start the selection.
* @param[out] _beginPos Position where the element start.
* @param[out] _endPos Position where the element stop.
* @return true if we find a selection around.
*/
bool getPosAround(const appl::Buffer::Iterator& _pos,
appl::Buffer::Iterator &_beginPos,
appl::Buffer::Iterator &_endPos) {
if (m_buffer==NULL) {
return false;
}
return m_buffer->getPosAround(_pos, _beginPos, _endPos);
}
/**
* @brief Get an iterator an an specific position
* @param[in] _pos Requested position of the iterator.
* @return The Iterator
*/
appl::Buffer::Iterator position(int64_t _pos) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->position(_pos);
}
/**
* @brief Get the cursor position.
* @return The iterator on the cursor position
*/
appl::Buffer::Iterator cursor(void) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->cursor();
}
/**
* @brief Get the begin position.
* @return The iterator on the begin position
*/
appl::Buffer::Iterator begin(void) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->begin();
}
/**
* @brief Get the end position.
* @return The iterator on the end position
*/
appl::Buffer::Iterator end(void) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->end();
}
/**
* @brief Get an Iterator on the start selection.
* @return The Iterator
*/
appl::Buffer::Iterator selectStart(void) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->selectStart();
}
/**
* @brief Get an Iterator on the stop selection.
* @return The Iterator
*/
appl::Buffer::Iterator selectStop(void) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->selectStop();
}
/**
* @brief get the start of a line with the position in the buffer.
* @param[in] _pos position in the buffer.
* @return The position in the buffer of the start of the line.
*/
appl::Buffer::Iterator getStartLine(const appl::Buffer::Iterator& _pos) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->getStartLine(_pos);
}
/**
* @brief get the end of a line with the position in the buffer.
* @param[in] _pos position in the buffer.
* @return The position in the buffer of the end of the line.
*/
appl::Buffer::Iterator getEndLine(const appl::Buffer::Iterator& _pos) {
if (m_buffer==NULL) {
return appl::Buffer::Iterator();
}
return m_buffer->getEndLine(_pos);
}
/**
* @brief Register of the arrival of a Multicast message
* @param[in] _messageId Event Id waiting for...
*/
void ext_registerMultiCast(const char* const _messageId) {
registerMultiCast(_messageId);
}
/**
* @brief add a specific shortcut with his description
* @param[in] _descriptiveString Description string of the shortcut
* @param[in] _generateEventId Event generic of the element
* @param[in] _data Associate data wit the event
*/
virtual void ext_shortCutAdd(const char * _descriptiveString,
const char * _generateEventId,
std::string _data="",
bool _broadcast=false) {
shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast);
}
};
};
#endif

View File

@@ -0,0 +1,77 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/Gui/ViewerManager.h>
#include <appl/Gui/TextViewer.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/EObjectManager.h>
#undef __class__
#define __class__ "ViewerManager"
appl::ViewerManager::ViewerManager(void) :
ewol::Resource("???ViewerManager???"),
m_viewer(NULL) {
addObjectType("appl::ViewerManager");
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
}
appl::ViewerManager::~ViewerManager(void) {
appl::BufferManager::release(m_bufferManager);
}
void appl::ViewerManager::setViewerSelected(appl::TextViewer* _viewer, appl::Buffer* _buffer) {
if (m_viewer == _viewer) {
return;
}
m_viewer = _viewer;
if (m_bufferManager != NULL) {
m_bufferManager->setBufferSelected(_buffer);
}
}
void appl::ViewerManager::onReceiveMessage(const ewol::EMessage& _msg) {
APPL_DEBUG("receive message !!! " << _msg);
}
void appl::ViewerManager::onObjectRemove(ewol::EObject* _removeObject) {
ewol::Resource:: onObjectRemove(_removeObject);
if (_removeObject == m_viewer) {
m_viewer = NULL;
return;
}
}
appl::ViewerManager* appl::ViewerManager::keep(void) {
//EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
appl::ViewerManager* object = static_cast<appl::ViewerManager*>(getManager().localKeep("???ViewerManager???"));
if (NULL != object) {
return object;
}
// this element create a new one every time ....
EWOL_INFO("CREATE : appl::ViewerManager: ???ViewerManager???");
object = new appl::ViewerManager();
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ???ViewerManager???");
return NULL;
}
getManager().localAdd(object);
return object;
}
void appl::ViewerManager::release(appl::ViewerManager*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@@ -0,0 +1,68 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __VIEWER_MANAGER_H__
#define __VIEWER_MANAGER_H__
#include <appl/Buffer.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
#include <ewol/resources/Resource.h>
#include <appl/BufferManager.h>
namespace appl {
class TextViewer;
class ViewerManager : public ewol::Resource {
protected:
ViewerManager(void);
~ViewerManager(void);
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
appl::TextViewer* m_viewer;
public:
/**
* @brief Set the current buffer selected
* @param[in] _viewer Pointer on the viewer selected
*/
void setViewerSelected(appl::TextViewer* _viewer, appl::Buffer* _buffer);
/**
* @brief Get the current buffer selected
* @return Pointer on the buffer selected
*/
appl::TextViewer* getViewerSelected(void) {
return m_viewer;
};
/**
* @breif Check if the element is the last request selection
* @param[in] _viewer element selected.
* @return true if the element is selected
*/
bool isLastSelected(appl::TextViewer* _viewer) {
return m_viewer == _viewer;
};
public: // herited function
void onReceiveMessage(const ewol::EMessage& _msg);
void onObjectRemove(ewol::EObject* _removeObject);
public: // resource manager
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static appl::ViewerManager* keep(void);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(appl::ViewerManager*& _object);
};
};
#endif

View File

@@ -0,0 +1,94 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/renderer/eContext.h>
#include <appl/debug.h>
#include <appl/Gui/WorkerCloseAllFile.h>
#undef __class__
#define __class__ "WorkerCloseAllFile"
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();
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy();
return;
}
// List all current open file :
for (int64_t iii=m_bufferManager->size()-1; iii>=0; --iii) {
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
if (tmpBuffer == NULL) {
continue;
}
if (tmpBuffer->isModify() == false) {
tmpBuffer->removeObject();
continue;
}
m_bufferNameList.push_back(tmpBuffer->getFileName());
}
// checkif an element has something to do in the queue
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
// create the worker :
m_worker = new appl::WorkerCloseFile(m_bufferNameList.front());
// remove first element :
m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
m_worker->registerOnEvent(this, appl::WorkerCloseFile::eventCloseDone, s_closeDone);
}
appl::WorkerCloseAllFile::~WorkerCloseAllFile(void) {
appl::BufferManager::release(m_bufferManager);
}
void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::EMessage& _msg) {
if (m_bufferManager == NULL) {
// nothing to do in this case ==> can do nothing ...
return;
}
if (_msg.getMessage() == s_closeDone) {
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
// create the worker :
m_worker = new appl::WorkerCloseFile(m_bufferNameList.front());
// remove first element :
m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
m_worker->registerOnEvent(this, appl::WorkerCloseFile::eventCloseDone, s_closeDone);
}
}
void appl::WorkerCloseAllFile::onObjectRemove(ewol::EObject* _removeObject) {
if (_removeObject == m_worker) {
m_worker = NULL;
APPL_VERBOSE("AutoRemove After saving sub widget ...");
autoDestroy();
} else if (_removeObject == m_bufferManager) {
m_bufferManager = NULL;
autoDestroy();
}
}

View File

@@ -0,0 +1,31 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __WORKER_CLOSE_ALL_FILE_H__
#define __WORKER_CLOSE_ALL_FILE_H__
#include <appl/BufferManager.h>
#include <appl/Gui/WorkerCloseFile.h>
namespace appl {
class WorkerCloseAllFile : public ewol::EObject {
public:
WorkerCloseAllFile(void);
virtual ~WorkerCloseAllFile(void);
private:
std::vector<std::string> m_bufferNameList;
appl::WorkerCloseFile* m_worker; //! pop-up element that is open...
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
};
#endif

View File

@@ -0,0 +1,154 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/renderer/eContext.h>
#include <appl/debug.h>
#include <appl/Gui/WorkerCloseFile.h>
#include <ewol/widget/meta/StdPopUp.h>
#undef __class__
#define __class__ "WorkerCloseFile"
const char* appl::WorkerCloseFile::eventCloseDone = "close-file-done";
static const char* s_saveAsValidate = "save-as-validate";
static const char* s_saveValidate = "save-validate";
static const char* s_closeValidate = "close-validate";
static const char* s_saveAsDone = "save-as-done";
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
m_bufferName(_bufferName),
m_buffer(NULL),
m_worker(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerCloseFile");
addEventId(eventCloseDone);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy();
return;
}
if (m_bufferName == "") {
// need to find the curent file ...
appl::Buffer* tmpp = m_bufferManager->getBufferSelected();
if (tmpp == NULL) {
APPL_ERROR("No selected buffer now ...");
autoDestroy();
return;
}
m_bufferName = tmpp->getFileName();
}
if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
autoDestroy();
return;
}
m_buffer = m_bufferManager->get(m_bufferName);
if (m_buffer == NULL) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy();
return;
}
if (m_buffer->isModify() == false) {
generateEventId(eventCloseDone);
m_buffer->removeObject();
return;
}
widget::StdPopUp* tmpPopUp = new widget::StdPopUp();
if (tmpPopUp == NULL) {
APPL_ERROR("Can not create a simple pop-up");
return;
}
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
ewol::Widget* bt = NULL;
if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true);
if (bt != NULL) {
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveValidate);
}
}
bt = tmpPopUp->addButton("Save As", true);
if (bt != NULL) {
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveAsValidate);
}
bt = tmpPopUp->addButton("Close", true);
if (bt != NULL) {
bt->registerOnEvent(this, widget::Button::eventPressed, s_closeValidate);
}
tmpPopUp->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true);
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == NULL) {
APPL_ERROR("Error to get the windows.");
autoDestroy();
return;
}
tmpWindows->popUpWidgetPush(tmpPopUp);
}
appl::WorkerCloseFile::~WorkerCloseFile(void) {
appl::BufferManager::release(m_bufferManager);
}
void appl::WorkerCloseFile::onReceiveMessage(const ewol::EMessage& _msg) {
if (m_bufferManager == NULL) {
// nothing to do in this case ==> can do nothing ...
return;
}
APPL_DEBUG("have message : " << _msg);
if (_msg.getMessage() == s_saveAsValidate) {
m_worker = new appl::WorkerSaveFile(m_bufferName);
if (m_worker != NULL) {
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
}
} else if (_msg.getMessage() == s_saveValidate) {
if (m_buffer == NULL) {
APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName);
autoDestroy();
return;
}
if (m_buffer->storeFile() == false) {
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == NULL) {
return;
}
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + m_buffer->getFileName() + "</i>");
} else {
generateEventId(eventCloseDone);
}
} else if ( _msg.getMessage() == s_closeValidate
|| _msg.getMessage() == s_saveAsDone) {
if (m_buffer == NULL) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy();
return;
}
generateEventId(eventCloseDone);
m_buffer->removeObject();
}
}
void appl::WorkerCloseFile::onObjectRemove(ewol::EObject* _removeObject) {
if (_removeObject == m_worker) {
m_worker = NULL;
APPL_VERBOSE("AutoRemove After closing sub widget ...");
autoDestroy();
} else if (_removeObject == m_bufferManager) {
m_bufferManager = NULL;
autoDestroy();
} else if (_removeObject == m_buffer) {
m_buffer = NULL;
autoDestroy();
}
}

View File

@@ -0,0 +1,35 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __WORKER_CLOSE_FILE_H__
#define __WORKER_CLOSE_FILE_H__
#include <ewol/widget/meta/FileChooser.h>
#include <appl/BufferManager.h>
#include <appl/Gui/WorkerSaveFile.h>
namespace appl {
class WorkerCloseFile : public ewol::EObject {
public:
static const char* eventCloseDone;
public:
// note : if == "" ==> current ...
WorkerCloseFile(const std::string& _bufferName);
virtual ~WorkerCloseFile(void);
private:
std::string m_bufferName;
appl::Buffer* m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
appl::WorkerSaveFile* m_worker; //! sub-worker element...
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
};
#endif

View File

@@ -0,0 +1,97 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/renderer/eContext.h>
#include <appl/debug.h>
#include <appl/Gui/WorkerSaveAllFile.h>
#undef __class__
#define __class__ "WorkerSaveAllFile"
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();
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy();
return;
}
// List all current open file :
for (size_t iii=0; iii<m_bufferManager->size(); ++iii) {
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
if (tmpBuffer == NULL) {
continue;
}
if (tmpBuffer->isModify() == false) {
continue;
}
if (tmpBuffer->hasFileName() == false) {
m_bufferNameList.push_back(tmpBuffer->getFileName());
} else {
tmpBuffer->storeFile();
}
}
// checkif an element has something to do in the queue
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
// create the worker :
m_worker = new appl::WorkerSaveFile(m_bufferNameList.front());
// remove first element :
m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
}
appl::WorkerSaveAllFile::~WorkerSaveAllFile(void) {
appl::BufferManager::release(m_bufferManager);
}
void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::EMessage& _msg) {
if (m_bufferManager == NULL) {
// nothing to do in this case ==> can do nothing ...
return;
}
if (_msg.getMessage() == s_saveAsDone) {
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
// create the worker :
m_worker = new appl::WorkerSaveFile(m_bufferNameList.front());
// remove first element :
m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) {
autoDestroy();
return;
}
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
}
}
void appl::WorkerSaveAllFile::onObjectRemove(ewol::EObject* _removeObject) {
if (_removeObject == m_worker) {
m_worker = NULL;
APPL_VERBOSE("AutoRemove After saving sub widget ...");
autoDestroy();
} else if (_removeObject == m_bufferManager) {
m_bufferManager = NULL;
autoDestroy();
}
}

View File

@@ -0,0 +1,30 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __WORKER_SAVE_ALL_FILE_H__
#define __WORKER_SAVE_ALL_FILE_H__
#include <appl/BufferManager.h>
#include <appl/Gui/WorkerSaveFile.h>
namespace appl {
class WorkerSaveAllFile : public ewol::EObject {
public:
WorkerSaveAllFile(void);
virtual ~WorkerSaveAllFile(void);
private:
std::vector<std::string> m_bufferNameList;
appl::WorkerSaveFile* m_worker; //! pop-up element that is open...
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
};
#endif

View File

@@ -0,0 +1,130 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/renderer/eContext.h>
#include <appl/debug.h>
#include <appl/Gui/WorkerSaveFile.h>
#undef __class__
#define __class__ "WorkerSaveFile"
const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done";
static const char* s_saveAsValidate = "save-as-validate";
appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs) :
m_bufferName(_bufferName),
m_chooser(NULL),
m_bufferManager(NULL) {
addObjectType("appl::WorkerSaveFile");
addEventId(eventSaveDone);
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
if (m_bufferManager == NULL) {
APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy();
return;
}
if (m_bufferName == "") {
// need to find the curent file ...
appl::Buffer* tmpp = m_bufferManager->getBufferSelected();
if (tmpp == NULL) {
APPL_ERROR("No selected buffer now ...");
autoDestroy();
return;
}
m_bufferName = tmpp->getFileName();
}
if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
autoDestroy();
return;
}
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == NULL) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy();
return;
}
if (_forceSaveAs == false) {
if (tmpBuffer->hasFileName() == true) {
tmpBuffer->storeFile();
generateEventId(eventSaveDone);
autoDestroy();
return;
}
}
m_chooser = new widget::FileChooser();
if (NULL == m_chooser) {
APPL_ERROR("Can not allocate widget == > display might be in error");
autoDestroy();
return;
}
m_chooser->setTitle("Save files As...");
m_chooser->setValidateLabel("Save");
etk::FSNode tmpName(m_bufferName);
m_chooser->setFolder(tmpName.getNameFolder());
m_chooser->setFileName(tmpName.getNameFile());
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == NULL) {
APPL_ERROR("Error to get the windows.");
autoDestroy();
return;
}
tmpWindows->popUpWidgetPush(m_chooser);
m_chooser->registerOnEvent(this, widget::FileChooser::eventValidate, s_saveAsValidate);
}
appl::WorkerSaveFile::~WorkerSaveFile(void) {
appl::BufferManager::release(m_bufferManager);
}
void appl::WorkerSaveFile::onReceiveMessage(const ewol::EMessage& _msg) {
if (m_bufferManager == NULL) {
// nothing to do in this case ==> can do nothing ...
return;
}
if (_msg.getMessage() == s_saveAsValidate) {
if (_msg.getData() == "") {
APPL_ERROR(" might be an error of the File chooser system...");
return;
}
if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
return;
}
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == NULL) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
return;
}
tmpBuffer->setFileName(_msg.getData());
if (tmpBuffer->storeFile() == false) {
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == NULL) {
return;
}
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
} else {
generateEventId(eventSaveDone);
}
}
}
void appl::WorkerSaveFile::onObjectRemove(ewol::EObject* _removeObject) {
if (_removeObject == m_chooser) {
m_chooser = NULL;
APPL_VERBOSE("AutoRemove After closing sub widget ...");
autoDestroy();
} else if (_removeObject == m_bufferManager) {
m_bufferManager = NULL;
autoDestroy();
}
}

View File

@@ -0,0 +1,32 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __WORKER_SAVE_FILE_H__
#define __WORKER_SAVE_FILE_H__
#include <ewol/widget/meta/FileChooser.h>
#include <appl/BufferManager.h>
namespace appl {
class WorkerSaveFile : public ewol::EObject {
public:
static const char* eventSaveDone;
public:
WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs=true);
virtual ~WorkerSaveFile(void);
private:
std::string m_bufferName;
widget::FileChooser* m_chooser; //! pop-up element that is open...
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
};
#endif

279
sources/appl/Highlight.cpp Normal file
View File

@@ -0,0 +1,279 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/Highlight.h>
#include <exml/exml.h>
#include <ewol/resources/ResourceManager.h>
#undef __class__
#define __class__ "Highlight"
void appl::Highlight::parseRules(exml::Element* _child,
std::vector<HighlightPattern*>& _mListPatern,
int32_t _level) {
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties);
// parse under Element
myPattern->parseRules(_child, _level);
// add element in the list
_mListPatern.push_back(myPattern);
}
appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) :
ewol::Resource(_xmlFilename),
m_typeName("") {
// keep color propertiy file :
m_paintingProperties = appl::GlyphPainting::keep(_colorFile);
exml::Document doc;
if (doc.load(_xmlFilename) == false) {
APPL_ERROR(" can not load file XML : " << _xmlFilename);
return;
}
exml::Element* root = doc.getNamed("EdnLang");
if (NULL == root ) {
APPL_ERROR("(l ?) main node not find: \"EdnLang\" ...");
return;
}
m_typeName = root->getAttribute("lang");
int32_t level1 = 0;
int32_t level2 = 0;
// parse all the elements :
for(int32_t iii = 0; iii < root->size(); ++iii) {
exml::Element* child = root->getElement(iii);
if (child == NULL) {
// trash here all that is not element ...
continue;
}
if (child->getValue() == "ext") {
std::string myData = child->getText();
if (myData.size()!=0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
m_listExtentions.push_back(myData);
}
} else if (child->getValue() == "pass1") {
// get sub Nodes ...
for(int32_t jjj=0; jjj< child->size(); jjj++) {
exml::Element* passChild = child->getElement(jjj);
if (passChild == NULL) {
continue;
}
if (passChild->getValue() != "rule") {
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" );
continue;
}
parseRules(passChild, m_listHighlightPass1, level1++);
}
} else if (child->getValue() == "pass2") {
// get sub Nodes ...
for(int32_t jjj=0; jjj< child->size(); jjj++) {
exml::Element* passChild = child->getElement(jjj);
if (passChild == NULL) {
continue;
}
if (passChild->getValue() != "rule") {
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" );
continue;
}
parseRules(passChild, m_listHighlightPass2, level2++);
}
} else {
APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" );
}
}
}
appl::Highlight::~Highlight(void) {
int32_t i;
// clean all Element
for (int32_t iii = 0; iii < m_listHighlightPass1.size(); ++iii) {
if (m_listHighlightPass1[iii] != NULL) {
delete(m_listHighlightPass1[iii]);
m_listHighlightPass1[iii] = NULL;
}
}
// clear the compleate list
m_listHighlightPass1.clear();
// clear the compleate list
m_listExtentions.clear();
}
bool appl::Highlight::hasExtention(const std::string& _ext) {
for (int32_t iii=0; iii<m_listExtentions.size(); iii++) {
APPL_VERBOSE(" check : " << m_listExtentions[iii] << "=?=" << _ext);
if ( m_listExtentions[iii] == "*." + _ext
|| m_listExtentions[iii] == _ext) {
return true;
}
}
return false;
}
bool appl::Highlight::fileNameCompatible(const std::string& _fileName) {
std::string extention;
etk::FSNode file(_fileName);
if (true == file.fileHasExtention() ) {
extention = "*.";
extention += file.fileGetExtention();
} else {
extention = file.getNameFile();
}
APPL_DEBUG(" try to find : in \"" << file << "\" extention:\"" << extention << "\" ");
for (int32_t iii=0; iii<m_listExtentions.size(); iii++) {
if (extention == m_listExtentions[iii] ) {
return true;
}
}
return false;
}
void appl::Highlight::display(void) {
APPL_INFO("List of ALL Highlight : ");
for (int32_t iii=0; iii< m_listExtentions.size(); iii++) {
APPL_INFO(" Extention : " << iii << " : " << m_listExtentions[iii] );
}
// display all elements
for (int32_t iii=0; iii< m_listHighlightPass1.size(); iii++) {
APPL_INFO(" " << iii << " Pass 1 : " << m_listHighlightPass1[iii]->getName() );
//m_listHighlightPass1[iii]->display();
}
// display all elements
for (int32_t iii=0; iii< m_listHighlightPass2.size(); iii++) {
APPL_INFO(" " << iii << " Pass 2 : " << m_listHighlightPass2[iii]->getName() );
//m_listHighlightPass2[iii]->display();
}
}
/* 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(int64_t start,
int64_t stop,
std::vector<appl::HighlightInfo> &metaData,
int64_t addingPos,
etk::Buffer &buffer) {
if (0 > addingPos) {
addingPos = 0;
}
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.size() << " == > position search: (" << start << "," << stop << ")" );
int64_t elementStart = start;
int64_t elementStop = stop;
appl::HighlightInfo resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<m_listHighlightPass1.size(); jjj++){
enum resultFind ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass1[jjj]->find(elementStart, buffer.size(), resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// remove element in the current List where the current Element have a end inside the next...
int64_t kkk=addingPos;
while(kkk < metaData.size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) {
// remove element
//APPL_INFO("Erase element=" << kkk);
metaData.erase(metaData.begin()+kkk, metaData.begin()+kkk+1);
// Increase the end of search
if (kkk < metaData.size()) {
// just befor the end of the next element
elementStop = metaData[kkk].beginStart-1;
} else {
// end of the buffer
elementStop = buffer.size();
}
} else {
// Not find == > exit the cycle :
break;
}
}
// add curent element in the list ...
metaData.insert(metaData.begin()+addingPos, resultat);
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
// update the current research starting element: (set position at the end of the current element
elementStart = resultat.endStop-1;
// increment the position of insertion:
addingPos++;
// We find a pattern == > Stop search for the current element
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}
/**
* @brief second pass of the hightlight
*
*/
void appl::Highlight::parse2(int64_t start,
int64_t stop,
std::vector<appl::HighlightInfo> &metaData,
etk::Buffer &buffer) {
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " == > position search: (" << start << "," << stop << ")" );
int64_t elementStart = start;
int64_t elementStop = stop;
appl::HighlightInfo resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
for (int64_t jjj=0; jjj<m_listHighlightPass2.size(); jjj++){
enum resultFind ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass2[jjj]->find(elementStart, elementStop, resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// add curent element in the list ...
metaData.push_back(resultat);
elementStart = resultat.endStop-1;
// Exit current cycle
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}
appl::Highlight* appl::Highlight::keep(const std::string& _filename) {
//EWOL_INFO("KEEP : appl::Highlight : file : \"" << _filename << "\"");
appl::Highlight* object = static_cast<appl::Highlight*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
EWOL_INFO("CREATE : appl::Highlight : file : \"" << _filename << "\"");
// this element create a new one every time ....
object = new appl::Highlight(_filename, "THEME:COLOR:textViewer.json");
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Highlight??");
return NULL;
}
getManager().localAdd(object);
return object;
}
void appl::Highlight::release(appl::Highlight*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

95
sources/appl/Highlight.h Normal file
View File

@@ -0,0 +1,95 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __HIGHLIGHT_H__
#define __HIGHLIGHT_H__
namespace appl {
class Highlight;
class HighlightPattern;
class HighlightInfo {
public:
int32_t beginStart;
int32_t beginStop;
int32_t endStart;
int32_t endStop;
bool notEnded;
appl::HighlightPattern* patern; // pointer on class :
};
};
#include <etk/os/FSNode.h>
#include <appl/HighlightPattern.h>
#include <appl/GlyphPainting.h>
#include <etk/Buffer.h>
#include <exml/exml.h>
namespace appl {
class Highlight : public ewol::Resource {
private:
appl::GlyphPainting* m_paintingProperties;
protected:
// Constructeur
Highlight(const std::string& _xmlFilename, const std::string& _colorFile);
~Highlight(void);
private:
std::string m_typeName; //!< descriptive string type like "C/C++"
public:
const std::string& getTypeName(void) {
return m_typeName;
}
public:
bool hasExtention(const std::string& _ext);
bool fileNameCompatible(const std::string& _fileName);
void display(void);
void parse(int64_t _start,
int64_t _stop,
std::vector<appl::HighlightInfo> &_metaData,
int64_t _addingPos,
etk::Buffer &_buffer);
void parse2(int64_t _start,
int64_t _stop,
std::vector<appl::HighlightInfo> &_metaData,
etk::Buffer &_buffer);
private:
void parseRules(exml::Element* _child,
std::vector<HighlightPattern*> &_mListPatern,
int32_t _level);
std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std::vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static appl::Highlight* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(appl::Highlight*& _object);
public: // herited function :
virtual void updateContext(void) {
// no upfate to do ...
};
};
};
#endif

View File

@@ -1,315 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <Highlight.h>
#include <tinyXML/tinyxml.h>
#undef __class__
#define __class__ "Highlight"
void Highlight::ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level)
{
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(child, level);
// add element in the list
mListPatern.PushBack(myPattern);
}
Highlight::Highlight(etk::UString &xmlFilename)
{
TiXmlDocument XmlDocument;
etk::FSNode fileName(etk::UString("DATA:") + xmlFilename);
if (false == fileName.Exist()) {
APPL_ERROR("File Does not exist : " << fileName);
return;
}
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
APPL_ERROR("This file is empty : " << fileName);
return;
}
if (false == fileName.FileOpenRead()) {
APPL_ERROR("Can not open the file : " << fileName);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
APPL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.FileClose();
// load the XML from the memory
bool loadError = XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
if (false == loadError) {
APPL_ERROR( "can not load Hightlight XML: PARSING error: \"" << xmlFilename << "\"");
return;
}
TiXmlElement* root = XmlDocument.FirstChildElement( "EdnLang" );
if (NULL == root) {
APPL_ERROR( "can not load Hightlight XML: main node not find: \"EdnLang\"");
return;
}
int32_t level1 = 0;
int32_t level2 = 0;
TiXmlNode * child = root->FirstChild();
while(NULL != child)
{
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(child->Value(), "ext")) {
const char *myData = child->ToElement()->GetText();
if (NULL != myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
etk::UString * myEdnData = new etk::UString(myData);
m_listExtentions.PushBack(myEdnData);
}
} else if (!strcmp(child->Value(), "pass1")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass1, level1++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else if (!strcmp(child->Value(), "pass2")) {
// Get sub Nodes ...
TiXmlNode *passChild = child->FirstChild();
while (NULL != passChild) {
if (passChild->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do ...
} else if (!strcmp(passChild->Value(), "rule")) {
ParseRules(passChild, m_listHighlightPass2, level2++);
} else {
APPL_ERROR("(l "<< passChild->Row() << ") node not suported : \""<< passChild->Value() << "\" must be [rule]" );
}
// get the next node element :
passChild = passChild->NextSibling();
}
} else {
APPL_ERROR("(l "<< child->Row() << ") node not suported : \""<< child->Value() << "\" must be [ext,pass1,pass2]" );
}
// get the next node element :
child = child->NextSibling();
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
}
Highlight::~Highlight(void)
{
int32_t i;
// clean all Element
for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
delete(m_listHighlightPass1[i]);
m_listHighlightPass1[i] = NULL;
}
}
// clear the compleate list
m_listHighlightPass1.Clear();
// clean all Element
for (i=0; i< m_listExtentions.Size(); i++) {
if (NULL != m_listExtentions[i]) {
delete(m_listExtentions[i]);
m_listExtentions[i] = NULL;
}
}
// clear the compleate list
m_listExtentions.Clear();
}
void Highlight::ReloadColor(void)
{
int32_t i;
for (i=0; i< m_listHighlightPass1.Size(); i++) {
if (NULL != m_listHighlightPass1[i]) {
m_listHighlightPass1[i]->ReloadColor();
}
}
for (i=0; i< m_listHighlightPass2.Size(); i++) {
if (NULL != m_listHighlightPass2[i]) {
m_listHighlightPass2[i]->ReloadColor();
}
}
}
bool Highlight::HasExtention(etk::UString &ext)
{
int32_t i;
for (i=0; i<m_listExtentions.Size(); i++) {
if (ext == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
bool Highlight::FileNameCompatible(etk::FSNode &fileName)
{
int32_t i;
etk::UString extention;
if (true == fileName.FileHasExtention() ) {
extention = "*.";
extention += fileName.FileGetExtention();
} else {
extention = fileName.GetNameFile();
}
APPL_DEBUG(" try to find : in \"" << fileName << "\" extention:\"" << extention << "\" ");
for (i=0; i<m_listExtentions.Size(); i++) {
if (extention == *m_listExtentions[i] ) {
return true;
}
}
return false;
}
void Highlight::Display(void)
{
int32_t i;
APPL_INFO("List of ALL Highlight : ");
for (i=0; i< m_listExtentions.Size(); i++) {
APPL_INFO(" Extention : " << i << " : " << *m_listExtentions[i] );
}
// Display all elements
for (i=0; i< m_listHighlightPass1.Size(); i++) {
APPL_INFO(" " << i << " Pass 1 : " << m_listHighlightPass1[i]->GetName() );
//m_listHighlightPass1[i]->Display();
}
// Display all elements
for (i=0; i< m_listHighlightPass2.Size(); i++) {
APPL_INFO(" " << i << " Pass 2 : " << m_listHighlightPass2[i]->GetName() );
//m_listHighlightPass2[i]->Display();
}
}
// 13h 46min 22s | (l= 214) Highlight::Parse | [II] Find Pattern in the Buffer : (2457,2479)
// TODO : Celui qui appelle suprime des element pour rien ... Enfin c'est pas tr<74>grave... Il suffirait juste de suprimer celuis d'avant si il n'est pas terminer...
void Highlight::Parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
etk::Buffer &buffer)
{
if (0 > addingPos) {
addingPos = 0;
}
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass1.Size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
for (int32_t jjj=0; jjj<m_listHighlightPass1.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass1[jjj]->Find(elementStart, buffer.Size(), resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Remove element in the current List where the current Element have a end inside the next...
int32_t kkk=addingPos;
while(kkk < metaData.Size() ) {
if (metaData[kkk].beginStart <= resultat.endStop) {
// Remove element
//APPL_INFO("Erase element=" << kkk);
metaData.EraseLen(kkk, kkk+1);
// Increase the end of search
if (kkk < metaData.Size()) {
// just befor the end of the next element
elementStop = metaData[kkk].beginStart-1;
} else {
// end of the buffer
elementStop = buffer.Size();
}
} else {
// Not find ==> exit the cycle :
break;
}
}
// Add curent element in the list ...
metaData.Insert(addingPos, resultat);
//APPL_DEBUG("INSERT at "<< addingPos << " S=" << resultat.beginStart << " E=" << resultat.endStop );
// Update the current research starting element: (Set position at the end of the current element
elementStart = resultat.endStop-1;
// increment the position of insertion:
addingPos++;
// We find a pattern ==> Stop search for the current element
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}
/**
* @brief second pass of the hightlight
*
*/
void Highlight::Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
etk::Buffer &buffer)
{
//APPL_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" );
int32_t elementStart = start;
int32_t elementStop = stop;
colorInformation_ts resultat;
while (elementStart<elementStop) {
//APPL_DEBUG("Parse element in the buffer id=" << elementStart);
//try to fond the HL in ALL of we have
int32_t jjj;
for (jjj=0; jjj<m_listHighlightPass2.Size(); jjj++){
resultFind_te ret = HLP_FIND_OK;
//APPL_DEBUG("Parse HL id=" << jjj << " position search: (" << start << "," << buffer.Size() << ")" );
// Stop the search to the end (to get the end of the pattern)
ret = m_listHighlightPass2[jjj]->Find(elementStart, elementStop, resultat, buffer);
if (HLP_FIND_ERROR != ret) {
//APPL_INFO("Find Pattern in the Buffer : (" << resultat.beginStart << "," << resultat.endStop << ")" );
// Add curent element in the list ...
metaData.PushBack(resultat);
elementStart = resultat.endStop-1;
// Exit current cycle
break;
}
}
// Go to the next element (and search again ...).
elementStart++;
}
}

View File

@@ -1,66 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __HIGHLIGHT_H__
#define __HIGHLIGHT_H__
class Highlight;
class HighlightPattern;
extern "C" {
typedef struct
{
int32_t beginStart;
int32_t beginStop;
int32_t endStart;
int32_t endStop;
bool notEnded;
HighlightPattern * patern; // pointer on class :
} colorInformation_ts;
}
#include <etk/os/FSNode.h>
#include <HighlightPattern.h>
#include <Colorize.h>
#include <etk/Buffer.h>
#include <tinyXML/tinyxml.h>
class Highlight {
public:
// Constructeur
Highlight(etk::UString &xmlFilename);
~Highlight(void);
bool HasExtention(etk::UString &ext);
bool FileNameCompatible(etk::FSNode &fileName);
void Display(void);
void ReloadColor(void);
void Parse(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
int32_t addingPos,
etk::Buffer &buffer);
void Parse2(int32_t start,
int32_t stop,
etk::Vector<colorInformation_ts> &metaData,
etk::Buffer &buffer);
private:
void ParseRules(TiXmlNode *child, etk::Vector<HighlightPattern*> &mListPatern, int32_t level);
etk::UString m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
etk::Vector<etk::UString*> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
etk::Vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer)
etk::Vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) )
};
#endif

View File

@@ -1,204 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <HighlightManager.h>
#include <ewol/eObject/EObject.h>
#include <ewol/eObject/EObjectManager.h>
#undef __class__
#define __class__ "HighlightManager"
class localClassHighlightManager: public ewol::EObject
{
private:
etk::Vector<Highlight*> listHighlight; //!< List of ALL hightlight modules
public:
// Constructeur
localClassHighlightManager(void) {
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
};
~localClassHighlightManager(void) {
int32_t i;
// clean all Element
for (i=0; i< listHighlight.Size(); i++) {
if (NULL != listHighlight[i]) {
delete(listHighlight[i]);
listHighlight[i] = NULL;
}
}
// clear the compleate list
listHighlight.Clear();
};
/**
* @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 GetObjectType(void)
{
return "ApplHighlightManager";
}
/**
* @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 ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
/*
switch (id)
{
case APPL_MSG__COLOR_HAS_CHANGE:
APPL_INFO("UPDATE the color pointer on the HL");
for (int32_t i=0; i<listHighlight.Size(); i++) {
if (NULL != listHighlight[i]) {
listHighlight[i]->ReloadColor();
}
}
break;
}
*/
}
Highlight* Get(etk::FSNode &fileName)
{
int32_t i;
for (i=0; i<listHighlight.Size(); i++) {
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
return listHighlight[i];
}
}
return NULL;
}
bool Exist(etk::FSNode &fileName)
{
if (NULL != Get(fileName) ) {
return true;
}
return false;
}
void loadLanguages(void)
{
etk::UString xmlFilename = "languages/c/highlight.xml";
Highlight *myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/boo/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/makefile/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/asm/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/xml/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/php/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/bash/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/matlab/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/java/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/lua/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/in/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
xmlFilename = "languages/glsl/highlight.xml";
myHightline = new Highlight(xmlFilename);
listHighlight.PushBack(myHightline);
//myHightline->Display();
}
};
#define EDN_CAST_HIGHLIGHT_MANAGER(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_HIGHLIGHT_MANAGER,localClassHighlightManager,curentPointer)
static localClassHighlightManager * localManager = NULL;
void HighlightManager::Init(void)
{
if (NULL != localManager) {
APPL_ERROR("HighlightManager ==> already exist, just unlink the previous ...");
localManager = NULL;
}
localManager = new localClassHighlightManager();
if (NULL == localManager) {
APPL_CRITICAL("Allocation of HighlightManager not done ...");
}
}
void HighlightManager::UnInit(void)
{
if (NULL == localManager) {
APPL_ERROR("HighlightManager ==> request UnInit, but does not exist ...");
return;
}
delete(localManager);
localManager = NULL;
}
void HighlightManager::loadLanguages(void)
{
if (NULL == localManager) {
return;
}
localManager->loadLanguages();
}
Highlight* HighlightManager::Get(etk::FSNode &fileName)
{
if (NULL == localManager) {
return NULL;
}
return localManager->Get(fileName);
}
bool HighlightManager::Exist(etk::FSNode &fileName)
{
if (NULL == localManager) {
return false;
}
return localManager->Exist(fileName);
}

View File

@@ -1,28 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __HIGHLIGHT_MANAGER_H__
#define __HIGHLIGHT_MANAGER_H__
#include <etk/UString.h>
#include <appl/globalMsg.h>
#include <Highlight.h>
#include <ewol/widget/Widget.h>
namespace HighlightManager{
void Init(void);
void UnInit(void);
void loadLanguages(void);
Highlight* Get(etk::FSNode &fileName);
bool Exist(etk::FSNode &fileName);
};
#endif

View File

@@ -1,233 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Debug.h>
#include <appl/global.h>
#include <HighlightPattern.h>
#include <ColorizeManager.h>
#undef __class__
#define __class__ "HighlightPattern"
HighlightPattern::HighlightPattern(void)
{
m_haveStopPatern = false;
m_multiline = false;
m_color = ColorizeManager::Get("normal");
m_regExpStart = new etk::RegExp<etk::Buffer>();
m_regExpStop = new etk::RegExp<etk::Buffer>();
m_escapeChar = 0;
}
HighlightPattern::~HighlightPattern(void)
{
delete(m_regExpStart);
delete(m_regExpStop);
}
void HighlightPattern::SetPaternStart(etk::UString &regExp)
{
m_regExpStart->SetRegExp(regExp);
}
void HighlightPattern::SetPaternStop(etk::UString &regExp)
{
if (regExp.Size() != 0) {
m_regExpStop->SetRegExp(regExp);
m_haveStopPatern = true;
} else {
m_haveStopPatern = false;
}
}
void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
{
if (EscapeChar.Size()>0) {
m_escapeChar = EscapeChar[0];
} else {
m_escapeChar = 0;
}
}
void HighlightPattern::SetColor(etk::UString &colorName)
{
m_colorName = colorName;
m_color = ColorizeManager::Get(m_colorName);
}
bool HighlightPattern::IsEnable(void)
{
return true;
}
void HighlightPattern::ReloadColor(void)
{
m_color = ColorizeManager::Get(m_colorName);
}
/**
* @brief
*
* @param[in,out]
*
* @eturn
*
*/
void HighlightPattern::Display(void)
{
/*
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
APPL_INFO(" ==> colorName \"" << m_colorName << "\"");
APPL_INFO(" ==> regExpStart \"" << m_regExpStart->GetRegExp() << "\"");
APPL_INFO(" ==> regExpStop \"" << m_regExpStop->GetRegExp() << "\"");
if (true == m_haveStopPatern) {
APPL_INFO(" ==> stop pattern: YES");
} else {
APPL_INFO(" ==> stop pattern: NO");
}
if (true == m_multiline) {
APPL_INFO(" ==> multiline pattern: YES");
} else {
APPL_INFO(" ==> multiline pattern: NO");
}
*/
// Display all elements
for (int32_t i=0; i< m_subPatern.Size(); i++) {
APPL_INFO(" " << i << " SubPattern : " << m_subPatern[i]->GetName() );
m_subPatern[i]->Display();
}
}
void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level)
{
//--------------------------------------------------------------------------------------------
/*
<rule name="my preprocesseur">
<color>preprocesseur</color>
<start>#</start>
<end>$</end>
<multiline>yes</multiline>
</rule>
*/
//--------------------------------------------------------------------------------------------
// process attribute
const char *highLightName = child->ToElement()->Attribute("name");
etk::UString myEdnDataTmp = "???";
if (NULL != highLightName) {
myEdnDataTmp = highLightName;
}
SetName(myEdnDataTmp);
SetLevel(level);
TiXmlElement *xChild = child->FirstChildElement("color");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetColor(myEdnData);
}
}
xChild = child->FirstChildElement("start");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStart(myEdnData);
}
}
xChild = child->FirstChildElement("end");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetPaternStop(myEdnData);
}
}
xChild = child->FirstChildElement("EscapeChar");
if (NULL != xChild) {
const char *myData = xChild->GetText();
if (myData) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
etk::UString myEdnData = myData;
SetEscapeChar(myEdnData);
}
}
xChild = child->FirstChildElement("rule");
if (NULL != xChild) {
/*
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern();
// parse under Element
myPattern->ParseRules(ruleChild, level+1);
// add element in the list
m_subPatern.PushBack(myPattern);
//ParseRules(passChild, m_listHighlightPass1, level1++);
*/
}
}
/**
* @brief Find Element only in the specify start characters and find the end with the range done
*
* @param[in] start First character to search data (if recognise it start here)
* @param[in] stop End of the possibility whe search can continue
* @param[out] resultat Position where find data
* @param[in] buffer : Where to search data
*
* @return HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
resultFind_te HighlightPattern::Find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer)
{
//APPL_DEBUG(" try to find the element");
resultat.beginStart = -1;
resultat.beginStop = -1;
resultat.endStart = -1;
resultat.endStop = -1;
resultat.notEnded = false;
resultat.patern = this;
// when we have only one element :
if (false == m_haveStopPatern) {
if (true == m_regExpStart->ProcessOneElement(buffer, start, stop)) {
resultat.beginStart = m_regExpStart->Start();
resultat.beginStop = m_regExpStart->Stop();
resultat.endStart = m_regExpStart->Start();
resultat.endStop = m_regExpStart->Stop();
return HLP_FIND_OK;
}
//APPL_DEBUG("NOT find hightlightpatern ...");
} else {
// try while we find the first element
if (true == m_regExpStart->ProcessOneElement(buffer, start, stop, m_escapeChar)) {
resultat.beginStart = m_regExpStart->Start();
resultat.beginStop = m_regExpStart->Stop();
if (true == m_regExpStop->Process(buffer, resultat.beginStop, stop, m_escapeChar)) {
resultat.endStart = m_regExpStop->Start();
resultat.endStop = m_regExpStop->Stop();
return HLP_FIND_OK;
} else {
resultat.endStart = stop+1;
resultat.endStop = stop+1;
resultat.notEnded = true;
return HLP_FIND_OK_NO_END;
}
}
//APPL_DEBUG("NOT find start hightlightpatern ...");
}
return HLP_FIND_ERROR;
}

View File

@@ -1,73 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
class HighlightPattern;
#include <etk/RegExp.h>
#include <Colorize.h>
#include <etk/Vector.h>
#include <tinyXML/tinyxml.h>
#include <etk/Buffer.h>
typedef enum {
HLP_FIND_ERROR,
HLP_FIND_OK,
HLP_FIND_OK_NO_END,
}resultFind_te;
class HighlightPattern;
class HighlightPattern {
public:
// Constructeur
HighlightPattern(void);
~HighlightPattern(void);
void SetName(etk::UString &name) { m_paternName = name;};
etk::UString GetName(void) { return m_paternName;};
void SetPaternStart(etk::UString &regExp);
void SetPaternStop(etk::UString &regExp);
void SetColor(etk::UString &colorName);
void SetEscapeChar(etk::UString &EscapeChar);
void SetMultiline(bool enable) { m_multiline = enable; };
void SetLevel(int32_t newLevel) { m_level = newLevel; };
int32_t GetLevel(void) { return m_level; };
bool IsEnable(void);
void Display(void);
resultFind_te Find(int32_t start, int32_t stop, colorInformation_ts &resultat, etk::Buffer &buffer);
Colorize * GetColor(void) { return m_color; };
void ParseRules(TiXmlNode *child, int32_t level);
void ReloadColor(void);
private:
int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher ....
etk::UString m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
etk::UString m_colorName; //!< Current color name
Colorize * m_color; //!< Link to the color manager
etk::RegExp<etk::Buffer> * m_regExpStart; //!< Start of Regular expression
etk::RegExp<etk::Buffer> * m_regExpStop; //!< Stop of Regular Expression
bool m_haveStopPatern; //!< Stop patern presence
bool m_multiline; //!< The patern is multiline
uniChar_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
etk::Vector<HighlightPattern *> m_subPatern; //!< Under patern of this one
// etk::Vector<HighlightPattern *> m_subColor; //!< Under Color in the start RegExp ...
};
#endif

View File

@@ -0,0 +1,118 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/HighlightManager.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/EObjectManager.h>
#undef __class__
#define __class__ "highlightManager"
static std::vector<appl::Highlight*>& s_list(void) {
static std::vector<appl::Highlight*> list;
return list;
}
void appl::highlightManager::init(void) {
std::vector<appl::Highlight*>& hlList = s_list();
if (hlList.size() != 0) {
APPL_ERROR("HighlightManager == > already exist, just unlink the previous ...");
hlList.clear();
}
etk::FSNode myFile("DATA:languages/");
// get the subfolder list :
std::vector<etk::FSNode *> list = myFile.folderGetSubList(false, true, false,false);
for (int32_t iii = 0; iii < list.size(); ++iii) {
if (list[iii] == NULL) {
continue;
}
if (list[iii]->getNodeType() != etk::FSN_FOLDER) {
continue;
}
std::string filename = list[iii]->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename);
appl::Highlight *myHightLine = appl::Highlight::keep(filename);
if (myHightLine != NULL) {
hlList.push_back(myHightLine);
} else {
APPL_ERROR("Can not allocate HighLight");
}
}
// display :
/*
for (int32_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
hlList[iii]->display();
}
*/
}
void appl::highlightManager::unInit(void) {
std::vector<Highlight*>& hlList = s_list();
if (hlList.size() == 0) {
APPL_DEBUG("HighlightManager ==> no highlight");
hlList.clear();
return;
}
for (int32_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
appl::Highlight::release(hlList[iii]);
hlList[iii] = NULL;
}
hlList.clear();
}
std::string appl::highlightManager::getTypeExtention(const std::string& _extention) {
if (_extention.size() == 0) {
return "";
}
APPL_VERBOSE("Try to find type for extention : '" << _extention << "' in " << s_list().size() << " types");
std::vector<Highlight*>& hlList = s_list();
for (int32_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
APPL_VERBOSE(" check : " << hlList[iii]->getTypeName());
if (hlList[iii]->hasExtention(_extention) == true) {
APPL_VERBOSE("Find type for extention : " << _extention
<< " type : " << hlList[iii]->getTypeName());
return hlList[iii]->getTypeName();
}
}
return "";
}
std::string appl::highlightManager::getFileWithTypeType(const std::string& _type) {
if (_type.size() == 0) {
return "";
}
std::vector<Highlight*>& hlList = s_list();
for (int32_t iii = 0; iii < hlList.size(); ++iii) {
if (hlList[iii] == NULL) {
continue;
}
if (hlList[iii]->getTypeName() == _type) {
return hlList[iii]->getName();
}
}
return "";
}
std::vector<std::string> appl::highlightManager::getTypeList(void) {
std::vector<std::string> ret;
return ret;
}

View File

@@ -0,0 +1,50 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __HIGHLIGHT_MANAGER_H__
#define __HIGHLIGHT_MANAGER_H__
#include <etk/UString.h>
#include <appl/globalMsg.h>
#include <appl/Highlight.h>
#include <ewol/widget/Widget.h>
namespace appl {
namespace highlightManager {
/**
* @brief Init the Highlight manager
*/
void init(void);
/**
* @brief Un-Init the Highlight manager
*/
void unInit(void);
/**
* @brief Un-Init the Highlight manager
* @param[in] extention of the file
* @return type of highlight
*/
std::string getTypeExtention(const std::string& _extention);
/**
* @brief Get filename with type.
* @param[in] _type Type name of the highlight.
* @return filename of the highlight.
*/
std::string getFileWithTypeType(const std::string& _type);
/**
* @brief Get the list of extention type
* @return the requested list.
*/
std::vector<std::string> getTypeList(void);
};
};
#endif

View File

@@ -0,0 +1,185 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/HighlightPattern.h>
#undef __class__
#define __class__ "HighlightPattern"
appl::HighlightPattern::HighlightPattern(appl::GlyphPainting*& _glyphPainting) :
m_glyphPainting(_glyphPainting),
m_paternName(""),
m_regExpStart(NULL),
m_regExpStop(NULL),
m_colorName(""),
m_escapeChar(etk::UChar::Null),
m_multiline(false),
m_level(0) {
m_regExpStart = new etk::RegExp<etk::Buffer>();
}
appl::HighlightPattern::~HighlightPattern(void) {
if (m_regExpStart != NULL) {
delete(m_regExpStart);
m_regExpStart = NULL;
}
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
}
void appl::HighlightPattern::setPaternStart(std::string& _regExp) {
if (m_regExpStart == NULL) {
return;
}
m_regExpStart->setRegExp(_regExp);
}
void appl::HighlightPattern::setPaternStop(std::string& _regExp) {
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
if (_regExp.size() != 0) {
m_regExpStop = new etk::RegExp<etk::Buffer>();
if (m_regExpStop != NULL) {
m_regExpStop->setRegExp(_regExp);
} else {
APPL_ERROR("Allocation error");
}
}
}
void appl::HighlightPattern::setEscapeChar(const char32_t& _EscapeChar) {
m_escapeChar = _EscapeChar;
}
void appl::HighlightPattern::setColorGlyph(std::string& _colorName) {
m_colorName = _colorName;
m_colorId = m_glyphPainting->request(m_colorName);
APPL_VERBOSE("Resuest color name '" << m_colorName << "' => id=" << m_colorId);
}
void appl::HighlightPattern::display(void) {
APPL_INFO("patern : \"" << m_paternName << "\" level=" << m_level );
APPL_INFO(" == > colorName \"" << m_colorName << "\"");
APPL_INFO(" == > regExpStart \"" << m_regExpStart->getRegExp() << "\"");
if (m_regExpStop != NULL) {
APPL_INFO(" == > regExpStop \"" << m_regExpStop->getRegExp() << "\"");
}
if (m_multiline == true) {
APPL_INFO(" == > multiline pattern: YES");
} else {
APPL_INFO(" == > multiline pattern: NO");
}
}
void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
//--------------------------------------------------------------------------------------------
/*
<rule name="my preprocesseur">
<color>preprocesseur</color>
<start>#</start>
<end>$</end>
<multiline>yes</multiline>
</rule>
*/
//--------------------------------------------------------------------------------------------
// process attribute
std::string highLightName = _child->getAttribute("name");
std::string myEdnDataTmp = "???";
if (highLightName.size()!=0) {
myEdnDataTmp = highLightName;
}
setName(myEdnDataTmp);
setLevel(_level);
exml::Element* xChild = _child->getNamed("color");
if (NULL != xChild) {
std::string myData = xChild->getText();
if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
std::string myEdnData = myData;
setColorGlyph(myEdnData);
}
}
xChild = _child->getNamed("start");
if (NULL != xChild) {
std::string myData = xChild->getText();
if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
std::string myEdnData = myData;
setPaternStart(myEdnData);
}
}
xChild = _child->getNamed("end");
if (NULL != xChild) {
std::string myData = xChild->getText();
if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
std::string myEdnData = myData;
setPaternStop(myEdnData);
}
}
xChild = _child->getNamed("EscapeChar");
if (NULL != xChild) {
std::string myData = xChild->getText();
if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
setEscapeChar(myData[0]);
}
}
}
enum resultFind appl::HighlightPattern::find(int32_t _start,
int32_t _stop,
appl::HighlightInfo& _resultat,
etk::Buffer& _buffer) {
//APPL_DEBUG(" try to find the element");
_resultat.beginStart = -1;
_resultat.beginStop = -1;
_resultat.endStart = -1;
_resultat.endStop = -1;
_resultat.notEnded = false;
_resultat.patern = this;
// when we have only one element:
if (m_regExpStop == NULL) {
if (true == m_regExpStart->processOneElement(_buffer, _start, _stop)) {
_resultat.beginStart = m_regExpStart->start();
_resultat.beginStop = m_regExpStart->stop();
_resultat.endStart = m_regExpStart->start();
_resultat.endStop = m_regExpStart->stop();
return HLP_FIND_OK;
}
//APPL_DEBUG("NOT find hightlightpatern ...");
return HLP_FIND_ERROR;
}
// try while we find the first element
if (m_regExpStart->processOneElement(_buffer, _start, _stop, m_escapeChar) == false) {
return HLP_FIND_ERROR;
}
_resultat.beginStart = m_regExpStart->start();
_resultat.beginStop = m_regExpStart->stop();
if (m_regExpStop->process(_buffer, _resultat.beginStop, _stop, m_escapeChar) == true) {
_resultat.endStart = m_regExpStop->start();
_resultat.endStop = m_regExpStop->stop();
return HLP_FIND_OK;
} else {
_resultat.endStart = _stop+1;
_resultat.endStop = _stop+1;
_resultat.notEnded = true;
return HLP_FIND_OK_NO_END;
}
//APPL_DEBUG("NOT find start hightlightpatern ...");
return HLP_FIND_ERROR;
}

View File

@@ -0,0 +1,106 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
class HighlightPattern;
#include <etk/RegExp.h>
#include <appl/GlyphPainting.h>
#include <vector>
#include <exml/exml.h>
#include <etk/Buffer.h>
enum resultFind {
HLP_FIND_ERROR,
HLP_FIND_OK,
HLP_FIND_OK_NO_END,
};
namespace appl {
class HighlightPattern {
private:
appl::GlyphPainting*& m_glyphPainting;
public:
// Constructeur
HighlightPattern(appl::GlyphPainting*& _glyphPainting);
~HighlightPattern(void);
private:
std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
public:
void setName(std::string& _name) {
m_paternName = _name;
};
std::string getName(void) {
return m_paternName;
};
private:
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
public:
void setPaternStart(std::string& _regExp);
private:
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
public:
void setPaternStop(std::string& _regExp);
private:
std::string m_colorName; //!< Current color name
int32_t m_colorId; //!< Id of the the glyph painting
public:
void setColorGlyph(std::string& _colorName);
const appl::GlyphDecoration& getColorGlyph(void) {
return (*m_glyphPainting)[m_colorId];
};
private:
char32_t m_escapeChar; //!< Escape char to prevent exeit of patern ....
public:
void setEscapeChar(const char32_t& _EscapeChar);
private:
bool m_multiline; //!< The patern is multiline
public:
void setMultiline(bool _enable) {
m_multiline = _enable;
};
private:
int32_t m_level; //!< Level of the pattern == > this is to overwrite next pattern when we create an higher ....
public:
void setLevel(int32_t _newLevel) {
m_level = _newLevel;
};
int32_t getLevel(void) {
return m_level;
};
private:
public:
void display(void);
/**
* @brief find Element only in the specify start characters and find the end with the range done
* @param[in] _start First character to search data (if recognise it start here)
* @param[in] _stop End of the possibility whe search can continue
* @param[out] _resultat Position where find data
* @param[in] _buffer : Where to search data
* @return HLP_FIND_OK We find a compleate pattern
* @return HLP_FIND_OK_NO_END Xe find a partial pattern (missing end)
* @return HLP_FIND_ERROR Not find the pattern
*/
enum resultFind find(int32_t _start,
int32_t _stop,
appl::HighlightInfo& _resultat,
etk::Buffer& _buffer);
void parseRules(exml::Element* _child, int32_t _level);
};
};
#endif

View File

@@ -0,0 +1,48 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/TextPlugin.h>
#include <appl/debug.h>
#undef __class__
#define __class__ "TextViewerPlugin"
appl::TextViewerPlugin::TextViewerPlugin(void) :
m_isEnable(true),
m_activateOnEventEntry(false),
m_activateOnEventInput(false),
m_activateOnWrite(false),
m_activateOnReplace(false),
m_activateOnRemove(false),
m_activateOnReceiveMessage(false),
m_activateOnCursorMove(false) {
}
appl::TextViewerPlugin::~TextViewerPlugin(void) {
if (m_isEnable == false) {
return;
}
m_isEnable = false;
onPluginDisable();
}
void appl::TextViewerPlugin::setEnableStatus(bool _status) {
if (_status == m_isEnable) {
return;
}
m_isEnable = _status;
if (m_isEnable == true) {
onPluginEnable();
} else {
onPluginDisable();
}
}

217
sources/appl/TextPlugin.h Normal file
View File

@@ -0,0 +1,217 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_TEXT_PLUGIN_H__
#define __APPL_TEXT_PLUGIN_H__
#include <etk/types.h>
#include <ewol/renderer/EObject.h>
#include <appl/Gui/TextViewer.h>
#include <ewol/compositing/Text.h>
namespace appl {
class TextViewerPlugin : public ewol::EObject {
friend class appl::TextViewer;
public:
TextViewerPlugin(void);
virtual ~TextViewerPlugin(void);
private:
bool m_isEnable; //!< The plugin is enable or not (for all viewer).
public:
/**
* @brief Set activity status of the plugin
* @param[in] _status new activity status
*/
void setEnableStatus(bool _status);
/**
* @brief Get the activity status.
* @return true if the plugin is active, false otherwise.
*/
bool isEnable(void) {
return m_isEnable;
};
public:
/**
* @brief On plugin global enable.
*/
virtual void onPluginEnable(void) {
// nothing to do here ...
};
/**
* @brief On plugin global disable.
*/
virtual void onPluginDisable(void) {
// nothing to do here ...
};
/**
* @brief On plugin enable on a specific text viewer.
* @param[in] _widget Reference on the widget caller.
*/
virtual void onPluginEnable(appl::TextViewer& _textDrawer) {
// nothing to do here ...
};
/**
* @brief On plugin disable on a specific text viewer.
* @param[in] _widget Reference on the widget caller.
*/
virtual void onPluginDisable(appl::TextViewer& _textDrawer) {
// nothing to do here ...
};
protected:
bool m_activateOnEventEntry; //!< onEventEntry is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnEventEntry(void) {
return m_activateOnEventEntry;
}
/**
* @brief On entry event call.
* @param[in] _widget Reference on the widget caller.
* @param[in] _event Generic event.
* @return true if the event might not propagate anymore.
*/
virtual bool onEventEntry(appl::TextViewer& _textDrawer,
const ewol::EventEntry& _event) {
return false;
};
protected:
bool m_activateOnEventInput; //!< onEventInput is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnEventInput(void) {
return m_activateOnEventInput;
}
/**
* @brief On Input event call.
* @param[in] _widget Reference on the widget caller.
* @param[in] _event Generic event.
* @return true if the event might not propagate anymore
*/
virtual bool onEventInput(appl::TextViewer& _textDrawer,
const ewol::EventInput& _event) {
return false;
};
protected:
bool m_activateOnWrite; //!< onWrite is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnWrite(void) {
return m_activateOnWrite;
}
/**
* @brief Called when data is written in the buffer.
* @param[in] _widget Reference on the widget caller.
* @param[in] _pos Position in the buffer where data might be witten.
* @param[in] _data Input stream written.
* @return true if the event might not propagate anymore
*/
virtual bool onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const std::string& _data) {
return false;
};
protected:
bool m_activateOnReplace; //!< onReplace is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnReplace(void) {
return m_activateOnReplace;
}
/**
* @brief Called when data is written in the buffer, and some are removed.
* @param[in] _widget Reference on the widget caller.
* @param[in] _pos Position in the buffer where data might be witten.
* @param[in] _data Input stream written.
* @param[in] _posEnd end replace position.
* @return true if the event might not propagate anymore
*/
virtual bool onReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const std::string& _data,
const appl::Buffer::Iterator& _posEnd) {
return false;
};
protected:
bool m_activateOnRemove; //!< onRemove is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnRemove(void) {
return m_activateOnRemove;
}
/**
* @brief Called when data is removed.
* @param[in] _widget Reference on the widget caller.
* @param[in] _pos Position in the buffer where data might be witten.
* @param[in] _posEnd end replace position.
* @return true if the event might not propagate anymore
*/
virtual bool onRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd) {
return false;
};
protected:
bool m_activateOnReceiveMessage; //!< onReceiveMessage is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnReceiveMessage(void) {
return m_activateOnReceiveMessage;
}
/**
* @brief Called when a message arrive.
* @param[in] _widget Reference on the widget caller.
* @param[in] _msg Generic message.
* @return true if the event might not propagate anymore
*/
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::EMessage& _msg) {
return false;
}
protected:
bool m_activateOnCursorMove; //!< onCursorMove is availlable for this plugin.
public:
/**
* @brief Get the availlability of a callback
* @return true if availlable
*/
bool isAvaillableOnCursorMove(void) {
return m_activateOnCursorMove;
}
/**
* @brief Called when Cursor move of position.
* @param[in] _widget Reference on the widget caller.
* @param[in] _pos New cursor position.
* @return true if the event might not propagate anymore
*/
virtual bool onCursorMove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos) {
return false;
}
};
};
#endif

View File

@@ -0,0 +1,63 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/TextPluginAutoIndent.h>
#include <ewol/clipBoard.h>
#include <appl/Gui/TextViewer.h>
#undef __class__
#define __class__ "TextPluginAutoIndent"
appl::TextPluginAutoIndent::TextPluginAutoIndent(void) {
m_activateOnEventEntry = true;
}
bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer,
const ewol::EventEntry& _event) {
if (isEnable() == false) {
return false;
}
//APPL_DEBUG("KB EVENT : " << _event);
// just forward event == > manage directly in the buffer
if (_event.getType() != ewol::keyEvent::keyboardChar) {
return false;
}
if (_event.getStatus() != ewol::keyEvent::statusDown) {
return false;
}
if (_event.getChar() != etk::UChar::Return) {
return false;
}
if (_event.getSpecialKey().isSetShift() == true) {
return false;
}
appl::Buffer::Iterator startLine = _textDrawer.cursor();
if (_textDrawer.hasTextSelected() == true) {
startLine = _textDrawer.selectStart();
}
startLine = _textDrawer.getStartLine(startLine);
std::string data = "\n";
for (appl::Buffer::Iterator it = startLine;
(bool)it == true;
++it) {
if (*it == etk::UChar::Space) {
data += etk::UChar::Space;
} else if(*it == etk::UChar::Tabulation) {
data += etk::UChar::Tabulation;
} else {
break;
}
}
_textDrawer.write(data);
return true;
}

View File

@@ -0,0 +1,32 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_TEXT_PLUGIN_AUTO_INDENT_H__
#define __APPL_TEXT_PLUGIN_AUTO_INDENT_H__
#include <etk/types.h>
#include <ewol/renderer/EObject.h>
#include <appl/Gui/TextViewer.h>
#include <ewol/compositing/Text.h>
#include <appl/TextPlugin.h>
namespace appl {
class TextPluginAutoIndent : public appl::TextViewerPlugin {
public:
TextPluginAutoIndent(void);
~TextPluginAutoIndent(void) {
// nothing to do ...
};
public:
virtual bool onEventEntry(appl::TextViewer& _textDrawer,
const ewol::EventEntry& _event);
};
};
#endif

View File

@@ -0,0 +1,61 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/TextPluginCopy.h>
#include <ewol/clipBoard.h>
#include <appl/Gui/TextViewer.h>
#undef __class__
#define __class__ "TextPluginCopy"
appl::TextPluginCopy::TextPluginCopy(void) {
m_activateOnReceiveMessage = true;
}
void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiCopy);
_textDrawer.ext_registerMultiCast(ednMsgGuiPaste);
_textDrawer.ext_registerMultiCast(ednMsgGuiCut);
_textDrawer.ext_shortCutAdd("ctrl+x", ednMsgGuiCut, "STD");
_textDrawer.ext_shortCutAdd("ctrl+c", ednMsgGuiCopy, "STD");
_textDrawer.ext_shortCutAdd("ctrl+v", ednMsgGuiPaste, "STD");
}
void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
}
bool appl::TextPluginCopy::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::EMessage& _msg) {
if (isEnable() == false) {
return false;
}
if ( _msg.getMessage() == ednMsgGuiCopy
|| _msg.getMessage() == ednMsgGuiCut) {
if (_textDrawer.hasBuffer() == true) {
std::string value;
_textDrawer.copy(value);
if (value.size() != 0) {
ewol::clipBoard::set(ewol::clipBoard::clipboardStd, value);
}
}
if (_msg.getMessage() == ednMsgGuiCut) {
_textDrawer.remove();
}
return true;
} else if (_msg.getMessage() == ednMsgGuiPaste) {
if (_textDrawer.hasBuffer() == true) {
ewol::clipBoard::request(ewol::clipBoard::clipboardStd);
}
return true;
}
return false;
}

View File

@@ -0,0 +1,33 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_TEXT_PLUGIN_COPY_H__
#define __APPL_TEXT_PLUGIN_COPY_H__
#include <etk/types.h>
#include <ewol/renderer/EObject.h>
#include <appl/Gui/TextViewer.h>
#include <ewol/compositing/Text.h>
#include <appl/TextPlugin.h>
namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin {
public:
TextPluginCopy(void);
~TextPluginCopy(void) {
// nothing to do ...
};
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::EMessage& _msg);
};
};
#endif

Some files were not shown because too many files have changed in this diff Show More