Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614/* * ReactOS kernel * Copyright (C) 2008 ReactOS Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *//* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: base/setup/usetup/mui.c * PURPOSE: Text-mode setup * PROGRAMMER: */
#include "usetup.h"#include "muilanguages.h"
#define NDEBUG#include <debug.h>
/* Special characters */CHAR CharBullet = 0x07; /* bullet */CHAR CharBlock = 0xDB; /* block */CHAR CharHalfBlock = 0xDD; /* half-left block */CHAR CharUpArrow = 0x18; /* up arrow */CHAR CharDownArrow = 0x19; /* down arrow */CHAR CharHorizontalLine = 0xC4; /* horizontal line */CHAR CharVerticalLine = 0xB3; /* vertical line */CHAR CharUpperLeftCorner = 0xDA; /* upper left corner */CHAR CharUpperRightCorner = 0xBF; /* upper right corner */CHAR CharLowerLeftCorner = 0xC0; /* lower left corner */CHAR CharLowerRightCorner = 0xD9; /* lower right corner */CHAR CharVertLineAndRightHorizLine = 0xC3; /* |- (vertical line and right horizontal line) */CHAR CharLeftHorizLineAndVertLine = 0xB4; /* -| (left horizontal line and vertical line) */CHAR CharDoubleHorizontalLine = 0xCD; /* double horizontal line (and underline) */CHAR CharDoubleVerticalLine = 0xBA; /* double vertical line */CHAR CharDoubleUpperLeftCorner = 0xC9; /* double upper left corner */CHAR CharDoubleUpperRightCorner = 0xBB; /* double upper right corner */CHAR CharDoubleLowerLeftCorner = 0xC8; /* double lower left corner */CHAR CharDoubleLowerRightCorner = 0xBC; /* double lower right corner */
staticULONGFindLanguageIndex(VOID){ ULONG lngIndex = 0;
if (SelectedLanguageId == NULL) { /* Default to en-US */ return 0; // FIXME!! // SelectedLanguageId = L"00000409"; }
while (ResourceList[lngIndex].MuiPages != NULL) { if (_wcsicmp(ResourceList[lngIndex].LanguageID, SelectedLanguageId) == 0) { return lngIndex; }
lngIndex++; }
return 0;}
#if 0BOOLEANIsLanguageAvailable( PWCHAR LanguageId){ ULONG lngIndex = 0;
while (ResourceList[lngIndex].MuiPages != NULL) { if (_wcsicmp(ResourceList[lngIndex].LanguageID, LanguageId) == 0) return TRUE;
lngIndex++; }
return FALSE;}#endif
staticconst MUI_ENTRY *FindMUIEntriesOfPage( IN ULONG PageNumber){ ULONG muiIndex = 0; ULONG lngIndex; const MUI_PAGE * Pages = NULL;
lngIndex = max(FindLanguageIndex(), 0); Pages = ResourceList[lngIndex].MuiPages;
while (Pages[muiIndex].MuiEntry != NULL) { if (Pages[muiIndex].Number == PageNumber) return Pages[muiIndex].MuiEntry;
muiIndex++; }
return NULL;}
staticconst MUI_ERROR *FindMUIErrorEntries(VOID){ ULONG lngIndex = max(FindLanguageIndex(), 0); return ResourceList[lngIndex].MuiErrors;}
staticconst MUI_STRING *FindMUIStringEntries(VOID){ ULONG lngIndex = max(FindLanguageIndex(), 0); return ResourceList[lngIndex].MuiStrings;}
VOIDMUIClearPage( IN ULONG page){ const MUI_ENTRY * entry; ULONG index;
entry = FindMUIEntriesOfPage(page); if (!entry) { PopupError("Error: Failed to find translated page", NULL, NULL, POPUP_WAIT_NONE); return; }
index = 0; while (entry[index].Buffer != NULL) { CONSOLE_ClearStyledText(entry[index].X, entry[index].Y, entry[index].Flags, (USHORT)strlen(entry[index].Buffer)); index++; }}
VOIDMUIDisplayPage( IN ULONG page){ const MUI_ENTRY * entry; ULONG index;
entry = FindMUIEntriesOfPage(page); if (!entry) { PopupError("Error: Failed to find translated page", NULL, NULL, POPUP_WAIT_NONE); return; }
index = 0; while (entry[index].Buffer != NULL) { CONSOLE_SetStyledText(entry[index].X, entry[index].Y, entry[index].Flags, entry[index].Buffer);
index++; }}
VOIDMUIDisplayErrorV( IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent, IN va_list args){ const MUI_ERROR* entry; CHAR Buffer[2048];
if (ErrorNum >= ERROR_LAST_ERROR_CODE) { PopupError("Invalid error number provided", "Press ENTER to continue", Ir, POPUP_WAIT_ENTER); return; }
entry = FindMUIErrorEntries(); if (!entry) { PopupError("Error: Failed to find translated error message", NULL, NULL, POPUP_WAIT_NONE); return; }
vsprintf(Buffer, entry[ErrorNum].ErrorText, args);
PopupError(Buffer, entry[ErrorNum].ErrorStatus, Ir, WaitEvent);}
VOID__cdeclMUIDisplayError( IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent, ...){ va_list arg_ptr;
va_start(arg_ptr, WaitEvent); MUIDisplayErrorV(ErrorNum, Ir, WaitEvent, arg_ptr); va_end(arg_ptr);}
PCSTRMUIGetString( ULONG Number){ ULONG i; const MUI_STRING * entry; CHAR szErr[128];
entry = FindMUIStringEntries(); if (entry) { for (i = 0; entry[i].Number != 0; i++) { if (entry[i].Number == Number) { return entry[i].String; } } }
sprintf(szErr, "Error: failed find string id %lu for language index %lu\n", Number, FindLanguageIndex());
PopupError(szErr, NULL, NULL, POPUP_WAIT_NONE);
return "<nostring>";}
/** * @MUIGetEntry * * Retrieves a MUI entry of a page, given the page number and the text ID. * * @param[in] Page * The MUI (Multilingual User Interface) entry page number, as a unsigned long integer. * * @param[in] TextID * The text identification number (ID), as a unsigned integer. The parameter is used to identify * its MUI properties like the coordinates, text style flag and its buffer content. * * @return * Returns a constant MUI entry. * */const MUI_ENTRY *MUIGetEntry( IN ULONG Page, IN INT TextID){ const MUI_ENTRY * entry; ULONG index;
/* Retrieve the entries of a MUI page */ entry = FindMUIEntriesOfPage(Page); if (!entry) { DPRINT("MUIGetEntryData(): Failed to get the translated entry page!\n"); return NULL; }
/* Loop over the ID entries and check if it matches with one of them */ for (index = 0; entry[index].Buffer != NULL; index++) { if (entry[index].TextID == TextID) { /* They match so return the MUI entry */ return &entry[index]; } }
/* Page number or ID are incorrect so in this case bail out */ DPRINT("Couldn't get the MUI entry field from the page!\n"); return NULL;}
/** * @MUIClearText * * Clears a portion of text from the console output. * * @param[in] Page * The MUI (Multilingual User Interface) entry page number, as a unsigned long integer. * * @param[in] TextID * The text identification number (ID), as an integer. The parameter is used to identify * its MUI properties like the coordinates, text style flag and its buffer content. * * @return * Nothing. * */VOIDMUIClearText( IN ULONG Page, IN INT TextID){ const MUI_ENTRY * entry; ULONG Index = 0;
/* Get the MUI entry */ entry = MUIGetEntry(Page, TextID);
if (!entry) return;
/* Ensure that the text string given by the text ID and page is not NULL */ while (entry[Index].Buffer != NULL) { /* If text ID is not correct, skip the entry */ if (entry[Index].TextID != TextID) { Index++; continue; }
/* Remove the text by using CONSOLE_ClearTextXY() */ CONSOLE_ClearTextXY( entry[Index].X, entry[Index].Y, (USHORT)strlen(entry[Index].Buffer));
/* Increment the index and loop over next entires with the same ID */ Index++; }}
/** * @MUIClearStyledText * * Clears a portion of text from the console output, given the actual state style flag of the text. * * @param[in] Page * The MUI (Multilingual User Interface) entry page number, as a unsigned long integer. * * @param[in] TextID * The text identification number (ID), as an integer. The parameter is used to identify * its MUI properties like the coordinates, text style flag and its buffer content. * * @param[in] Flags * The text style flag, as an integer. The flag determines the style of the text, such * as being highlighted, underlined, high padding and so on. * * @return * Nothing. * */VOIDMUIClearStyledText( IN ULONG Page, IN INT TextID, IN INT Flags){ const MUI_ENTRY * entry; ULONG Index = 0;
/* Get the MUI entry */ entry = MUIGetEntry(Page, TextID);
if (!entry) return;
/* Ensure that the text string given by the text ID and page is not NULL */ while (entry[Index].Buffer != NULL) { /* If text ID is not correct, skip the entry */ if (entry[Index].TextID != TextID) { Index++; continue; }
/* Now, begin removing the text by calling CONSOLE_ClearStyledText() */ CONSOLE_ClearStyledText( entry[Index].X, entry[Index].Y, Flags, (USHORT)strlen(entry[Index].Buffer));
/* Increment the index and loop over next entires with the same ID */ Index++; }}
/** * @MUISetText * * Prints a text to the console output. * * @param[in] Page * The MUI (Multilingual User Interface) entry page number, as a unsigned long integer. * * @param[in] TextID * The text identification number (ID), as an integer. The parameter is used to identify * its MUI properties like the coordinates, text style flag and its buffer content. * * @return * Nothing. * */VOIDMUISetText( IN ULONG Page, IN INT TextID){ const MUI_ENTRY * entry; ULONG Index = 0;
/* Get the MUI entry */ entry = MUIGetEntry(Page, TextID);
if (!entry) return;
/* Ensure that the text string given by the text ID and page is not NULL */ while (entry[Index].Buffer != NULL) { /* If text ID is not correct, skip the entry */ if (entry[Index].TextID != TextID) { Index++; continue; }
/* Print the text to the console output by calling CONSOLE_SetTextXY() */ CONSOLE_SetTextXY(entry[Index].X, entry[Index].Y, entry[Index].Buffer);
/* Increment the index and loop over next entires with the same ID */ Index++; }}
/** * @MUISetStyledText * * Prints a text to the console output, with a style for it. * * @param[in] Page * The MUI (Multilingual User Interface) entry page number, as a unsigned long integer. * * @param[in] TextID * The text identification number (ID), as an integer. The parameter is used to identify * its MUI properties like the coordinates, text style flag and its buffer content. * * @param[in] Flags * The text style flag, as an integer. The flag determines the style of the text, such * as being highlighted, underlined, high padding and so on. * * @return * Nothing. * */VOIDMUISetStyledText( IN ULONG Page, IN INT TextID, IN INT Flags){ const MUI_ENTRY * entry; ULONG Index = 0;
/* Get the MUI entry */ entry = MUIGetEntry(Page, TextID);
if (!entry) return;
/* Ensure that the text string given by the text ID and page is not NULL */ while (entry[Index].Buffer != NULL) { /* If text ID is not correct, skip the entry */ if (entry[Index].TextID != TextID) { Index++; continue; }
/* Print the text to the console output by calling CONSOLE_SetStyledText() */ CONSOLE_SetStyledText(entry[Index].X, entry[Index].Y, Flags, entry[Index].Buffer);
/* Increment the index and loop over next entires with the same ID */ Index++; }}
VOIDSetConsoleCodePage(VOID){ UINT wCodePage;
#if 0 ULONG lngIndex = 0;
while (ResourceList[lngIndex].MuiPages != NULL) { if (_wcsicmp(ResourceList[lngIndex].LanguageID, SelectedLanguageId) == 0) { wCodePage = ResourceList[lngIndex].OEMCPage; SetConsoleOutputCP(wCodePage); return; }
lngIndex++; }#else wCodePage = MUIGetOEMCodePage(SelectedLanguageId); SetConsoleOutputCP(wCodePage);#endif
switch (wCodePage) { case 28606: /* Romanian */ case 932: /* Japanese */ /* Set special characters */ CharBullet = 0x07; CharBlock = 0x01; CharHalfBlock = 0x02; CharUpArrow = 0x03; CharDownArrow = 0x04; CharHorizontalLine = 0x05; CharVerticalLine = 0x06; CharUpperLeftCorner = 0x08; CharUpperRightCorner = 0x09; CharLowerLeftCorner = 0x0B; CharLowerRightCorner = 0x0C; CharVertLineAndRightHorizLine = 0x0E; CharLeftHorizLineAndVertLine = 0x0F; CharDoubleHorizontalLine = 0x10; CharDoubleVerticalLine = 0x11; CharDoubleUpperLeftCorner = 0x12; CharDoubleUpperRightCorner = 0x13; CharDoubleLowerLeftCorner = 0x14; CharDoubleLowerRightCorner = 0x15;
/* FIXME: Enter 640x400 video mode */ break;
default: /* Other codepages */ /* Set special characters */ CharBullet = 0x07; CharBlock = 0xDB; CharHalfBlock = 0xDD; CharUpArrow = 0x18; CharDownArrow = 0x19; CharHorizontalLine = 0xC4; CharVerticalLine = 0xB3; CharUpperLeftCorner = 0xDA; CharUpperRightCorner = 0xBF; CharLowerLeftCorner = 0xC0; CharLowerRightCorner = 0xD9; CharVertLineAndRightHorizLine = 0xC3; CharLeftHorizLineAndVertLine = 0xB4; CharDoubleHorizontalLine = 0xCD; CharDoubleVerticalLine = 0xBA; CharDoubleUpperLeftCorner = 0xC9; CharDoubleUpperRightCorner = 0xBB; CharDoubleLowerLeftCorner = 0xC8; CharDoubleLowerRightCorner = 0xBC;
/* FIXME: Enter 720x400 video mode */ break; }}