Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Syntax Edit
  New Posts New Posts RSS Feed - A few questions about Syntax Editor
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

A few questions about Syntax Editor

 Post Reply Post Reply
Author
Message
Italo View Drop Down
Groupie
Groupie


Joined: 10 December 2003
Location: United States
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote Italo Quote  Post ReplyReply Direct Link To This Post Topic: A few questions about Syntax Editor
    Posted: 28 December 2006 at 12:07am

1.       How to I programmatically setup the control without using ini files? Can you please give us an example?

2.       The sample application only works if you’re working with a file extensions. Is it possible to use the control without a file extension? Example: All documents without extensions should use the cpp syntax.
 
Thanks,
Italo

 

 

 

 

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2007 at 12:25pm
Hi,

There are no a direct interface for that. For more information look for implementations of methods:
1)CXTPSyntaxEditBufferManager::Load(CFile *pFile, LPCTSTR pcszFileExt)
2)CXTPSyntaxEditBufferManager::SetFileExt

--
WBR,
Serge
Back to Top
Italo View Drop Down
Groupie
Groupie


Joined: 10 December 2003
Location: United States
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote Italo Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2007 at 9:09am

Is it possible to dynamically add keywords? If not, can this feature be added?

 

Thanks,

Italo

Back to Top
jrodd View Drop Down
Newbie
Newbie


Joined: 07 March 2007
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jrodd Quote  Post ReplyReply Direct Link To This Post Posted: 08 March 2007 at 11:08am
Originally posted by Italo Italo wrote:

Is it possible to dynamically add keywords? If not, can this feature be added?

 

Thanks,

Italo



How about dynamically adding classes to the schema also?  One, or both, of these features would be helpful.

Thanks,
jrodd
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 06 May 2007 at 5:35pm
What would be very useful also would be the ability to
 
1. get it to edit a string, rather than a file
2. Allow us to set config not using an INI file - I don't want to have to ship an extra file around just to get syntax editing working, and I don't want anyone messing with the file either - I want it fixed
3. Enable using a string for the schema rather than a schema file.
 
 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2007 at 2:06am
I agree completely. In my application, I certainly do not want to provide a SyntaxEdit.ini among primitive scheme-files. Also, I cannot get the desired highlighting without adding keywords.
I believe these are must-have features in order to compete with controls such as BCGEdit.
 
CXTPSyntaxEditCtrl definitely needs these two features:
1) Adding keywords in run-time.
2) A tokenizer similar to the one found in Scintilla.
Back to Top
AndreiM View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 18 August 2007
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndreiM Quote  Post ReplyReply Direct Link To This Post Posted: 28 September 2007 at 5:28am
About set text rather then file:
  You can use CXTPSyntaxEditBufferManager::SerializeEx to do this now.
  I will add them as members of CXTPSyntaxEditCtrl.
 
EXAMPLE:
 
CString GetText()
{
 if (m_wndSyntaxEdit.GetEditBuffer())
 {
  CMemFile memFile;
  CArchive ar(&memFile, CArchive::store);
 
  BOOL bUnicode = (sizeof(TCHAR) == 2);
  m_wndSyntaxEdit.GetEditBuffer()->SerializeEx(ar, bUnicode, FALSE, -1);
 
  ar << (DWORD)0;
 
  ar.Close();
 
  memFile.SeekToBegin();
 
  void* pTextData = NULL;
  void* pTextEnd = NULL;
  memFile.GetBufferPtr(CFile::bufferRead, (UINT)-1, &pTextData, &pTextEnd);
 
  return pTextData;
 }
 return _T("");
}
 
void SetText(LPCTSTR pcszText)
{
 if (m_wndSyntaxEdit.GetEditBuffer() && pcszText)
 { 
  int nStrLenB = (int)_tcslen(pcszText) * sizeof(TCHAR);
  CMemFile memFile((BYTE*)pcszText, nStrLenB);
  memFile.SeekToBegin();
 
  CArchive ar(&memFile, CArchive::load);
 
  BOOL bUnicode = (sizeof(TCHAR) == 2);
  m_wndSyntaxEdit.GetEditBuffer()->SerializeEx(ar, bUnicode);
 
  //---------------------------------------
  m_wndSyntaxEdit.RefreshColors();
  m_wndSyntaxEdit.RecalcScrollBars();
  
  m_wndSyntaxEdit.UpdateWindow();  
 }
}
Back to Top
AndreiM View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 18 August 2007
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndreiM Quote  Post ReplyReply Direct Link To This Post Posted: 28 September 2007 at 5:30am
I think we will add possibility to load configuration and schemas from resources rather then from files.
 
Adding keywords in run-time will be added after 11.2.1.
   Can you explain more about your needs for this feature.
 
A tokenizer similar to the one found in Scintilla.
   Can you explain more about this point too.
Back to Top
Tomasz View Drop Down
Senior Member
Senior Member


Joined: 05 August 2006
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomasz Quote  Post ReplyReply Direct Link To This Post Posted: 28 September 2007 at 10:10am

One needs to be able to add KEYWORDS in run-time.

This is CRUICIAL. For example, I have an application that features full-blown programming language that allows user to define his own functions. Either via DLLs (plugins) or by function definition. And I want user-defined functions to be HIGHLIGHTED. For that I need to be able to add keywords in runtime to SyntaxEdit colorizer. I also need to add them to auto-complete boxes as well as parameter info.
 
I have got impression that CodeJock developers do not really use the libraries they create. You should actually try to create some bigger sample application that actually does something more than being Notepad replacement in order to understand what issues are met with when one tries to actually use the control in real-world.
This is similar to compiler creator that should actually compile the programs with the compiler he created. Otherwise he won't be aware of many issues that surface when you actually try to use the product in real-world situation, not only the most trivial 'demo' case.
 
As far as loading from string via CArchive - why making this most basic and required operation as complicated???? Should I mention SLOW, too?
 
Do you really imagine that anybody would program for Windows if there was no SetWindowText() function???? And Windows API required to go through CArchive instead????  This is ridiculous.
 
Give us straight SetWindowText() equivalent! That's after all Windows standard. Why do you make things harder than they should be!
 
Codejock you need to decide whenever you want to release somethign SERIOUS or just a toy for kids. At the moment SyntaxEdit is a toy.
 
To be considered professional it needs:
a) full API (with basic operations like SetText/GetText available directly, not using slow workarounds)
b) full feature set (colorizing, user-defined keywords added programmatically, programmatic control over auto-complete, "Parameter info" functionality with programmatic control too). Everything what is available from .INI config, should be also available from the code (without any external files)
c) it must be FAST. I can not stress it more. Speed is cruicial thing. Right now the control is slow. Please use the PROFILER to find bottlenecks. 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 29 September 2007 at 7:18pm
Scintilla is open-source. In it, you find a tokenizer which lets you colorize on the fly. Even though their state machine is flawed, it gives the programmer great control of the colorization.
 
I'm not saying that the current implementation of SE is bad, I'm just saying that there will be situations where the programmer wants total control of the syntax highlighting. In these situations there must be a customizable callback function: "Current line changed. How do you want to colorize it?" (don't forget multiline comment changes...)
 
When it comes to adding keywords, this requires not just "colorize all words found in list X", but also "colorize all words matching pattern X".
 
For instance, the user might want to colorize all strings ("some text") in a certain color/style without having to alter some shclass-file... Hence, all we need is a well-designed callback function where we can do whatever we want 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.