wxFBE, editor for both Windows and Linux

User projects written in or related to FreeBASIC.
Post Reply
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by TJF »

marcov wrote:But the basic problem that is the issue here is matching the right encoding to each API, not the conversion an sich.
Yes, that's what I try to say: unless you can pay an expert to care about this issue, aviod it by using one API and one GUI toolkit for all systems.


@MOD

An other feature of libintl is that you can translate between different character encodings. So you may use one encoding in your source and an other in the GUI. I didn't test this yet. It may cause additional trouble:
http://www.gnu.org/software/gettext/manual/gettext.html wrote:When single quote characters or double quote characters are used in translations for your language, and your locale's encoding is one of the ISO-8859-* charsets, it is best if you create your PO files in UTF-8 encoding, instead of your locale's encoding. This is because in UTF-8 the real quote characters can be represented (single quote characters: U+2018, U+2019, double quote characters: U+201C, U+201D), whereas none of ISO-8859-* charsets has them all. Users in UTF-8 locales will see the real quote characters, whereas users in ISO-8859-* locales will see the vertical apostrophe and the vertical double quote instead (because that's what the character set conversion will transliterate them to).
So it's recommended to use UTF-8 encoding for source code and translation files. Only the GUI output should use the translated encoding.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

I found a bug with the current regular expression matcher. While matching works as expected replacing does not. The routine that does the replacing uses a call to wxStyledTextCtrl_ReplaceSelection to replace the selected text.
Which is fine when not using a regular expression. But when using a regular expression \1 .. \9 are not handled correcly (these should evaluate to the text matched).

Example
input = "hello world"
regex = "\(hello\)"
replacement = "\1 freebasic"

Find-and-replace using regular expression should yield "hello freebasic". Instead I get
\1 freebasic. That's because the \1 does not get evaluated the way it should (not replaced
with the word "hello").

When using a regular expression the function wxStyledTextCtrl_ReplaceTargetRE should be used instead of wxStyledTextCtrl_ReplaceSelection. A possible solution to the problem would be to replace every occurence of
wxStyledTextCtrl_ReplaceSelection( stcPTR, wxComboBox_GetValue( searchAndRepDialog.comboReplace ) ) with:

Code: Select all

If wxCheckBox_GetValue( searchAndRepDialog.checkboxRegExp ) Then
  ''get target from selection (needed because selection, not target, is used by wxfbe)
  wxStyledTextCtrl_TargetFromSelection(stcPTR)
  wxStyledTextCtrl_ReplaceTargetRE( stcPTR, wxComboBox_GetValue( searchAndRepDialog.comboReplace ) )
else
  wxStyledTextCtrl_ReplaceSelection( stcPTR, wxComboBox_GetValue( searchAndRepDialog.comboReplace ) )
end if
There is no ReplaceSelectionRE so ReplaceTarget must be used.

I've got one idea on the subject of regular expression find/replace that can be implemented without having to include a different regex engine. There are shorthand character classes for some character classes. These are:
\d -> [:digit:] -> [0-9]
\w -> [:alnum:] -> [a-zA-Z0-9_]
\s -> [:blank:] -> [ \t]

and their opposites \D \W \S (which translate to the negation of the previously mentioned character classes).
Actually \s is not shorthand for :blank: but for :space: which also includes cr, lf, vertical tab and formfeed.

These shorthand character classes can be translated into character classes in a straightforward manner :
\d -> [0-9]
\D -> [^0-9]
\w -> [a-zA-Z0-9_]
\W -> [^a-zA-Z0-9_]
\s -> [ \t]
\S -> [^ \t]

\s actually should match a lot more than space and tab (is should match space\t\r\n\f\v) but the built-in regex library has no special character for line endings, form feeds or vertical tabs. But space and tab are good enough (multi-line regex selection/replacement is not possible with the built-in regex engine anyway).

wxfbe can change the shorthand character classes into full character classes (\d into [0-9], \w into [a-zA-Z0-9_] etc...). When a regular expression contains the above mentioned shorthands then the shorthands get expanded into full character classes and the expanded form is then used as replacement for the value in the combo box.

The regular expression
function\s+
is transformed into
function[ \t]+
which is something the scintilla regex engine understands.

This replacement scheme should be fairly easy to implement (replacing shorthand charclass with full charclass).

A possible use of shorthand character classes:
Replacing some common prefix of identifiers with another prefix. This can then be done by using the following regular expressions:
find -> prefix\(\w+\)
replace -> newprefix\1

Other regular expression extensions (| operator) or the more sophisticated PCRE stuff (assertions) let alone the use of recursion in a regular expression cannot be implemented using the existing regex engine. Ultimately something more needs to be done to get proper regex support. But in the meantime shorthand character classes are a nice thing to have (and are easily implemented as an extension to the current regex engine).

I was able to make wxfbe crash by using regex $ and then perform a search-all ($ denotes 'end-of-line'). Could that be because of a bug in wxfbe (or is the scintilla regex engine to blame?).
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by marcov »

TJF wrote:
marcov wrote:But the basic problem that is the issue here is matching the right encoding to each API, not the conversion an sich.
Yes, that's what I try to say: unless you can pay an expert to care about this issue, aviod it by using one API and one GUI toolkit for all systems.
For the non experts they invented Wine :-)
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: wxFBE, editor for both Windows and Linux

Post by MOD »

AGS: thank you for your fix, I commited it today together with support for templates. Maybe your replacement example will follow, we'll see. About the crash: I couldn't confirm this in my test but maybe I missed something as I'm not used to use regexp. But if it's a bug it should be scintillas fault as wxFBE just passes the strings.
leodescal
Posts: 165
Joined: Oct 16, 2009 14:44
Location: Jodhpur, Rajputana, Empire of Aryavart
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by leodescal »

This is really cool! Really love this editor... I think you got your first convert(Wouldn't be surprised if I'm not first)... I completely moved from FBedit to wxFBE.

I really don't have much 'advance' demands from IDE. For special things I don't mind command line.
I spend hours and hours on programming... SO my first demand is IDE should look smart.... It should look beautiful... I found FBIDE ugly and FBedit some better option :D. But this is way better looking than both.
This gives me everything what I need mostly :D. Thankyou!

EDIT:
Currently I'm writing a new Virtual Machine for my language in your editor and VANAYA's Window9. It is much more a pleasure to work in wxFBE than any other editor I have seen...
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

MOD wrote:AGS: thank you for your fix, I commited it today together with support for templates. Maybe your replacement example will follow, we'll see. About the crash: I couldn't confirm this in my test but maybe I missed something as I'm not used to use regexp. But if it's a bug it should be scintillas fault as wxFBE just passes the strings.
It wasn't much of a fix, it was more of an 'idea'. I did not test whether my fix would work.... If it doesn't then I am surely the one to blame.

A question: wx-c has the possibility to use () instead of \(\) to capture parts of a regex.

You should use wxSTC_FIND_POSIX instead of wxSTC_FIND_REGEXP to enable the use of () instead of \(\)
(wxSTC_FIND_REGEXP is used in proceedSearch).

Default for Scintilla is the use of \( \) but ( ) is used in most editors.
(you don't want to use \ more \(than\) necessary as it tends to uglify\\(make\) a \(regex\) harder to \(read\)
as opposed to
you don't want to use \ more (than) necessary as it tends to uglify\(make) a (regex) harder to (read)
It's a simple edit (replace wxSTC_FIND_REGEXP with wxSTC_FIND_POSIX) and I am sure it would make the use of regular expressions that much easier (I can assure you fb programmers that use regexes a lot will want to use () instead of \(\)).
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: wxFBE, editor for both Windows and Linux

Post by MOD »

leodescal: I didn't think, that anyone would use the editor as it is because lots of things are missing like projects, auto complete, etc. Thank you for your kind words. :)

AGS: Your code worked so I thought, that you have tested it. Meanwhile we added also some replacement possibilities, would you please check the current repository version?
I guess we can switch to wxSTC_FIND_POSIX as well.
leodescal
Posts: 165
Joined: Oct 16, 2009 14:44
Location: Jodhpur, Rajputana, Empire of Aryavart
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by leodescal »

I tried compiling it on Fedora 17 64 bit but got following error:

Code: Select all

[ehitam@eHitam-Technologies wxFBE]$ fbc -l wx-c-0-9-0-2 "wxFBE.bas" "util.bas" "xmlparse.bas" "settings.bas" -x "wxFBE"
/home/ehitam/Desktop/wxFBE/newdocument.bas(41) error 5: Expected 'AS', found 'Encoding' in 'Open file For Input Encoding "UTF-8" As #FF'
/home/ehitam/Desktop/wxFBE/newdocument.bas(41) error 3: Expected End-of-Line, found 'UTF-8' in 'Open file For Input Encoding "UTF-8" As #FF'
How can I get rid of this problem?
MOD wrote:leodescal: I didn't think, that anyone would use the editor as it is because lots of things are missing like projects, auto complete, etc. Thank you for your kind words. :)
I have almost completed Hindi Translation and I would do Sanskrit and Interlingua translation soon. I might find some people to do Esperanto, Spanish, Greek, Chinese, Italian, etc. translation :)

I haven't quite used wxWidgets or wx-c but I can give the main code with you can easily integrate with GUI.

EDIT:
wx-c is looking very interesting. I would most probably would create a complete project system with GUI :)

Project can be of these types(Tell me if I'm forgetting something):
1. Console
2. Dll

3. wx-c
4. gtk+
5. window9
6. WIN32

7. header file

With different compiler settings available where applicable...
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by TJF »

leodescal wrote:I tried compiling it on Fedora 17 64 bit but got following error:

Code: Select all

[ehitam@eHitam-Technologies wxFBE]$ fbc -l wx-c-0-9-0-2 "wxFBE.bas" "util.bas" "xmlparse.bas" "settings.bas" -x "wxFBE"
/home/ehitam/Desktop/wxFBE/newdocument.bas(41) error 5: Expected 'AS', found 'Encoding' in 'Open file For Input Encoding "UTF-8" As #FF'
/home/ehitam/Desktop/wxFBE/newdocument.bas(41) error 3: Expected End-of-Line, found 'UTF-8' in 'Open file For Input Encoding "UTF-8" As #FF'
How can I get rid of this problem?
Remove
  • Encoding "UTF-8"
It's needless.

BTW: Which fbc version do you use?
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: wxFBE, editor for both Windows and Linux

Post by AGS »

AGS: Your code worked so I thought, that you have tested it. Meanwhile we added also some replacement possibilities, would you please check the current repository version?
I guess we can switch to wxSTC_FIND_POSIX as well.
I have taken a quick look at the new code and found these lines in utils.bas (function regexp).

Code: Select all

Select Case As Const ret[i + 1]
  Case 40	 ' "\("
  ret = Left( ret, i ) & "(" & Mid( ret, i + 3 )
  i += 1
  Case 41	 ' "\)"
  ret = Left( ret, i ) & ")" & Mid( ret, i + 3 )
  i += 1
By using wxSTR_FIND_POSIX those two cases can be dropped. I'll be testing the new
regular expression features (on first sight the code looks fine).
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: wxFBE, editor for both Windows and Linux

Post by MOD »

leodescal: This is the same issue D.J.Peters had. In the header wxstring.bi there was a enum with "encoding" as identifier. You can simply rename it as it was done here: Patch
main code
What main code? For translations I just need the language files. Would be great to have some additional languages, especially if they don't need any non-ascii symbols.^^
But there would be the need of updating them as I'm hard working at the editor in my spare time. For now I'm implementing auto complete, calltips and project support (some are already visible in the repository).

You can do everything with wx-c but, also I like it, sometimes it's a pain. wx-c is just a small wrapper for wxWidgets and lacks many nice things. I'm planning to extend the wrapper under new name but first I have lots of todos for wxFBE.

Btw, you need 0.24 to compile wxFBE.


AGS: Yes, I could delete these cases or use wxSTC_FIND_REGEXP again. Not sure so far. Any suggestions which version would fit better?
leodescal
Posts: 165
Joined: Oct 16, 2009 14:44
Location: Jodhpur, Rajputana, Empire of Aryavart
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by leodescal »

MOD wrote:leodescal: This is the same issue D.J.Peters had. In the header wxstring.bi there was a enum with "encoding" as identifier. You can simply rename it as it was done here: Patch
main code
What main code? For translations I just need the language files. Would be great to have some additional languages, especially if they don't need any non-ascii symbols.^^
But there would be the need of updating them as I'm hard working at the editor in my spare time. For now I'm implementing auto complete, calltips and project support (some are already visible in the repository).

You can do everything with wx-c but, also I like it, sometimes it's a pain. wx-c is just a small wrapper for wxWidgets and lacks many nice things. I'm planning to extend the wrapper under new name but first I have lots of todos for wxFBE.

Btw, you need 0.24 to compile wxFBE.
Oh! Sorry MOD, I just mixed up two things I wanted to say. I was saying that I am translating stuff and creating a good project management thing. It would be completed by today :). So you can safely forget about at least one headache :D

This is current state of project.bi file:

Code: Select all

#ifndef __project_bi__
#define __project_bi__

'***************************************************************
'***************************************************************
'**                       PROJECT.BI                          **
'**              Project System Declaration File              **
'***************************************************************
'***************************************************************



'/////////////////////////////////////////////
'
'Data Structures
'
'/////////////////////////////////////////////



'Project type enumeration
Enum project_type
	CONSOLE= 1    'console Application
	DLL= 2        'dll
	WXC= 3        'wx-c application
	GTK= 4        'gtk+ application
	WINDOW9= 5    'window9 application
	WIN32= 6      'win32 application
	HEADER= 7     'header file
End Enum


