Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Edit.h"
- using namespace std;
- Edit::Edit(): text(NULL), hc(GetStdHandle(STD_OUTPUT_HANDLE))
- {
- c.X = 0;
- c.Y = 0;
- }
- Edit::~Edit()
- {
- }
- void Edit::setPosition(int x, int y)
- {
- c.X = x;
- c.Y = y;
- SetConsoleCursorPosition(hc,c);
- }
- void Edit::setLength(int L)
- {
- delete[] text;
- this->text = new char[L+1];
- text[L] = '\0';
- Length = L;
- }
- void Edit::setText(const char* text)
- {
- if (strlen(this->text) > 0)
- {
- //setLength(strlen(this->text));
- for (int i = 0; i < strlen(this->text); i++)
- this->text[i] = text[i];
- this->text[strlen(text)] = '\0'; //Ustawianie spacji na ostatnim miejscu tablicy
- }
- else
- {
- this->text = new char[strlen(text) + 1]; //Alokowanie pamieci na wprowadzony text
- for (int i = 0; i < strlen(text); i++)
- this->text[i] = text[i];
- this->text[strlen(text)] = '\0'; //Ustawianie spacji na ostatnim miejscu tablicy
- }
- }
- void Edit::display()
- {
- for (int i = 0; i < Length; i++)
- {
- if(text[i]!='\0')
- else
- }
- }
- char *Edit::getText()
- {
- return text;
- }
- void Edit::userText()
- {
- char charly;
- int length = strlen(text);
- cout << "length" << length<<endl;
- int index = 0;
- bool bolek = 1;
- /*
- for (int i = 0; i < (length + 1); i++)
- {
- if (text[i] != '\0')
- {
- index++;
- cout << "index" << index << endl;
- }
- else if(text[i]=='\0' && index==0)
- index = 0;
- }*/
- if (length > 0)
- {
- while (bolek)
- {
- charly =_getch();
- }
- this->text[length] = '\0'; //Ustawianie spacji na ostatnim miejscu tablicy
- }
- else
- {
- cout << "0";
- }
- }
- /*
- std::ostream& operator<<(std::ostream o, const Edit eddy)
- {
- // TODO: tu wstawić instrukcję return
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement