Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //METODY
  2.  
  3. void Edit::userText()
  4. {
  5. char charly; //Zmienna na wpisany znak
  6. bool bolek = 1; //gdy klikniemy ENTER wychodzi z petli
  7. COORD tempc;
  8. tempc.X = c.X;
  9. tempc.Y = c.Y;
  10.  
  11. //Wyswietla text
  12. SetConsoleCursorPosition(hc, c);
  13. this->display();
  14. tempc.X += RealTextLength;
  15. while (bolek)
  16. {
  17. //Ustawia dobrze podkreslnik
  18. SetConsoleCursorPosition(hc, tempc);
  19.  
  20. charly = _getch();
  21. if ((int)charly == 13) //Jesli ENTER to wychodzi z petli
  22. {
  23. bolek = 0;
  24. }
  25. else
  26. {
  27. if ((int)charly == 8 && tempc.X > c.X) //Dzialanie Backspace + zabezpieczenie
  28. {
  29. tempc.X--;
  30. text[tempc.X - c.X] = ' ';
  31. SetConsoleCursorPosition(hc, tempc);
  32. cout << text[tempc.X - c.X];
  33. }
  34. else
  35. {
  36. if (tempc.X < (c.X + Length) && (int)charly != 8) // Podstawianie znaku + zabezpieczenie
  37. {
  38. text[tempc.X - c.X] = charly;
  39. SetConsoleCursorPosition(hc, tempc);
  40. cout << text[tempc.X - c.X];
  41. tempc.X++;
  42. }
  43.  
  44. }
  45. }
  46.  
  47. }
  48.  
  49.  
  50.  
  51. }
  52.  
  53. void Edit::display()
  54. {
  55. cout << getText();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement