Subversion Repositories Kolibri OS

Rev

Rev 3363 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #define MEMSIZE 0x3E80
  2. #include "..\lib\kolibri.h"
  3. #include "..\lib\strings.h"
  4. #include "..\lib\mem.h"
  5. #include "..\lib\file_system.h"
  6.  
  7. void str_replace(dword buf_in, what_replace, to_what_replace) {
  8.         dword start_pos=0;
  9.         dword buf_from;
  10.  
  11.         buf_from = malloc(strlen(buf_in));
  12.         loop() {
  13.                 strcpy(buf_from, buf_in);
  14.                 start_pos = strstr(buf_from, what_replace);
  15.                 if (start_pos == 0) break;
  16.                 strlcpy(buf_in, buf_from, start_pos-buf_from);
  17.                 strcat(buf_in, to_what_replace);
  18.                 start_pos += strlen(what_replace);
  19.                 strcat(buf_in, start_pos);
  20.         }
  21.         free(buf_from);
  22. }
  23.  
  24. void main()
  25. {  
  26.         int id, key;
  27.         strcpy(#param, " <html>lorem</html>");
  28.         str_replace(#param, "<", "&lt");
  29.         str_replace(#param, ">", "&gt");
  30.        
  31.         loop()
  32.    {
  33.       switch(WaitEvent())
  34.       {
  35.          case evButton:
  36.             id=GetButtonID();              
  37.             if (id==1) ExitProcess();
  38.                         break;
  39.      
  40.         case evKey:
  41.                         key = GetKey();
  42.                         IF (key==013){ //Enter
  43.                                 WriteText(50,90,0x80,0xFF00FF,"Pressed Enter");
  44.                         }
  45.                         break;
  46.          
  47.          case evReDraw:
  48.                         draw_window();
  49.                         break;
  50.       }
  51.    }
  52. }
  53.  
  54.  
  55. void draw_window()
  56. {
  57.         proc_info Form;
  58.         DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Window header");
  59.         GetProcessInfo(#Form, SelfInfo);
  60.         WriteText(50,80,0x80,0,"Press Enter");
  61.         WriteText(10,110,0x80,0,#param);
  62. }
  63.  
  64.  
  65. stop:
  66.