applicat.cpp Tolta una riga vuota

files.cpp       Cambiato il metodo TRecnotype& flags() in long& flags()
files.h         Vedi sopra
golem.cpp       Usate sempre le estensioni in minuscolo
golem.h         Resi pubblici i metodi goto_url e print_url
viswin.cpp      Usato il novello metodo goto_url al posto di notepad


git-svn-id: svn://10.65.10.50/trunk@5575 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-11-07 08:51:14 +00:00
parent 8378eb183a
commit dd0a101b38
6 changed files with 59 additions and 79 deletions

View File

@ -371,7 +371,6 @@ const char* TApplication::get_module_name() const
TString module(scanner.token().mid(3)); TString module(scanner.token().mid(3));
if (ok) ok = has_module(aut); if (ok) ok = has_module(aut);
if (!ok) if (!ok)
{ {
TToken_string em(extra_modules()); TToken_string em(extra_modules());

View File

@ -226,7 +226,7 @@ TRecnotype & TDir::eox () const
return _dir->EOX; return _dir->EOX;
} }
TRecnotype & TDir::flags () const long& TDir::flags () const
{ {
return _dir->Flags; return _dir->Flags;

View File

@ -134,7 +134,7 @@ public:
// @cmember Ritorna l'EOX del file selezionato // @cmember Ritorna l'EOX del file selezionato
TRecnotype& eox() const; TRecnotype& eox() const;
// @cmember Ritorna il flag del file selezionato // @cmember Ritorna il flag del file selezionato
TRecnotype& flags() const; long& flags() const;
// @cmember Ritorna la lunghezza del tracciato record in bytes // @cmember Ritorna la lunghezza del tracciato record in bytes
word& len() const; word& len() const;
// @cmember Ritorna lo stato d'errore del file // @cmember Ritorna lo stato d'errore del file

View File

@ -45,11 +45,12 @@ HIDDEN bool file2app(const char* filename, TString& app)
if (!ok) if (!ok)
{ {
char ext[_MAX_EXT]; TString ext(_MAX_EXT);
if (*filename == '.') if (*filename == '.')
strncpy(ext, filename, _MAX_EXT); ext = filename;
else else
_splitpath(filename, NULL, NULL, NULL, ext); _splitpath(filename, NULL, NULL, NULL, ext.get_buffer());
ext.lower();
TFilename key; TFilename key;
if (get_reg_key(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS) if (get_reg_key(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
@ -109,37 +110,24 @@ HIDDEN word file2icon(const char* filename)
if (ext != ".exe") if (ext != ".exe")
{ {
// Prima controlla il mio registro delle applicazioni ... if (get_reg_key(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
TConfig link(CONFIG_USER, "Link"); {
key = link.get(ext.mid(1, -1)); // Ignora il . key << "\\DefaultIcon";
if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) // Windows 95 only
if (key.not_empty()) {
{ const int comma = key.find(',');
ext = key.ext(); if (comma > 0)
if (ext.empty())
key.ext("exe");
}
else // ... poi controlla il registro di Windows
{
if (get_reg_key(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
{
key << "\\DefaultIcon";
if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) // Windows 95 only
{ {
const int comma = key.find(','); icon_number = atoi(key.mid(comma+1));
if (comma > 0) key.cut(comma);
{
icon_number = atoi(key.mid(comma+1));
key.cut(comma);
}
} }
else
{
if (!file2app(filename, key))
file2app(".htm", key);
}
} }
} else
{
if (!file2app(filename, key))
file2app(".htm", key);
}
}
} }
else else
key = filename; key = filename;
@ -159,18 +147,22 @@ HIDDEN word file2icon(const char* filename)
return icon; return icon;
} }
HIDDEN bool goto_url(const char* url) bool goto_url(const char* url)
{ {
TFilename app(url); TFilename app(url);
app.lower();
const TString ext(app.ext());
TConfig link(CONFIG_USER, "Link"); TConfig link(CONFIG_USER, "Link");
app = link.get(app.ext()); app = link.get(ext);
if (app.not_empty()) if (app.not_empty())
{ {
app << ' ' << url; app << ' ' << url;
UINT error = WinExec(app, SW_SHOWNORMAL); UINT error = WinExec(app, SW_SHOWNORMAL);
if (error > 32) if (error > 32)
return TRUE; return TRUE;
else
link.set(ext, "");
} }
bool retflag = FALSE; bool retflag = FALSE;
@ -195,7 +187,7 @@ HIDDEN bool goto_url(const char* url)
} }
HIDDEN bool print_url(const char* url) bool print_url(const char* url)
{ {
HINSTANCE hinst = ShellExecute(NULL, "print", url, NULL, NULL, SW_SHOWNORMAL); HINSTANCE hinst = ShellExecute(NULL, "print", url, NULL, NULL, SW_SHOWNORMAL);
DWORD winst = DWORD((DWORD*)hinst); DWORD winst = DWORD((DWORD*)hinst);
@ -423,7 +415,7 @@ void TGolem_field::set_window_data(const char* data)
char* pipe = strchr(data, '|'); char* pipe = strchr(data, '|');
if (pipe) if (pipe)
{ {
*pipe = '\0'; *pipe = '\0'; // Poor man TToken_string
icon = file2icon(data); icon = file2icon(data);
*pipe = '|'; *pipe = '|';
} }
@ -476,7 +468,7 @@ bool TGolem_field::autosave(TRelation& r)
TToken_string new_value(get(), '\n'); TToken_string new_value(get(), '\n');
if (new_value != _old_value) if (new_value != _old_value)
{ {
TFilename golem_path(_MAX_PATH); TFilename golem_path;
TDir dir; dir.get(r.lfile().num()); TDir dir; dir.get(r.lfile().num());
const long ditta = dir.is_com() ? 0 : prefix().get_codditta(); const long ditta = dir.is_com() ? 0 : prefix().get_codditta();
golem_path = firm2dir(ditta); golem_path = firm2dir(ditta);

View File

@ -5,6 +5,9 @@
#include <strings.h> #include <strings.h>
#endif #endif
bool goto_url(const char* url);
bool print_url(const char* url);
// @doc EXTERNAL // @doc EXTERNAL
// @class TDDE | Classe per la gestione del DDE // @class TDDE | Classe per la gestione del DDE

View File

@ -5,7 +5,8 @@
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
#include <execp.h> #include <execp.h>
#include <golem.h>
#include <mailbox.h> #include <mailbox.h>
#include <printapp.h> #include <printapp.h>
#include <urldefid.h> #include <urldefid.h>
@ -2214,49 +2215,34 @@ void TViswin::sel_to_clipboard()
bool TViswin::call_editor() bool TViswin::call_editor()
{ {
TConfig cnf (CONFIG_USER, "Link"); TFilename newfilename; newfilename.tempdir();
const TFilename editor (cnf.get ("txt", NULL, -1, "notepad"));
FILE_SPEC fs;
xvt_fsys_convert_str_to_dir(newfilename.get_buffer(), &fs.dir);
strcpy (fs.type, "txt");
strcpy (fs.name, "tmp");
strcpy (fs.creator, "PRINT");
bool ok = FALSE; xvt_fsys_save_dir ();
bool ok = xvt_dm_post_file_save (&fs, "Salva il file con il nome:") == FL_OK;
if (!editor.empty ()) xvt_fsys_restore_dir ();
{
TFilename newfilename; newfilename.tempdir();
FILE_SPEC fs;
xvt_fsys_convert_str_to_dir((char*)(const char*)newfilename, &fs.dir);
strcpy (fs.type, "txt");
strcpy (fs.name, "");
xvt_fsys_save_dir ();
ok = xvt_dm_post_file_save (&fs, "Salva il file con il nome:") == FL_OK;
xvt_fsys_restore_dir ();
if (ok) if (ok)
{
xvt_fsys_convert_dir_to_str (&fs.dir, newfilename.get_buffer(), newfilename.size());
newfilename.add(fs.name);
TPoint p1, p2;
if (_isselection)
adjust_selection (p1, p2);
if (_txt.write (newfilename, _isselection ? &p1 : NULL,
_isselection ? &p2 : NULL))
{ {
char path[256]; ok = goto_url(newfilename);
xvt_fsys_convert_dir_to_str (&fs.dir, path, sizeof (path));
newfilename = path;
newfilename << '/' << fs.name;
TPoint p1, p2;
if (_isselection)
adjust_selection (p1, p2);
if (_txt.write (newfilename, _isselection ? &p1 : NULL,
_isselection ? &p2 : NULL))
{
newfilename.insert (" ", 0);
newfilename.insert (editor, 0);
TExternal_app edit (newfilename);
if (edit.run(TRUE, FALSE))
beep ();
else
ok = TRUE;
}
} }
} }
else
warning_box ("Nessun editor specificato nei parametri studio");
return ok; return ok;
} }