Commit 35094f13 authored by Ercan Ersoy's avatar Ercan Ersoy

Source codes divide to seperate files

- "dosshell.c" has been divided to "common.cpp",
  "fm.cpp", "main.cpp" and "run.cpp".
- Changed "Makefile" and added "link.lbc".
parent 6af5fd45
......@@ -6,7 +6,7 @@
LIB=lib
INCLUDE=include
SRC=src
OBJ=bin
OBJ=src
BIN=bin
# Command variables
......@@ -17,11 +17,14 @@ LINK=wlink
# Command flags
CPPFLAGS=-mm -0 -bt=DOS
LINKFLAGS=system dos op stack=4096 file
LINKFLAGS=system dos op stack=4096
# Objects
OBJECTS=$(OBJ)\dosshell.obj &
OBJECTS=$(OBJ)\common.obj &
$(OBJ)\fm.obj &
$(OBJ)\run.obj &
$(OBJ)\main.obj &
$(LIB)\kitten\kitten.obj &
$(LIB)\fdostui\lib\fdtuid16.lib
......@@ -30,13 +33,33 @@ $(LIB)\fdostui\lib\fdtuid16.lib
all: $(BIN)\dosshell.exe
$(BIN)\dosshell.exe: $(OBJECTS)
$(LINK) $(LINKFLAGS) &
$(OBJ)\dosshell.obj, &
$(LIB)\kitten\kitten.obj, &
$(LIB)\fdostui\lib\fdtuid16.lib
$(LINK) $(LINKFLAGS) name $@ file @link.lbc
$(OBJ)\common.obj: $(SRC)\common.cpp
$(CPP) $(CPPFLAGS) &
-i=$(LIB)\fdostui\include &
-i=$(LIB)\kitten &
-i=$(INCLUDE) &
$? &
-fo=$@
$(OBJ)\fm.obj: $(SRC)\fm.cpp
$(CPP) $(CPPFLAGS) &
-i=$(LIB)\fdostui\include &
-i=$(LIB)\kitten &
-i=$(INCLUDE) &
$? &
-fo=$@
$(OBJ)\run.obj: $(SRC)\run.cpp
$(CPP) $(CPPFLAGS) &
-i=$(LIB)\fdostui\include &
-i=$(LIB)\kitten &
-i=$(INCLUDE) &
$? &
-fo=$@
$(OBJ)\dosshell.obj: $(SRC)\dosshell.cpp
$(OBJ)\main.obj: $(SRC)\main.cpp
$(CPP) $(CPPFLAGS) &
-i=$(LIB)\fdostui\include &
-i=$(LIB)\kitten &
......
No preview for this file type
src\common.obj,src\fm.obj,src\run.obj,src\main.obj,lib\kitten\kitten.obj,lib\fdostui\lib\fdtuid16.lib
\ No newline at end of file
/*
* common.cpp - Common functions source file
* Written by Ercan Ersoy and Mark Olesen.
*/
#include <dosshell.h>
// Exit window manager function
void exit_window_manager(menuitem *, void *)
{
// Close window manager
wm_deinit();
// Release current directory string on memory
free(current_directory);
// Release clipboard item path name string on memory
free(clipboard_item_name);
// Release clipboard item path string on memory
free(clipboard_item_path);
}
// Command run function
void command_run(char const* command)
{
// Mouse release on memory
mouse_deinit();
// Clear screen
system("CLS");
// Run command
system(command);
// Show end
printf(kittengets(1, 1, "\r\nPress any key to return to the DOSSHELL."));
getchar();
// Mouse initalization
mouse_init();
// Mouse show
mouse_show();
// Hide cursor
cursor_hide();
// Draw window manager
wm_draw(NULL);
}
// Quit function
void quit(menuitem *, void *)
{
// Exit window manager
exit_window_manager(NULL, NULL);
if(kitten_status != -1) // If Kitten library is open
{
// Close Kitten library
kittenclose();
}
// Exit FreeDOS TUI Shell
exit(EXIT_SUCCESS);
}
/*
* dosshell.cpp - Main source file
* Written by Ercan Ersoy and Mark Olesen.
* fm.cpp - Fime amanger application source file
* Written by Ercan Ersoy.
*/
#include <dosshell.h>
// Common Functions
// Exit window manager function
void exit_window_manager(menuitem *, void *)
{
// Close window manager
wm_deinit();
// Release current directory string on memory
free(current_directory);
// Release clipboard item path name string on memory
free(clipboard_item_name);
// Release clipboard item path string on memory
free(clipboard_item_path);
}
// Command run function
void command_run(char const* command)
{
// Mouse release on memory
mouse_deinit();
// Clear screen
system("CLS");
// Run command
system(command);
// Show end
printf(kittengets(1, 1, "\r\nPress any key to return to the DOSSHELL."));
getchar();
// Mouse initalization
mouse_init();
// Mouse show
mouse_show();
// Hide cursor
cursor_hide();
// Draw window manager
wm_draw(NULL);
}
// Directory view function
void directory_view(menuitem *, void *)
{
// Element pointer variable
struct dirent *element;
// Directory pointer variable
// Directory pointer variable2
DIR *directory = opendir(getcwd(current_directory, MAX_NAME_LENGTH + 1));
// Element status variable
struct stat element_status;
......@@ -691,38 +646,6 @@ void show_file_manager(menuitem *, void *)
}
}
// Show file manager function
void show_run(menuitem *, void *)
{
// Input of command line
char* command = (char *)popup_input(reinterpret_cast<unsigned char const*>(kittengets(12, 0, "Run")), reinterpret_cast<unsigned char const*>(kittengets(12, 1, "Command to Run:")), reinterpret_cast<unsigned char const*>(""));
if(command) // If command is not blank
{
// Run command
command_run(command);
}
}
// Quit function
void quit(menuitem *, void *)
{
// Exit window manager
exit_window_manager(NULL, NULL);
if(kitten_status != -1) // If Kitten library is open
{
// Close Kitten library
kittenclose();
}
// Exit FreeDOS TUI Shell
exit(EXIT_SUCCESS);
}
// File Manager Menu Functions
// Item open function
void item_open(menuitem *, void *)
......@@ -1089,122 +1012,3 @@ void show_system_items(menuitem *menu_item, void *)
// Refresh directories
directory_view(NULL, NULL);
}
// Main Function
int main(int argc, char *argv[])
{
// Initalization
if(argc == 2) // If argument count is 2.
{
if(argv[1][0] == '/' && argv[1][1] == '?') // If help argument have used.
{
// Help message.
puts("FreeDOS TUI Shell 0.2");
puts("");
puts(kittengets(0, 0, " FreeDOS TUI Shell is a TUI Shell for FreeDOS."));
puts("");
puts(kittengets(0, 1, " Copyright (C) 2018 Ercan Ersoy"));
puts(kittengets(0, 2, " FreeDOS TUI Shell licensed under GNU GPL version 3."));
// Exit FreeDOS TUI Shell
return EXIT_SUCCESS;
}
}
// Initializtion window and get error information
wm_error error= wm_init();
if(error) // If FDOSTUI initalization give error
{
// Display error message
puts(kittengets(1, 0, "Unable to initialze FDOSTUI subsystem."));
// CLose Kitten Library
kittenclose();
// Exit FreeDOS TUI Shell with error
return error;
}
// Current Directory
// Current directory variable allocate
current_directory = (char *) malloc(MAX_PATH_LENGTH + 1);
// Get current directory
getcwd(current_directory, MAX_PATH_LENGTH + 1);
// Upper directory control
upper_directory_control_for_go_menu_item();
// Bar
// Register bar window
wm_register_window(bar);
// Set menu of bar
bar_menus->set_menu(menus_of_bar);
// Set bar window
bar->set_attributes(window::EMPTY);
bar->add(bar_menus);
// File Manager
// History initalizing
strcpy(history_path_names[0], current_directory);
// Register file manager window
wm_register_window(file_manager);
// Set menu of file manager
file_manager_menus->set_menu(menus_of_file_manager);
// Set current directory label text
current_directory_label->set_text((unsigned char *)current_directory);
// Set signal of drivers listbox
drivers->set_signal_selected(change_current_drive);
drivers->set_emit_selected_signal_always(true);
// Set signal of directories and files listbox
directories_and_files->set_signal_selected(select_directory_or_file);
directories_and_files->set_emit_selected_signal_always(true);
// Set "Item Attribute:" message label text
item_attributes_label->set_text((unsigned char *)kittengets(11, 0, "Item Attributes:"));
// Set file manager window
file_manager->set_attributes(window::TITLE | window::BORDER);
file_manager->set_title((unsigned char *)kittengets(4, 0, "File Manager"));
file_manager->add(file_manager_menus);
file_manager->add(current_directory_label);
file_manager->add(drivers);
file_manager->add(directories_and_files);
file_manager->add(item_attributes_label);
file_manager->add(item_attributes_view);
file_manager->set_hidden();
// Draw bar
wm_draw_widget(bar);
// Run window manager
wm_run();
// Exit window manager
exit_window_manager(NULL, NULL);
if(kitten_status != -1) // If Kitten library is open
{
// Close Kitten library
kittenclose();
}
// Exit FreeDOS TUI Shell
return EXIT_SUCCESS;
}
/*
* main.cpp - Main source file
* Written by Ercan Ersoy.
*/
#include <dosshell.h>
// Main function
int main(int argc, char *argv[])
{
// Initalization
if(argc == 2) // If argument count is 2.
{
if(argv[1][0] == '/' && argv[1][1] == '?') // If help argument have used.
{
// Help message.
puts("FreeDOS TUI Shell 0.2");
puts("");
puts(kittengets(0, 0, " FreeDOS TUI Shell is a TUI Shell for FreeDOS."));
puts("");
puts(kittengets(0, 1, " Copyright (C) 2018 Ercan Ersoy"));
puts(kittengets(0, 2, " FreeDOS TUI Shell licensed under GNU GPL version 3."));
// Exit FreeDOS TUI Shell
return EXIT_SUCCESS;
}
}
// Initializtion window and get error information
wm_error error= wm_init();
if(error) // If FDOSTUI initalization give error
{
// Display error message
puts(kittengets(1, 0, "Unable to initialze FDOSTUI subsystem."));
// CLose Kitten Library
kittenclose();
// Exit FreeDOS TUI Shell with error
return error;
}
// Current Directory
// Current directory variable allocate
current_directory = (char *) malloc(MAX_PATH_LENGTH + 1);
// Get current directory
getcwd(current_directory, MAX_PATH_LENGTH + 1);
// Upper directory control
upper_directory_control_for_go_menu_item();
// Bar
// Register bar window
wm_register_window(bar);
// Set menu of bar
bar_menus->set_menu(menus_of_bar);
// Set bar window
bar->set_attributes(window::EMPTY);
bar->add(bar_menus);
// File Manager
// History initalizing
strcpy(history_path_names[0], current_directory);
// Register file manager window
wm_register_window(file_manager);
// Set menu of file manager
file_manager_menus->set_menu(menus_of_file_manager);
// Set current directory label text
current_directory_label->set_text((unsigned char *)current_directory);
// Set signal of drivers listbox
drivers->set_signal_selected(change_current_drive);
drivers->set_emit_selected_signal_always(true);
// Set signal of directories and files listbox
directories_and_files->set_signal_selected(select_directory_or_file);
directories_and_files->set_emit_selected_signal_always(true);
// Set "Item Attribute:" message label text
item_attributes_label->set_text((unsigned char *)kittengets(11, 0, "Item Attributes:"));
// Set file manager window
file_manager->set_attributes(window::TITLE | window::BORDER);
file_manager->set_title((unsigned char *)kittengets(4, 0, "File Manager"));
file_manager->add(file_manager_menus);
file_manager->add(current_directory_label);
file_manager->add(drivers);
file_manager->add(directories_and_files);
file_manager->add(item_attributes_label);
file_manager->add(item_attributes_view);
file_manager->set_hidden();
// Draw bar
wm_draw_widget(bar);
// Run window manager
wm_run();
// Exit window manager
exit_window_manager(NULL, NULL);
if(kitten_status != -1) // If Kitten library is open
{
// Close Kitten library
kittenclose();
}
// Exit FreeDOS TUI Shell
return EXIT_SUCCESS;
}
/*
* run.cpp - Run application source file
* Written by Ercan Ersoy.
*/
#include <dosshell.h>
// Show file manager function
void show_run(menuitem *, void *)
{
// Input of command line
char* command = (char *)popup_input(reinterpret_cast<unsigned char const*>(kittengets(12, 0, "Run")), reinterpret_cast<unsigned char const*>(kittengets(12, 1, "Command to Run:")), reinterpret_cast<unsigned char const*>(""));
if(command) // If command is not blank
{
// Run command
command_run(command);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment