C.L.O.S.E - Text Editor

anuragcoder 0 Tallied Votes 310 Views Share

Hi guys,
Here's my project finally.
It's name is C.L.O.S.E - The Command Line Open Source Editor
Please review and comment.

Mention errors if any,
Also, for this code to work.
Please download open.cpp, find.cpp, new.cpp, append.cpp, compile them and place all of them including the main source in a single directory. Now compile main source and run.

Anurag.

#include <iostream>
#include <string>
#include <fstream>
#include <time.h>
#include <windows.h>

using namespace std;
char input[256];

void cls(){
     system("cls");
     }

void pause(){
     system("PAUSE");
     }

void help(){
     cout << "\t _________________________\t" << endl;
     cout << "\t|         HELP INFO       |\t" << endl;
     cout << "\t---------------------------\t" << endl;
     cout << "\t| CLS - Clear Screen      |\t" << endl;
     cout << "\t| OPEN - Open File        |\t" << endl;
     cout << "\t| NEW - New File          |\t" << endl;
     cout << "\t| FIND - Find in file     |\t" << endl;
     cout << "\t| APP - Append To File    |\t" << endl;
     cout << "\t| HELP - Show this text   |\t" << endl;
     cout << "\t| QUIT - Quit the program |\t" << endl;
     cout << "\t---------------------------\t" << endl;
     }
void splash(){
     system("title C.L.O.S.E V3 Enhanced.");
    int i = 4; //replace to 6
    while (i > 0)
    {
          if (i == 0, 2, 4,6)
          {
                system("color 2A");
                cout << "\n\n\n\n\n\n\n\n\n\n\t\t        C.L.O.S.E\t\t";
                  cout << "\n\t\tThe Command Line Open Source Editor. VERSION 3 ALPHA\t\t";
    cout << "\n\t\t   Inanimate Studios 2010. (C)Envy Inc. 2010\t\t";
    Sleep(500);
    system("cls");
 i--; 
             }
             if (i == 1, 3, 5) {
                  system("color 1A");
                  cout << "\n\n\n\n\n\n\n\n\n\n\t\t        C.L.O.S.E\t\t";
                  cout << "\n\t\tThe Command Line Open Source Editor. VERSION 3 ALPHA\t\t";
    cout << "\n\t\t   Inanimate Studios 2010. (C)Envy Inc. 2010\t\t";
    Sleep(500);
    system("cls");
 i--; 
                  }  
        }
}

void cmdline(){
     cout << "\tC.L.O.S.E -- THE NEW COMMAND LINE INTERFACE\t" << endl;
     string inp;
     do
     {
          cout << "|=>";
          cin >> inp;
          if(inp == "open"){
            system("open.exe");
            }
          if(inp == "new"){
            system("new.exe");
            }
          if(inp == "cls"){
            cls();
            }
          if(inp == "help"){
            help();
            }
          if(inp == "app"){
            system("append.exe");
            }
          if(inp == "find"){
            system("find.exe");
            }
          }while(inp != "quit");
     
     
     
          

}

int main(){
    splash();
    cmdline();
}
nbaztec 45 Posting Pro in Training

Personally I'm all against system() calls.

anuragcoder -6 Junior Poster in Training

I have that itself on windows.
Can you please throw light on the topic?

anuragcoder -6 Junior Poster in Training

Also, a review of the program?
Suggestions
Comments.
Please

nbaztec 45 Posting Pro in Training

Well for they tend to make your application slower & inefficient. It's like using your furniture to produce heat, or calling a bull-dozer to open your front door.
The events taking place upon calling system() are roughly the foll:
1. Suspends your program.
2. Calls the OS Shell. (Slowest Step)
3. OS Shell finds the command.
4. Allocates memory to execute it.
5. Executes it.
6. Deallocates memory
7. Exits the shell.
8. Resumes your program.

You can try using ShellExecute() or ShellExecuteEx(), clrscr() & getch()
for their respective purposes of opening a executable, clearing screen & pausing.

anuragcoder -6 Junior Poster in Training

Yep.. thanks...
Okay.. lets see C.L.O.S.E V4....

clrscr() and gotoxy() aren't common/recognized functs i think
(Coz i use Dev C++)

anuragcoder -6 Junior Poster in Training

Anyway.... I Dont See any delay in my prog when I use system()

nbaztec 45 Posting Pro in Training

Anyway.... I Dont See any delay in my prog when I use system()

That's because it's in milliseconds.

anuragcoder -6 Junior Poster in Training

Haha hell yeah!

anuragcoder -6 Junior Poster in Training

What would you want in V4?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.