Fixes in preferences

This commit is contained in:
llsth 2015-04-08 11:05:41 +02:00
parent d7f8c6cbd3
commit 05efc36c6f
24 changed files with 65 additions and 63 deletions

View File

@ -24,7 +24,7 @@
*
* Generated with FlexCat. For more information, see:
* http://sourceforge.net/projects/flexcat/
*
*
*/
#ifndef AMATH_LOCALIZE_HELP_H
@ -33,7 +33,7 @@
/**
* @file help.h
* @brief Localized help text definitions.
*
*
*/
#include "clib.h"

View File

@ -24,7 +24,7 @@
*
* Generated with FlexCat. For more information, see:
* http://sourceforge.net/projects/flexcat/
*
*
*/
#ifndef AMATH_LOCALIZE_IDENT_HELP_H
@ -33,7 +33,7 @@
/**
* @file ident.h
* @brief Localized help text definitions.
*
*
*/
#include "clib.h"

View File

@ -24,7 +24,7 @@
*
* Generated with FlexCat. For more information, see:
* http://sourceforge.net/projects/flexcat/
*
*
*/
#ifndef AMATH_LOCALIZE_TEXT_H
@ -33,7 +33,7 @@
/**
* @file text.h
* @brief Localized text definitions.
*
*
*/
#include "clib.h"

View File

@ -31,6 +31,7 @@
int main(int argc, char **argv)
{
Program = CreateProgram(argc, argv);
Program->Initialize(argc, argv);
Program->Run();
delete Program;
FreeAllSafe();

View File

@ -104,10 +104,7 @@ char* PromptStatement::Execute()
buf->ClearAndCopy(prompt);
while(buf->RemoveTrailing(' '));
buf->Append(' ');
Program->Console->SetPrompt(buf->GetString());
Program->Preferences->SetPrompt(buf->GetString());
Program->SetPrompt(buf->GetString());
delete buf;
return (char*)EMPTYSTRING;
}

View File

@ -98,7 +98,6 @@ class Program* CreateProgram(int argc, char **argv) {
out = new StandardProgram();
#endif
}
out->Initialize(argc, argv);
return out;
}

View File

@ -27,10 +27,9 @@
#include "clib.h"
#include "main/nodes.h"
#include "main/evaluator.h"
#include "system/console_amiga.h"
#ifdef AMIGA
#include <clib/dos_protos.h>
#include "system/console_amiga.h"
AmigaShellConsole::AmigaShellConsole(const char *prompt) :
ConsoleBase(prompt)

View File

@ -91,7 +91,7 @@ void StandardConsole::ReadLine()
line = proc->GetLine();
#ifdef UNIX
tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
#endif
}

View File

