sourcefile.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "stdafx.h"
  2. #include "sourcefile.h"
  3. #include "prefs.h"
  4. IMPLEMENT_DYNAMIC( SourceFile,CRichEditCtrl )
  5. BEGIN_MESSAGE_MAP( SourceFile,CRichEditCtrl )
  6. ON_WM_CREATE()
  7. END_MESSAGE_MAP()
  8. SourceFile::SourceFile(){
  9. }
  10. SourceFile::~SourceFile(){
  11. }
  12. int SourceFile::OnCreate( LPCREATESTRUCT lpCreateStruct ){
  13. CRichEditCtrl::OnCreate( lpCreateStruct );
  14. SetReadOnly( true );
  15. SetFont( &prefs.editFont );
  16. SetBackgroundColor( false,prefs.rgb_bkgrnd );
  17. CHARFORMAT fmt={sizeof( fmt )};
  18. fmt.dwMask=CFM_COLOR;
  19. fmt.crTextColor=prefs.rgb_default;
  20. SetSel( 0,-1 );
  21. SetDefaultCharFormat( fmt );
  22. SetSelectionCharFormat( fmt );
  23. SetSel( 0,0 );
  24. return 0;
  25. }
  26. void SourceFile::highLight( int row,int col ){
  27. int pos=LineIndex( row )+col;
  28. HideSelection( true,false );
  29. bool quote=false;
  30. int end=pos,len=GetTextLength();
  31. while( end<len ){
  32. char temp[8];
  33. SetSel( end,end+1 );
  34. GetSelText( temp );
  35. if( temp[0]=='\"' ) quote=!quote;
  36. if( !quote && (temp[0]==':' || !isprint( temp[0] )) ) break;
  37. ++end;
  38. }
  39. HideSelection( false,false );
  40. SetSel( pos,end );
  41. }