Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 184.11 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<SDL2/SDL.h>
  3. #include<SDL2/SDL_image.h>
  4. #include<SDL2/SDL_ttf.h>
  5. #include <SDL2/SDL_mixer.h>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  
  12. class LTexture
  13. {
  14.  
  15. public:
  16.  
  17.     LTexture();
  18.     ~LTexture();
  19.     bool loadFromFile(std::string path);
  20.  
  21. #if defined(_SDL_TTF_H) || defined(SDL_TTF_H)
  22.     bool loadFromRenderedText(std::string textureText, SDL_Color textColor);
  23. #endif
  24.  
  25.     void free();
  26.     void setColor(Uint8 red, Uint8 green, Uint8 blue);
  27.     void setBlendMode(SDL_BlendMode blending);
  28.     void setAlpha(Uint8 alpha);
  29.     void render(int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE );
  30.     int getWidth();
  31.     int getHeight();
  32.  
  33. private:
  34.     SDL_Texture* mTexture;
  35.     int mWidth;
  36.     int mHeight;
  37.  
  38. };
  39.  
  40. LTexture::LTexture()
  41. {
  42.     mTexture = NULL;
  43.     mWidth = 0;
  44.     mHeight = 0;
  45. }
  46.  
  47. LTexture::~LTexture()
  48. {
  49.     free();
  50. }
  51.  
  52. // constants and declarations
  53.  
  54. char mama_mia[1]={3};
  55. string newl;
  56. //newl=mama_mia;
  57.  
  58.  
  59.  
  60. int image_int=0;
  61. int search_int=0;
  62. const int SCREEN_WIDTH = 2000;
  63. const int SCREEN_HEIGHT = 1000;
  64. int Font_WIDTH = 30;
  65. string date;
  66. string oldEntryInput;
  67. char savedStringFile[1001000];
  68. char indicator[5] = "!";
  69. bool search_bar_bool=false;
  70. bool global_check_for_first_window_flag = false;
  71. bool global_check_for_main_menu = false;
  72. bool firstWindowShowFuntionFlag = false;
  73. bool quit = false;
  74. bool init();
  75. bool loadMedia();
  76. void close();
  77. SDL_Texture* loadTexture(std::string path);
  78. SDL_Texture* firstWindow = NULL;
  79. SDL_Window* main_window = NULL;
  80. SDL_Renderer* main_renderer = NULL;
  81. TTF_Font* main_font=NULL;
  82. TTF_Font* menu_font = NULL;
  83. TTF_Font* time_font = NULL;
  84. LTexture mainTextTexture[101];
  85. LTexture header_text_input_texture;
  86. LTexture Ltemp;
  87. LTexture search_bar;
  88. LTexture indi;
  89. LTexture header;
  90. LTexture gDotTexture;
  91. SDL_Color textColor= {0x00,0x00,0x00};
  92. SDL_Color hColor = {0x00,0x00,0xFF};
  93. SDL_Texture* main_menu_texture = NULL;
  94. SDL_Texture* HeaderEntry = NULL;
  95. SDL_Texture* background_texture = NULL;
  96. SDL_Texture* selectBackground = NULL;
  97. SDL_Texture* PreferenceMenuTexture = NULL;
  98. SDL_Texture* backGroundChooseTexture = NULL;
  99. SDL_Texture* clickToChooseMusicTexture = NULL;
  100. SDL_Texture* selectionImageTexture = NULL;
  101. bool isThereAnyImageSavedToThisFile = false;
  102. SDL_Texture* showImageTexture  = NULL;
  103. /// MONONS GLOBAL variables
  104.  
  105. SDL_Texture* topMenuTexture1 = NULL;
  106. SDL_Texture* topMenuTexture2 = NULL;
  107. SDL_Texture* topMenuTexture3 = NULL;
  108. SDL_Texture* topMenuTexture4 = NULL;
  109. SDL_Texture* entrySavedSuccessfullyTexture = NULL;
  110. SDL_Texture* timeTexture = NULL;
  111. SDL_Texture* newMenuShowTexture = NULL;
  112. SDL_Texture* viewMenuShowTexture = NULL;
  113. SDL_Texture* closeWithoutSavingTexture = NULL;
  114. Mix_Music* backgroundMusic[4] = {NULL};
  115. int konGaanBaaje = -1;
  116. SDL_Texture* screenImageTexture = NULL;
  117. string imageSavedString = "";
  118. string usernameString = "";
  119. string oldEntryErJonnoUsernameString = "";
  120.  
  121.  
  122.  
  123. bool LTexture::loadFromFile(std:: string path)
  124. {
  125.     free();
  126.     SDL_Texture* newTexture = NULL;
  127.     SDL_Surface* loadedSurface = IMG_Load(path.c_str());
  128.     if(loadedSurface==NULL)
  129.     {
  130.         printf( "Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError() );
  131.     }
  132.     else
  133.     {
  134.         SDL_SetColorKey(loadedSurface, SDL_TRUE, SDL_MapRGB(loadedSurface->format, 0, 0xFF, 0xFF));
  135.         newTexture = SDL_CreateTextureFromSurface(main_renderer, loadedSurface);
  136.         if( newTexture == NULL )  printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
  137.  
  138.         else
  139.         {
  140.             mWidth = loadedSurface->w;
  141.             if(path == "data/indi.png")
  142.             {
  143.               mHeight = loadedSurface->h;
  144.                 mWidth = 5;
  145.                 mHeight = 20;
  146.             }
  147.         }
  148.         SDL_FreeSurface(loadedSurface);
  149.     }
  150.     mTexture = newTexture;
  151.     return mTexture !=NULL;
  152. }
  153.  
  154.  
  155. #if defined(_SDL_TTF_H) || defined(SDL_TTF_H)
  156. bool LTexture::loadFromRenderedText(std::string textureText, SDL_Color textColor)
  157. {
  158.  
  159.     free();
  160.  
  161.  
  162.     SDL_Surface* textSurface = TTF_RenderText_Solid(main_font, textureText.c_str(), textColor);
  163.     if( textSurface == NULL ) printf( "Unable to render text surface! SDL_ttf Error: %s\n", TTF_GetError() );
  164.     else
  165.     {
  166.         mTexture = SDL_CreateTextureFromSurface(main_renderer, textSurface);
  167.         if(mTexture == NULL)    printf( "Unable to create texture from rendered text! SDL Error: %s\n", SDL_GetError() );
  168.         else
  169.         {
  170.             mWidth = textSurface->w;
  171.             mHeight = textSurface->h;
  172.         }
  173.         SDL_FreeSurface(textSurface);
  174.     }
  175.     return mTexture!=NULL;
  176. }
  177.  
  178. #endif
  179. void LTexture::free()
  180. {
  181.     if(mTexture!=NULL)
  182.     {
  183.         SDL_DestroyTexture(mTexture);
  184.         mTexture = NULL;
  185.         mWidth = 0;
  186.         mHeight = 0;
  187.     }
  188. }
  189.  
  190. void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
  191. {
  192.     SDL_SetTextureColorMod(mTexture, red, green, blue);
  193.  
  194. }
  195.  
  196. void LTexture::setBlendMode(SDL_BlendMode blending)
  197. {
  198.     SDL_SetTextureBlendMode(mTexture, blending);
  199. }
  200.  
  201. void LTexture::setAlpha(Uint8 alpha)
  202. {
  203.     SDL_SetTextureAlphaMod(mTexture, alpha);
  204. }
  205.  
  206. void LTexture::render(int x, int y, SDL_Rect* clip, double angle, SDL_Point* center, SDL_RendererFlip flip)
  207. {
  208.     SDL_Rect renderQuad = {x,y,mWidth,mHeight};
  209.     if(clip!=NULL)
  210.     {
  211.         renderQuad.w = clip->w;
  212.         renderQuad.h = clip->h;
  213.     }
  214.     SDL_RenderCopyEx(main_renderer, mTexture, clip, &renderQuad, angle, center, flip);
  215. }
  216.  
  217.  
  218. int LTexture::getWidth()
  219. {
  220.     return mWidth;
  221. }
  222.  
  223. int LTexture::getHeight()
  224. {
  225.     return mHeight;
  226. }
  227.  
  228. SDL_Texture* loadTexture(std::string path)
  229. {
  230.     SDL_Texture* newTexture = NULL;
  231.     SDL_Surface* loadedSurface = IMG_Load(path.c_str());
  232.     if(loadedSurface == NULL)   printf( "Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError() );
  233.     else
  234.     {
  235.         newTexture = SDL_CreateTextureFromSurface(main_renderer, loadedSurface);
  236.         if(newTexture==NULL)  printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
  237.         SDL_FreeSurface(loadedSurface);
  238.     }
  239.     return newTexture;
  240. }
  241.  
  242. SDL_Texture* loadTextTexture(string textureText,SDL_Color textColor)
  243. {
  244.     SDL_Texture* textTextureTemp = NULL;
  245.     SDL_Surface* textSurface = TTF_RenderText_Blended(time_font, textureText.c_str(), textColor);
  246.     if( textSurface == NULL ) printf( "Unable to render text texture for menu! SDL_ttf Error: %s\n", TTF_GetError() );
  247.     else
  248.     {
  249.         textTextureTemp = SDL_CreateTextureFromSurface(main_renderer, textSurface);
  250.         if(textTextureTemp == NULL)   printf( "Unable to create texture from rendered text! SDL Error: %s\n", SDL_GetError() );
  251.         SDL_FreeSurface(textSurface);
  252.     }
  253.     return textTextureTemp;
  254. }
  255.  
  256. bool init()
  257. {
  258.     bool success = true;
  259.     if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  260.     {
  261.         printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
  262.         success = false;
  263.     }
  264.     else
  265.     {
  266.         if(!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,"1")) printf("Warning: Linear texture filtering not enabled!" );
  267.         main_window = SDL_CreateWindow("!TYPO",0,0,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
  268.         if(main_window==NULL)
  269.         {
  270.             printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
  271.             success = false;
  272.         }
  273.         else
  274.         {
  275.             main_renderer = SDL_CreateRenderer(main_window,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
  276.             if( main_renderer == NULL )
  277.             {
  278.                 printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
  279.                 success = false;
  280.             }
  281.             else
  282.             {
  283.                 SDL_SetRenderDrawColor(main_renderer, 0xFF,0xFF,0xFF,0xFF);
  284.                 int imgFlags = IMG_INIT_PNG;
  285.                 if(!(IMG_Init(imgFlags)&imgFlags))
  286.                 {
  287.                     printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
  288.                     success = false;
  289.                 }
  290.                 if( TTF_Init() == -1 )
  291.                 {
  292.                     printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
  293.                     success = false;
  294.                 }
  295.                 if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
  296.                 {
  297.                     printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() );
  298.                     success = false;
  299.                 }
  300.             }
  301.         }
  302.     }
  303.     return success;
  304. }
  305.  
  306. bool loadMedia()
  307. {
  308.     bool success = true;
  309.  
  310.     main_font = TTF_OpenFont("data/JosefinSans-Regular.ttf", Font_WIDTH);
  311.     if(main_font==NULL)
  312.     {
  313.         printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  314.         success = false;
  315.     }
  316.  
  317.     time_font = TTF_OpenFont("data/RobotoCondensed-Regular.ttf", 20);
  318.     if(time_font == NULL)
  319.     {
  320.       printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError());
  321.       success = false;
  322.     }
  323.  
  324.     selectionImageTexture = loadTexture("data/selectionImage.png");
  325.     if(selectionImageTexture == NULL){
  326.       printf( "Failed to load selectionImageTexture!\n" );
  327.       success = false;
  328.     }
  329.  
  330.     backGroundChooseTexture = loadTexture("data/clickToChooseBackground.png");
  331.     if(backGroundChooseTexture == NULL){
  332.       printf( "Failed to load backGroundChooseTexture!\n" );
  333.       success = false;
  334.     }
  335.  
  336.  
  337.     entrySavedSuccessfullyTexture = loadTexture("data/entrySavedSuccessfully.png");
  338.     if(entrySavedSuccessfullyTexture == NULL){
  339.  
  340.         printf( "Failed to load entrySavedSuccessfully!\n" );
  341.         success = false;
  342.     }
  343.  
  344.     //Load dot texture
  345.     if( !gDotTexture.loadFromFile("data/indi.png") )
  346.     {
  347.         printf( "Failed to load dot texture!\n" );
  348.         success = false;
  349.     }
  350.     // first window loader
  351.  
  352.     firstWindow = loadTexture("data/firstWindow.png");
  353.     if( firstWindow == NULL )
  354.     {
  355.         printf( "Failed to load firstWindow!\n" );
  356.         success = false;
  357.     }
  358.  
  359.     // main menu loader
  360.  
  361.     main_menu_texture = loadTexture("data/main_menu_texture.png");
  362.     if( main_menu_texture == NULL )
  363.     {
  364.         printf( "Failed to load main_menu_texture!\n" );
  365.         success = false;
  366.     }
  367.  
  368.     // header entry loader
  369.  
  370.     HeaderEntry = loadTexture("data/HeaderEntry.png");
  371.     if( HeaderEntry == NULL )
  372.     {
  373.         printf( "Failed to load HeaderEntry!\n" );
  374.         success = false;
  375.     }
  376.  
  377.     clickToChooseMusicTexture = loadTexture("data/clickToChooseMusic.png");
  378.     if( clickToChooseMusicTexture == NULL )
  379.     {
  380.         printf( "Failed to load clickToChooseMusicTexture!\n" );
  381.         success = false;
  382.     }
  383.  
  384.  
  385.  
  386.     background_texture = loadTexture("data/yellow_back.png");
  387.     if(background_texture==NULL)
  388.     {
  389.         printf( "Failed to load background_texture!\n" );
  390.         success = false;
  391.     }
  392.  
  393.  
  394.         topMenuTexture1 = loadTexture("data/topMenuTexture1.png");
  395.         if(topMenuTexture1==NULL)
  396.         {
  397.             printf( "Failed to load topMenuTexture1!\n" );
  398.             success = false;
  399.         }
  400.  
  401.  
  402.         topMenuTexture2 = loadTexture("data/topMenuTexture2.png");
  403.         if(topMenuTexture2==NULL)
  404.         {
  405.             printf( "Failed to load topMenuTexture2!\n" );
  406.             success = false;
  407.         }
  408.  
  409.         topMenuTexture3 = loadTexture("data/topMenuTexture3.png");
  410.         if(topMenuTexture3==NULL)
  411.         {
  412.             printf( "Failed to load topMenuTexture3!\n" );
  413.             success = false;
  414.         }
  415.  
  416.         topMenuTexture4 = loadTexture("data/topMenuTexture4.png");
  417.         if(topMenuTexture4==NULL)
  418.         {
  419.             printf( "Failed to load topMenuTexture4!\n" );
  420.             success = false;
  421.         }
  422.  
  423.  
  424.     newMenuShowTexture = loadTexture("data/newMenuShowTexture.png");
  425.     if(newMenuShowTexture == NULL)
  426.     {
  427.         printf( "Failed to load newMenuShowTexture!\n" );
  428.         success = false;
  429.     }
  430.  
  431.     viewMenuShowTexture = loadTexture("data/viewMenuShowTexture.png");
  432.     if(viewMenuShowTexture == NULL)
  433.     {
  434.         printf( "Failed to load viewMenuShowTexture!\n" );
  435.         success = false;
  436.     }
  437.  
  438.     closeWithoutSavingTexture = loadTexture("data/closeWithoutSaving.png");
  439.     if(closeWithoutSavingTexture == NULL)
  440.     {
  441.         printf( "Failed to load closeWithoutSavingTexture!\n" );
  442.         success = false;
  443.     }
  444.  
  445.     PreferenceMenuTexture = loadTexture("data/PreferenceMenuTexture.png");
  446.     if(PreferenceMenuTexture == NULL)
  447.     {
  448.         printf( "Failed to load PreferenceMenuTexture!\n" );
  449.         success = false;
  450.     }
  451.  
  452.  
  453.     backgroundMusic[0] = Mix_LoadMUS( "data/classical_playlist.mp3" );
  454.     if( backgroundMusic[0] == NULL )
  455.     {
  456.         printf( "Failed to load background music 0 ! SDL_mixer Error: %s\n", Mix_GetError() );
  457.         success = false;
  458.     }
  459.  
  460.     backgroundMusic[1] = Mix_LoadMUS( "data/modern_playlist.mp3" );
  461.     if( backgroundMusic[1] == NULL )
  462.     {
  463.         printf( "Failed to load background music 1 ! SDL_mixer Error: %s\n", Mix_GetError() );
  464.         success = false;
  465.     }
  466.  
  467.     backgroundMusic[2] = Mix_LoadMUS( "data/upbeat_playlist.mp3" );
  468.     if( backgroundMusic[2] == NULL )
  469.     {
  470.         printf( "Failed to load background music 2 ! SDL_mixer Error: %s\n", Mix_GetError() );
  471.         success = false;
  472.     }
  473.  
  474.     backgroundMusic[3] = Mix_LoadMUS( "data/sad_playlist.mp3" );
  475.     if( backgroundMusic[3] == NULL )
  476.     {
  477.         printf( "Failed to load background music 3 ! SDL_mixer Error: %s\n", Mix_GetError() );
  478.         success = false;
  479.     }
  480.  
  481.  
  482.  
  483.  
  484.  
  485.     return success;
  486. }
  487.  
  488. void close()
  489. {
  490.     for(int i=0; i<50; i++)
  491.     {
  492.         mainTextTexture[i].free();
  493.     }
  494.     SDL_DestroyTexture(topMenuTexture1);
  495.     topMenuTexture1 = NULL;
  496.     SDL_DestroyTexture(topMenuTexture2);
  497.     topMenuTexture2 = NULL;
  498.     SDL_DestroyTexture(topMenuTexture3);
  499.     topMenuTexture3 = NULL;
  500.     SDL_DestroyTexture(topMenuTexture4);
  501.     topMenuTexture4 = NULL;
  502.     SDL_DestroyTexture(firstWindow);
  503.     firstWindow = NULL;
  504.     SDL_DestroyTexture(backGroundChooseTexture);
  505.     backGroundChooseTexture = NULL;
  506.     SDL_DestroyTexture(main_menu_texture);
  507.     main_menu_texture = NULL;
  508.     SDL_DestroyTexture(newMenuShowTexture);
  509.     newMenuShowTexture = NULL;
  510.     SDL_DestroyTexture(HeaderEntry);
  511.     HeaderEntry = NULL;
  512.     SDL_DestroyTexture(timeTexture);
  513.     timeTexture = NULL;
  514.     SDL_DestroyTexture(background_texture);
  515.     background_texture = NULL;
  516.     SDL_DestroyTexture(selectBackground);
  517.     selectBackground = NULL;
  518.     SDL_DestroyTexture(viewMenuShowTexture);
  519.     viewMenuShowTexture = NULL;
  520.     SDL_DestroyTexture(PreferenceMenuTexture);
  521.     PreferenceMenuTexture = NULL;
  522.     SDL_DestroyTexture(screenImageTexture);
  523.     SDL_DestroyTexture(closeWithoutSavingTexture);
  524.     closeWithoutSavingTexture = NULL;
  525.     screenImageTexture = NULL;
  526.     SDL_DestroyTexture(selectionImageTexture);
  527.     selectionImageTexture = NULL;
  528.     SDL_DestroyTexture(clickToChooseMusicTexture);
  529.     clickToChooseMusicTexture = NULL;
  530.     SDL_DestroyTexture(entrySavedSuccessfullyTexture);
  531.     entrySavedSuccessfullyTexture = NULL;
  532.  
  533.     for(int k=0; k<4; k++)
  534.     {
  535.         Mix_FreeMusic( backgroundMusic[k] );
  536.         backgroundMusic[k] = NULL;
  537.     }
  538.  
  539.     gDotTexture.free();
  540.     header.free();
  541.     TTF_CloseFont(main_font);
  542.     main_font = NULL;
  543.     TTF_CloseFont(menu_font);
  544.     menu_font = NULL;
  545.     SDL_DestroyRenderer(main_renderer);
  546.     main_renderer = NULL;
  547.     SDL_DestroyWindow(main_window);
  548.  
  549.     main_window = NULL;
  550.     Mix_Quit();
  551.     TTF_Quit();
  552.     IMG_Quit();
  553.     SDL_Quit();
  554. }
  555.  
  556. void firstWindowShowFuntion()
  557. {
  558.     SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  559.     SDL_RenderCopy(main_renderer, firstWindow, NULL, NULL);
  560.     SDL_RenderPresent(main_renderer);
  561.     SDL_Delay(1200);
  562.     SDL_RenderClear( main_renderer );
  563.     firstWindowShowFuntionFlag = true;
  564. }
  565.  
  566. int main_menu_show_funtion()
  567. {
  568.     int xNewmin = (475*SCREEN_WIDTH/2000), xNewmax = (475*SCREEN_WIDTH/2000)+ (1050*SCREEN_WIDTH/2000);
  569.     int yNewmin = (123*SCREEN_HEIGHT/1000), yNewmax = (123*SCREEN_HEIGHT/1000)+ (185*SCREEN_HEIGHT/1000);
  570.  
  571.     int xOldmin = (475*SCREEN_WIDTH/2000), xOldmax = (475*SCREEN_WIDTH/2000)+ (1050*SCREEN_WIDTH/2000);
  572.     int yOldmin = (423*SCREEN_HEIGHT/1000), yOldmax = (423*SCREEN_HEIGHT/1000) + (185*SCREEN_HEIGHT/1000);
  573.  
  574.     int xExitmin = (475*SCREEN_WIDTH/2000), xExitmax = (475*SCREEN_WIDTH/2000) + (1050*SCREEN_WIDTH/2000);
  575.     int yExitmin = (695*SCREEN_HEIGHT/1000), yExitmax = (695*SCREEN_HEIGHT/1000) + (185*SCREEN_HEIGHT/1000);
  576.  
  577.     SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  578.     SDL_RenderCopy(main_renderer, main_menu_texture, NULL, NULL);
  579.     SDL_RenderPresent(main_renderer);
  580.  
  581.     SDL_Event event_for_first_window2 ;
  582.     if(SDL_PollEvent(&event_for_first_window2))
  583.     {
  584.  
  585.         if(event_for_first_window2.type == SDL_QUIT)
  586.         {
  587.             quit = true;
  588.         }
  589.  
  590.         if(event_for_first_window2.type == SDL_MOUSEBUTTONDOWN)
  591.         {
  592.  
  593.             if((event_for_first_window2.button.x>xNewmin)&&(event_for_first_window2.button.x<xNewmax)&&(event_for_first_window2.button.y>yNewmin)&&(event_for_first_window2.button.y<yNewmax))
  594.             {
  595.                 return 1;
  596.             }
  597.  
  598.             if((event_for_first_window2.button.x > xOldmin)&&(event_for_first_window2.button.x<xOldmax)&&(event_for_first_window2.button.y>yOldmin)&&(event_for_first_window2.button.y<yOldmax))
  599.             {
  600.                 return 2;
  601.             }
  602.  
  603.             if((event_for_first_window2.button.x>xExitmin)&&(event_for_first_window2.button.x<xExitmax)&&(event_for_first_window2.button.y>yExitmin)&&(event_for_first_window2.button.y<yExitmax))
  604.             {
  605.                 return 3;
  606.             }
  607.         }
  608.     }
  609.  
  610.     SDL_RenderClear( main_renderer );
  611.     return 0;
  612. }
  613.  
  614. void HeaderInputFromUser(){
  615.  
  616.   SDL_Rect  headerRect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
  617.   bool quit_this = false;
  618.   SDL_Event e1;
  619.   SDL_Color textColor ={0xFF,0xFF,0xFF};
  620.   SDL_Rect rectangleDraw = {(395*SCREEN_WIDTH)/2000, (290*SCREEN_HEIGHT)/1000, (1150*SCREEN_WIDTH)/2000, (50*SCREEN_HEIGHT)/1000};
  621.  
  622.  
  623.   string inputText = "";
  624.  
  625.   SDL_StartTextInput();
  626.  
  627.   while( !quit_this )
  628.   {
  629.  
  630.     bool renderText = false;
  631.  
  632.  
  633.     while( SDL_PollEvent( &e1 ) != 0 )
  634.     {
  635.       if(e1.type == SDL_QUIT)
  636.       {
  637.         quit_this = true;
  638.  
  639.       }
  640.  
  641.        if( e1.type == SDL_KEYDOWN )
  642.       {
  643.         if( e1.key.keysym.sym == SDLK_RETURN )
  644.         {
  645.           quit_this = true;
  646.         }
  647.  
  648.         if( e1.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 )
  649.         {
  650.           inputText.pop_back();
  651.           renderText = true;
  652.         }
  653.  
  654.         if(e1.type == SDL_QUIT)
  655.         {
  656.           quit_this = true;
  657.  
  658.         }
  659.  
  660.       }
  661.       else if( e1.type == SDL_TEXTINPUT )
  662.       {
  663.         if( !( SDL_GetModState() & KMOD_CTRL && ( e1.text.text[ 0 ] == 'c' || e1.text.text[ 0 ] == 'C' || e1.text.text[ 0 ] == 'v' || e1.text.text[ 0 ] == 'V' ) ) )
  664.         {
  665.           inputText += e1.text.text;
  666.           renderText = true;
  667.         }
  668.       }
  669.     }
  670.  
  671.  
  672.     if( renderText )
  673.     {
  674.  
  675.       if( inputText != " " )
  676.       {
  677.  
  678.         header_text_input_texture.loadFromRenderedText( inputText.c_str(), hColor );
  679.       }
  680.  
  681.       else
  682.       {
  683.  
  684.         header_text_input_texture.loadFromRenderedText( " ", hColor );
  685.       }
  686.  
  687.     }
  688.  
  689.  
  690.  
  691.  
  692.  
  693.     SDL_SetRenderDrawColor( main_renderer, 0xFF, 0x00, 0x00, 0xFF );
  694.     SDL_RenderClear( main_renderer );
  695.  
  696.  
  697.     SDL_RenderSetViewport(main_renderer, &headerRect);
  698.  
  699.     SDL_RenderCopy(main_renderer, HeaderEntry, NULL, NULL);
  700.  
  701.     SDL_RenderDrawRect(main_renderer, &rectangleDraw);
  702.     header_text_input_texture.render( (600*SCREEN_WIDTH)/2000,(300*SCREEN_HEIGHT)/1000 );
  703.  
  704.  
  705.     SDL_RenderPresent( main_renderer);
  706.   }
  707.  
  708.  
  709.   SDL_StopTextInput();
  710.   SDL_RenderClear( main_renderer );
  711.   date = "./saved/";
  712.   date += inputText + ".typo";
  713. //  printf("header input: %s/n", date.c_str());
  714. }
  715.  
  716. void loadbackground_texture(int backSelect)
  717. {
  718.  
  719.       if(backSelect == 5){
  720.       background_texture = loadTexture("data/green_back.png");
  721.       hColor = {0x00,0x00,0x00};
  722.       }
  723.  
  724.      if (backSelect == 6){
  725.         background_texture = loadTexture("data/pink_back.png");
  726.         hColor = {0x00,0x00,0x00};
  727.       }
  728.  
  729.     else if(backSelect == 1)
  730.     {
  731.         background_texture = loadTexture("data/blue_back.png");
  732.         hColor = {0x00,0x00,0x00};
  733.     }
  734.  
  735.     else if(backSelect == 2)
  736.     {
  737.         background_texture = loadTexture("data/yellow_back.png");
  738.         hColor = {0xFF,0xFF,0xFF};
  739.     }
  740.  
  741.     else if(backSelect == 3)
  742.     {
  743.         background_texture = loadTexture("data/dark_back.png");
  744.         hColor = {0x00,0x00,0x00};
  745.     }
  746.  
  747.     else if(backSelect = 4)
  748.     {
  749.         background_texture = loadTexture("data/white_back.png");
  750.         hColor = {0x00,0x00,0x00};
  751.     }
  752.  
  753. }
  754.  
  755.  
  756. void loadFont(int kontaFont)
  757. {
  758.     if(kontaFont == 1)
  759.     {
  760.         main_font = TTF_OpenFont("data/JosefinSans-Regular.ttf", Font_WIDTH);
  761.         if(main_font==NULL)
  762.         {
  763.             printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  764.         }
  765.     }
  766.  
  767.     else if(kontaFont == 2)
  768.     {
  769.         main_font = TTF_OpenFont("data/OpenSans-Regular.ttf", Font_WIDTH);
  770.         if(main_font==NULL)
  771.         {
  772.             printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  773.         }
  774.     }
  775.     else if(kontaFont == 3)
  776.     {
  777.         main_font = TTF_OpenFont("data/Walkway_Oblique_Bold.ttf", Font_WIDTH);
  778.         if(main_font==NULL)
  779.         {
  780.             printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  781.         }
  782.  
  783.     }
  784.     else
  785.     {
  786.         main_font = TTF_OpenFont("data/RobotoCondensed-Regular.ttf", Font_WIDTH);
  787.         if(main_font==NULL)
  788.         {
  789.             printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  790.         }
  791.     }
  792. }
  793.  
  794. void seeOldEntryFunction(){
  795.  
  796.   FILE *oldEntryLoad = fopen("allEntries.typo", "r");
  797.   SDL_Rect oldEntryRect = {(100*SCREEN_WIDTH)/2000, (200*SCREEN_HEIGHT)/1000, (50*SCREEN_WIDTH)/2000, (30*SCREEN_HEIGHT)/1000};
  798.   SDL_Rect entireRect = {0,0,SCREEN_WIDTH,SCREEN_HEIGHT};
  799.   char str[100];
  800.   SDL_Texture* oldEntryTexture = NULL;
  801.   SDL_Color textColorEntry = {0xFF,0xFF,0xFF, 0xFF};
  802.   int j = 0;
  803.   SDL_Texture* backTextureEntryOld = loadTexture("./data/seeOldEntry.png");
  804.   SDL_RenderSetViewport(main_renderer, &entireRect);
  805.   SDL_SetRenderDrawColor(main_renderer, 0xFF, 0xFF, 0x00, 0xFF);
  806.   SDL_RenderCopy(main_renderer, backTextureEntryOld, NULL, NULL);
  807.  
  808.   while(fgets(str, sizeof(str), oldEntryLoad)!=NULL){
  809.     oldEntryTexture = loadTextTexture(str, textColorEntry);
  810.     oldEntryRect.y += 30;
  811.     oldEntryRect.w = strlen(str)*20;
  812.     SDL_RenderCopy(main_renderer, oldEntryTexture, NULL, &oldEntryRect);
  813.     j++;
  814.   }
  815.   SDL_RenderPresent(main_renderer);
  816.  
  817.   int kontaString = 1;
  818.   SDL_Event e1;
  819.   bool quit_this = false;
  820.  
  821.   while(!quit_this){
  822.  
  823.     while( SDL_PollEvent( &e1 ) != 0 )
  824.     {
  825.  
  826.         if(e1.type == SDLK_ESCAPE)
  827.         {
  828.           quit_this = true;
  829.         }
  830.  
  831.         if(e1.type == SDL_QUIT)
  832.         {
  833.           quit_this = true;
  834.         }
  835.  
  836.         if(e1.type == SDL_MOUSEBUTTONDOWN)
  837.         {
  838.             if(e1.button.x > 99) kontaString = (e1.button.y-200)/30;
  839.             quit_this = true;
  840.         }
  841.     }
  842.  
  843.   }
  844.  
  845.   oldEntryLoad = fopen("allEntries.typo", "r");
  846.   j = 1;
  847.   char putm[10000];
  848.   while(j<=kontaString){
  849.     fgets(putm, sizeof(putm), oldEntryLoad);
  850.     j++;
  851.   }
  852.   putm[strlen(putm)-1] = 0;
  853.   int i;
  854.     string s = "";
  855.     for (i = 0; i < strlen(putm); i++) {
  856.         s = s + putm[i];
  857.     }
  858.   oldEntryInput = "";
  859.   oldEntryInput += s;
  860.   oldEntryTexture = NULL;
  861.   backTextureEntryOld = NULL;
  862.  
  863. }
  864.  
  865.  
  866.  
  867. void imageStringInputFunction(){
  868.  
  869.   SDL_Rect  headerRect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
  870.   bool quit_this = false;
  871.   SDL_Event e1;
  872.   SDL_Color textColor ={0xFF,0xFF,0xFF};
  873.   SDL_Rect rectangleDraw = {(395*SCREEN_WIDTH)/2000, (290*SCREEN_HEIGHT)/1000, (1150*SCREEN_WIDTH)/2000, (50*SCREEN_HEIGHT)/1000};
  874.  
  875.   SDL_Texture* backTextureEntryIMG = loadTexture("data/imageNameEntry.png");
  876.   string inputText = "";
  877.   imageSavedString = "";
  878.  
  879.   SDL_StartTextInput();
  880.  
  881.   while( !quit_this )
  882.   {
  883.  
  884.     bool renderText = false;
  885.  
  886.  
  887.     while( SDL_PollEvent( &e1 ) != 0 )
  888.     {
  889.       if(e1.type == SDL_QUIT)
  890.       {
  891.         quit_this = true;
  892.  
  893.       }
  894.  
  895.        if( e1.type == SDL_KEYDOWN )
  896.       {
  897.         if( e1.key.keysym.sym == SDLK_RETURN )
  898.         {
  899.           quit_this = true;
  900.         }
  901.  
  902.         if( e1.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 )
  903.         {
  904.           inputText.pop_back();
  905.           renderText = true;
  906.         }
  907.  
  908.         if(e1.type == SDL_QUIT)
  909.         {
  910.           quit_this = true;
  911.  
  912.         }
  913.  
  914.       }
  915.       else if( e1.type == SDL_TEXTINPUT )
  916.       {
  917.         if( !( SDL_GetModState() & KMOD_CTRL && ( e1.text.text[ 0 ] == 'c' || e1.text.text[ 0 ] == 'C' || e1.text.text[ 0 ] == 'v' || e1.text.text[ 0 ] == 'V' ) ) )
  918.         {
  919.           inputText += e1.text.text;
  920.           renderText = true;
  921.         }
  922.       }
  923.     }
  924.  
  925.  
  926.     if( renderText )
  927.     {
  928.  
  929.       if( inputText != " " )
  930.       {
  931.  
  932.         header_text_input_texture.loadFromRenderedText( inputText.c_str(), hColor );
  933.       }
  934.  
  935.       else
  936.       {
  937.  
  938.         header_text_input_texture.loadFromRenderedText( " ", hColor );
  939.       }
  940.  
  941.     }
  942.  
  943.     SDL_SetRenderDrawColor( main_renderer, 0xFF, 0x00, 0x00, 0xFF );
  944.     SDL_RenderClear( main_renderer );
  945.  
  946.  
  947.     SDL_RenderSetViewport(main_renderer, &headerRect);
  948.  
  949.     SDL_RenderCopy(main_renderer, backTextureEntryIMG, NULL, NULL);
  950.  
  951.     SDL_RenderDrawRect(main_renderer, &rectangleDraw);
  952.     header_text_input_texture.render( (600*SCREEN_WIDTH)/2000,(300*SCREEN_HEIGHT)/1000 );
  953.  
  954.  
  955.     SDL_RenderPresent( main_renderer);
  956.   }
  957.  
  958.  
  959.   SDL_StopTextInput();
  960.   SDL_RenderClear( main_renderer );
  961.   imageSavedString = "./images/";
  962.   imageSavedString += inputText + ".png";
  963.   isThereAnyImageSavedToThisFile = true;
  964.   image_int = 300;
  965. }
  966.  
  967.  
  968.  
  969.  
  970.  
  971. void usernameStringInputFunction(){
  972.  
  973.   SDL_Rect  headerRect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
  974.   bool quit_this = false;
  975.   SDL_Event e1;
  976.   SDL_Color textColor ={0xFF,0xFF,0xFF};
  977.   SDL_Rect rectangleDraw = {(452*SCREEN_WIDTH)/2000, (392*SCREEN_HEIGHT)/1000, (1120*SCREEN_WIDTH)/2000, (102*SCREEN_HEIGHT)/1000};
  978.  
  979.   SDL_Texture* backTextureEntryIMG = loadTexture("data/enterUsernameScreen.png");
  980.   string inputText = "";
  981.   usernameString = "";
  982.  
  983.   SDL_StartTextInput();
  984.  
  985.   while( !quit_this )
  986.   {
  987.     if(e1.type == SDL_MOUSEBUTTONDOWN)
  988.     {
  989.       if( e1.button.x> (632*SCREEN_WIDTH)/2000 && e1.button.x < (1396*SCREEN_WIDTH)/2000 && e1.button.y > (768*SCREEN_HEIGHT)/1000 && e1.button.y < (881*SCREEN_HEIGHT)/1000)
  990.       {
  991.         usernameString = "Random Entry";
  992.         return;
  993.       }
  994.     }
  995.  
  996.     bool renderText = false;
  997.  
  998.  
  999.     while( SDL_PollEvent( &e1 ) != 0 )
  1000.     {
  1001.       if(e1.type == SDL_QUIT)
  1002.       {
  1003.         quit_this = true;
  1004.  
  1005.       }
  1006.  
  1007.        if( e1.type == SDL_KEYDOWN )
  1008.       {
  1009.         if( e1.key.keysym.sym == SDLK_RETURN )
  1010.         {
  1011.           quit_this = true;
  1012.         }
  1013.  
  1014.         if( e1.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 )
  1015.         {
  1016.           inputText.pop_back();
  1017.           renderText = true;
  1018.         }
  1019.  
  1020.         if(e1.type == SDL_QUIT)
  1021.         {
  1022.           quit_this = true;
  1023.  
  1024.         }
  1025.  
  1026.       }
  1027.       else if( e1.type == SDL_TEXTINPUT )
  1028.       {
  1029.         if( !( SDL_GetModState() & KMOD_CTRL && ( e1.text.text[ 0 ] == 'c' || e1.text.text[ 0 ] == 'C' || e1.text.text[ 0 ] == 'v' || e1.text.text[ 0 ] == 'V' ) ) )
  1030.         {
  1031.           inputText += e1.text.text;
  1032.           renderText = true;
  1033.         }
  1034.       }
  1035.     }
  1036.  
  1037.  
  1038.     if( renderText )
  1039.     {
  1040.  
  1041.       if( inputText != " " )
  1042.       {
  1043.  
  1044.         header_text_input_texture.loadFromRenderedText( inputText.c_str(), hColor );
  1045.       }
  1046.  
  1047.       else
  1048.       {
  1049.  
  1050.         header_text_input_texture.loadFromRenderedText( " ", hColor );
  1051.       }
  1052.  
  1053.     }
  1054.  
  1055.     SDL_SetRenderDrawColor( main_renderer, 0xFF, 0x00, 0x00, 0xFF );
  1056.     SDL_RenderClear( main_renderer );
  1057.  
  1058.  
  1059.     SDL_RenderSetViewport(main_renderer, &headerRect);
  1060.  
  1061.     SDL_RenderCopy(main_renderer, backTextureEntryIMG, NULL, NULL);
  1062.  
  1063.     //SDL_RenderDrawRect(main_renderer, &rectangleDraw);
  1064.     header_text_input_texture.render( (490*SCREEN_WIDTH)/2000, (425*SCREEN_HEIGHT)/1000 );
  1065.  
  1066.  
  1067.     SDL_RenderPresent( main_renderer);
  1068.   }
  1069.  
  1070.   SDL_StopTextInput();
  1071.   SDL_RenderClear( main_renderer );
  1072.   usernameString = "";
  1073.   usernameString += inputText;
  1074.  
  1075. }
  1076.  
  1077.  
  1078.  
  1079. void userNameInputFromUser(){
  1080.  
  1081.   SDL_Rect  headerRect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
  1082.   bool quit_this = false;
  1083.   SDL_Event e1;
  1084.   SDL_Color textColor ={0xFF,0xFF,0xFF};
  1085.   SDL_Rect rectangleDraw = {(452*SCREEN_WIDTH)/2000, (392*SCREEN_HEIGHT)/1000, (1120*SCREEN_WIDTH)/2000, (102*SCREEN_HEIGHT)/1000};
  1086.  
  1087.   SDL_Texture* backTextureEntryIMG = loadTexture("data/aarNameKhujePaitesinaTextureErJonno.png");
  1088.   string inputText = "";
  1089.  
  1090.   SDL_StartTextInput();
  1091.  
  1092.   while( !quit_this )
  1093.   {
  1094.     bool renderText = false;
  1095.  
  1096.  
  1097.     while( SDL_PollEvent( &e1 ) != 0 )
  1098.     {
  1099.       if(e1.type == SDL_QUIT)
  1100.       {
  1101.         quit_this = true;
  1102.  
  1103.       }
  1104.  
  1105.        if( e1.type == SDL_KEYDOWN )
  1106.       {
  1107.         if( e1.key.keysym.sym == SDLK_RETURN )
  1108.         {
  1109.           quit_this = true;
  1110.         }
  1111.  
  1112.         if( e1.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 )
  1113.         {
  1114.           inputText.pop_back();
  1115.           renderText = true;
  1116.         }
  1117.  
  1118.         if(e1.type == SDL_QUIT)
  1119.         {
  1120.           quit_this = true;
  1121.  
  1122.         }
  1123.  
  1124.       }
  1125.       else if( e1.type == SDL_TEXTINPUT )
  1126.       {
  1127.         if( !( SDL_GetModState() & KMOD_CTRL && ( e1.text.text[ 0 ] == 'c' || e1.text.text[ 0 ] == 'C' || e1.text.text[ 0 ] == 'v' || e1.text.text[ 0 ] == 'V' ) ) )
  1128.         {
  1129.           inputText += e1.text.text;
  1130.           renderText = true;
  1131.         }
  1132.       }
  1133.     }
  1134.  
  1135.  
  1136.     if( renderText )
  1137.     {
  1138.  
  1139.       if( inputText != " " )
  1140.       {
  1141.  
  1142.         header_text_input_texture.loadFromRenderedText( inputText.c_str(), hColor );
  1143.       }
  1144.  
  1145.       else
  1146.       {
  1147.  
  1148.         header_text_input_texture.loadFromRenderedText( " ", hColor );
  1149.       }
  1150.  
  1151.     }
  1152.  
  1153.     SDL_SetRenderDrawColor( main_renderer, 0xFF, 0x00, 0x00, 0xFF );
  1154.     SDL_RenderClear( main_renderer );
  1155.  
  1156.  
  1157.     SDL_RenderSetViewport(main_renderer, &headerRect);
  1158.  
  1159.     SDL_RenderCopy(main_renderer, backTextureEntryIMG, NULL, NULL);
  1160.  
  1161.     //SDL_RenderDrawRect(main_renderer, &rectangleDraw);
  1162.     header_text_input_texture.render( (490*SCREEN_WIDTH)/2000, (425*SCREEN_HEIGHT)/1000 );
  1163.  
  1164.  
  1165.     SDL_RenderPresent( main_renderer);
  1166.   }
  1167.  
  1168.   SDL_StopTextInput();
  1169.   SDL_RenderClear( main_renderer );
  1170.   oldEntryErJonnoUsernameString = "";
  1171.   oldEntryErJonnoUsernameString += "./users/";
  1172.   oldEntryErJonnoUsernameString += inputText;
  1173.   oldEntryErJonnoUsernameString += ".typo";
  1174.   usernameString = inputText;
  1175. }
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185. int main(int argn, char* args[])
  1186. {
  1187.     newl=mama_mia;
  1188.     //printf("%s %d\n",mama_mia,strlen(newl.c_str()) );
  1189.     image_int=0;
  1190.     search_int=60;
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.     int z=0,p=0,q,count=0,x=0,current_line=0,c=0,total_line=0,flag=0,backspace_check=0,length,side_count=0;
  1198.     int left_sign=0,indi_xpos,indi_xpos_width[1000],final_indi_xpos,huda,left_check,middle_backspace=0;
  1199.     int right_new_line=0,left_new_line=0,previous_line_indi_xpos=0,r_length,l_length,ctrl_count=0,all_select=0;
  1200.     int scroll_count=0,max_line=0,up_sign=0,total_length=0;
  1201.     char s[1001000],v[100][2002],ctemp[1000],char_temp,stemp[1000];
  1202.     int word_count = 0;
  1203.  
  1204.  
  1205.  
  1206.  
  1207.     //ABDULLAHS variable
  1208.     int overflow_check=0,full_length,line_temp=0,indi_pos_temp,left_sign_check=0,itemp=0,normal_mouse_tap_check=0;
  1209.    int selected_copy_ini_x,selected_copy_ini_y,selected_copy_final_x,selected_copy_final_y=0,selected_copy_check=0;
  1210.    int indicator_temp=0,lengthtemp;
  1211.    int ini_xpos,ini_ypos,final_xpos,final_ypos;
  1212.    int undo_redo_check=0, now_search = 1, search_length,search_count=-1;
  1213.    int c_l_temp,l_s_temp;
  1214.    char s2[1000], tchar[100];
  1215.    int view_int=0;
  1216.  
  1217.  
  1218.     //sprintf(date, "%d th October, %d", day, year);
  1219.  
  1220.  
  1221.     // Monon variables
  1222.     FILE *resumeFile = fopen("resume.typo","r+a");
  1223.     bool backGroundChooseBool = false;
  1224.  
  1225.  
  1226.  
  1227.  
  1228.     //std
  1229.  
  1230.  
  1231.             std::string inputText[101];
  1232.             std::string fulltext;
  1233.             std::string copyText[101];
  1234.             std::string sh;
  1235.             std::string itTemp;
  1236.  
  1237.  
  1238.  
  1239.     //selected rect
  1240.     SDL_Rect  s_ini;
  1241.     SDL_Rect  s_mid[100];
  1242.  
  1243.     SDL_Rect  s_fin;
  1244.     //search_rect[]
  1245.     SDL_Rect s_bar[1000];
  1246.  
  1247.     //search rect
  1248.     SDL_Rect  search_rect = {0, SCREEN_HEIGHT-3, SCREEN_WIDTH,-60};
  1249.  
  1250.     SDL_Rect  topMenuRect1 = {0, 0, SCREEN_WIDTH/20, (25*SCREEN_HEIGHT)/1000};
  1251.     SDL_Rect  topMenuRect2 = {(20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20), 0, SCREEN_WIDTH/20, (25*SCREEN_HEIGHT)/1000};
  1252.     SDL_Rect  topMenuRect3 = {(40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10), 0, (70*SCREEN_WIDTH)/2000+(SCREEN_WIDTH/20), (25*SCREEN_HEIGHT)/1000};
  1253.     SDL_Rect  topMenuRect4 = {(440*SCREEN_WIDTH)/2000, (5*SCREEN_HEIGHT)/1000, (210*SCREEN_WIDTH)/2000, (20*SCREEN_HEIGHT)/1000};
  1254.     SDL_Rect  textBackgroundRect = {0,25, SCREEN_WIDTH, SCREEN_HEIGHT };
  1255.     SDL_Rect  newMenuRect = {0, (25*SCREEN_HEIGHT)/1000, (200*SCREEN_WIDTH)/2000, (300*SCREEN_HEIGHT)/1000};
  1256.     SDL_Rect  viewMenuRect = {(20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20), (25*SCREEN_HEIGHT)/1000, (200*SCREEN_WIDTH)/2000, (300*SCREEN_HEIGHT)/1000 };
  1257.     SDL_Rect  preferenceMenuRect = {(40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10), (25*SCREEN_HEIGHT)/1000, (200*SCREEN_WIDTH)/2000, (300*SCREEN_HEIGHT)/1000  };
  1258.     SDL_Rect  screenImageRect = {(400*SCREEN_WIDTH)/2000, (100*SCREEN_HEIGHT)/1000, (800*SCREEN_WIDTH)/2000, (500*SCREEN_HEIGHT)/1000 };
  1259.     SDL_Rect  timeViewRect = {(1700*SCREEN_WIDTH)/2000, (33*SCREEN_HEIGHT)/1000, (200*SCREEN_WIDTH)/2000, (25*SCREEN_HEIGHT)/1000};
  1260.     SDL_Rect  timeViewRect2 = {(1700*SCREEN_WIDTH)/2000, (SCREEN_HEIGHT*60)/1000, (180*SCREEN_WIDTH)/2000, (20*SCREEN_HEIGHT)/1000};
  1261.     SDL_Rect closeWithoutSavingRect = {(SCREEN_WIDTH/3), SCREEN_HEIGHT/3, SCREEN_WIDTH/4, SCREEN_HEIGHT/4};
  1262.     bool newMenuBool = false, viewMenuBool = false, preferenceMenuBool = false, closeWithoutSavingBool = false;
  1263.     bool screenImagebool = false, saveHoiseBool = false, clickToChooseMusicBool = false;
  1264.     SDL_Rect entrySavedSuccessfullyRect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
  1265.     SDL_Rect backGroundChooseRect = {(400*SCREEN_WIDTH)/2000, (100*SCREEN_HEIGHT)/1000, (800*SCREEN_WIDTH)/2000, (600*SCREEN_HEIGHT)/1000};
  1266.  
  1267.        //stack
  1268.         stack<string> old_s;
  1269.         stack<int> old_l;
  1270.         stack<int> old_x;
  1271.         stack<string> new_s;
  1272.         stack<int> new_l;
  1273.         stack<int> new_x;
  1274.     int interationForKontaFont = 0;
  1275.  
  1276.  
  1277.  
  1278. ///
  1279.         SDL_Rect imageShownRect = { (500*SCREEN_WIDTH)/2000, (28*SCREEN_HEIGHT)/1000, (700*SCREEN_WIDTH)/2000, (330*SCREEN_HEIGHT)/1000 };
  1280.         bool ekbarImageLoadErJonnoBool = false;
  1281.         SDL_Rect usernameViewRect = {(30*SCREEN_WIDTH)/2000, (SCREEN_HEIGHT*40)/1000, (150*SCREEN_WIDTH)/2000, (25*SCREEN_HEIGHT)/1000};
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.     if(!init()) printf("Failed to initialize/n");
  1292.     else
  1293.     {
  1294.         if(!loadMedia()) printf("Failed to load media\n");
  1295.         else
  1296.         {
  1297.  
  1298.  
  1299.  
  1300.  
  1301.           //file open ba save er kaaaj
  1302.  
  1303.  
  1304.           //initially shob kisu null kora
  1305.           for(int i=0;i<=total_line;i++)
  1306.           {
  1307.             inputText[i]="a";
  1308.             inputText[i].pop_back();
  1309.           }
  1310.           total_line=0;
  1311.           current_line=0;
  1312.           FILE *oldEntryFIle = fopen("allEntries.typo", "a");
  1313.                 //file theke string e newa
  1314.  
  1315.       char fullFile[100000];
  1316.       std::string fullString;
  1317.       fullString = "a";
  1318.       fullString.pop_back();
  1319.       FILE *resume = fopen("./saved/resume.typo","r+a");
  1320.       while(fgets(fullFile, sizeof(fullFile),resume)!=NULL){
  1321.         fullString+= fullFile;
  1322.       }
  1323.       fullString.pop_back();
  1324.  
  1325.       //string theke character array te newa
  1326.  
  1327.       full_length=strlen(fullString.c_str());
  1328.  
  1329.       for(int i=0;i<full_length;i++)
  1330.       {
  1331.         stemp[i]=fullString.c_str()[i];
  1332.       }
  1333.       stemp[full_length]=0;
  1334.       //printf("%s\n",stemp );
  1335.  
  1336.  
  1337.     //character array theke input text e newa &&render
  1338.  
  1339.  
  1340.       count=0;
  1341.       for(int i=0; i<full_length; i++)
  1342.       {
  1343.  
  1344.           if(stemp[i]=='\n')stemp[i]=3;
  1345.           if(stemp[i]==3&&i<full_length-1)
  1346.           {
  1347.  
  1348.             ctemp[count]=3;
  1349.             ctemp[count+1]=0;
  1350.             sh=ctemp;
  1351.  
  1352.  
  1353.             inputText[current_line]=sh;
  1354.               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1355.  
  1356.  
  1357.             current_line++;
  1358.             total_line++;
  1359.             count=0;
  1360.             continue;
  1361.           }
  1362.           ctemp[count]=stemp[i];
  1363.           count++;
  1364.           ctemp[count]=0;
  1365.  
  1366.           sh=ctemp;
  1367.           if(i==full_length-1)
  1368.           {
  1369.               inputText[current_line]=sh;
  1370.               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1371.           }
  1372.           Ltemp.loadFromRenderedText( sh, textColor );
  1373.           if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1374.           {
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.               if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  1383.               {
  1384.  
  1385.                   word_count=0;
  1386.                   for(int j=count-1; j>=0; j--)
  1387.                   {
  1388.                       if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  1389.                       word_count++;
  1390.                   }
  1391.  
  1392.                   if(word_count<(count-1))
  1393.                   {
  1394.  
  1395.                       ctemp[count-1-word_count+1]=0;
  1396.  
  1397.  
  1398.                       inputText[current_line]=ctemp;
  1399.  
  1400.                       i=i-word_count;
  1401.  
  1402.  
  1403.                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1404.                   }
  1405.  
  1406.                   else
  1407.                   {
  1408.                       inputText[current_line]=sh;
  1409.                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1410.                   }
  1411.  
  1412.  
  1413.               }
  1414.               else
  1415.               {
  1416.                   inputText[current_line]=sh;
  1417.                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1418.               }
  1419.  
  1420.  
  1421.  
  1422.               current_line++;
  1423.               total_line++;
  1424.               inputText[total_line]="@";
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.               count=0;
  1431.               //inputText[current_line].pop_back();
  1432.  
  1433.  
  1434.           }
  1435.           else
  1436.           {
  1437.             inputText[current_line]=sh;
  1438.               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1439.           }
  1440.           left_sign=0;
  1441.  
  1442.           }
  1443.  
  1444.             //clock
  1445.  
  1446.             char show_time[100];
  1447.  
  1448.  
  1449.  
  1450.  
  1451.             bool firstWindowShowFuntionFlag = false;
  1452.             if(!firstWindowShowFuntionFlag) firstWindowShowFuntion();
  1453.             usernameStringInputFunction();
  1454.             bool quit = false;
  1455.             SDL_Event e;
  1456.  
  1457.  
  1458.             string tempu3=" ";
  1459.             tempu3 = "Username:  ";
  1460.             tempu3 += usernameString;
  1461.             usernameViewRect.w = 10*tempu3.size();
  1462.  
  1463.  
  1464.             SDL_StartTextInput();
  1465.  
  1466.  
  1467.  
  1468.             while(!quit)
  1469.             {
  1470.  
  1471.                 bool renderText = false;
  1472.  
  1473.                 while(SDL_PollEvent(&e)!=0)
  1474.                 {
  1475.                     if(view_int==1)
  1476.                         {
  1477.                             view_int=0;
  1478.  
  1479.  
  1480.                                   fullString = "a";
  1481.                                   fullString.pop_back();
  1482.                                     //initially shob kisu null kora
  1483.                                   for(int i=0;i<=total_line;i++)
  1484.                                   {
  1485.                                     fullString+=inputText[i];
  1486.                                     inputText[i]="a";
  1487.                                     inputText[i].pop_back();
  1488.                                   }
  1489.                                   total_line=0;
  1490.                                   current_line=0;
  1491.  
  1492.  
  1493.  
  1494.                                   //string theke character array te newa
  1495.  
  1496.                                   full_length=strlen(fullString.c_str());
  1497.  
  1498.                                   for(int i=0;i<full_length;i++)
  1499.                                   {
  1500.                                     stemp[i]=fullString.c_str()[i];
  1501.                                   }
  1502.                                   stemp[full_length]=0;
  1503.  
  1504.  
  1505.                                 //character array theke input text e newa &&render
  1506.  
  1507.  
  1508.                                   count=0;
  1509.                                   for(int i=0; i<full_length; i++)
  1510.                                       {
  1511.  
  1512.                                           if(stemp[i]=='\n')stemp[i]=3;
  1513.                                           if(stemp[i]==3&&i<full_length-1)
  1514.                                           {
  1515.  
  1516.  
  1517.                                                 ctemp[count]=3;
  1518.                                                 ctemp[count+1]=0;
  1519.                                                 sh=ctemp;
  1520.  
  1521.  
  1522.                                                 inputText[current_line]=sh;
  1523.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1524.  
  1525.  
  1526.                                                 current_line++;
  1527.                                                 total_line++;
  1528.                                                 count=0;
  1529.                                                 continue;
  1530.                                           }
  1531.                                           ctemp[count]=stemp[i];
  1532.                                           count++;
  1533.                                           ctemp[count]=0;
  1534.  
  1535.                                           sh=ctemp;
  1536.                                           if(i==full_length-1)
  1537.                                           {
  1538.                                               inputText[current_line]=sh;
  1539.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1540.                                           }
  1541.                                           Ltemp.loadFromRenderedText( sh, textColor );
  1542.                                           if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1543.                                           {
  1544.  
  1545.                                               if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  1546.                                               {
  1547.  
  1548.                                                   word_count=0;
  1549.                                                   for(int j=count-1; j>=0; j--)
  1550.                                                   {
  1551.                                                       if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  1552.                                                       word_count++;
  1553.                                                   }
  1554.  
  1555.                                                   if(word_count<(count-1))
  1556.                                                   {
  1557.  
  1558.                                                       ctemp[count-1-word_count+1]=0;
  1559.  
  1560.  
  1561.                                                       inputText[current_line]=ctemp;
  1562.  
  1563.                                                       i=i-word_count;
  1564.  
  1565.  
  1566.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1567.                                                   }
  1568.  
  1569.                                                   else
  1570.                                                   {
  1571.                                                       inputText[current_line]=sh;
  1572.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1573.                                                   }
  1574.  
  1575.                                               }
  1576.                                               else
  1577.                                               {
  1578.                                                   inputText[current_line]=sh;
  1579.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1580.                                               }
  1581.                                               current_line++;
  1582.                                               total_line++;
  1583.                                               inputText[total_line]="@";
  1584.                                               count=0;
  1585.                                               //inputText[current_line].pop_back();
  1586.                                           }
  1587.                                           else
  1588.                                           {
  1589.                                             inputText[current_line]=sh;
  1590.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1591.                                           }
  1592.  
  1593.  
  1594.                                     }
  1595.  
  1596.  
  1597.                           }
  1598.  
  1599.                   // if(e.type == SDL_MOUSEMOTION){
  1600.                   //    printf("%d %d\n", e.button.x, e.button.y);
  1601.                   //   if( (e.button.x>0)&&(e.button.x<(SCREEN_WIDTH/20))&&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000))
  1602.                   //   {
  1603.                   //     SDL_RenderSetViewport(main_renderer, &newMenuRect);
  1604.                   //     SDL_RenderCopy(main_renderer, selectionImageTexture, NULL, NULL);
  1605.                   //     SDL_RenderPresent(main_renderer);
  1606.                   //   }
  1607.                   // }
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.                     if(e.type == SDL_MOUSEBUTTONDOWN)
  1617.                     {
  1618.  
  1619.                         printf("%d %d\n", e.button.x, e.button.y);
  1620.  
  1621.                         selected_copy_check=0;
  1622.                         if(e.button.y>SCREEN_HEIGHT-search_int)
  1623.                         {
  1624.                             l_s_temp=left_sign;
  1625.                             c_l_temp=current_line;
  1626.                             current_line=100;
  1627.                             left_sign=0;
  1628.                             search_bar_bool=true;
  1629.                         }
  1630.  
  1631.                         else if(e.button.y<SCREEN_HEIGHT-search_int)
  1632.                         {
  1633.                             search_bar_bool=false;
  1634.  
  1635.                         }
  1636.                         if( (e.button.x>0)&&(e.button.x<(SCREEN_WIDTH/20))&&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000) && newMenuBool==false)
  1637.                         {
  1638.                             newMenuBool = true;
  1639.                             viewMenuBool = false;
  1640.                             preferenceMenuBool = false;
  1641.                         }
  1642.  
  1643.                         else if(screenImagebool && !(e.button.x > 400 && e.button.y > 100 && e.button.x < 1200 && e.button.y < 600)){
  1644.                           screenImagebool = false;
  1645.                         }
  1646.  
  1647.  
  1648.  
  1649.                         else if( (e.button.x>0)&&(e.button.x<(SCREEN_WIDTH/20))&&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000) && newMenuBool==true)
  1650.                         {
  1651.                             newMenuBool = false;
  1652.                         }
  1653.  
  1654.  
  1655.                         else if( (e.button.x>((20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20)) && (e.button.x<((20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20))+SCREEN_WIDTH/20)) &&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000) && viewMenuBool==false)
  1656.                         {
  1657.                             viewMenuBool = true;
  1658.                             newMenuBool = false;
  1659.                             preferenceMenuBool = false;
  1660.                         }
  1661.  
  1662.                         else if( (e.button.x>((20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20)) && (e.button.x<((20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20))+SCREEN_WIDTH/20)) &&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT/1000)) && viewMenuBool==true)
  1663.                         {
  1664.                             viewMenuBool = false;
  1665.                         }
  1666.  
  1667.  
  1668.  
  1669.                         else if( e.button.x>((40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10)) && (e.button.x<((40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10))+(70*SCREEN_WIDTH)/2000+(SCREEN_WIDTH/20)) &&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000) && preferenceMenuBool==false)
  1670.                         {
  1671.                             preferenceMenuBool = true;
  1672.                             viewMenuBool = false;
  1673.                             newMenuBool = false;
  1674.                         }
  1675.  
  1676.                         else if(  e.button.x>((40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10)) && (e.button.x<((40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10))+(70*SCREEN_WIDTH)/2000+(SCREEN_WIDTH/20)) &&(e.button.y>0)&&(e.button.y<(25*SCREEN_HEIGHT)/1000) && preferenceMenuBool==true)
  1677.                         {
  1678.                             preferenceMenuBool = false;
  1679.                         }
  1680.                         else if( newMenuBool && (e.button.x > (10*SCREEN_WIDTH)/2000 && e.button.x < (190*SCREEN_WIDTH)/2000 && e.button.y > (57*SCREEN_HEIGHT)/1000 && e.button.y < (115*SCREEN_HEIGHT)/1000)){
  1681.                           newMenuBool = false;
  1682.                           //file open ba save er kaaaj
  1683.                           isThereAnyImageSavedToThisFile = false;
  1684.                           showImageTexture = NULL;
  1685.                           image_int = 0;
  1686.                           //initially shob kisu null kora
  1687.                           for(int i=0;i<=total_line;i++)
  1688.                           {
  1689.                             inputText[i]="a";
  1690.                             inputText[i].pop_back();
  1691.                           }
  1692.                           total_line=0;
  1693.                           current_line=0;
  1694.                           char fullFile[100000];
  1695.                           std::string fullString;
  1696.                           fullString = " ";
  1697.                           fullString.pop_back();
  1698.                           SDL_RenderClear(main_renderer);
  1699.                           FILE *resume = fopen("./saved/fakaFile.typo","w");
  1700.                           while(fgets(fullFile, sizeof(fullFile),resume)!=NULL){
  1701.                             fullString+= fullFile;
  1702.                           }
  1703.                           fullString.pop_back();
  1704. mama
  1705.  
  1706.                           //string theke character array te newa
  1707.  
  1708.                           full_length=strlen(fullString.c_str());
  1709.  
  1710.                           for(int i=0;i<full_length;i++)
  1711.                           {
  1712.                             stemp[i]=fullString.c_str()[i];
  1713.                           }
  1714.                           stemp[full_length]=0;
  1715.  
  1716.  
  1717.                         //character array theke input text e newa &&render
  1718.  
  1719.  
  1720.                           count=0;
  1721.                           for(int i=0; i<full_length; i++)
  1722.                           {
  1723.  
  1724.                               if(stemp[i]=='\n')stemp[i]=3;
  1725.                               if(stemp[i]==3&&i<full_length-1)
  1726.                               {
  1727.  
  1728.  
  1729.                                     ctemp[count]=3;
  1730.                                     ctemp[count+1]=0;
  1731.                                     sh=ctemp;
  1732.  
  1733.  
  1734.                                     inputText[current_line]=sh;
  1735.                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1736.  
  1737.  
  1738.                                     current_line++;
  1739.                                     total_line++;
  1740.                                     count=0;
  1741.                                     continue;
  1742.                               }
  1743.                               ctemp[count]=stemp[i];
  1744.                               count++;
  1745.                               ctemp[count]=0;
  1746.  
  1747.                               sh=ctemp;
  1748.                               if(i==full_length-1)
  1749.                               {
  1750.                                   inputText[current_line]=sh;
  1751.                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1752.                               }
  1753.                               Ltemp.loadFromRenderedText( sh, textColor );
  1754.                               if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1755.                               {
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.                                   if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  1764.                                   {
  1765.  
  1766.                                       word_count=0;
  1767.                                       for(int j=count-1; j>=0; j--)
  1768.                                       {
  1769.                                           if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  1770.                                           word_count++;
  1771.                                       }
  1772.  
  1773.                                       if(word_count<(count-1))
  1774.                                       {
  1775.  
  1776.                                           ctemp[count-1-word_count+1]=0;
  1777.  
  1778.  
  1779.                                           inputText[current_line]=ctemp;
  1780.  
  1781.                                           i=i-word_count;
  1782.  
  1783.  
  1784.                                           mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1785.                                       }
  1786.  
  1787.                                       else
  1788.                                       {
  1789.                                           inputText[current_line]=sh;
  1790.                                           mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1791.                                       }
  1792.  
  1793.  
  1794.                                   }
  1795.                                   else
  1796.                                   {
  1797.                                       inputText[current_line]=sh;
  1798.                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1799.                                   }
  1800.  
  1801.  
  1802.                                   current_line++;
  1803.                                   total_line++;
  1804.                                   inputText[total_line]="@";
  1805.  
  1806.                                   count=0;
  1807.                                   //inputText[current_line].pop_back();
  1808.  
  1809.  
  1810.                               }
  1811.                               else
  1812.                               {
  1813.                                 inputText[current_line]=sh;
  1814.                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1815.                               }
  1816.                               left_sign=0;
  1817.  
  1818.                             }
  1819.  
  1820.  
  1821.                         }
  1822.  
  1823.  
  1824.  
  1825.  
  1826.                         else if( e.button.x> (123*SCREEN_WIDTH)/2000 && e.button.x < (319*SCREEN_WIDTH)/2000 && e.button.y > (81*SCREEN_HEIGHT)/1000 && e.button.y < (153*SCREEN_HEIGHT)/1000 && viewMenuBool==true)
  1827.                         {
  1828.                             backGroundChooseBool = true;
  1829.                             viewMenuBool = false;
  1830.                             view_int=1;
  1831.                         }
  1832.  
  1833.  
  1834.                         else if(backGroundChooseBool && e.button.x > (499*SCREEN_WIDTH)/2000 && e.button.y > (309*SCREEN_HEIGHT)/1000 && e.button.x < (645*SCREEN_WIDTH)/2000 && e.button.y < (420*SCREEN_HEIGHT)/1000){
  1835.                           backGroundChooseBool = false;
  1836.                           loadbackground_texture(1);
  1837.                           view_int=1;
  1838.                         }
  1839.  
  1840.                         else if(backGroundChooseBool && e.button.x > (736*SCREEN_WIDTH)/2000 && e.button.y > (307*SCREEN_HEIGHT)/1000 && e.button.x < (881*SCREEN_WIDTH)/2000 && e.button.y < (416*SCREEN_HEIGHT)/1000){
  1841.                           backGroundChooseBool = false;
  1842.                           loadbackground_texture(2);
  1843.                           view_int=1;
  1844.                         }
  1845.  
  1846.  
  1847.                         else if(backGroundChooseBool && e.button.x > (963*SCREEN_WIDTH)/2000 && e.button.y > (307*SCREEN_HEIGHT)/1000 && e.button.x < (1111*SCREEN_WIDTH)/2000 && e.button.y < (416*SCREEN_HEIGHT)/1000){
  1848.                           backGroundChooseBool = false;
  1849.                           loadbackground_texture(3);
  1850.                           view_int=1;
  1851.                         }
  1852.  
  1853.                         else if(backGroundChooseBool && e.button.x > (507*SCREEN_WIDTH)/2000 && e.button.y > (561*SCREEN_HEIGHT)/1000 && e.button.x < (643*SCREEN_WIDTH)/2000 && e.button.y < (665*SCREEN_HEIGHT)/1000){
  1854.                           backGroundChooseBool = false;
  1855.                           loadbackground_texture(4);
  1856.                           view_int=1;
  1857.                         }
  1858.  
  1859.                         else if(backGroundChooseBool && e.button.x > (734*SCREEN_WIDTH)/2000 && e.button.y > (560*SCREEN_HEIGHT)/1000 && e.button.x < (873*SCREEN_WIDTH)/2000 && e.button.y < (663*SCREEN_HEIGHT)/1000){
  1860.                           backGroundChooseBool = false;
  1861.                           background_texture = loadTexture("data/green_back.png");
  1862.  
  1863.                         }
  1864.  
  1865.  
  1866.                         else if(backGroundChooseBool && e.button.x > (967*SCREEN_WIDTH)/2000 && e.button.y > (563*SCREEN_HEIGHT)/1000 && e.button.x < (1112*SCREEN_WIDTH)/2000 && e.button.y < (669*SCREEN_HEIGHT)/1000){
  1867.                           backGroundChooseBool = false;
  1868.                           loadbackground_texture(6);
  1869.                           view_int=1;
  1870.                         }
  1871.  
  1872.  
  1873.  
  1874.  
  1875.                         else if( e.button.x> (125*SCREEN_WIDTH)/2000 && e.button.x < (313*SCREEN_WIDTH)/2000 && e.button.y > (209*SCREEN_HEIGHT)/1000 && e.button.y < (261*SCREEN_HEIGHT)/1000 && viewMenuBool==true)
  1876.                         {
  1877.                             interationForKontaFont++;
  1878.                             interationForKontaFont %= 4;
  1879.                             loadFont(interationForKontaFont);
  1880.                         }
  1881.  
  1882.                         else if( e.button.x> (443*SCREEN_WIDTH)/2000 && e.button.x < (648*SCREEN_WIDTH)/2000 && e.button.y > (5*SCREEN_HEIGHT)/1000 && e.button.y < (22*SCREEN_HEIGHT)/1000)
  1883.                         {
  1884.                           userNameInputFromUser();
  1885.                           SDL_StartTextInput();
  1886.  
  1887.  
  1888.                           //initially shob kisu null kora
  1889.                           for(int i=0;i<=total_line;i++)
  1890.                           {
  1891.                             inputText[i]="a";
  1892.                             inputText[i].pop_back();
  1893.                           }
  1894.                           total_line=0;
  1895.                           current_line=0;
  1896.  
  1897.                                 char fullFile[100000];
  1898.                                 std::string fullString;
  1899.                                 fullString = "a";
  1900.                                 fullString.pop_back();
  1901.                                 SDL_RenderClear(main_renderer);
  1902.                                 FILE *resume = fopen(oldEntryErJonnoUsernameString.c_str(),"a+r");
  1903.                                 while(fgets(fullFile, sizeof(fullFile),resume)!=NULL){
  1904.                                   fullString+= fullFile;
  1905.                                 }
  1906.                                 fullString.pop_back();
  1907.  
  1908.                                 //string theke character array te newa
  1909.  
  1910.                                 full_length=strlen(fullString.c_str());
  1911.  
  1912.                                 for(int i=0;i<full_length;i++)
  1913.                                 {
  1914.                                     stemp[i]=fullString.c_str()[i];
  1915.                                 }
  1916.                                 stemp[full_length]=0;
  1917.                                 //printf("%s\n",stemp );
  1918.  
  1919.  
  1920.                               //character array theke input text e newa &&render
  1921.  
  1922.  
  1923.                                 count=0;
  1924.                                 for(int i=0; i<full_length; i++)
  1925.                                 {
  1926.  
  1927.                                     if(stemp[i]=='\n')stemp[i]=3;
  1928.                                     if(stemp[i]==3&&i<full_length-1)
  1929.                                     {
  1930.  
  1931.                                         ctemp[count]=3;
  1932.                                         ctemp[count+1]=0;
  1933.                                         sh=ctemp;
  1934.  
  1935.  
  1936.                                         inputText[current_line]=sh;
  1937.                                           mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1938.  
  1939.  
  1940.                                         current_line++;
  1941.                                         total_line++;
  1942.                                         count=0;
  1943.                                         continue;
  1944.                                     }
  1945.                                     ctemp[count]=stemp[i];
  1946.                                     count++;
  1947.                                     ctemp[count]=0;
  1948.  
  1949.                                     sh=ctemp;
  1950.                                     if(i==full_length-1)
  1951.                                     {
  1952.                                         inputText[current_line]=sh;
  1953.                                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1954.                                     }
  1955.                                     Ltemp.loadFromRenderedText( sh, textColor );
  1956.                                     if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1957.                                     {
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.                                         if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  1966.                                         {
  1967.  
  1968.                                             word_count=0;
  1969.                                             for(int j=count-1; j>=0; j--)
  1970.                                             {
  1971.                                                 if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  1972.                                                 word_count++;
  1973.                                             }
  1974.  
  1975.                                             if(word_count<(count-1))
  1976.                                             {
  1977.  
  1978.                                                 ctemp[count-1-word_count+1]=0;
  1979.  
  1980.  
  1981.                                                 inputText[current_line]=ctemp;
  1982.  
  1983.                                                 i=i-word_count;
  1984.  
  1985.  
  1986.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1987.                                             }
  1988.  
  1989.                                             else
  1990.                                             {
  1991.                                                 inputText[current_line]=sh;
  1992.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1993.                                             }
  1994.  
  1995.  
  1996.                                         }
  1997.                                         else
  1998.                                         {
  1999.                                             inputText[current_line]=sh;
  2000.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2001.                                         }
  2002.  
  2003.  
  2004.  
  2005.                                         current_line++;
  2006.                                         total_line++;
  2007.                                         inputText[total_line]="@";
  2008.  
  2009. \
  2010.                                         count=0;
  2011.                                         //inputText[current_line].pop_back();
  2012.  
  2013.  
  2014.                                     }
  2015.                                     else
  2016.                                     {
  2017.                                         inputText[current_line]=sh;
  2018.                                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2019.                                     }
  2020.                                     left_sign=0;
  2021.  
  2022.                                   }
  2023.                                   isThereAnyImageSavedToThisFile = false;
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.                         }
  2035.  
  2036.  
  2037.                         else if(preferenceMenuBool && ((e.button.x > (40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10)+(200*SCREEN_WIDTH)/2000)||(e.button.x < (40*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/10))|| e.button.y > (320*SCREEN_HEIGHT)/1000))
  2038.                         {
  2039.                             preferenceMenuBool = false;
  2040.                         }
  2041.  
  2042.                         else if( newMenuBool && ((e.button.x > (200*SCREEN_WIDTH)/2000)||(e.button.y > (320*SCREEN_HEIGHT)/1000)))
  2043.                         {
  2044.                             newMenuBool = false;
  2045.                         }
  2046.  
  2047.                         else if(viewMenuBool && ((e.button.x<(20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20))||(e.button.x > (20*SCREEN_WIDTH)/2000+ (SCREEN_WIDTH/20) + (200*SCREEN_WIDTH)/2000)||(e.button.y > (320*SCREEN_HEIGHT)/1000)) )
  2048.                         {
  2049.                             viewMenuBool = false;
  2050.                         }
  2051.  
  2052.                         else if(newMenuBool==true && !saveHoiseBool && (e.button.x > (10*SCREEN_WIDTH)/2000 && e.button.x < (193*SCREEN_WIDTH)/2000 && e.button.y > (265*SCREEN_HEIGHT)/1000 && e.button.y < (316*SCREEN_HEIGHT)/1000))
  2053.                         {
  2054.                           closeWithoutSavingBool = true;
  2055.                           newMenuBool = false;
  2056.                           viewMenuBool = false;
  2057.                           preferenceMenuBool = false;
  2058.                         }
  2059.  
  2060.                         else if(newMenuBool && (e.button.x > (4*SCREEN_WIDTH)/2000 && e.button.x < (197*SCREEN_WIDTH)/2000 && e.button.y > (189*SCREEN_HEIGHT)/1000 && e.button.y < (255*SCREEN_HEIGHT)/1000))
  2061.                         {
  2062.                           newMenuBool = false;
  2063.                           seeOldEntryFunction();
  2064.                           //file open ba save er kaaaj
  2065.  
  2066.                           //initially shob kisu null kora
  2067.                           for(int i=0;i<=total_line;i++)
  2068.                           {
  2069.                             inputText[i]="a";
  2070.                             inputText[i].pop_back();
  2071.                           }
  2072.                           total_line=0;
  2073.                           current_line=0;
  2074.  
  2075.                                 char fullFile[100000];
  2076.                                 std::string fullString;
  2077.                                 fullString = "a";
  2078.                                 fullString.pop_back();
  2079.                                 SDL_RenderClear(main_renderer);
  2080.                                 FILE *resume = fopen(oldEntryInput.c_str(),"a+r");
  2081.                                 while(fgets(fullFile, sizeof(fullFile),resume)!=NULL){
  2082.                                   fullString+= fullFile;
  2083.                                 }
  2084.                                 fullString.pop_back();
  2085.  
  2086.                                 //string theke character array te newa
  2087.  
  2088.                                 full_length=strlen(fullString.c_str());
  2089.  
  2090.                                 for(int i=0;i<full_length;i++)
  2091.                                 {
  2092.                                     stemp[i]=fullString.c_str()[i];
  2093.                                 }
  2094.                                 stemp[full_length]=0;
  2095.                                 //printf("%s\n",stemp );
  2096.  
  2097.  
  2098.                               //character array theke input text e newa &&render
  2099.  
  2100.  
  2101.                                 count=0;
  2102.                                 for(int i=0; i<full_length; i++)
  2103.                                 {
  2104.  
  2105.                                     if(stemp[i]=='\n')stemp[i]=3;
  2106.                                     if(stemp[i]==3&&i<full_length-1)
  2107.                                     {
  2108.  
  2109.                                         ctemp[count]=3;
  2110.                                         ctemp[count+1]=0;
  2111.                                         sh=ctemp;
  2112.  
  2113.  
  2114.                                         inputText[current_line]=sh;
  2115.                                           mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2116.  
  2117.  
  2118.                                         current_line++;
  2119.                                         total_line++;
  2120.                                         count=0;
  2121.                                         continue;
  2122.                                     }
  2123.                                     ctemp[count]=stemp[i];
  2124.                                     count++;
  2125.                                     ctemp[count]=0;
  2126.  
  2127.                                     sh=ctemp;
  2128.                                     if(i==full_length-1)
  2129.                                     {
  2130.                                         inputText[current_line]=sh;
  2131.                                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2132.                                     }
  2133.                                     Ltemp.loadFromRenderedText( sh, textColor );
  2134.                                     if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  2135.                                     {
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.                                         if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  2144.                                         {
  2145.  
  2146.                                             word_count=0;
  2147.                                             for(int j=count-1; j>=0; j--)
  2148.                                             {
  2149.                                                 if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  2150.                                                 word_count++;
  2151.                                             }
  2152.  
  2153.                                             if(word_count<(count-1))
  2154.                                             {
  2155.  
  2156.                                                 ctemp[count-1-word_count+1]=0;
  2157.  
  2158.  
  2159.                                                 inputText[current_line]=ctemp;
  2160.  
  2161.                                                 i=i-word_count;
  2162.  
  2163.  
  2164.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2165.                                             }
  2166.  
  2167.                                             else
  2168.                                             {
  2169.                                                 inputText[current_line]=sh;
  2170.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2171.                                             }
  2172.  
  2173.  
  2174.                                         }
  2175.                                         else
  2176.                                         {
  2177.                                             inputText[current_line]=sh;
  2178.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2179.                                         }
  2180.  
  2181.  
  2182.  
  2183.                                         current_line++;
  2184.                                         total_line++;
  2185.                                         inputText[total_line]="@";
  2186.  
  2187. \
  2188.                                         count=0;
  2189.                                         //inputText[current_line].pop_back();
  2190.  
  2191.  
  2192.                                     }
  2193.                                     else
  2194.                                     {
  2195.                                         inputText[current_line]=sh;
  2196.                                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2197.                                     }
  2198.                                     left_sign=0;
  2199.  
  2200.                                   }
  2201.                                   isThereAnyImageSavedToThisFile = false;
  2202.                                   ekbarImageLoadErJonnoBool = false;
  2203.                                   imageSavedString = "";
  2204.  
  2205.  
  2206.  
  2207.                                   FILE *imageShowFIle = fopen("imagesPlusFile.typo","r");
  2208.                                   char tempstr[100];
  2209.  
  2210.                                   while(fscanf(imageShowFIle, "%s", tempstr)!=EOF){
  2211.                                     if(!strcmp(oldEntryInput.c_str(),tempstr)){
  2212.                                       memset(tempstr, 0, sizeof(tempstr));
  2213.                                       fscanf(imageShowFIle, "%s", tempstr);
  2214.  
  2215.  
  2216.                                       for(int g=0; g<strlen(tempstr); g++){
  2217.                                         imageSavedString[g] = tempstr[g];
  2218.                                       }
  2219.  
  2220.                                       isThereAnyImageSavedToThisFile = true;
  2221.                                       image_int = 300;
  2222.  
  2223.  
  2224.                                     }
  2225.                                     else{
  2226.                                       memset(tempstr, 0, sizeof(tempstr));
  2227.                                       fscanf(imageShowFIle, "%s", tempstr);
  2228.                                     }
  2229.  
  2230.                                   }
  2231.  
  2232.  
  2233.                         }
  2234.  
  2235.                         else if(saveHoiseBool && newMenuBool==true &&  (e.button.x > (10*SCREEN_WIDTH)/2000 && e.button.x < (193*SCREEN_WIDTH)/2000 && e.button.y > (265*SCREEN_HEIGHT)/1000 && e.button.y < (316*SCREEN_HEIGHT)/1000))
  2236.                         {
  2237.                           quit = true;
  2238.                         }
  2239. // see old
  2240.                         // else if(newMenuBool==true && (e.button.x > (7*SCREEN_WIDTH)/2000 && e.button.x < (195*SCREEN_WIDTH)/2000 && e.button.y > (134*SCREEN_HEIGHT)/1000 && e.button.y < (179*SCREEN_HEIGHT)/1000))
  2241.                         // {
  2242.                         //
  2243.                         //
  2244.                         //
  2245.                         //
  2246.                         //   newMenuBool = false;
  2247.                         // }
  2248. // save
  2249.                         else if(newMenuBool==true && (e.button.x > (7*SCREEN_WIDTH)/2000 && e.button.x < (195*SCREEN_WIDTH)/2000 && e.button.y > (134*SCREEN_HEIGHT)/1000 && e.button.y < (179*SCREEN_HEIGHT)/1000))
  2250.                         {
  2251.  
  2252.                           saveHoiseBool = true;
  2253.                           closeWithoutSavingBool = false;
  2254.  
  2255.  
  2256.                           for(int i=0; i<=current_line; i++)
  2257.                           {
  2258.                               strcat(savedStringFile,inputText[i].c_str());
  2259.                           }
  2260.  
  2261.                           printf("save theke save kora\n" );
  2262.                           HeaderInputFromUser();
  2263.                           fprintf(oldEntryFIle, "%s\n", date.c_str());
  2264.  
  2265.                           FILE *notunFile = fopen(date.c_str(),"w");
  2266.                           fprintf(notunFile, "%s", savedStringFile);
  2267.  
  2268.                           if(imageSavedString.size()>1){
  2269.                           string temp = "";
  2270.                           temp = date + "  " + imageSavedString;
  2271.                           printf("%s\n", temp.c_str());
  2272.                           FILE *ImageFile = fopen("imagesPlusFile.typo", "a");
  2273.                           fprintf(ImageFile, "%s\n", temp.c_str());
  2274.                           }
  2275.  
  2276.                           if(strcmp(usernameString.c_str(), "Random Entry")){
  2277.                           string tempu = "";
  2278.                           tempu = "./users/" + usernameString + ".typo";
  2279.                           printf("usernameString %s\n", tempu.c_str());
  2280.                           FILE *userEntireEntry = fopen(tempu.c_str(), "a");
  2281.                           // file e tarikh dhukao
  2282.                           time_t t1 = time(NULL);
  2283.                           struct tm tm1 = *localtime(&t1);
  2284.                           char fileEtimeDhukainorArray[100];
  2285.                           sprintf(fileEtimeDhukainorArray, "Entry date : %2d/%2d/%4d.\nEntry Time: Hour:%2d Minute:%2d", tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900, tm1.tm_hour%12, tm1.tm_min);
  2286.                           fprintf(userEntireEntry,"%s\n", fileEtimeDhukainorArray);
  2287.  
  2288.                           // file e shob dhukao
  2289.                           string tempu2 = "   ";
  2290.                           fprintf(userEntireEntry, "%s\n", savedStringFile);
  2291.                           fprintf(userEntireEntry, "%s\n\n", tempu2.c_str());
  2292.                           }
  2293.  
  2294.                           SDL_SetClipboardText(savedStringFile);
  2295.                           savedStringFile[0]=0;
  2296.  
  2297.  
  2298.  
  2299.  
  2300.                           SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  2301.  
  2302.                           SDL_RenderSetViewport(main_renderer, &entrySavedSuccessfullyRect);
  2303.                           SDL_RenderCopy(main_renderer, entrySavedSuccessfullyTexture, NULL, NULL);
  2304.                           SDL_RenderPresent(main_renderer);
  2305.                           SDL_Delay(600);
  2306.                           SDL_RenderClear(main_renderer);
  2307.  
  2308.  
  2309.                           // render saved font
  2310.                           newMenuBool = false;
  2311.                         }
  2312.  
  2313.                         else if(closeWithoutSavingBool  && (e.button.x > (749*SCREEN_WIDTH)/2000 && e.button.x < (799*SCREEN_WIDTH)/2000 && e.button.y > (508*SCREEN_HEIGHT)/1000 && e.button.y < (543*SCREEN_HEIGHT)/1000))
  2314.                         {
  2315.                           // quit kore dao save na kore
  2316.  
  2317.                           for(int i=0; i<=current_line; i++)
  2318.                           {
  2319.                               strcat(savedStringFile,inputText[i].c_str());
  2320.  
  2321.  
  2322.                           }
  2323.  
  2324.                           FILE *resumeFile = fopen("./saved/resume.typo","w");
  2325.                           fprintf(resumeFile, "%s\n", savedStringFile);
  2326.                           SDL_SetClipboardText(savedStringFile);
  2327.                           savedStringFile[0]=0;
  2328.  
  2329.  
  2330.                           quit = true;
  2331.                           closeWithoutSavingBool = false;
  2332.                         }
  2333.  
  2334.                         else if(closeWithoutSavingBool  && (e.button.x > (1020*SCREEN_WIDTH)/2000 && e.button.x < (1109*SCREEN_WIDTH)/2000 && e.button.y > (510*SCREEN_HEIGHT)/1000 && e.button.y < (545*SCREEN_HEIGHT)/1000))
  2335.                         {
  2336.                           closeWithoutSavingBool = false;
  2337.                         }
  2338.  
  2339.  
  2340.  
  2341.                         else if(closeWithoutSavingBool && !saveHoiseBool  && (e.button.x > (893*SCREEN_WIDTH)/2000 && e.button.x < (943*SCREEN_WIDTH)/2000 && e.button.y > (506*SCREEN_HEIGHT)/1000 && e.button.y < (546*SCREEN_HEIGHT)/1000))
  2342.                         {
  2343.                           closeWithoutSavingBool = false;
  2344.                           for(int i=0; i<=current_line; i++)
  2345.                           {
  2346.                               strcat(savedStringFile,inputText[i].c_str());
  2347.                           }
  2348.                           printf("exit theke save kora\n" );
  2349.                           HeaderInputFromUser();
  2350.                           fprintf(oldEntryFIle, "%s\n", date.c_str());
  2351.  
  2352.                           FILE *notunFile = fopen(date.c_str(),"w");
  2353.                           fprintf(notunFile, "%s", savedStringFile);
  2354.  
  2355.                           if(imageSavedString.size()>1){
  2356.                           string temp = "";
  2357.                           temp = date + "  " + imageSavedString;
  2358.                           printf("%s\n", temp.c_str());
  2359.                           FILE *ImageFile = fopen("imagesPlusFile.typo", "a");
  2360.                           fprintf(ImageFile, "%s\n", temp.c_str());
  2361.                           }
  2362.  
  2363.                           if(strcmp(usernameString.c_str(), "Random Entry")){
  2364.                           string tempu = "";
  2365.                           tempu = "./users/" + usernameString + ".typo";
  2366.                           printf("usernameString %s\n", tempu.c_str());
  2367.                           FILE *userEntireEntry = fopen(tempu.c_str(), "a");
  2368.                           // file e tarikh dhukao
  2369.                           time_t t1 = time(NULL);
  2370.                           struct tm tm1 = *localtime(&t1);
  2371.                           char fileEtimeDhukainorArray[100];
  2372.                           sprintf(fileEtimeDhukainorArray, "Entry date : %2d/%2d/%4d", tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900);
  2373.                           fprintf(userEntireEntry,"%s\n", fileEtimeDhukainorArray);
  2374.  
  2375.                           // file e shob dhukao
  2376.                           string tempu2 = "   ";
  2377.                           fprintf(userEntireEntry, "%s\n", savedStringFile);
  2378.                           fprintf(userEntireEntry, "%s\n\n", tempu2.c_str());
  2379.                           }
  2380.  
  2381.                           SDL_SetClipboardText(savedStringFile);
  2382.                           savedStringFile[0]=0;
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.                           quit = true;
  2392.                           //fahim
  2393.  
  2394.                         }
  2395.  
  2396.  
  2397.                         else if(preferenceMenuBool==true && (e.button.x > (288*SCREEN_WIDTH)/2000 && e.button.x < (422*SCREEN_WIDTH)/2000 && e.button.y > (35*SCREEN_HEIGHT)/1000 && e.button.y < (98*SCREEN_HEIGHT)/1000))
  2398.                         {
  2399.                             isThereAnyImageSavedToThisFile = false;
  2400.                             ekbarImageLoadErJonnoBool = false;
  2401.                             imageStringInputFunction();
  2402.                             SDL_StartTextInput();
  2403.                             //printf("%s\n\n\n", imageSavedString.c_str());
  2404.                             preferenceMenuBool = false;
  2405.  
  2406.                         }
  2407.  
  2408.  
  2409.                         else if(preferenceMenuBool==true && (e.button.x > (253*SCREEN_WIDTH)/2000 && e.button.x < (415*SCREEN_WIDTH)/2000 && e.button.y > (198*SCREEN_HEIGHT)/1000 && e.button.y < (242*SCREEN_HEIGHT)/1000))
  2410.                         {
  2411.                             clickToChooseMusicBool = true;
  2412.                             preferenceMenuBool = false;
  2413.                         }
  2414.  
  2415.                         else if(clickToChooseMusicBool && e.button.x > (SCREEN_WIDTH*507)/2000 && e.button.x < (SCREEN_WIDTH*712)/2000 && e.button.y > (SCREEN_HEIGHT*292)/1000 && e.button.y <(SCREEN_HEIGHT*409)/1000){
  2416.                           Mix_HaltMusic();
  2417.                           Mix_PlayMusic(backgroundMusic[0], -1);
  2418.                           clickToChooseMusicBool = false;
  2419.                           printf("DHUKSE 1\n");
  2420.                         }
  2421.  
  2422.                         else if(clickToChooseMusicBool && e.button.x > (SCREEN_WIDTH*905)/2000 && e.button.x < (SCREEN_WIDTH*1129)/2000 && e.button.y > (SCREEN_HEIGHT*292)/1000 && e.button.y < (SCREEN_HEIGHT*403)/1000){
  2423.                           Mix_HaltMusic();
  2424.                           Mix_PlayMusic(backgroundMusic[1], -1);
  2425.                           printf("DHUKSE 2\n");
  2426.                           clickToChooseMusicBool = false;
  2427.                         }
  2428.  
  2429.                         else if(clickToChooseMusicBool && e.button.x > (SCREEN_WIDTH*507)/2000 && e.button.x < (SCREEN_WIDTH*712)/2000 && e.button.y > (SCREEN_HEIGHT*491)/1000 && e.button.y < (SCREEN_HEIGHT*611)/1000){
  2430.                           Mix_HaltMusic();
  2431.                           Mix_PlayMusic(backgroundMusic[2], -1);
  2432.                           printf("DHUKSE 3\n");
  2433.                           clickToChooseMusicBool = false;
  2434.                         }
  2435.  
  2436.                         else if(clickToChooseMusicBool && e.button.x > (SCREEN_WIDTH*906)/2000 && e.button.x < (SCREEN_WIDTH*1126)/2000 && e.button.y > (SCREEN_HEIGHT*492)/1000 && e.button.y < (SCREEN_HEIGHT*612)/1000){
  2437.                           Mix_HaltMusic();
  2438.                           Mix_PlayMusic(backgroundMusic[3], -1);
  2439.                           printf("DHUKSE 4\n");
  2440.                           clickToChooseMusicBool = false;
  2441.                         }
  2442.  
  2443.  
  2444.                         else if(preferenceMenuBool==true && (e.button.x > (260*SCREEN_WIDTH)/2000 && e.button.x < (416*SCREEN_WIDTH)/2000 && e.button.y > (261*SCREEN_HEIGHT)/1000 && e.button.y < (309*SCREEN_HEIGHT)/1000))
  2445.                         {
  2446.                             konGaanBaaje = -1;
  2447.                             Mix_HaltMusic();
  2448.                         }
  2449.  
  2450.                         // else if(preferenceMenuBool==true && !screenImagebool && (e.button.x > (269*SCREEN_WIDTH)/2000 && e.button.x < (405*SCREEN_WIDTH)/2000 && e.button.y > (117*SCREEN_HEIGHT)/1000 && e.button.y < (174*SCREEN_HEIGHT)/1000))
  2451.                         // {
  2452.                         //     showImageFunction();
  2453.                         //     //screenImageTexture = loadTexture("data/screenImageTexture.png");
  2454.                         //     screenImagebool = true;
  2455.                         // }
  2456.  
  2457.  
  2458.  
  2459.                         else if((e.button.x > (246*SCREEN_WIDTH)/2000 && e.button.x < (430*SCREEN_WIDTH)/2000 && e.button.y > (50*SCREEN_HEIGHT)/1000 && e.button.y < (128*SCREEN_HEIGHT)/1000)&&screenImagebool)
  2460.                         {
  2461.                             screenImagebool = false;
  2462.                         }
  2463.  
  2464.  
  2465.                         else if( !(closeWithoutSavingBool || newMenuBool || preferenceMenuBool || viewMenuBool) && e.button.x<SCREEN_WIDTH-100 && e.button.y >80+image_int&&e.button.y<total_line*50+130+image_int )
  2466.                         {
  2467.                             printf("whatnow\n");
  2468.  
  2469.                             {
  2470.  
  2471.                               normal_mouse_tap_check=1;
  2472.  
  2473.  
  2474.                               current_line=((e.button.y-80-image_int)/50)+scroll_count-up_sign;
  2475.                               ini_ypos=e.button.y;
  2476.                               ini_xpos=e.button.x;
  2477.                               selected_copy_ini_y=current_line;
  2478.                                Ltemp.loadFromRenderedText( inputText[current_line], textColor );
  2479.  
  2480.  
  2481.                                 if(Ltemp.getWidth()>e.button.x)
  2482.                                 {
  2483.                                   for(int i=0;i<strlen(inputText[current_line].c_str())-1;i++)
  2484.                                           {
  2485.  
  2486.                                               ctemp[i]=inputText[current_line].c_str()[i];
  2487.                                               ctemp[i+1]=0;
  2488.                                               Ltemp.loadFromRenderedText( ctemp, textColor );
  2489.                                               l_length=Ltemp.getWidth();
  2490.  
  2491.  
  2492.  
  2493.                                               ctemp[i+1]=inputText[current_line].c_str()[i+1];
  2494.                                               ctemp[i+1+1]=0;
  2495.                                               Ltemp.loadFromRenderedText( ctemp, textColor );
  2496.                                               r_length=Ltemp.getWidth();
  2497.  
  2498.  
  2499.  
  2500.                                               if(e.button.x>=l_length&&e.button.x<=r_length)
  2501.                                               {
  2502.                                                   if(e.button.x-l_length<=r_length-e.button.x)
  2503.                                                   {
  2504.                                                       left_sign=strlen(inputText[current_line].c_str())-i-1;
  2505.                                                       break;
  2506.                                                   }
  2507.                                                   else
  2508.                                                   {
  2509.                                                       left_sign=strlen(inputText[current_line].c_str())-i-2;
  2510.                                                       break;
  2511.                                                   }
  2512.  
  2513.  
  2514.                                               }
  2515.  
  2516.  
  2517.                                           }
  2518.                                           selected_copy_ini_x=strlen(inputText[current_line].c_str())-left_sign;
  2519.                                }
  2520.                                 else
  2521.                                 {
  2522.  
  2523.                                   left_sign=0;
  2524.                                   selected_copy_ini_x=strlen(inputText[current_line].c_str())-left_sign;
  2525.  
  2526.                                  }
  2527.                          }
  2528.  
  2529.  
  2530.                         }
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.                     }
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.                       else if(e.type == SDL_MOUSEBUTTONUP&&normal_mouse_tap_check==1)
  2543.                         {
  2544.                           normal_mouse_tap_check=0;
  2545.  
  2546.  
  2547.  
  2548.  
  2549.                           if(e.button.x<SCREEN_WIDTH-100)
  2550.                           {
  2551.                             final_ypos=e.button.y;
  2552.                             final_xpos=e.button.x;
  2553.  
  2554.                             selected_copy_final_y=((e.button.y-80-image_int)/50)+scroll_count-up_sign;
  2555.                             Ltemp.loadFromRenderedText( inputText[selected_copy_final_y], textColor );
  2556.  
  2557.  
  2558.                              if(Ltemp.getWidth()>e.button.x)
  2559.                            {
  2560.                                  for(int i=0;i<strlen(inputText[selected_copy_final_y].c_str())-1;i++)
  2561.                                             {
  2562.  
  2563.                                                 ctemp[i]=inputText[selected_copy_final_y].c_str()[i];
  2564.                                                 ctemp[i+1]=0;
  2565.                                                 Ltemp.loadFromRenderedText( ctemp, textColor );
  2566.                                                 l_length=Ltemp.getWidth();
  2567.  
  2568.  
  2569.  
  2570.                                                 ctemp[i+1]=inputText[selected_copy_final_y].c_str()[i+1];
  2571.                                                 ctemp[i+1+1]=0;
  2572.                                                 Ltemp.loadFromRenderedText( ctemp, textColor );
  2573.                                                 r_length=Ltemp.getWidth();
  2574.  
  2575.  
  2576.  
  2577.                                                 if(e.button.x>=l_length&&e.button.x<=r_length)
  2578.                                                 {
  2579.                                                     if(e.button.x-l_length<=r_length-e.button.x)
  2580.                                                     {
  2581.                                                         selected_copy_final_x=i+1;
  2582.                                                         break;
  2583.                                                     }
  2584.                                                     else
  2585.                                                     {
  2586.                                                         selected_copy_final_x=i+2;
  2587.                                                         break;
  2588.                                                     }
  2589.  
  2590.  
  2591.                                                 }
  2592.  
  2593.  
  2594.                                             }
  2595.                               }
  2596.                               else
  2597.                                 selected_copy_final_x=0;
  2598.                             }
  2599.                             if(selected_copy_final_y!=selected_copy_ini_y||selected_copy_final_x!=selected_copy_ini_x)
  2600.                             {
  2601.                               selected_copy_check=1;
  2602.                             //  printf("%d %d %d %d\n",selected_copy_final_y,selected_copy_ini_y,selected_copy_final_x,selected_copy_ini_x );
  2603.                             }
  2604.                             else
  2605.                                 selected_copy_check=0;
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.                         }
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.                     if(e.type == SDL_QUIT)
  2619.                     {
  2620.  
  2621.                       for(int i=0; i<=current_line; i++)
  2622.                       {
  2623.                           strcat(savedStringFile,inputText[i].c_str());
  2624.  
  2625.  
  2626.                       }
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.                       FILE *resumeFile = fopen("./saved/resume.typo","w");
  2634.                       fprintf(resumeFile, "%s\n", savedStringFile);
  2635.                       SDL_SetClipboardText(savedStringFile);
  2636.                       savedStringFile[0]=0;
  2637.  
  2638.                       quit = true;
  2639.  
  2640.                     }
  2641.  
  2642.  
  2643.                     else if(e.type == SDL_KEYDOWN)
  2644.                     {
  2645.                          now_search=1;
  2646.  
  2647.                       if(saveHoiseBool == true){
  2648.                         saveHoiseBool = false;
  2649.                       }
  2650.  
  2651.                       undo_redo_check=0;
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.                       //undo
  2658.                       if( e.key.keysym.sym == SDLK_z && SDL_GetModState() & KMOD_CTRL&& !(SDL_GetModState() & KMOD_SHIFT)&&current_line<=total_line)
  2659.  
  2660.                       {
  2661.                         undo_redo_check=1;
  2662.                         if(old_s.empty()==0 )
  2663.                         {
  2664.  
  2665.                                   fullString = "a";
  2666.                                   fullString.pop_back();
  2667.                                     //initially shob kisu null kora
  2668.                                   for(int i=0;i<=total_line;i++)
  2669.                                   {
  2670.                                     fullString+=inputText[i];
  2671.                                     inputText[i]="a";
  2672.                                     inputText[i].pop_back();
  2673.                                   }
  2674.                                   total_line=0;
  2675.  
  2676.  
  2677.                                   new_s.push(fullString);
  2678.  
  2679.                                   fullString=old_s.top();
  2680.  
  2681.                                   new_x.push(left_sign);
  2682.                                   new_l.push(current_line);
  2683.                                   current_line=0;
  2684.  
  2685.                                   old_s.pop();
  2686.  
  2687.  
  2688.                                   //string theke character array te newa
  2689.  
  2690.                                   full_length=strlen(fullString.c_str());
  2691.  
  2692.                                   for(int i=0;i<full_length;i++)
  2693.                                   {
  2694.                                     stemp[i]=fullString.c_str()[i];
  2695.                                   }
  2696.                                   stemp[full_length]=0;
  2697.  
  2698.  
  2699.                                 //character array theke input text e newa &&render
  2700.  
  2701.  
  2702.                                   count=0;
  2703.                                   for(int i=0; i<full_length; i++)
  2704.                                       {
  2705.  
  2706.                                           if(stemp[i]=='\n')stemp[i]=3;
  2707.                                           if(stemp[i]==3&&i<full_length-1)
  2708.                                           {
  2709.  
  2710.  
  2711.                                                 ctemp[count]=3;
  2712.                                                 ctemp[count+1]=0;
  2713.                                                 sh=ctemp;
  2714.  
  2715.  
  2716.                                                 inputText[current_line]=sh;
  2717.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2718.  
  2719.  
  2720.                                                 current_line++;
  2721.                                                 total_line++;
  2722.                                                 count=0;
  2723.                                                 continue;
  2724.                                           }
  2725.                                           ctemp[count]=stemp[i];
  2726.                                           count++;
  2727.                                           ctemp[count]=0;
  2728.  
  2729.                                           sh=ctemp;
  2730.                                           if(i==full_length-1)
  2731.                                           {
  2732.                                               inputText[current_line]=sh;
  2733.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2734.                                           }
  2735.                                           Ltemp.loadFromRenderedText( sh, textColor );
  2736.                                           if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  2737.                                           {
  2738.  
  2739.                                               if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  2740.                                               {
  2741.  
  2742.                                                   word_count=0;
  2743.                                                   for(int j=count-1; j>=0; j--)
  2744.                                                   {
  2745.                                                       if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  2746.                                                       word_count++;
  2747.                                                   }
  2748.  
  2749.                                                   if(word_count<(count-1))
  2750.                                                   {
  2751.  
  2752.                                                       ctemp[count-1-word_count+1]=0;
  2753.  
  2754.  
  2755.                                                       inputText[current_line]=ctemp;
  2756.  
  2757.                                                       i=i-word_count;
  2758.  
  2759.  
  2760.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2761.                                                   }
  2762.  
  2763.                                                   else
  2764.                                                   {
  2765.                                                       inputText[current_line]=sh;
  2766.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2767.                                                   }
  2768.  
  2769.                                               }
  2770.                                               else
  2771.                                               {
  2772.                                                   inputText[current_line]=sh;
  2773.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2774.                                               }
  2775.                                               current_line++;
  2776.                                               total_line++;
  2777.                                               inputText[total_line]="@";
  2778.                                               count=0;
  2779.                                               //inputText[current_line].pop_back();
  2780.                                           }
  2781.                                           else
  2782.                                           {
  2783.                                             inputText[current_line]=sh;
  2784.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2785.                                           }
  2786.  
  2787.  
  2788.                                     }
  2789.                                     current_line=old_l.top();
  2790.                                     old_l.pop();
  2791.  
  2792.                                     left_sign=old_x.top();
  2793.  
  2794.  
  2795.                                     old_x.pop();
  2796.  
  2797.                         }
  2798.  
  2799.                       }
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.                        else if( e.key.keysym.sym == SDLK_z && SDL_GetModState() & KMOD_CTRL && SDL_GetModState() & KMOD_SHIFT&&current_line<=total_line )
  2807.                        {
  2808.                          undo_redo_check=1;
  2809.                          if(new_s.empty()==0 )
  2810.                         {
  2811.  
  2812.  
  2813.  
  2814.                                     //initially shob kisu null kora
  2815.  
  2816.                                   fullString = "a";
  2817.                                   fullString.pop_back();
  2818.                                     //initially shob kisu null kora
  2819.                                   for(int i=0;i<=total_line;i++)
  2820.                                   {
  2821.                                     fullString+=inputText[i];
  2822.                                     inputText[i]="a";
  2823.                                     inputText[i].pop_back();
  2824.                                   }
  2825.                                   total_line=0;
  2826.                                    old_s.push(fullString);
  2827.  
  2828.                                   fullString=new_s.top();
  2829.  
  2830.                                   old_x.push(left_sign);
  2831.                                   old_l.push(current_line);
  2832.                                   new_s.pop();
  2833.                                   current_line=0;
  2834.  
  2835.  
  2836.                                   //string theke character array te newa
  2837.  
  2838.                                   full_length=strlen(fullString.c_str());
  2839.  
  2840.                                   for(int i=0;i<full_length;i++)
  2841.                                   {
  2842.                                     stemp[i]=fullString.c_str()[i];
  2843.                                   }
  2844.                                   stemp[full_length]=0;
  2845.  
  2846.  
  2847.  
  2848.                                 //character array theke input text e newa &&render
  2849.  
  2850.  
  2851.                                   count=0;
  2852.                                   for(int i=0; i<full_length; i++)
  2853.                                       {
  2854.  
  2855.                                           if(stemp[i]=='\n')stemp[i]=3;
  2856.                                           if(stemp[i]==3&&i<full_length-1)
  2857.                                           {
  2858.  
  2859.  
  2860.                                                 ctemp[count]=3;
  2861.                                                 ctemp[count+1]=0;
  2862.                                                 sh=ctemp;
  2863.  
  2864.  
  2865.                                                 inputText[current_line]=sh;
  2866.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2867.  
  2868.  
  2869.                                                 current_line++;
  2870.                                                 total_line++;
  2871.                                                 count=0;
  2872.                                                 continue;
  2873.                                           }
  2874.                                           ctemp[count]=stemp[i];
  2875.                                           count++;
  2876.                                           ctemp[count]=0;
  2877.  
  2878.                                           sh=ctemp;
  2879.                                           if(i==full_length-1)
  2880.                                           {
  2881.                                               inputText[current_line]=sh;
  2882.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2883.                                           }
  2884.                                           Ltemp.loadFromRenderedText( sh, textColor );
  2885.                                           if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  2886.                                           {
  2887.  
  2888.                                               if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  2889.                                               {
  2890.  
  2891.                                                   word_count=0;
  2892.                                                   for(int j=count-1; j>=0; j--)
  2893.                                                   {
  2894.                                                       if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  2895.                                                       word_count++;
  2896.                                                   }
  2897.  
  2898.                                                   if(word_count<(count-1))
  2899.                                                   {
  2900.  
  2901.                                                       ctemp[count-1-word_count+1]=0;
  2902.  
  2903.  
  2904.                                                       inputText[current_line]=ctemp;
  2905.  
  2906.                                                       i=i-word_count;
  2907.  
  2908.  
  2909.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2910.                                                   }
  2911.  
  2912.                                                   else
  2913.                                                   {
  2914.                                                       inputText[current_line]=sh;
  2915.                                                       mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2916.                                                   }
  2917.  
  2918.                                               }
  2919.                                               else
  2920.                                               {
  2921.                                                   inputText[current_line]=sh;
  2922.                                                   mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2923.                                               }
  2924.                                               current_line++;
  2925.                                               total_line++;
  2926.                                               inputText[total_line]="@";
  2927.                                               count=0;
  2928.                                               //inputText[current_line].pop_back();
  2929.                                           }
  2930.                                           else
  2931.                                           {
  2932.                                             inputText[current_line]=sh;
  2933.                                               mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  2934.                                           }
  2935.  
  2936.  
  2937.                                     }
  2938.                                     current_line=new_l.top();
  2939.                                     new_l.pop();
  2940.  
  2941.                                     left_sign=new_x.top();
  2942.  
  2943.  
  2944.                                     new_x.pop();
  2945.  
  2946.                         }
  2947.                        }
  2948.  
  2949.  
  2950.  
  2951.  
  2952.                       else if(e.key.keysym.sym != SDLK_UP&&e.key.keysym.sym != SDLK_DOWN&&e.key.keysym.sym != SDLK_LEFT&&e.key.keysym.sym != SDLK_RIGHT&&e.key.keysym.sym != SDLK_CAPSLOCK)
  2953.                         {
  2954.                             if(e.key.keysym.sym != SDLK_LSHIFT&&e.key.keysym.sym != SDLK_LALT&&e.key.keysym.sym != SDLK_TAB&&e.key.keysym.sym != SDLK_RSHIFT&&e.key.keysym.sym != SDLK_RALT)
  2955.                             {
  2956.                                 if(e.key.keysym.sym != SDLK_RCTRL&&e.key.keysym.sym != SDLK_LCTRL&&undo_redo_check==0&&current_line<=total_line)
  2957.                                     {
  2958.  
  2959.                                         fulltext="a";
  2960.                                         fulltext.pop_back();
  2961.                                         for(int i=0;i<=total_line;i++)
  2962.                                         {
  2963.                                             fulltext+=inputText[i];
  2964.                                         }
  2965.  
  2966.                                         if(strlen(fulltext.c_str())>0||e.key.keysym.sym != SDLK_BACKSPACE)
  2967.                                         {
  2968.  
  2969.                                             old_s.push(fulltext);
  2970.                                             old_l.push(current_line);
  2971.  
  2972.  
  2973.  
  2974.                                             old_x.push(left_sign);
  2975.  
  2976.  
  2977.  
  2978.                                         }
  2979.  
  2980.                                     }
  2981.                             }
  2982.  
  2983.                         }
  2984.  
  2985.  
  2986.  
  2987.                         huda=1;
  2988.  
  2989.  
  2990.                         //backspace key
  2991.  
  2992.  
  2993.  
  2994.                         if( e.key.keysym.sym != SDLK_RETURN)search_count=-1;
  2995.  
  2996.                         if( e.key.keysym.sym == SDLK_BACKSPACE )
  2997.                         {
  2998.                                 while(!new_s.empty())new_s.pop();
  2999.                                 while(!new_x.empty())new_x.pop();
  3000.                                 while(!new_l.empty())new_l.pop();
  3001.                                 backspace_check=1;
  3002.  
  3003.                             if(all_select==1)
  3004.                             {
  3005.                                 if(search_bar_bool)
  3006.                                 {
  3007.                                     inputText[100]="a";
  3008.                                     inputText[100].pop_back();
  3009.                                     mainTextTexture[100].loadFromRenderedText(" ",textColor);
  3010.                                 }
  3011.                                 else
  3012.                                 {
  3013.                                     all_select=0;
  3014.                                     left_sign=0;
  3015.                                     sh=" ";
  3016.                                     for(int i=0; i<=total_line; i++)
  3017.                                     {
  3018.                                         inputText[i]=sh;
  3019.                                         mainTextTexture[i].loadFromRenderedText(inputText[i],textColor);
  3020.                                         inputText[i].pop_back();
  3021.                                     }
  3022.                                     total_line=0;
  3023.                                     current_line=0;
  3024.                                     indi_xpos=0;
  3025.                                 }
  3026.  
  3027.  
  3028.                             }
  3029.  
  3030.  
  3031.  
  3032.                             //selected onsho delete
  3033.                             if(selected_copy_check&&current_line!=100)
  3034.                             {
  3035.                                 selected_copy_check=0;
  3036.                                 if(selected_copy_ini_y==selected_copy_final_y)
  3037.                                 {
  3038.  
  3039.                                     if(selected_copy_final_x>selected_copy_ini_x)
  3040.                                     {
  3041.                                         left_sign=selected_copy_final_x-selected_copy_ini_x+1;
  3042.                                         itemp=selected_copy_ini_x;
  3043.                                         selected_copy_ini_x=selected_copy_final_x;
  3044.                                         selected_copy_final_x=itemp;
  3045.                                     }
  3046.                                     current_line=selected_copy_final_y;
  3047.  
  3048.  
  3049.  
  3050.  
  3051.                                     for(int i=0; i<selected_copy_final_x; i++)
  3052.                                     {
  3053.                                         stemp[i]=inputText[current_line].c_str()[i];
  3054.  
  3055.  
  3056.  
  3057.                                     }
  3058.                                     stemp[selected_copy_final_x]=0;
  3059.  
  3060.  
  3061.                                     for(int i=0; i<strlen(inputText[selected_copy_final_y].c_str())-selected_copy_ini_x; i++)
  3062.                                     {
  3063.                                         stemp[i+selected_copy_final_x]=inputText[current_line].c_str()[i+selected_copy_ini_x];
  3064.  
  3065.  
  3066.  
  3067.                                     }
  3068.                                     stemp[strlen(inputText[selected_copy_final_y].c_str())-selected_copy_ini_x+selected_copy_final_x]=0;
  3069.  
  3070.  
  3071.                                     inputText[selected_copy_final_y]=stemp;
  3072.                                     mainTextTexture[selected_copy_final_y].loadFromRenderedText(inputText[selected_copy_ini_y],textColor);
  3073.                                 }
  3074.  
  3075.                                 else if(selected_copy_ini_y>selected_copy_final_y)
  3076.                                 {
  3077.                                     current_line=selected_copy_final_y;
  3078.                                     left_sign=0;
  3079.                                     for(int i=0; i<selected_copy_final_x; i++)
  3080.                                     {
  3081.  
  3082.                                         stemp[i]=inputText[current_line].c_str()[i];
  3083.  
  3084.  
  3085.                                     }
  3086.                                     stemp[selected_copy_final_x]=0;
  3087.                                     inputText[current_line]=stemp;
  3088.                                     mainTextTexture[current_line].loadFromRenderedText(inputText[current_line],textColor);
  3089.  
  3090.                                     for(int i=selected_copy_ini_x;i<strlen(inputText[selected_copy_ini_y].c_str());i++)
  3091.                                     {
  3092.                                         stemp[i-selected_copy_ini_x]=inputText[selected_copy_ini_y].c_str()[i];
  3093.                                     }
  3094.  
  3095.                                     stemp[strlen(inputText[selected_copy_ini_y].c_str())-selected_copy_ini_x]=0;
  3096.  
  3097.                                      inputText[current_line+1]=stemp;
  3098.                                     mainTextTexture[current_line+1].loadFromRenderedText(inputText[current_line+1],textColor);
  3099.  
  3100.                                     if(total_line==selected_copy_ini_y)
  3101.                                     {
  3102.                                         for(int i=0;i<selected_copy_ini_y-selected_copy_final_y-1;i++)
  3103.                                             {
  3104.                                                 inputText[current_line+i+2]="a";
  3105.  
  3106.                                                 inputText[current_line+i+2].pop_back();
  3107.                                             }
  3108.  
  3109.                                     }
  3110.                                     else if(total_line>selected_copy_ini_y)
  3111.                                     {
  3112.                                         int dif=selected_copy_ini_y-selected_copy_final_y-1;
  3113.                                         if(dif>0)
  3114.                                         {
  3115.                                             for(int i=0;i<total_line-selected_copy_ini_y;i++)
  3116.                                             {
  3117.                                                inputText[current_line+2+i]=inputText[selected_copy_ini_y+1+i];
  3118.                                             }
  3119.                                             for(int i=0;i<dif;i++)
  3120.                                             {
  3121.                                                 inputText[total_line-i]="a";
  3122.                                                 inputText[total_line-i].pop_back();
  3123.                                             }
  3124.                                         }
  3125.                                     }
  3126.  
  3127.  
  3128.  
  3129.                                     total_line=total_line-(selected_copy_ini_y-selected_copy_final_y)+1;
  3130.  
  3131.                                 }
  3132.  
  3133.  
  3134.                                 else if(selected_copy_ini_y<selected_copy_final_y)
  3135.                                 {
  3136.                                     current_line=selected_copy_ini_y;
  3137.                                     left_sign=0;
  3138.                                     for(int i=0; i<selected_copy_ini_x; i++)
  3139.                                     {
  3140.  
  3141.                                         stemp[i]=inputText[current_line].c_str()[i];
  3142.  
  3143.  
  3144.                                     }
  3145.                                     stemp[selected_copy_ini_x]=0;
  3146.                                     inputText[current_line]=stemp;
  3147.                                     mainTextTexture[current_line].loadFromRenderedText(inputText[current_line],textColor);
  3148.  
  3149.                                     for(int i=selected_copy_final_x;i<strlen(inputText[selected_copy_final_y].c_str());i++)
  3150.                                     {
  3151.                                         stemp[i-selected_copy_final_x]=inputText[selected_copy_final_y].c_str()[i];
  3152.                                     }
  3153.  
  3154.                                     stemp[strlen(inputText[selected_copy_final_y].c_str())-selected_copy_final_x]=0;
  3155.  
  3156.                                      inputText[current_line+1]=stemp;
  3157.                                     mainTextTexture[current_line+1].loadFromRenderedText(inputText[current_line+1],textColor);
  3158.  
  3159.                                     if(total_line==selected_copy_final_y)
  3160.                                     {
  3161.                                         for(int i=0;i<selected_copy_final_y-selected_copy_ini_y-1;i++)
  3162.                                             {
  3163.                                                 inputText[current_line+i+2]="a";
  3164.  
  3165.                                                 inputText[current_line+i+2].pop_back();
  3166.                                             }
  3167.  
  3168.                                     }
  3169.                                     else if(total_line>selected_copy_final_y)
  3170.                                     {
  3171.                                         int dif=selected_copy_final_y-selected_copy_ini_y-1;
  3172.                                         if(dif>0)
  3173.                                         {
  3174.                                             for(int i=0;i<total_line-selected_copy_final_y;i++)
  3175.                                             {
  3176.                                                inputText[current_line+2+i]=inputText[selected_copy_final_y+1+i];
  3177.                                             }
  3178.                                             for(int i=0;i<dif;i++)
  3179.                                             {
  3180.                                                 inputText[total_line-i]="a";
  3181.                                                 inputText[total_line-i].pop_back();
  3182.                                             }
  3183.                                         }
  3184.                                     }
  3185.                                     current_line++;
  3186.                                     left_sign=(strlen(inputText[current_line].c_str()));
  3187.  
  3188.  
  3189.  
  3190.                                     total_line=total_line-(selected_copy_final_y-selected_copy_ini_y)+1;
  3191.  
  3192.                                 }
  3193.                             }
  3194.                             //first line er majh theke kichu katle last e atkai zabe
  3195.                             else if(current_line==0&&indi_xpos==0&&left_sign>0||current_line==100&&indi_xpos==0);
  3196.  
  3197.                             //normal lst line katar jonno
  3198.                             else if(final_indi_xpos==0&&current_line!=0&&total_line==current_line&&left_sign<1)
  3199.                             {
  3200.  
  3201.                                 backspace_check=1;
  3202.                                 current_line--;
  3203.                                 left_sign=0;
  3204.                                 total_line--;
  3205.                             }
  3206.  
  3207.  
  3208.  
  3209.                             else if(left_sign<1)
  3210.                             {
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.                                 //backspace main part
  3218.  
  3219.  
  3220.  
  3221.                                 if(inputText[current_line].length()==0&&current_line!=0&&current_line!=100)
  3222.                                 {
  3223.  
  3224.  
  3225.                                     //if(mainTextTexture[current_line-1].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  3226.                                     //majher ekta line kaatle
  3227.  
  3228.  
  3229.                                     if(current_line<total_line)
  3230.                                     {
  3231.                                         for(int a=0; a<total_line-current_line; a++)
  3232.                                         {
  3233.                                             sh=inputText[current_line+a];
  3234.                                             inputText[current_line+a]=inputText[current_line+1+a];
  3235.                                             inputText[current_line+1+a]=sh;
  3236.                                             mainTextTexture[current_line+a].loadFromRenderedText( inputText[current_line+a].c_str(), textColor );
  3237.                                         }
  3238.                                     }
  3239.  
  3240.                                     if(total_line>0)total_line--;
  3241.                                     current_line--;
  3242.  
  3243.                                     left_sign=0;
  3244.  
  3245.                                     mainTextTexture[total_line+1].loadFromRenderedText( " ", textColor );
  3246.  
  3247.  
  3248.  
  3249.                                     if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100&&total_line>=0)
  3250.                                     {
  3251.                                         backspace_check=1;
  3252.  
  3253.                                     }
  3254.                                     renderText = false;
  3255.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  3256.                                 }
  3257.  
  3258.                                 //first line zodi delete dite thaki
  3259.  
  3260.                                 else if(inputText[current_line].length()==0&&current_line==0)
  3261.                                 {
  3262.  
  3263.  
  3264.                                     if(current_line<total_line)
  3265.                                     {
  3266.                                         for(int a=0; a<total_line; a++)
  3267.                                         {
  3268.                                             sh=inputText[1+a];
  3269.                                             inputText[a]=inputText[1+a];
  3270.                                             inputText[1+a]=sh;
  3271.                                             mainTextTexture[a].loadFromRenderedText( inputText[current_line+a].c_str(), textColor );
  3272.                                         }
  3273.                                     }
  3274.  
  3275.                                     if(total_line>0)total_line--;
  3276.                                     current_line=0;
  3277.  
  3278.  
  3279.                                     left_sign=strlen(inputText[current_line].c_str());
  3280.                                 }
  3281.  
  3282.                                 //indicator er karone width bere gele overflow line theke kaTAr jonno
  3283.  
  3284.  
  3285.                                 else if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  3286.                                 {
  3287.  
  3288.                                     inputText[current_line].pop_back();
  3289.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  3290.                                     renderText = false;
  3291.  
  3292.                                 }
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.                                 else if(inputText[current_line].length() > 0)
  3301.                                 {
  3302.                                     inputText[current_line].pop_back();
  3303.                                     renderText = true;
  3304.                                 }
  3305.                             }
  3306.  
  3307.                             else
  3308.                             {
  3309.  
  3310.                                 if(final_indi_xpos==0)
  3311.                                 {
  3312.                                     current_line--;
  3313.                                     left_sign=0;
  3314.                                     if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  3315.  
  3316.  
  3317.                                 }
  3318.                                 else
  3319.                                 {
  3320.                                     //beshi jhamela badhle eikhane stemp e inputtext copy korbo
  3321.  
  3322.                                             for(int i=indi_xpos-1; i<length-1; i++)
  3323.                                             {
  3324.                                                 char_temp=stemp[i];
  3325.                                                 stemp[i]=stemp[i+1];
  3326.                                                 stemp[i+1]=char_temp;
  3327.  
  3328.  
  3329.                                             }
  3330.                                             stemp[length-1]=0;
  3331.                                             //left_sign--;
  3332.  
  3333.  
  3334.                                      for(int i=0; i<=length; i++)inputText[current_line].pop_back();
  3335.  
  3336.  
  3337.  
  3338.                                     inputText[current_line]=stemp;
  3339.                                     mainTextTexture[current_line].loadFromRenderedText(inputText[current_line],textColor);
  3340.                                 }
  3341.                             }
  3342.                             if(current_line<total_line&&final_indi_xpos!=0&&strlen(inputText[current_line].c_str())!=0)
  3343.                             {
  3344.  
  3345.                                 fulltext="q";
  3346.                                 fulltext.pop_back();
  3347.  
  3348.  
  3349.                                 int xpos_temp=strlen(inputText[current_line].c_str())-left_sign;
  3350.                                 line_temp=current_line;
  3351.  
  3352.  
  3353.                                 for(int i=current_line;i<=total_line;i++)
  3354.                                 {
  3355.                                     fulltext+=inputText[i];
  3356.                                     sh=inputText[i];
  3357.                                     Ltemp.loadFromRenderedText(sh,textColor);
  3358.                                     inputText[i]="a";
  3359.                                     inputText[i].pop_back();
  3360.                                 }
  3361.  
  3362.                                 full_length=strlen(fulltext.c_str());
  3363.  
  3364.                                 total_line=current_line;
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                                 for(int i=0;i<full_length;i++)
  3371.                                 {
  3372.                                     stemp[i]=fulltext.c_str()[i];
  3373.                                 }
  3374.                                 stemp[full_length]=0;
  3375.  
  3376.  
  3377.  
  3378.  
  3379.                                     count=0;
  3380.                                     for(int i=0; i<full_length; i++)
  3381.                                     {
  3382.  
  3383.  
  3384.                                         if(stemp[i]==3&&i<full_length-1)
  3385.                                         {
  3386.                                             ctemp[count]=stemp[i];
  3387.                                             ctemp[count+1]=0;
  3388.                                             sh=ctemp;
  3389.  
  3390.  
  3391.                                             inputText[current_line]=sh;
  3392.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3393.  
  3394.                                             current_line++;
  3395.                                             total_line++;
  3396.                                             count=0;
  3397.                                             i++;
  3398.                                         }
  3399.                                         ctemp[count]=stemp[i];
  3400.                                         count++;
  3401.                                         ctemp[count]=0;
  3402.  
  3403.  
  3404.                                         sh=ctemp;
  3405.                                         if(i==full_length-1)
  3406.                                         {
  3407.  
  3408.                                             inputText[current_line]=sh;
  3409.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3410.                                         }
  3411.  
  3412.                                         Ltemp.loadFromRenderedText( sh, textColor );
  3413.                                         if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  3414.                                         {
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.                                         if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  3425.                                         {
  3426.  
  3427.                                                 word_count=0;
  3428.                                                 for(int j=count-1; j>=0; j--)
  3429.                                                 {
  3430.                                                     if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  3431.                                                     word_count++;
  3432.                                                 }
  3433.  
  3434.                                                 if(word_count<(count-1))
  3435.                                                 {
  3436.  
  3437.                                                     ctemp[count-1-word_count+1]=0;
  3438.  
  3439.  
  3440.                                                     inputText[current_line]=ctemp;
  3441.  
  3442.                                                     i=i-word_count;
  3443.  
  3444.  
  3445.                                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3446.                                                 }
  3447.  
  3448.                                                 else
  3449.                                                 {
  3450.                                                     inputText[current_line]=sh;
  3451.                                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3452.                                                 }
  3453.  
  3454.  
  3455.                                         }
  3456.                                             else
  3457.                                             {
  3458.                                                 inputText[current_line]=sh;
  3459.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3460.                                             }
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.                                             current_line++;
  3478.                                             total_line++;
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.                                             count=0;
  3486.                                         //inputText[current_line].pop_back();
  3487.  
  3488.  
  3489.                                     }
  3490.                                     else
  3491.                                     {
  3492.                                         inputText[current_line]=sh;
  3493.                                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  3494.                                     }
  3495.  
  3496.  
  3497.                                 }
  3498.                                 current_line=line_temp;
  3499.                                 left_sign=strlen(inputText[current_line].c_str())-xpos_temp;
  3500.                             }
  3501.                                             // printf("%d\n",left_sign );
  3502.                        }
  3503.  
  3504.  
  3505.                         //Up key
  3506.  
  3507.  
  3508.  
  3509.                         if( e.key.keysym.sym == SDLK_UP&&current_line!=100 )
  3510.  
  3511.                         {
  3512.  
  3513.  
  3514.  
  3515.                             if(current_line>0)
  3516.  
  3517.                             {
  3518.                                 //indicator y axis e align kora
  3519.  
  3520.  
  3521.  
  3522.                                 {
  3523.  
  3524.  
  3525.                                     previous_line_indi_xpos=final_indi_xpos;
  3526.  
  3527.                                     if(mainTextTexture[current_line-1].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  3528.  
  3529.                                     current_line--;
  3530.  
  3531.  
  3532.                                     if(mainTextTexture[current_line].getWidth()<=previous_line_indi_xpos)left_sign=0;
  3533.  
  3534.  
  3535.                                     else
  3536.                                     {
  3537.  
  3538.  
  3539.                                         for(int i=0; i<strlen(inputText[current_line].c_str())-1; i++)
  3540.                                         {
  3541.  
  3542.                                             ctemp[i]=inputText[current_line].c_str()[i];
  3543.                                             ctemp[i+1]=0;
  3544.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  3545.                                             l_length=Ltemp.getWidth();
  3546.  
  3547.  
  3548.  
  3549.                                             ctemp[i+1]=inputText[current_line].c_str()[i+1];
  3550.                                             ctemp[i+1+1]=0;
  3551.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  3552.                                             r_length=Ltemp.getWidth();
  3553.  
  3554.  
  3555.  
  3556.                                             if(previous_line_indi_xpos>=l_length&&previous_line_indi_xpos<=r_length)
  3557.                                             {
  3558.                                                 if(previous_line_indi_xpos-l_length<=r_length-previous_line_indi_xpos)
  3559.                                                 {
  3560.                                                     left_sign=strlen(inputText[current_line].c_str())-i-1;
  3561.                                                     break;
  3562.                                                 }
  3563.                                                 else
  3564.                                                 {
  3565.                                                     left_sign=strlen(inputText[current_line].c_str())-i-2;
  3566.                                                     break;
  3567.                                                 }
  3568.  
  3569.  
  3570.                                             }
  3571.  
  3572.  
  3573.                                         }
  3574.                                     }
  3575.  
  3576.  
  3577.                                 }
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.                             }
  3585.                             else
  3586.                             {
  3587.                                 backspace_check=1;
  3588.                                 current_line=0;
  3589.  
  3590.                             }
  3591.                             renderText=false;
  3592.                         }
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.                         //down key
  3600.  
  3601.  
  3602.  
  3603.                         else if( e.key.keysym.sym == SDLK_DOWN &&inputText[current_line].length()>0&&current_line!=100)
  3604.                         {
  3605.  
  3606.                             if(current_line<total_line)
  3607.                             {
  3608.  
  3609.                                 {
  3610.  
  3611.  
  3612.                                     previous_line_indi_xpos=final_indi_xpos;
  3613.  
  3614.                                     if(mainTextTexture[current_line+1].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  3615.  
  3616.                                     current_line++;
  3617.  
  3618.  
  3619.                                     if(mainTextTexture[current_line].getWidth()<=previous_line_indi_xpos)left_sign=0;
  3620.  
  3621.  
  3622.                                     else
  3623.                                     {
  3624.  
  3625.  
  3626.                                         for(int i=0; i<strlen(inputText[current_line].c_str())-1; i++)
  3627.                                         {
  3628.  
  3629.                                             ctemp[i]=inputText[current_line].c_str()[i];
  3630.                                             ctemp[i+1]=0;
  3631.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  3632.                                             l_length=Ltemp.getWidth();
  3633.  
  3634.  
  3635.  
  3636.                                             ctemp[i+1]=inputText[current_line].c_str()[i+1];
  3637.                                             ctemp[i+1+1]=0;
  3638.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  3639.                                             r_length=Ltemp.getWidth();
  3640.  
  3641.  
  3642.  
  3643.                                             if(previous_line_indi_xpos>=l_length&&previous_line_indi_xpos<=r_length)
  3644.                                             {
  3645.  
  3646.                                                 if(previous_line_indi_xpos-l_length<=r_length-previous_line_indi_xpos)
  3647.                                                 {
  3648.                                                     left_sign=strlen(inputText[current_line].c_str())-i-1;
  3649.                                                     break;
  3650.                                                 }
  3651.                                                 else
  3652.                                                 {
  3653.                                                     left_sign=strlen(inputText[current_line].c_str())-i-2;
  3654.                                                     break;
  3655.                                                 }
  3656.  
  3657.                                             }
  3658.  
  3659.  
  3660.                                         }
  3661.                                     }
  3662.  
  3663.  
  3664.                                 }
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.                             }
  3671.  
  3672.  
  3673.  
  3674.                             renderText = false;
  3675.                         }
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.                         //right key
  3682.  
  3683.                         else if( e.key.keysym.sym == SDLK_RIGHT )
  3684.                         {
  3685.  
  3686.                             if(left_sign>0)left_sign--;
  3687.                             if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  3688.                             {
  3689.                                 backspace_check=1;
  3690.  
  3691.                             }
  3692.  
  3693.                             //continuous right click
  3694.                             if(left_sign<=0&&current_line<total_line)
  3695.  
  3696.                             {
  3697.                                 if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100||right_new_line==1)
  3698.                                 {
  3699.                                     current_line++;
  3700.                                     length=strlen(inputText[current_line].c_str());
  3701.                                     left_sign=length;
  3702.                                     right_new_line=0;
  3703.                                 }
  3704.                                 else
  3705.  
  3706.                                     right_new_line=1;
  3707.  
  3708.                             }
  3709.                         }
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.                         //left key
  3716.                         else if( e.key.keysym.sym == SDLK_LEFT )
  3717.                         {
  3718.  
  3719.                             //left overflow check
  3720.                             if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  3721.                             {
  3722.                                 backspace_check=1;
  3723.                                 left_check=1;
  3724.                             }
  3725.  
  3726.                             if(indi_xpos>0)
  3727.                             {
  3728.                                 left_sign++;
  3729.  
  3730.                             }
  3731.                             if(left_sign==length&&current_line!=0&&left_new_line!=0)
  3732.                             {
  3733.                                 backspace_check=1;
  3734.                                 current_line--;
  3735.                                 left_sign=0;
  3736.                                 length=strlen(inputText[current_line].c_str());
  3737.                                 left_new_line=0;
  3738.                             }
  3739.  
  3740.                             if(left_sign==length&&current_line!=0&&left_new_line==0)
  3741.                             {
  3742.                                 left_new_line=1;
  3743.                             }
  3744.  
  3745.                         }
  3746.  
  3747.  
  3748.                         //search bar enter
  3749.                          else if( e.key.keysym.sym == SDLK_RETURN&&search_bar_bool)
  3750.                          {
  3751.                             search_count++;
  3752.                             if(search_count>=word_count)search_count=0;
  3753.                          }
  3754.  
  3755.  
  3756.  
  3757.  
  3758.                         //enter key
  3759.  
  3760.  
  3761.  
  3762.                         else if( e.key.keysym.sym == SDLK_RETURN&&!search_bar_bool)
  3763.                         {
  3764.                                 while(!new_s.empty())new_s.pop();
  3765.                                 while(!new_x.empty())new_x.pop();
  3766.                                 while(!new_l.empty())new_l.pop();
  3767.  
  3768.                             //line er majhe enter dile
  3769.  
  3770.                             if(left_sign>0)
  3771.                             {
  3772.                                 if(left_sign==length)
  3773.                                 {
  3774.                                     total_line++;
  3775.                                     mainTextTexture[current_line].loadFromRenderedText( " ", textColor );
  3776.                                     sh=inputText[current_line];
  3777.                                     inputText[current_line]=newl;
  3778.  
  3779.                                     //inputText[current_line].pop_back();
  3780.                                     for(int i=current_line+1; i<=total_line; i++)
  3781.                                     {
  3782.                                         if(i!=total_line)itTemp=inputText[i];
  3783.                                         inputText[i]=sh;
  3784.                                         if(i!=total_line) sh=itTemp;
  3785.                                         mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  3786.                                     }
  3787.                                     current_line++;
  3788.  
  3789.                                     left_sign=strlen(inputText[current_line].c_str());
  3790.  
  3791.                                 }
  3792.                                 else
  3793.                                 {
  3794.                                     for(int i=0; i<indi_xpos; i++)
  3795.                                         ctemp[i]=inputText[current_line].c_str()[i];
  3796.                                     ctemp[indi_xpos]=3;
  3797.                                     ctemp[indi_xpos+1]=0;
  3798.  
  3799.  
  3800.                                     for(int i=indi_xpos; i<length; i++)
  3801.                                         stemp[i-indi_xpos]=inputText[current_line].c_str()[i];
  3802.                                     stemp[length-indi_xpos]=0;
  3803.  
  3804.  
  3805.                                     total_line++;
  3806.                                     for(int i=0; i<length; i++)
  3807.                                         inputText[current_line].pop_back();
  3808.  
  3809.  
  3810.                                     inputText[current_line]=ctemp;
  3811.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  3812.  
  3813.  
  3814.                                     sh=inputText[current_line+1];
  3815.  
  3816.  
  3817.                                     inputText[current_line+1]=stemp;
  3818.                                     mainTextTexture[current_line+1].loadFromRenderedText( inputText[current_line+1].c_str(), textColor );
  3819.  
  3820.  
  3821.                                     for(int i=current_line+2; i<=total_line; i++)
  3822.                                     {
  3823.  
  3824.                                         if(i!=total_line)itTemp=inputText[i];
  3825.                                         inputText[i]=sh;
  3826.                                         if(i!=total_line) sh=itTemp;
  3827.                                         mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  3828.  
  3829.                                     }
  3830.                                     current_line++;
  3831.                                 }
  3832.  
  3833.  
  3834.  
  3835.                             }
  3836.                             else
  3837.                             {
  3838.                                 inputText[current_line]+=newl;
  3839.                                 current_line++;
  3840.                                 total_line++;
  3841.                                 left_sign=0;
  3842.                             }
  3843.  
  3844.  
  3845.                             //jani na jhamela badhle dekhbo c++;
  3846.  
  3847.                             //mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  3848.  
  3849.  
  3850.                             renderText = false;
  3851.                         }
  3852.  
  3853.  
  3854.  
  3855.                         //shob select kora
  3856.  
  3857.                         else if(e.key.keysym.sym == SDLK_a && SDL_GetModState() & KMOD_CTRL)
  3858.                         {
  3859.                             if(all_select==1)all_select =0;
  3860.                             else
  3861.                                 all_select=1;
  3862.                         }
  3863.  
  3864.  
  3865.  
  3866.                         else if( e.key.keysym.sym == SDLK_f && SDL_GetModState() & KMOD_CTRL )
  3867.                         {
  3868.                             if(!search_bar_bool)
  3869.                             {
  3870.                                 l_s_temp=left_sign;
  3871.                                 c_l_temp=current_line;
  3872.                                 current_line=100;
  3873.                                 left_sign=0;
  3874.                                 search_bar_bool=true;
  3875.                             }
  3876.                             else
  3877.                             {
  3878.                                 left_sign=l_s_temp;
  3879.                                 current_line=c_l_temp;
  3880.  
  3881.                                 search_bar_bool=false;
  3882.                             }
  3883.                         }
  3884.  
  3885.  
  3886.  
  3887.                         //copy something
  3888.  
  3889.                         else if( e.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL )
  3890.                         {   old_s.pop();
  3891.                             old_x.pop();
  3892.                             old_l.pop();
  3893.                           renderText=false;
  3894.                             if(selected_copy_check==1)
  3895.                             {
  3896.  
  3897.                                 if(selected_copy_ini_y==selected_copy_final_y)
  3898.                                 {
  3899.  
  3900.                                     if(selected_copy_final_x>selected_copy_ini_x)
  3901.                                     {
  3902.                                         itemp=selected_copy_ini_x;
  3903.                                         selected_copy_ini_x=selected_copy_final_x;
  3904.                                         selected_copy_final_x=itemp;
  3905.                                     }
  3906.  
  3907.                                     for(int i=selected_copy_final_x; i<selected_copy_ini_x; i++)
  3908.                                     {
  3909.  
  3910.                                         s[i-selected_copy_final_x]=inputText[selected_copy_final_y].c_str()[i];
  3911.  
  3912.  
  3913.                                     }
  3914.                                     s[selected_copy_ini_x-selected_copy_final_x]=0;
  3915.                                 }
  3916.  
  3917.                                 else if(selected_copy_ini_y>selected_copy_final_y)
  3918.                                 {
  3919.                                     for(int i=selected_copy_final_x; i<strlen(inputText[selected_copy_final_y].c_str()); i++)
  3920.                                     {
  3921.  
  3922.                                         s2[i-selected_copy_final_x]=inputText[selected_copy_final_y].c_str()[i];
  3923.  
  3924.                                     }
  3925.                                     s2[strlen(inputText[selected_copy_final_y].c_str())]=0;
  3926.                                     strcpy(s,s2);
  3927.  
  3928.  
  3929.                                     for(int i=selected_copy_final_y+1; i<selected_copy_ini_y; i++)
  3930.                                     {
  3931.                                         strcat(s,inputText[i].c_str());
  3932.  
  3933.                                     }
  3934.                                     for(int i=0; i<=selected_copy_ini_x; i++)
  3935.                                     {
  3936.                                         s2[i]=inputText[selected_copy_ini_y].c_str()[i];
  3937.                                     }
  3938.                                     s2[selected_copy_ini_x+1]=0;
  3939.                                     strcat(s,s2);
  3940.  
  3941.  
  3942.  
  3943.                                 }
  3944.  
  3945.  
  3946.                                 else if(selected_copy_ini_y<selected_copy_final_y)
  3947.                                 {
  3948.                                     for(int i=selected_copy_ini_x; i<strlen(inputText[selected_copy_ini_y].c_str()); i++)
  3949.                                     {
  3950.  
  3951.                                         s2[i-selected_copy_ini_x]=inputText[selected_copy_ini_y].c_str()[i];
  3952.  
  3953.  
  3954.                                     }
  3955.                                     s2[strlen(inputText[selected_copy_ini_y].c_str())]=0;
  3956.  
  3957.                                     strcpy(s,s2);
  3958.                                  ;
  3959.  
  3960.                                     for(int i=selected_copy_ini_y+1; i<selected_copy_final_y; i++)
  3961.                                     {
  3962.                                         strcat(s,inputText[i].c_str());
  3963.  
  3964.                                     }
  3965.                                     for(int i=0; i<=selected_copy_final_x; i++)
  3966.                                     {
  3967.                                         s2[i]=inputText[selected_copy_final_y].c_str()[i];
  3968.                                     }
  3969.                                     s2[selected_copy_final_x+1]=0;
  3970.                                     strcat(s,s2);
  3971.  
  3972.  
  3973.  
  3974.                                 }
  3975.  
  3976.  
  3977.                                 SDL_SetClipboardText(s);
  3978.                                 selected_copy_check=0;
  3979.                                 s[0]=0;
  3980.  
  3981.                             }
  3982.                             else if(all_select==1)
  3983.                             {
  3984.                                 if(search_bar_bool)strcpy(s,inputText[100].c_str());
  3985.                                 else
  3986.                                 {
  3987.                                     for(int i=0; i<=current_line; i++)
  3988.                                     {
  3989.                                         if(i==0)
  3990.                                             strcpy(s,inputText[i].c_str());
  3991.                                         else
  3992.                                             strcat(s,inputText[i].c_str());
  3993.  
  3994.  
  3995.  
  3996.  
  3997.                                     }
  3998.                                 }
  3999.                                 SDL_SetClipboardText(s);
  4000.                                 s[1]=0;
  4001.                             }
  4002.                         }
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.                         //paste something
  4009.  
  4010.  
  4011.                         else if( e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL &&current_line!=100)
  4012.                         {
  4013.  
  4014.                                 while(!new_s.empty())new_s.pop();
  4015.                                 while(!new_x.empty())new_x.pop();
  4016.                                 while(!new_l.empty())new_l.pop();
  4017.  
  4018.                           renderText=false;
  4019.  
  4020.  
  4021.                             sh=SDL_GetClipboardText();
  4022.                             if(strlen(sh.c_str())>0)
  4023.                             {
  4024.  
  4025.  
  4026.                                 if(strlen(inputText[current_line].c_str())==0)inputText[current_line]=' ';
  4027.  
  4028.  
  4029.                                 if(left_sign==0)
  4030.                                     fulltext = inputText[current_line]+SDL_GetClipboardText();
  4031.                                 else
  4032.                                 {
  4033.                                     for(int i=0; i<left_sign; i++)
  4034.                                     {
  4035.                                         tchar[i]=inputText[current_line].c_str()[length-left_sign+i];
  4036.  
  4037.                                         tchar[i+1]=0;
  4038.                                     }
  4039.                                     for(int i=0; i<left_sign; i++)
  4040.                                     {
  4041.                                         inputText[current_line].pop_back();
  4042.                                     }
  4043.                                     fulltext = inputText[current_line]+SDL_GetClipboardText();
  4044.                                     fulltext = fulltext+tchar;
  4045.                                     inputText[current_line]=' ';
  4046.                                     inputText[current_line].pop_back();
  4047.                                 }
  4048.  
  4049.                                 int l=strlen(fulltext.c_str());
  4050.  
  4051.                                 for(int i=0; i<l; i++)stemp[i]=fulltext.c_str()[i];
  4052.                                 stemp[l]=0;
  4053.  
  4054.  
  4055.                                 Ltemp.loadFromRenderedText( fulltext, textColor );
  4056.                                 //  printf("%d\n",Ltemp.getWidth() );
  4057.  
  4058.  
  4059.  
  4060.                                 {
  4061.                                     count=0;
  4062.                                     for(int i=0; i<l; i++)
  4063.                                     {
  4064.  
  4065.  
  4066.                                         if(stemp[i]=='\n')stemp[i]=3;
  4067.                                         if(stemp[i]==3&&i!=l-1)
  4068.                                         {
  4069.  
  4070.                                             ctemp[count]=stemp[i];
  4071.                                             ctemp[count+1]=0;
  4072.                                             sh=ctemp;
  4073.                                             inputText[current_line]=sh;
  4074.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4075.                                             count=0;
  4076.                                             current_line++;
  4077.                                             total_line++;
  4078.                                             inputText[total_line]=" ";
  4079.                                             for(int j=total_line; j>current_line+1; j--)
  4080.                                             {
  4081.                                                 sh=inputText[j];
  4082.                                                 inputText[j]=inputText[j-1];
  4083.                                                 inputText[j-1]=sh;
  4084.                                                 mainTextTexture[j].loadFromRenderedText( inputText[j], textColor );
  4085.                                             }
  4086.                                             i++;
  4087.  
  4088.                                         }
  4089.                                         ctemp[count]=stemp[i];
  4090.                                         count++;
  4091.                                         ctemp[count]=0;
  4092.  
  4093.                                         sh=ctemp;
  4094.                                         if(i==l-1)
  4095.                                         {
  4096.                                             inputText[current_line]=sh;
  4097.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4098.                                         }
  4099.                                         Ltemp.loadFromRenderedText( sh, textColor );
  4100.                                         if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  4101.                                         {
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.                                             if(ctemp[count-1]!=' '&&ctemp[count-1]!=','&&ctemp[count-1]!='.'&&ctemp[count-1]!='!'&&ctemp[count-1]!='?'&&ctemp[count-1]!='-'&&ctemp[count-1]!=';')
  4110.                                             {
  4111.  
  4112.                                                 word_count=0;
  4113.                                                 for(int j=count-1; j>=0; j--)
  4114.                                                 {
  4115.                                                     if(ctemp[j]==' '||ctemp[j]=='.'||ctemp[j]=='!'||ctemp[j]=='?'||ctemp[j]=='-'||ctemp[j]==';'||ctemp[j]==',')break;
  4116.                                                     word_count++;
  4117.                                                 }
  4118.  
  4119.                                                 if(word_count<(count-1))
  4120.                                                 {
  4121.  
  4122.                                                     ctemp[count-1-word_count+1]=0;
  4123.  
  4124.  
  4125.                                                     inputText[current_line]=ctemp;
  4126.  
  4127.                                                     i=i-word_count;
  4128.  
  4129.  
  4130.                                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4131.                                                 }
  4132.  
  4133.                                                 else
  4134.                                                 {
  4135.                                                     inputText[current_line]=sh;
  4136.                                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4137.                                                 }
  4138.  
  4139.  
  4140.                                             }
  4141.                                             else
  4142.                                             {
  4143.                                                 inputText[current_line]=sh;
  4144.                                                 mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4145.                                             }
  4146.  
  4147.  
  4148.  
  4149.                                             current_line++;
  4150.                                             total_line++;
  4151.                                             inputText[total_line]=" ";
  4152.                                             for(int j=total_line; j>current_line+1; j--)
  4153.                                             {
  4154.                                                 sh=inputText[j];
  4155.                                                 inputText[j]=inputText[j-1];
  4156.                                                 inputText[j-1]=sh;
  4157.                                                 mainTextTexture[j].loadFromRenderedText( inputText[j], textColor );
  4158.                                             }
  4159.  
  4160.                                             for(int j=0; j<=count; j++)sh.pop_back();
  4161.  
  4162.  
  4163.                                             count=0;
  4164.                                             //inputText[current_line].pop_back();
  4165.  
  4166.  
  4167.                                         }
  4168.  
  4169.                                     }
  4170.  
  4171.                                 }
  4172.  
  4173.                                 renderText=false;
  4174.  
  4175.                             }
  4176.                         }
  4177.  
  4178.  
  4179.  
  4180.                         //newline
  4181.  
  4182.  
  4183.  
  4184.                         if( SDL_GetModState() & KMOD_CTRL )ctrl_count=1;
  4185.  
  4186.  
  4187.                         if(mainTextTexture[current_line].getWidth() >= SCREEN_WIDTH-100&&ctrl_count!=1)
  4188.                         {
  4189.  
  4190.                             if(backspace_check!=1)
  4191.                             {
  4192.  
  4193.                                 Ltemp.loadFromRenderedText(inputText[current_line],textColor);
  4194.  
  4195.                                 //while(Ltemp.getWidth() >= SCREEN_WIDTH-100)
  4196.  
  4197.  
  4198.                                 //word detect korasdfsdfjsdf
  4199.                                 if(inputText[current_line].c_str()[length-1]!=' '&&inputText[current_line].c_str()[length-1]!=','&&inputText[current_line].c_str()[length-1]!='.'&&inputText[current_line].c_str()[length-1]!='!'&&inputText[current_line].c_str()[length-1]!='?'&&inputText[current_line].c_str()[length-1]!='-'&&inputText[current_line].c_str()[length-1]!=';'&&current_line==total_line)
  4200.                                 {
  4201.  
  4202.                                     word_count=0;
  4203.                                     for(int i=length-1; i>=0; i--)
  4204.                                     {
  4205.                                         if(stemp[i]==' '||stemp[i]=='.'||stemp[i]=='!'||stemp[i]=='?'||stemp[i]=='-'||stemp[i]==';'||stemp[i]==',')break;
  4206.                                         word_count++;
  4207.                                     }
  4208.  
  4209.                                     if(word_count<(length-1))
  4210.                                     {
  4211.                                         for(int i=0; i<=word_count; i++)
  4212.                                         {
  4213.                                             ctemp[i]=stemp[length-1-word_count+1+i];
  4214.  
  4215.                                         }
  4216.                                         if(stemp[length-1]==' ')stemp[length-1-word_count]=0;
  4217.                                         else
  4218.                                             stemp[length-1-word_count+1]=0;
  4219.                                         ctemp[word_count+1]=0;
  4220.                                         lengthtemp=length;
  4221.  
  4222.                                         inputText[current_line]=stemp;
  4223.  
  4224.                                         inputText[current_line+1]=ctemp;
  4225.  
  4226.  
  4227.                                         //indicator positio Thik kora
  4228.                                         if(left_sign>word_count)
  4229.                                         {
  4230.                                             left_sign=left_sign-word_count;
  4231.                                             left_sign_check=1;
  4232.                                             current_line--;
  4233.                                             overflow_check=1;
  4234.  
  4235.  
  4236.                                         }
  4237.                                         else if(left_sign!=0)
  4238.                                         {
  4239.                                             left_sign=left_sign;
  4240.                                         }
  4241.                                         else
  4242.  
  4243.                                             left_sign=0;
  4244.                                         word_count=0;
  4245.  
  4246.  
  4247.  
  4248.                                         if(left_sign_check!=1)
  4249.                                         {
  4250.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4251.                                         }
  4252.                                         else
  4253.                                         {
  4254.                                             mainTextTexture[current_line+2].loadFromRenderedText( inputText[current_line+2], textColor );
  4255.                                             left_sign_check=0;
  4256.                                         }
  4257.                                     }
  4258.                                     //eikhane ektu jhamela ache
  4259.  
  4260.  
  4261.  
  4262.  
  4263.                                 }
  4264.  
  4265.  
  4266.  
  4267.  
  4268.                                 else if(current_line<total_line)
  4269.                                 {
  4270.                                     fulltext=' ';
  4271.                                     fulltext.pop_back();
  4272.  
  4273.  
  4274.                                     line_temp=current_line;
  4275.                                     for(int i=current_line; i<=total_line; i++)
  4276.                                     {
  4277.                                         fulltext+=inputText[i];
  4278.  
  4279.                                     }
  4280.                                     full_length=strlen(fulltext.c_str());
  4281.  
  4282.  
  4283.                                     for(int j=0,c=0; j<full_length; j++)
  4284.                                     {
  4285.                                         if(j==full_length-1)
  4286.                                         {
  4287.                                              ctemp[c]=fulltext.c_str()[j];
  4288.  
  4289.                                             ctemp[c+1]=0;
  4290.                                             inputText[current_line]=ctemp;
  4291.                                             c++;
  4292.                                             mainTextTexture[current_line].loadFromRenderedText(ctemp,textColor);
  4293.                                         }
  4294.                                         if(fulltext.c_str()[j]==3&&j!=full_length-1)
  4295.                                         {
  4296.                                             ctemp[c]=fulltext.c_str()[j];
  4297.                                             ctemp[c+1]=0;
  4298.                                             c=0;
  4299.                                             inputText[current_line]=ctemp;
  4300.                                             mainTextTexture[current_line].loadFromRenderedText(inputText[current_line],textColor);
  4301.                                             current_line++;
  4302.                                             if(current_line>total_line)total_line=current_line;
  4303.                                             j++;
  4304.  
  4305.                                         }
  4306.  
  4307.                                         ctemp[c]=fulltext.c_str()[j];
  4308.  
  4309.                                         ctemp[c+1]=0;
  4310.                                         inputText[current_line]=ctemp;
  4311.                                         c++;
  4312.                                         mainTextTexture[current_line].loadFromRenderedText(ctemp,textColor);
  4313.                                         if(mainTextTexture[current_line].getWidth() >= SCREEN_WIDTH-100)
  4314.                                         {
  4315.                                             length=strlen(inputText[current_line].c_str());
  4316.                                             for(int i=0; i<=length; i++)
  4317.                                             {
  4318.  
  4319.                                                 stemp[i]=inputText[current_line].c_str()[i];
  4320.  
  4321.  
  4322.  
  4323.                                             }
  4324.  
  4325.  
  4326.                                             if(inputText[current_line].c_str()[length-1]!=' '&&inputText[current_line].c_str()[length-1]!=','&&inputText[current_line].c_str()[length-1]!='.'&&inputText[current_line].c_str()[length-1]!='!'&&inputText[current_line].c_str()[length-1]!='?'&&inputText[current_line].c_str()[length-1]!='-'&&inputText[current_line].c_str()[length-1]!=';')
  4327.                                             {
  4328.  
  4329.                                                 word_count=0;
  4330.                                                 for(int i=length-1; i>=0; i--)
  4331.                                                 {
  4332.                                                     if(stemp[i]==' '||stemp[i]=='.'||stemp[i]=='!'||stemp[i]=='?'||stemp[i]=='-'||stemp[i]==';'||stemp[i]==',')break;
  4333.                                                     word_count++;
  4334.                                                 }
  4335.  
  4336.                                                 if(word_count<(length-1))
  4337.                                                 {
  4338.                                                     for(int i=0; i<=word_count; i++)
  4339.                                                     {
  4340.                                                         ctemp[i]=stemp[length-1-word_count+1+i];
  4341.  
  4342.                                                     }
  4343.  
  4344.                                                     stemp[length-1-word_count+1]=0;
  4345.  
  4346.                                                     ctemp[word_count+1]=0;
  4347.  
  4348.                                                     inputText[current_line]=stemp;
  4349.  
  4350.                                                     j=j-word_count;
  4351.                                                     if(indicator_temp==0)
  4352.                                                     {
  4353.                                                         indicator_temp=1;
  4354.                                                         indi_pos_temp=word_count;
  4355.  
  4356.  
  4357.  
  4358.  
  4359.                                                     }
  4360.  
  4361.  
  4362.  
  4363.                                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  4364.                                                 }
  4365.                                                 else
  4366.                                                 {
  4367.                                                     if(left_sign!=0)
  4368.                                                     {
  4369.                                                         j--;
  4370.                                                         if(overflow_check!=1&&indicator_temp==0)overflow_check=1;
  4371.                                                         inputText[current_line].pop_back();
  4372.                                                         left_sign--;
  4373.  
  4374.                                                     }
  4375.                                                     if(indicator_temp==0)
  4376.                                                     {
  4377.                                                         indicator_temp=1;
  4378.                                                         indi_pos_temp=0;
  4379.                                                         indi_xpos;
  4380.  
  4381.  
  4382.                                                     }
  4383.                                                 }
  4384.  
  4385.  
  4386.                                             }
  4387.  
  4388.                                             //printf("%s\n",ctemp );
  4389.                                             current_line++;
  4390.                                             c=0;
  4391.                                             if(current_line>total_line)total_line=current_line;
  4392.                                         }
  4393.                                     }
  4394.                                     total_line--;
  4395.                                     current_line=line_temp;
  4396.                                     backspace_check=1;
  4397.                                     indicator_temp=0;
  4398.                                     overflow_check=0;
  4399.                                     if(left_sign==0)left_sign=strlen(inputText[current_line+1].c_str())-indi_pos_temp;
  4400.  
  4401.                                     else
  4402.                                     {
  4403.                                         if(overflow_check==1)
  4404.                                         {
  4405.  
  4406.                                             current_line--;
  4407.                                         }
  4408.                                         else if(left_sign-indi_pos_temp>0)
  4409.                                         {
  4410.                                             //printf("how\n");
  4411.                                             if(indi_pos_temp!=0&&lengthtemp!=strlen(inputText[current_line].c_str())) left_sign=strlen(inputText[current_line].c_str())-indi_xpos;
  4412.                                             if(left_sign<0)left_sign=0;
  4413.                                             current_line--;
  4414.                                         }
  4415.                                         else
  4416.                                         {
  4417.                                             left_sign=strlen(inputText[current_line+1].c_str())-indi_pos_temp+left_sign-1;
  4418.                                             //printf("why\n");
  4419.                                         }
  4420.  
  4421.                                        // printf("left sign %d\n",left_sign );
  4422.                                         indi_pos_temp=0;
  4423.  
  4424.                                     }
  4425.  
  4426.  
  4427.                                 }
  4428.  
  4429.                                 current_line++;
  4430.  
  4431.  
  4432.                                 total_line++;
  4433.                             }
  4434.                             else
  4435.                                 backspace_check=0;
  4436.  
  4437.                             renderText = true;
  4438.  
  4439.  
  4440.                         }
  4441.                         else
  4442.                             ctrl_count=0;
  4443.  
  4444.  
  4445.  
  4446.  
  4447.                     }
  4448.  
  4449.  
  4450.  
  4451.  
  4452.  
  4453.                     else if( e.type == SDL_TEXTINPUT )
  4454.                     {
  4455.                         if( !( SDL_GetModState() & KMOD_CTRL && ( e.text.text[ 0 ] == 'c' || e.text.text[ 0 ] == 'C' || e.text.text[ 0 ] == 'v' || e.text.text[ 0 ] == 'V'|| e.text.text[ 0 ] == 'a' || e.text.text[ 0 ] == 'A' ) ) )
  4456.                         {
  4457.                             inputText[current_line] += e.text.text;
  4458.                             renderText = true;
  4459.                              if(left_sign>=1)
  4460.                                 {
  4461.  
  4462.                                     length=strlen(inputText[current_line].c_str());
  4463.                                      length=strlen(inputText[current_line].c_str());
  4464.                                         indi_xpos=length-left_sign;
  4465.                                         if(indi_xpos<0)indi_xpos=0;
  4466.  
  4467.  
  4468.                                         for(int i=0; i<=length; i++)
  4469.                                         {
  4470.                                             if(i<indi_xpos)ctemp[i]=inputText[current_line].c_str()[i];
  4471.                                             stemp[i]=inputText[current_line].c_str()[i];
  4472.  
  4473.  
  4474.                                         }
  4475.                                         stemp[length+1]=0;
  4476.                                         ctemp[indi_xpos]=0;
  4477.  
  4478.  
  4479.  
  4480.                                     {
  4481.                                         //ekhane ken eta disi jani na eita dile majhe kichu likhe Thikmoto kaj kore na .....left_sign++;
  4482.                                         for(int i=length-1; i>indi_xpos-1; i--)
  4483.                                         {
  4484.                                             char_temp=stemp[i];
  4485.                                             stemp[i]=stemp[i-1];
  4486.                                             stemp[i-1]=char_temp;
  4487.  
  4488.  
  4489.                                         }
  4490.  
  4491.  
  4492.                                     }
  4493.                                    inputText[current_line]=stemp;
  4494.                                     //for(int i=0; i<=length; i++)inputText[current_line].pop_back();
  4495.                                 }
  4496.  
  4497.  
  4498.  
  4499.                         }
  4500.                     }
  4501.  
  4502.  
  4503.  
  4504.  
  4505.  
  4506.  
  4507.                     //indicator
  4508.  
  4509.  
  4510.  
  4511.                     length=strlen(inputText[current_line].c_str());
  4512.                     indi_xpos=length-left_sign;
  4513.                     if(indi_xpos<0)indi_xpos=0;
  4514.  
  4515.  
  4516.                     for(int i=0; i<=length; i++)
  4517.                     {
  4518.                         if(i<indi_xpos)ctemp[i]=inputText[current_line].c_str()[i];
  4519.                         stemp[i]=inputText[current_line].c_str()[i];
  4520.  
  4521.  
  4522.                     }
  4523.                     stemp[length+1]=0;
  4524.                     ctemp[indi_xpos]=0;
  4525.                     if(indi_xpos!=0)
  4526.                     {
  4527.                         Ltemp.loadFromRenderedText( ctemp, textColor );
  4528.                         final_indi_xpos=Ltemp.getWidth();
  4529.                     }
  4530.                     else
  4531.                         final_indi_xpos=0;
  4532.  
  4533.                     if(huda==1)
  4534.                     {
  4535.                         printf("l=%d ,ix=%d ,f_ix=%d ,ls=%d ,t_l=%d, c_l=%d\n",length,indi_xpos,final_indi_xpos,left_sign,total_line,current_line);
  4536.  
  4537.                         huda=0;
  4538.                     }
  4539.  
  4540.  
  4541.  
  4542.                 }
  4543.  
  4544.  
  4545.  
  4546.                 if( renderText )
  4547.                 {
  4548.                     while(!new_s.empty())new_s.pop();
  4549.                     while(!new_x.empty())new_x.pop();
  4550.                     while(!new_l.empty())new_l.pop();
  4551.  
  4552.                   all_select=0;
  4553.                   selected_copy_check=0;
  4554.  
  4555.                     if( inputText[current_line] != "" )
  4556.                     {
  4557.  
  4558.  
  4559.  
  4560.                         mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  4561.  
  4562.  
  4563.                     }
  4564.  
  4565.                     else
  4566.                     {
  4567.                         mainTextTexture[current_line].loadFromRenderedText( " ", textColor );
  4568.                     }
  4569.                 }
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.                 max_line=(SCREEN_HEIGHT-90-image_int-search_int)/50;
  4577.                 //  printf("%d\n",max_line );
  4578.                 if( total_line>max_line)scroll_count=total_line-max_line;
  4579.                 else
  4580.                     scroll_count=0;
  4581.                 if(current_line<=scroll_count&&total_line!=0)up_sign=scroll_count-current_line;
  4582.                 else
  4583.                     up_sign=0;
  4584.  
  4585.                     //search
  4586.                    if(search_bar_bool&&now_search==1&&strlen(inputText[100].c_str())>0)
  4587.                         {
  4588.  
  4589.                             now_search=0;
  4590.                             word_count=0;
  4591.  
  4592.                             for(int j=0;j<strlen(inputText[100].c_str());j++)ctemp[j]=inputText[100].c_str()[j];
  4593.                                 ctemp[strlen(inputText[100].c_str())]=0;
  4594.  
  4595.                             Ltemp.loadFromRenderedText(ctemp,textColor);
  4596.                             search_length=Ltemp.getWidth();
  4597.  
  4598.                             for(int i=0;i<=total_line;i++)
  4599.                             {
  4600.                               if(strlen(inputText[i].c_str())>strlen(inputText[100].c_str()))
  4601.  
  4602.                                 for(int j=0,k=0;j<strlen(inputText[i].c_str())-strlen(inputText[100].c_str());)
  4603.                                 {
  4604.                                     if(j>=1)stemp[j-1]=inputText[i].c_str()[j-1];
  4605.                                     stemp[j]=0;
  4606.  
  4607.                                     while(ctemp[k]==inputText[i].c_str()[k+j])
  4608.                                     {
  4609.                                         if(strlen(inputText[100].c_str())-1==k)
  4610.                                         {
  4611.                                             Ltemp.loadFromRenderedText(stemp,textColor);
  4612.  
  4613.  
  4614.                                             s_bar[word_count].w=search_length;
  4615.                                             if(j>=1)s_bar[word_count].x=Ltemp.getWidth();
  4616.                                             else s_bar[word_count].x=0;
  4617.                                             s_bar[word_count].y=i*50+40+image_int;
  4618.                                             s_bar[word_count].h=45;
  4619.  
  4620.  
  4621.                                             word_count++;
  4622.                                             break;
  4623.                                         }
  4624.                                         k++;
  4625.  
  4626.                                     }
  4627.                                     if(k==(strlen(inputText[100].c_str())-1))
  4628.                                     {
  4629.                                         for(int f=0;f<strlen(inputText[100].c_str());f++)
  4630.                                         {
  4631.                                             if(j>=1)stemp[j-1]=inputText[i].c_str()[j-1];
  4632.                                                 stemp[j]=0;
  4633.                                                 j++;
  4634.                                         }
  4635.  
  4636.                                     }
  4637.                                     else
  4638.                                         j++;
  4639.  
  4640.                                     k=0;
  4641.                                 }
  4642.                             }
  4643.                             printf("%d\n",word_count );
  4644.  
  4645.  
  4646.                         }
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.                 SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  4657.                 SDL_RenderClear( main_renderer );
  4658.  
  4659.  
  4660.                 SDL_RenderSetViewport(main_renderer, &textBackgroundRect);
  4661.                 SDL_RenderCopy(main_renderer, background_texture, NULL, NULL);
  4662.                 SDL_RenderDrawRect(main_renderer, &search_rect);
  4663.  
  4664.                 //search onsho show kora
  4665.                 if(search_bar_bool && inputText[100].size() > 0)
  4666.                 {
  4667.                   for(int i=0; i<word_count; i++)
  4668.                   {
  4669.                     SDL_RenderDrawRect(main_renderer, &s_bar[i]);
  4670.                   }
  4671.                   SDL_SetRenderDrawColor( main_renderer, 0, 128, 255, 0 );
  4672.                   SDL_RenderFillRect(main_renderer, &s_bar[search_count]);
  4673.                 }
  4674.  
  4675.  
  4676.                 //all select
  4677.                 if(all_select)
  4678.                 {
  4679.                  SDL_SetRenderDrawColor( main_renderer, 0, 128, 255, 0 );
  4680.                         for(int i=0;i<=total_line;i++)
  4681.                         {
  4682.                             s_mid[i].x=0;
  4683.                             s_mid[i].y=i*50+40+image_int;
  4684.                             s_mid[i].w=mainTextTexture[i].getWidth();
  4685.                             s_mid[i].h=45;
  4686.                              SDL_RenderFillRect(main_renderer, &s_mid[i]);
  4687.                         }
  4688.                 }
  4689.  
  4690.  
  4691.  
  4692.                 //selected onsho show kora
  4693.  
  4694.  
  4695.                 if(selected_copy_check)
  4696.                 {
  4697.                     SDL_SetRenderDrawColor( main_renderer, 0, 128, 255, 0 );
  4698.                     if(selected_copy_final_y==selected_copy_ini_y)
  4699.                     {
  4700.                          if(selected_copy_final_x>selected_copy_ini_x)
  4701.                             {
  4702.  
  4703.                                  s_ini.x=ini_xpos;
  4704.                                 s_ini.y=selected_copy_final_y*50+40+image_int;;
  4705.                                 s_ini.h=45;
  4706.                                 s_ini.w=final_xpos-ini_xpos;
  4707.                                 if(s_ini.w>5)
  4708.  
  4709.                                 SDL_RenderFillRect(main_renderer, &s_ini);
  4710.  
  4711.                             }
  4712.                             else
  4713.                             {
  4714.                                  s_ini.x=ini_xpos;
  4715.                                 s_ini.y=selected_copy_final_y*50+40+image_int;;
  4716.                                 s_ini.h=45;
  4717.                                 s_ini.w=final_xpos-ini_xpos;
  4718.                                 if(s_ini.w<5)SDL_RenderFillRect(main_renderer, &s_ini);
  4719.                             }
  4720.  
  4721.                     }
  4722.                     else if(selected_copy_final_y<selected_copy_ini_y)
  4723.                     {
  4724.                         s_ini.x=final_xpos;
  4725.                         s_ini.y=selected_copy_final_y*50+40+image_int;
  4726.                         s_ini.w=mainTextTexture[selected_copy_final_y].getWidth()-final_xpos;
  4727.                         s_ini.h=45;
  4728.                          SDL_RenderFillRect(main_renderer, &s_ini);
  4729.  
  4730.                         for(int i=selected_copy_final_y+1;i<selected_copy_ini_y;i++)
  4731.                         {
  4732.                             s_mid[i].x=0;
  4733.                             s_mid[i].y=i*50+40+image_int;
  4734.                             s_mid[i].w=mainTextTexture[i].getWidth();
  4735.                             s_mid[i].h=45;
  4736.                              SDL_RenderFillRect(main_renderer, &s_mid[i]);
  4737.                         }
  4738.                         s_fin.x=0;
  4739.                         s_fin.y=selected_copy_ini_y*50+40+image_int;
  4740.                         s_fin.w=ini_xpos;
  4741.                         s_fin.h=45;
  4742.                          SDL_RenderFillRect(main_renderer, &s_fin);
  4743.  
  4744.                     }
  4745.                     else if(selected_copy_final_y>selected_copy_ini_y)
  4746.                     {
  4747.                         s_ini.x=ini_xpos;
  4748.                         s_ini.y=selected_copy_ini_y*50+40+image_int;
  4749.                         s_ini.w=mainTextTexture[selected_copy_ini_y].getWidth()-ini_xpos;
  4750.                         s_ini.h=45;
  4751.                          SDL_RenderFillRect(main_renderer, &s_ini);
  4752.  
  4753.                         for(int i=selected_copy_ini_y+1;i<selected_copy_final_y;i++)
  4754.                         {
  4755.                             s_mid[i].x=0;
  4756.                             s_mid[i].y=i*50+40+image_int;
  4757.                             s_mid[i].w=mainTextTexture[i].getWidth();
  4758.                             s_mid[i].h=45;
  4759.                              SDL_RenderFillRect(main_renderer, &s_mid[i]);
  4760.                         }
  4761.                         s_fin.x=0;
  4762.                         s_fin.y=selected_copy_final_y*50+40+image_int;
  4763.                         s_fin.w=final_xpos;
  4764.                         s_fin.h=45;
  4765.                          SDL_RenderFillRect(main_renderer, &s_fin);
  4766.  
  4767.                     }
  4768.                 }
  4769.  
  4770.  
  4771.              //blinking indicaotr
  4772.                 c++;
  4773.                 if(c%70>=32)
  4774.                     //    gDotTexture.render( final_indi_xpos,(current_line-scroll_count+up_sign)*50+50);
  4775.                     SDL_SetRenderDrawColor( main_renderer, 0xFF, 0xFF, 0xFF, 0xFF );
  4776.                 if(current_line!=100)SDL_RenderDrawLine( main_renderer, final_indi_xpos, (current_line-scroll_count+up_sign)*50+50+image_int, final_indi_xpos, (current_line-scroll_count+up_sign)*50+50+ 40+image_int );
  4777.              else
  4778.                     SDL_RenderDrawLine( main_renderer, final_indi_xpos+150, SCREEN_HEIGHT-search_int, final_indi_xpos+150, SCREEN_HEIGHT-search_int+40 );
  4779.  
  4780.                 if(c>70)c=0;
  4781.  
  4782.  
  4783.                 header.render( SCREEN_WIDTH/2-SCREEN_WIDTH/10,0);
  4784.                 for(int j=0; j<=total_line-scroll_count; j++ )   mainTextTexture[j+scroll_count-up_sign].render( 0, j*50+ 50 +image_int);
  4785.  
  4786.  
  4787.                     //seachbar
  4788.                     search_bar.loadFromRenderedText( "search:", textColor );
  4789.                     search_bar.render( 0,SCREEN_HEIGHT-search_int);
  4790.                     if(search_bar_bool)
  4791.                     {   if(strlen(inputText[100].c_str())==0)mainTextTexture[100].loadFromRenderedText(" ",textColor);
  4792.                         else
  4793.                             mainTextTexture[100].loadFromRenderedText(inputText[100],textColor);
  4794.                         mainTextTexture[100].render(150,SCREEN_HEIGHT-search_int);
  4795.                     }
  4796. //  image render related work
  4797.                 if(isThereAnyImageSavedToThisFile && !ekbarImageLoadErJonnoBool){
  4798.                   ekbarImageLoadErJonnoBool = true;
  4799.  
  4800.                   showImageTexture = loadTexture(imageSavedString.c_str());
  4801.                 }
  4802.  
  4803.  
  4804.                 if(isThereAnyImageSavedToThisFile){
  4805.                   SDL_RenderSetViewport(main_renderer, &imageShownRect);
  4806.                   SDL_RenderCopy(main_renderer, showImageTexture, NULL, NULL);
  4807.                   //SDL_RenderPresent(main_renderer);
  4808.                 }
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.  
  4818. //  menu show
  4819.  
  4820.  
  4821.                 SDL_RenderSetViewport(main_renderer, &topMenuRect1);
  4822.                 SDL_RenderCopy(main_renderer, topMenuTexture1, NULL, NULL);
  4823.                 SDL_RenderSetViewport(main_renderer, &topMenuRect2);
  4824.                 SDL_RenderCopy(main_renderer, topMenuTexture2, NULL, NULL);
  4825.                 SDL_RenderSetViewport(main_renderer, &topMenuRect3);
  4826.                 SDL_RenderCopy(main_renderer, topMenuTexture3, NULL, NULL);
  4827.                 SDL_RenderSetViewport(main_renderer, &topMenuRect4);
  4828.                 SDL_RenderCopy(main_renderer, topMenuTexture4, NULL, NULL);
  4829.  
  4830.  
  4831.                 if(newMenuBool)
  4832.                 {
  4833.                     SDL_RenderSetViewport(main_renderer, &newMenuRect);
  4834.                     SDL_RenderCopy(main_renderer, newMenuShowTexture, NULL, NULL);
  4835.                 }
  4836.  
  4837.                 if(viewMenuBool)
  4838.                 {
  4839.                     view_int=1;
  4840.                     SDL_RenderSetViewport(main_renderer, &viewMenuRect);
  4841.                     SDL_RenderCopy(main_renderer, viewMenuShowTexture, NULL, NULL);
  4842.                 }
  4843.  
  4844.                 if(preferenceMenuBool)
  4845.                 {
  4846.                     SDL_RenderSetViewport(main_renderer, &preferenceMenuRect);
  4847.                     SDL_RenderCopy(main_renderer, PreferenceMenuTexture, NULL, NULL);
  4848.                 }
  4849.  
  4850.  
  4851.                 if(screenImagebool)
  4852.                 {
  4853.                     SDL_RenderSetViewport(main_renderer, &screenImageRect);
  4854.                     SDL_RenderCopy(main_renderer, screenImageTexture, NULL, NULL);
  4855.                 }
  4856.                 if(closeWithoutSavingBool){
  4857.  
  4858.                   SDL_RenderSetViewport(main_renderer, &closeWithoutSavingRect);
  4859.                   SDL_RenderCopy(main_renderer, closeWithoutSavingTexture, NULL, NULL);
  4860.                 }
  4861.  
  4862.                 if(backGroundChooseBool)
  4863.                 {
  4864.                   SDL_RenderSetViewport(main_renderer, &backGroundChooseRect);
  4865.                   SDL_RenderCopy(main_renderer, backGroundChooseTexture, NULL, NULL);
  4866.                 }
  4867.  
  4868.                 if(clickToChooseMusicBool)
  4869.                 {
  4870.                   SDL_RenderSetViewport(main_renderer, &backGroundChooseRect);
  4871.                   SDL_RenderCopy(main_renderer, clickToChooseMusicTexture, NULL, NULL);
  4872.                 }
  4873.  
  4874.  
  4875.                 time_t t = time(NULL);
  4876.                 struct tm tm = *localtime(&t);
  4877.                 sprintf(show_time, "TODAYS DATE : %2d/%2d/%4d", tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
  4878.                 timeTexture = loadTextTexture(show_time, textColor);
  4879.                 SDL_RenderSetViewport(main_renderer, &timeViewRect);
  4880.                 SDL_RenderCopy(main_renderer, timeTexture, NULL, NULL);
  4881.  
  4882.                 sprintf(show_time, "CLOCK: %2d:%2d:%2d", tm.tm_hour%12, tm.tm_min, tm.tm_sec);
  4883.                 timeTexture = NULL;
  4884.                 timeTexture = loadTextTexture(show_time, textColor);
  4885.                 SDL_RenderSetViewport(main_renderer, &timeViewRect2);
  4886.                 SDL_RenderCopy(main_renderer, timeTexture, NULL, NULL);
  4887.  
  4888.  
  4889.                 timeTexture = NULL;
  4890.                 timeTexture = loadTextTexture(tempu3.c_str(), textColor);
  4891.  
  4892.                 SDL_RenderSetViewport(main_renderer, &usernameViewRect);
  4893.                 SDL_RenderCopy(main_renderer,timeTexture, NULL, NULL);
  4894.  
  4895.  
  4896.                 SDL_RenderPresent( main_renderer );
  4897.  
  4898.  
  4899.  
  4900.             }
  4901.             SDL_StopTextInput();
  4902.  
  4903.  
  4904.         }
  4905.     }
  4906.     close();
  4907.     return 0;
  4908. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement