(c++) You need to write a program similar to NOTEPAD. The program will allow the
ID: 3885979 • Letter: #
Question
(c++) You need to write a program similar to NOTEPAD. The program will allow the user to type anything he/she wants. Letters, digits, special characters. In as many rows as he/she wants.
The user then can save the text he/she wrote, then later on load it to continue working on. Your program should allow the user to do the following:
-Navigate the screen using the arrow keys (go up if there is text above the cursor and down if there is text below cursor, right if there is text on the right side of cursor and left if there is text on left side of cursor: linked list)
-Cursor can not go outside screen.
-User can save the document on disk in text format
-User can load item from a file into the editor. So if I have my own TEXT file, I can load it into your editor to read it and edit it
-User can manipulate text by adding, deleting, copy/pasting....etc.
-Display a menu with the options/commands the user can use to operate your editor
**Make sure you use your own code, do not use any reserved functions from external libraries.
Use this code to manipulate the interface:
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
void gotoxy(int x, int y) {
COORD pos = { x, y };
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(output, pos);
}
Explanation / Answer
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iostream.h>
class NotePad
{
private:
int x;
int y;
int key;
int total_chars;
int total_words;
int total_sentance;
int line[100];
public:
void clipboard()
x=1,y=1,total_words=0,total_chars=0;
int line_index=0;
while(key!=27)
{
gotoxy(1,50);cout<<"Col: "<<x<<" ";
gotoxy(11,50);cout<<"Rows: "<<y;
gotoxy(21,50);cout<<"Total Chars: "<<total_chars;
gotoxy(40,50);cout<<"Total Words: "<<total_words;
total_chars++;
gotoxy(x,y);
key=getch();
gotoxy(x,y);printf("%c",key);
if(key==13)
{
y++;
line[y]=x;
x=1;
}
else if(key==32)
{
total_words++;
}
else if(key==8)
{
x=line[y]-1;
gotoxy(x,y);cout<<" ";
}
else
{
x++;
}
}
}
};
void main(void)
{
clrscr();
NotePad np;
np.clipboard();
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.