void StartConsole(){ //CONSOLE *tmp; //FirstConsole=malloc(sizeof(CONSOLE)); LastConsole=malloc(sizeof(CONSOLE)); FirstConsole=CreateConsole(USER_CONSOLE,0,"JouleCon",2); FirstConsole->prev=LastConsole; LastConsole->prev=FirstConsole; DebugCon=CreateConsole(REALTIME_CONSOLE,0,"JouleOS Debug",1); //realtime so that in an error we could see it SysControlCon=CreateConsole(USER_CONSOLE,0,"System Control Console",1); //FirstConsole=CreateConsole(USER_CONSOLE,0,"JouleCon",1); CurrentConsole=FirstConsole; ProcessConsole=FirstConsole; cls(); SwitchConsole(CurrentConsole->next); SwitchConsole(CurrentConsole->next); SwitchConsole(CurrentConsole->next); //SwitchConsole(FirstConsole); //free(FirstConsole); JouleCon=FirstConsole; SwitchConsole(JouleCon); }
types::Function::ReturnValue sci_consolebox(types::typed_list &in, int _iRetCount, types::typed_list &out) { if (in.size() < 0 || in.size() > 1) { Scierror(77, _("%s: Wrong number of input argument(s): %d or %d expected.\n"), "consolebox", 0, 1); return types::Function::Error; } if (getScilabMode() != SCILAB_STD) { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); out.push_back(new types::String(L"off")); return types::Function::OK; } //request mode if (in.size() == 0) { if (GetConsoleState()) { out.push_back(new types::String(L"on")); } else { out.push_back(new types::String(L"off")); } return types::Function::OK; } types::InternalType* pIT1 = in[0]; if (pIT1->isString() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "consolebox", 1); return types::Function::Error; } types::String* pS1 = pIT1->getAs<types::String>(); if (pS1->isScalar() == false) { Scierror(999, _("%s: Wrong size for input argument #%d: string expected.\n"), "consolebox", 1); return types::Function::Error; } std::wstring wcsAction(pS1->get(0)); if (wcsAction == L"on") { SetConsoleState(1); ShowScilex(); } else if (wcsAction == L"off") { SetConsoleState(0); HideScilex(); } else if (wcsAction == L"toggle") { SwitchConsole(); } else { Scierror(999, ("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"), "consolebox", "on", "off", "toggle"); return types::Function::Error; } if (GetConsoleState()) { out.push_back(new types::String(L"on")); } else { out.push_back(new types::String(L"off")); } return types::Function::OK; }
/*--------------------------------------------------------------------------*/ int sci_consolebox(char *fname,unsigned long l) { static int l1,n1,m1; char *Output=NULL; Rhs=Max(Rhs,0); CheckRhs(0,1); CheckLhs(0,1); Output=(char*)MALLOC(4*sizeof(char)); if (Rhs==0) { if (getScilabMode() == SCILAB_STD) { if (GetConsoleState()) strcpy(Output,"on"); else strcpy(Output,"off"); } else { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); strcpy(Output,"off"); } } else if (GetType(1) == sci_strings) { char *param=NULL; GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1); param=cstk(l1); if ( (strcmp(param,"off")==0) || (strcmp(param,"on")==0) || (strcmp(param,"toggle")==0) ) { if (getScilabMode() == SCILAB_STD) { if (strcmp(param,"on")==0) { SetConsoleState(1); ShowScilex(); strcpy(Output,"on"); } else if (strcmp(param,"off")==0) { SetConsoleState(0); HideScilex(); strcpy(Output,"off"); } else /* toggle */ { SwitchConsole(); if (GetConsoleState()) strcpy(Output,"on"); else strcpy(Output,"off"); } } else { sciprint(_("Only on Windows Mode, not in Console Mode.\n")); strcpy(Output,"off"); } } else { Scierror(999,("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"),fname,"on", "off", "toggle"); return 0; } } else { Scierror(999,("%s: Wrong input argument: '%s', '%s' or '%s' expected.\n"),fname,"on", "off", "toggle"); return 0; } n1=1; CreateVarFromPtr(Rhs+ 1,STRING_DATATYPE,(m1=(int)strlen(Output), &m1),&n1,&Output); if (Output) {FREE(Output);Output=NULL;} LhsVar(1) = Rhs+1; PutLhsVar(); return 0; }
CONSOLE *CreateConsole(unsigned char type,unsigned int owner, char *name,unsigned char video_mode){ CONSOLE *new_console; __asm("cli"); //disable ints so no drawing crap going on new_console=malloc(sizeof(CONSOLE)); if(new_console==0){return 0;} LastConsole->next=new_console; new_console->prev=LastConsole; LastConsole=new_console; new_console->next=FirstConsole; //copy the name new_console->name=malloc(strlen(name)); memcpy(new_console->name,name,strlen(name)); //set video mode info new_console->video_mode=video_mode; new_console->vga_registers=video_modes[video_mode]; memset(&new_console->ConsoleEvents,0,sizeof(CONSOLE_EVENTS)); //zero the events //must resolve the font for each video mode switch(video_mode){ //set appropriate fonts, and sizes case 0: new_console->font=g_8x8_font; new_console->text_height=8; new_console->width=90; new_console->height=60; new_console->size=90*60*2; break; case 1: new_console->font=g_8x16_font; new_console->text_height=16; new_console->width=80; new_console->height=25; new_console->size=80*25*2; break; case 2: new_console->font=g_8x16_font; new_console->text_height=16; new_console->width=90; new_console->height=30; new_console->size=90*30*2; break; case 3: new_console->font=g_8x8_font; new_console->text_height=8; new_console->width=80; new_console->height=50; new_console->size=80*50*2; break; case 4: new_console->font=g_8x8_font; new_console->text_height=8; new_console->width=40; new_console->height=50; new_console->size=40*50*2; break; case 5: new_console->font=g_8x16_font; new_console->text_height=16; new_console->width=40; new_console->height=25; new_console->size=40*25*2; break; } //allocate buffer, even if buffering is disabled new_console->buffer=malloc(new_console->size+(new_console->width*2*2)); //provides room for 2 extra lines to avoid memory overwriting new_console->video_memory=0xB8000; //set owner process //only the owner process can kill a console(anyone can request..) //unless of course it is a system process(ring0 drivers or kernel services) new_console->owner_process=owner; switch(type){ case SYSTEM_CONSOLE: //same as virtual console new_console->buffering=NO_BUFFER; break; case USER_CONSOLE: default: //also the default new_console->buffering=NORMAL_BUFFER; break; case REALTIME_CONSOLE: new_console->buffering=BUFFER_REFRESH; //puets instantly refreshed break; } //zero out the cursor new_console->curx=0; new_console->cury=0; //set color to white on black new_console->color=0x0F; new_console->text=TRUE; CurrentConsole=new_console; //replace this with SwitchConsole.. ProcessConsole=new_console; SwitchConsole(CurrentConsole); _memsetw(ProcessConsole->buffer,(ProcessConsole->color<<8)|' ',ProcessConsole->size/2+1); //cls... _memsetw(ProcessConsole->video_memory,(ProcessConsole->color<<8)|' ',ProcessConsole->size/2+1); //and the actual video memory __asm("sti"); //renabled interrupts return new_console; }