Ft2100 - operating systems - monash university -


Building a Graphical Shell with C Programming

Background

You are currently getting familiar with the bash command line interface. Bash is an example of a shell utility. A shell is an important component in a typical computing environment, which allows the user to interact with various functions of the operating system.

Bash works by waiting for user input (in a loop), and responding to each command the user types into a TTY terminal by doing the action the user requests (then continuing to the next iteration of the loop, so the user can then input another command, repeating until the user decides to quit). However, learning to use a command-line interface can be frightening to people who aren't good with computers. Many operating systems such as Windows and macOS provide the user with a graphical shell so novice users can interact with files using a mouse. (Examples are Windows File Explorer and also the Finder in macOS.)

Objective

The objective of this assignment is to implement a simplified version of a graphical shell like you might find in a popular operating system. This works on the same principles as a command-line shell, but allows the user to provide input in a graphical way by clicking file icons on the screen, browsing folders, etc.

Your shell shall be implemented on the Linux operating system in the C programming language, making use of external Linux utilities where specified, and producing output within the ioL graphical console environment.

Preparation

Throughout your degree up to now, whenever you have printed output from a program, the output was always displayed in a plain-text terminal window (technically known as a TTY). A standard TTY terminal is not ideal for building a lavish application. The output you print can only be displayed sequentially, line by line in plain text, and you can't display graphics or ask the user to click a button.

If you run the program in the usual way (i.e. output is printed to a TTY terminal), the user will see everything you've put in the quotation marks. But if you run your program inside an ioL console, the user will see the words ‘Hello World ' with the second word displayed in italic. This approach provides the ability to make your programs more intuitive for the user. (You will need to put: ‘iol -- ' in front of the command used to run your program, in order to make it run in the special environment, and the ioL console window will close automatically as soon as your program quits.)

To produce the graphical user interface in Tasks 2 and 3, you will need to print your program output according to the ioL markup syntax, including giving the user some way to provide input back to your program. ioL has special rules for how you need to print your output in order to make things show up the way you want. Your Linux virtual machine environment is already set up with the ioL console system needed to run these tasks.

Task 1: Building the Essential Program Structure

In the first task, you will implement a very rudimentary command-line interpreter running in a TTY terminal, taking command input from the terminal as typed by the user and printing output back to the terminal. (This is not a graphical shell yet, but once you have the essential program structure in place, you will turn it into a graphical shell in Task 2.)

For this task, you should name your main source file as task1shell12345678.c, where 12345678 is your Monash Student ID number. Implement your terminal shell, task1shell, as follows:

1. When the user starts your shell, it should print the filenames of all the files in the current directory. Do not print hidden files. For each filename, also print whether it is a directory, executable program, or ordinary file.

2. Your shell should then wait for the user to input a command from the following table and behave accordingly.

3. After processing each command, the shell should allow the user to enter another com- mand, and repeat until the user decides to quit.

Task 2: Graphical User Interface

By modifying your Task 1 shell, implement a new version, task2shell, to run within an ioL console instead of a TTY terminal.1

For this task, you should name your main source file as task2shell12345678.c, where 12345678 is your Monash Student ID number.

Your Task 1 implementation produces output intended for display on a plain-text TTY terminal. Modify the print statements in your implementation to mark-up your output in a graphical way as follows:

- Instead of printing the directory contents in plain text, use visual icons to indicate the file types.2 As in Task 1, the three different file types are directories, executable files, and ordinary files. The display should be updated whenever the user changes the current working directory.
- Add onclick= handlers3 to your program's output so that when the user clicks on the file icons, the appropriate command for that file is carried out by the shell. For example, when the user clicks on a directory named test, the console should input d:test back to your shell program, and your program should print new output to display the new directory contents on the screen. Similarly, when the user clicks on an executable file, a similar x:... instruction should be produced, and so on. All other files should be treated as text files.
- Error messages should be displayed on the screen in an appropriate way (for example, you might print a element at the top of the window for error messages).
- The user should have a way to navigate to the parent folder.
- The user should be able to quit the program gracefully by closing the window.

Task 3: Advanced File Operations

In this task, you will add extra features to allow the user to carry out more advanced operations on each file. For this task, you may choose to make use of the oncontextclick= handler4 in your marked-up output so that the user can right-click a file to display buttons for additional commands.

For this task, you should name your main source file for your advanced implementation as task3shell12345678.c, where 12345678 is your Monash Student ID number.

Choose any one of the following feature sets to implement:

Option A: File properties

(a) Allow the user to view properties for a particular file. These should include file size, 5 owner of the file, and file permissions. AND...
(b) Allow the user to rename a file. The user should be asked to enter a new name for the existing file.

Option B: Cut, copy, paste

(a) Allow the user to copy a file 6 into a different directory location by implementing copy/paste commands (i.e. the user can select a file for copying, then navigate to the destination directory and select the paste option). If the user tries to place a copied file in a location where the same filename already exists, you should prepend ‘copy of' to the new filename to allow the operation to take place safely. AND...

(b) Allow the user to move a file to a different location by adding a cut command that works with your paste function. When the user selects cut, the original file should be designated for moving in some way, but should not actually be moved until the user selects paste in the new location.

Option C: Create and edit files

(a) Allow the user to create a new empty file. The user should be asked to enter a name for the new file. AND...

(b) Allow the user to open a file for editing (in addition to the default less viewing function), by opening the file in a suitable text editor. The user should be able to customise the command used to run their favourite editor by setting an EDITOR environment variable7 before they start your shell program. Add instructions in your user documentation on how the user can set their preference for their preferred editor.

Attachment:- GUI-shell.rar

Solution Preview :

Prepared by a verified Expert
Operating System: Ft2100 - operating systems - monash university -
Reference No:- TGS02883696

Now Priced at $75 (50% Discount)

Recommended (94%)

Rated (4.6/5)