'Compiler option details
Enum compiler_option
	GUI= 1           'To develop GUI application
	GUI_DEBUG= 2     'To develop GUI debug application
	
	CONSOLE= 3        'To develop Console application
	CONSOLE_DEBUG= 4  'To develop Console(debug) application
	
	DEPRECATED_GUI= 5        'To develop deprecated GUI application
	DEPRECATED_GUI_DEBUG= 6  'To develop deprecated GUI(debug) application
	
	DEPRECATED_CONSOLE= 7       'To develop deprecated Console application
	DEPRECATED_CONSOLE_DEBUG= 8 'To develop deprecated Console(debug) application
	
	QB_GUI= 9         'To develop a QB GUI application
	QB_GUI_DEBUG= 10  'To develop a QB GUI(debug) application
	
	QB_CONSOLE= 11        'To develop a QB Console application
	QB_CONSOLE_DEBUG= 12  'To develop a QB Console(debug) application
	
	WINDOWS_DLL= 13 'To develop a windows Dll
	
	LIBRARY= 16   'To develop a static link library
	
End Enum


'Project Data Structure
Type project
	Dim As project_type target        'Target application type of the project
	Dim As compiler_option compiler   'Compiler option to use to compile project
	
	Dim As String p_name           'Name of Project
	Dim As String p_destination    'Location of Project
End Type


'/////////////////////////////////////////////
'
'Functions handling Project
'
'/////////////////////////////////////////////



'Function to create a new project
Declare Function p_add_project(myproject As project) As Integer 'If success returns 1, else 0

'Function to add new file to project
Declare Function p_add_new_file(project_file_add As String) As Integer 'If success returns 1, else 0

'Function to replace file from project
Declare Function p_replace_file(project_file_replace As String) As Integer 'If success returns 1, else 0

'Function to remove file from project
Declare Function p_remove_file(project_file_remove As String) As Integer 'If success returns 1, else 0

'Function to Remove file used by project from both project and hardisk
Declare Function p_kill_file(project_file_kill As String) As Integer 'If success returns 1, else 0

'Function to encrypt Data
Declare Function p_encrypt(input_data As String, data_key As String) As Integer 'If success returns 1, else 0

'Function to decrypt Data
Declare Function p_decrypt(input_data As String, data_key As String) As Integer 'If success returns 1, else 0

#EndIf '__project_bi__
I hope you like the way I'm working :).

And about compiling at Linux issues... Actually I'm using 64 bit version of Fedora... So Installing FreeBASIC is really a headache there... But I really like 64 bit Fedora 17. First I would make sure it is working fine then I'll try to compile it again.

And at ASCII thing :P. lol. Sadly most of the humanity's writing system don't use ASCII :P. But luckily Devanagari(Writing system of Hindi, Sanskrit, Marathi, etc.) is working very fine. It is actually the most complicated writing system to render... With tons of ligatures, etc. And no good OCR for Devanagari languages is developed to this day.
Devanagari:
Image

Another thing I would be adding is to project the image files. From encrypted data files, images would be generated on each run. So that there is less changes of images getting corrupt or edited, etc. This really make look program less professional. And we can also encrypt the languages files but in this case we need to create language file generator. So my To do list is:
1. Project Management System
2. Image encryption
3. Language file encryption and creation of language generator

cheers, I'll updated you with these things very soon :)
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: wxFBE, editor for both Windows and Linux

Post by MOD »

My project support is almost done, so no need for you to do it. Moreover it have to fit in the structure like using xml for loading/saving projects etc.

The wx-c GUI and mdLanguage can handle unicode symbols but it won't work with paths, that's the biggest issue here.

About image and language file encryption: it was designed to be open. If someone doesn't like my icons he can simply edit or replace them. Same for language files. Any errors etc. can be fixed right by the user. So no need for encryption here, too.
leodescal
Posts: 165
Joined: Oct 16, 2009 14:44
Location: Jodhpur, Rajputana, Empire of Aryavart
Contact:

Re: wxFBE, editor for both Windows and Linux

Post by leodescal »

MOD wrote:My project support is almost done, so no need for you to do it. Moreover it have to fit in the structure like using xml for loading/saving projects etc.

The wx-c GUI and mdLanguage can handle unicode symbols but it won't work with paths, that's the biggest issue here.

About image and language file encryption: it was designed to be open. If someone doesn't like my icons he can simply edit or replace them. Same for language files. Any errors etc. can be fixed right by the user. So no need for encryption here, too.
kk... So anywhere I can help :D?
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: wxFBE, editor for both Windows and Linux

Post by MOD »

For now not much as most things I'd like to do depend on the next update. But then I'll find a nice job for you. ;)

If your language files are complete, you can post them here.
Post Reply