@ -31,12 +31,6 @@
#include "system/filesystem_amiga.h"
#ifdef AMIGA
#include <dos/exall.h>
#include <dos/var.h>
#include <exec/memory.h>
#include <exec/types.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
/**
* @brief

View File

@ -39,7 +39,7 @@
CharBuffer* StandardFilesystem::ListDirectory(const char *path)
{
#ifdef UNIX
CharBuffer *pathbuf = new CharBuffer();
CharBuffer *pathbuf = new CharBuffer();
pathbuf->Empty();
if (path == NOMEM) {
pathbuf->Append(".");
@ -108,9 +108,9 @@ CharBuffer* StandardFilesystem::ListDirectory(const char *path)
delete pathbuf;
return lines;
#else
CharBuffer *lines = new CharBuffer();
lines->Empty();
return lines;
CharBuffer *lines = new CharBuffer();
lines->Empty();
return lines;
#endif
}

View File

@ -34,9 +34,7 @@
#include "system/language_amiga.h"
#ifdef AMIGA
#include "clib/locale_protos.h"
//#include <inline/locale.h>
#include <clib/exec_protos.h>
#include <clib/locale_protos.h>
AmigaLanguage::AmigaLanguage()
{

View File

@ -118,7 +118,7 @@ bool StandardLanguage::CharIsSpace(long unsigned int character)
bool StandardLanguage::CharIsCntrl(long unsigned int character)
{
return (character <= 32 || character >= 126);
return (character < 32 || character > 125);
}
bool StandardLanguage::StrIsEqualLoc(const char* s1, const char* s2)

View File

@ -47,15 +47,16 @@ PreferencesBase::~PreferencesBase()
void PreferencesBase::SetDefaults()
{
AllocAndCopy(&this->prompt, ">>> ");
AllocAndCopy(&this->prompt, "> ");
digits = 9;
}
char* PreferencesBase::GetDescription()
{
static const char *promptq = "\"";
static const char *sprompt = "prompt";
static const char promptq = '"';
static const char *sprompt = "prompt";
static const char *sdigits = "digits";
static const char delimitor = ';';
Number *d = new RealNumber(GetDigits());
NumeralSystem *ns = new DecimalSystem(2);
@ -64,20 +65,22 @@ char* PreferencesBase::GetDescription()
buf->Empty();
buf->EnsureSize(
StrLen(sprompt) + StrLen(SPACE) + StrLen(promptq) +
StrLen(prompt) + StrLen(promptq) + StrLen(NEWLINE) +
StrLen(sdigits) + StrLen(SPACE) + StrLen(dtext) +
StrLen(NEWLINE) + 1);
sizeof(sprompt) + sizeof(SPACE) + sizeof(promptq) + StrLen(prompt) +
sizeof(promptq) + sizeof(delimitor) + sizeof(NEWLINE) +
sizeof(sdigits) + sizeof(SPACE) + StrLen(dtext) + sizeof(delimitor) +
sizeof(NEWLINE) + 1);
buf->Append(sprompt);
buf->Append(SPACE);
buf->Append(promptq);
buf->Append(prompt);
buf->Append(promptq);
buf->Append(delimitor);
buf->Append(NEWLINE);
buf->Append(sdigits);
buf->Append(SPACE);
buf->Append(dtext);
buf->Append(delimitor);
buf->Append(NEWLINE);
delete ns;
@ -86,6 +89,10 @@ char* PreferencesBase::GetDescription()
void PreferencesBase::SetPrefs(char* prefs)
{
if (prefs == NOMEM) {
return;
}
Parser *parser = new Parser(prefs);
SyntaxNode *node = parser->Parse();
delete parser;

View File

@ -30,12 +30,6 @@
#include "system/preferences_amiga.h"
#ifdef AMIGA
#include <dos/exall.h>
#include <dos/var.h>
#include <exec/memory.h>
#include <exec/types.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
static const char *tempname = "ENV:amath.prefs";
static const char *permname = "ENVARC:amath.prefs";
@ -53,10 +47,12 @@ bool AmigaPreferences::Load()
const int bufsize = 64;
char* buf = new char[bufsize];
char* c;
int s = 1;
do {
c = FGets(file, buf, bufsize);
if (c != NULL) {
text->EnsureSize(s++);
text->Append(c);
}
} while (c != NULL);

View File

@ -38,6 +38,7 @@ static const char *permname = "/usr/local/etc/amath.conf";
bool StandardPreferences::Load()
{
#ifdef UNIX
FILE *file = fopen(tempname, "r");
if (!file) {
return false;
@ -49,10 +50,12 @@ bool StandardPreferences::Load()
const int bufsize = 64;
char* buf = new char[bufsize];
char* c;
int s = 1;
do {
c = fgets(buf, bufsize, file);
if (c != NULL) {
text->EnsureSize(s++);
text->Append(c);
}
} while (c != NULL);
@ -61,6 +64,7 @@ bool StandardPreferences::Load()
fclose(file);
SetPrefs(text->GetString());
delete text;
#endif
return true;
}
@ -76,6 +80,7 @@ bool StandardPreferences::Save()
bool StandardPreferences::SavePrefs(const char* name)
{
#ifdef UNIX
FILE *file = fopen(name, "w");
if (!file) {
return false;
@ -84,6 +89,7 @@ bool StandardPreferences::SavePrefs(const char* name)
char *out = GetDescription();
fputs(out, file);
fclose(file);
#endif
return true;
}

View File

@ -37,7 +37,6 @@
#include "system/task.h"
#include "system/base/thread.h"
#ifdef WITHTEST // Still under development
#ifdef AMIGA
#include <exec/io.h>
#include <exec/memory.h>
@ -70,4 +69,3 @@ private:
#endif
#endif
#endif

View File

@ -38,14 +38,11 @@ Program::Program()
Functions = new FunctionList();
Graphs = new GraphList();
ins = new RealNumber();
Preferences = CreatePreferences();
// Preferences->Load();
Language = CreateLanguage();
Filesystem = CreateFilesystem();
Preferences = CreatePreferences();
Input = new DecimalSystem(Preferences->GetDigits(), Language->GetFractionPoint());
Output = new DecimalSystem(Preferences->GetDigits(), Language->GetFractionPoint());
Filesystem = CreateFilesystem();
}
Program::~Program()
@ -59,9 +56,8 @@ Program::~Program()
delete Language;
delete ins;
// Preferences->Keep();
Preferences->Keep();
delete Preferences;
}
void Program::NewPositionalInput(short unsigned int base, short unsigned int digits)
@ -90,6 +86,14 @@ void Program::NewPositionalOutput(short unsigned int base, short unsigned int di
}
}
void Program::SetPrompt(const char* text)
{
if (Console != NOMEM) {
Console->SetPrompt(text);
}
Preferences->SetPrompt(text);
}
Number* Program::GetLastResult()
{
return ins;

View File

@ -63,7 +63,8 @@ public:
void NewPositionalInput(short unsigned int base, short unsigned int digits);
void NewPositionalOutput(short unsigned int base, short unsigned int digits);
void SetLastResult(Number *number);
struct Number* GetLastResult();
void SetPrompt(const char *text);
struct Number* GetLastResult();
class Language *Language;
class ConsoleBase *Console;
class PreferencesBase *Preferences;
@ -75,7 +76,7 @@ public:
class GraphList *Graphs;
private:
struct Number* ins;
struct Number* ins;
};
#endif

View File

@ -25,7 +25,6 @@
*/
#include "clib.h"
#include "platform.h"
#include "lib/charbuf.h"
#include "main/graphlist.h"
#include "main/evaluator.h"
@ -40,11 +39,6 @@
#include "system/base/io.h"
#ifdef AMIGA
#include <exec/types.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#define ARGS_FORMAT "SHELL/S,INPUT/F"
AmigaProgram::AmigaProgram()
@ -88,6 +82,8 @@ void AmigaProgram::Initialize(int argc, char **argv)
void AmigaProgram::Run()
{
Preferences->Load();
if (Console != NULL) {
Console->Run();
} else if (args.input != NULL) {
@ -106,3 +102,4 @@ void AmigaProgram::Exit()
#endif

View File

@ -79,6 +79,8 @@ void StandardProgram::Initialize(int argc, char **argv)
void StandardProgram::Run()
{
Preferences->Load();
if (Console != NOMEM) {
Console->Run();
return;

View File

@ -56,7 +56,9 @@ void TestProgram::Run()
}
void TestProgram::Initialize(int argc, char** argv)
{ }
{
Preferences->Load();
}
void TestProgram::Exit()
{ }

View File

@ -29,7 +29,6 @@
#include "system/task_amiga.h"
#ifdef AMIGA
#ifdef DEVNOTFINISH // Still under development
#include <exec/io.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
@ -86,4 +85,3 @@ void AmigaTask::WaitExit()
}
#endif
#endif

View File

@ -34,11 +34,11 @@
*/
#include "clib.h"
#include "system/task.h"
#include "system/task_amiga.h"
#include "system/base/thread.h"
#ifdef AMIGA
#ifdef DEVNOTFINISH // Still under development
#include <exec/io.h>
#include <exec/memory.h>
#include <libraries/dos.h>
@ -76,4 +76,3 @@ private:
#endif
#endif
#endif

View File

@ -75,11 +75,15 @@ typedef int bool;
# ifndef ANSICONSOLE
# define ANSICONSOLE
# endif
# include <dos/var.h>
# include <dos/exall.h>
# include <exec/io.h>
# include <exec/types.h>
# include <exec/memory.h>
# include <exec/semaphores.h>
# include <clib/alib_protos.h>
# include <clib/exec_protos.h>
# include <clib/dos_protos.h>
#endif
// Check weather an POSIX compatible API is available