From cffe61201197ca416a04d9f1787f3a8a3e2f1a2a Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 23 Aug 2007 23:52:59 +0000 Subject: [PATCH] - make more util mui-aware - english translation needs to be done svn path=/trunk/; revision=28502 --- .../applications/cmdutils/more/lang/de-DE.rc | 35 ++++++++++ .../base/applications/cmdutils/more/more.c | 69 ++++++++++++++----- .../applications/cmdutils/more/more.rbuild | 1 + .../base/applications/cmdutils/more/more.rc | 2 + .../applications/cmdutils/more/resource.h | 20 ++++++ .../base/applications/cmdutils/more/rsrc.rc | 5 ++ 6 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 reactos/base/applications/cmdutils/more/lang/de-DE.rc create mode 100644 reactos/base/applications/cmdutils/more/resource.h create mode 100644 reactos/base/applications/cmdutils/more/rsrc.rc diff --git a/reactos/base/applications/cmdutils/more/lang/de-DE.rc b/reactos/base/applications/cmdutils/more/lang/de-DE.rc new file mode 100644 index 00000000000..82d6c95714d --- /dev/null +++ b/reactos/base/applications/cmdutils/more/lang/de-DE.rc @@ -0,0 +1,35 @@ +LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_USAGE, "Zeigt Daten seitenweise auf dem Bildschirm an.\n\n\ + MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < [Laufwerk:][Pfad]Dateiname\n\ + Befehl | MORE [/E [/C] [/P] [/S] [/Tn] [+n]] \n\ + MORE /E [/C] [/P] [/S] [/Tn] [+n] [Dateien]\n\n\ + [Laufwerk:][Pfad]Dateiname Ein Datei, deren Inhalt angezeigt\n\ +\t\t\t werden soll.\n\n\ + Befehl\t\t Ein Befehl, dessen Ausgabe angezeigt\n\ +\t\t\t werden soll.\n\n\ + /E\tAktiviert die erweiterten Möglichkeiten.\n\ + /C\tLöscht den Bildschirm, bevor eine Seite angezeigt wird.\n\ + /P\tFührt Seitenvorschubzeichen aus.\n\ + /S\tFasst mehrere leere Zeilen zu einer Zeile zusammen.\n\ + /Tn\tErsetzt Tabulatorenzeichen durch n Leerzeichen (Standard 8).\n\n\ +\tDie Optionen können in der Umgebungsvariablen MORE angegeben\n\ +\twerden.\n\n\ + +n\tBeginnt mit der Anzeige der ersten Datei in Zeile n.\n\n\ + Dateien Gibt eine Liste mit anzuzeigenden Dateien an.\n\ +\t Trennen sie die Dateinamen durch ein Leerzeichen.\n\n\ + Wenn die erweiterten Möglichkeiten aktiviert sind, können die folgenden\n\ + Befehle an der Eingabeforderung \"--Fortsetzung--\" eingegeben werden:\n\n\ + P n\t Zeigt die nächsten n Zeilen an.\n\ + S n\t Überspringt die nächsten n Zeilen.\n\ + Q\tBeendet die Ausgabe.\n\ + =\tZeigt die Zeilennummer an.\n\ + ?\tZeigt die Hilfezeile an.\n\ + Zeigt die nächste Zeile an.\n\ + Zeigt die nächste Zeile an.\n" + + IDS_CONTINUE, " -- Fortsetzung (100%) -- " + IDS_FILE_ACCESS, "Auf die Datei %s kann nicht zugegriffen werden." +} diff --git a/reactos/base/applications/cmdutils/more/more.c b/reactos/base/applications/cmdutils/more/more.c index ae6bf36cac6..7d9bc9734ba 100644 --- a/reactos/base/applications/cmdutils/more/more.c +++ b/reactos/base/applications/cmdutils/more/more.c @@ -13,11 +13,12 @@ #include #include #include +#include +#include "resource.h" - -DWORD len; -LPTSTR msg = _T("--- continue ---"); - +static TCHAR szCont[128]; +static DWORD szContLength; +static HINSTANCE hApp; /*handle for file and console*/ HANDLE hStdIn; @@ -42,7 +43,7 @@ static VOID ConOutPuts (LPTSTR szText) { DWORD dwWritten; - + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -70,7 +71,7 @@ WaitForKey (VOID) { DWORD dwWritten; - WriteFile (hStdErr,msg , len, &dwWritten, NULL); + WriteFile (hStdErr, szCont , szContLength, &dwWritten, NULL); ConInKey(); @@ -88,7 +89,7 @@ int main (int argc, char **argv) DWORD i, last; HANDLE hFile = INVALID_HANDLE_VALUE; TCHAR szFullPath[MAX_PATH]; - + TCHAR szMsg[1024]; /*reading/writing buffer*/ TCHAR *buff; @@ -98,14 +99,28 @@ int main (int argc, char **argv) /*ReadFile() return value*/ BOOL bRet; - len = _tcslen (msg); + hStdIn = GetStdHandle(STD_INPUT_HANDLE); hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); hStdErr = GetStdHandle(STD_ERROR_HANDLE); + hApp = GetModuleHandle(NULL); + + buff=malloc(4096); + if (!buff) + { + ConOutPuts(_T("Error: no memory")); + return 0; + } if (argc > 1 && _tcsncmp (argv[1], _T("/?"), 2) == 0) { - ConOutPuts(_T("Help text still missing!!")); + if (LoadString(hApp, IDS_USAGE, buff, 4096 / sizeof(TCHAR)) < 4096 / sizeof(TCHAR)) + { + CharToOem(buff, buff); + ConOutPuts(buff); + } + + free(buff); return 0; } @@ -114,20 +129,31 @@ int main (int argc, char **argv) GetScreenSize(&maxx,&maxy); - buff=malloc(4096); + FlushConsoleInputBuffer (hKeyboard); if(argc > 1) { - GetFullPathName(argv[1], MAX_PATH, szFullPath, NULL); - hFile = CreateFile (szFullPath, GENERIC_READ, - 0,NULL,OPEN_ALWAYS,0,0); - - if (hFile == INVALID_HANDLE_VALUE) + GetFullPathNameA(argv[1], MAX_PATH, szFullPath, NULL); + hFile = CreateFile (szFullPath, + GENERIC_READ, + 0, + NULL, + OPEN_EXISTING, + 0, + 0); + if (hFile == INVALID_HANDLE_VALUE) { - ConOutPuts(_T("The file could not be opened")); - return 0; + if (LoadString(hApp, IDS_FILE_ACCESS, szMsg, sizeof(szMsg) / sizeof(TCHAR)) < sizeof(szMsg) / sizeof(TCHAR)) + { + _stprintf(buff, szMsg, szFullPath); + CharToOem(buff, buff); + ConOutPuts(buff); + } + + free(buff); + return 0; } } else @@ -135,6 +161,15 @@ int main (int argc, char **argv) hFile = hStdIn; } + if (!LoadString(hApp, IDS_CONTINUE, szCont, sizeof(szCont) / sizeof(TCHAR))) + { + /* fail back to english */ + _tcscpy(szCont, _T("--- continue ---")); + } + szContLength = _tcslen(szCont); + + + do { bRet = ReadFile(hFile,buff,4096,&dwRead,NULL); diff --git a/reactos/base/applications/cmdutils/more/more.rbuild b/reactos/base/applications/cmdutils/more/more.rbuild index 89d60edbf4e..b84c1c95b50 100644 --- a/reactos/base/applications/cmdutils/more/more.rbuild +++ b/reactos/base/applications/cmdutils/more/more.rbuild @@ -4,6 +4,7 @@ 0x0501 kernel32 ntdll + user32 more.c more.rc diff --git a/reactos/base/applications/cmdutils/more/more.rc b/reactos/base/applications/cmdutils/more/more.rc index e1741c20501..c46e4f8c77f 100644 --- a/reactos/base/applications/cmdutils/more/more.rc +++ b/reactos/base/applications/cmdutils/more/more.rc @@ -4,3 +4,5 @@ #define REACTOS_STR_INTERNAL_NAME "more\0" #define REACTOS_STR_ORIGINAL_FILENAME "more.exe\0" #include + +#include "rsrc.rc" diff --git a/reactos/base/applications/cmdutils/more/resource.h b/reactos/base/applications/cmdutils/more/resource.h new file mode 100644 index 00000000000..eb430d80b81 --- /dev/null +++ b/reactos/base/applications/cmdutils/more/resource.h @@ -0,0 +1,20 @@ +#ifndef RESOURCE_H__ /* resource.h */ +#define RESOURCE_H__ + +#define IDS_USAGE 100 +#define IDS_CONTINUE 101 +#define IDS_FILE_ACCESS 102 + + + + + + + + + + + + + +#endif /* EOF of resource.h */ diff --git a/reactos/base/applications/cmdutils/more/rsrc.rc b/reactos/base/applications/cmdutils/more/rsrc.rc new file mode 100644 index 00000000000..f01602f1e7c --- /dev/null +++ b/reactos/base/applications/cmdutils/more/rsrc.rc @@ -0,0 +1,5 @@ +#include +#include "resource.h" + +#include "lang/de-DE.rc" +