Пример #1
0
static inline void WCEL_Update(WCEL_Context* ctx, int beg, int len)
{
    WriteConsoleOutputCharacterW(ctx->hConOut, &ctx->line[beg], len,
                                 WCEL_GetCoord(ctx, beg), NULL);
    FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, len,
                               WCEL_GetCoord(ctx, beg), NULL);
}
Пример #2
0
static int outputChars(struct current *current, const char *buf, int len)
{
    COORD pos;
    DWORD n;

    pos.Y = (SHORT)current->y;

#ifdef USE_UTF8
    while ( len > 0 ) {
        int c, s;
        wchar_t wc;

        s = utf8_tounicode(buf, &c);

        len -= s;
        buf += s;

        wc = (wchar_t)c;

        pos.X = (SHORT)current->x;

        /* fixed display utf8 character */
        WriteConsoleOutputCharacterW(current->outh, &wc, 1, pos, &n);

        current->x += utf8_width(c);
    }
#else
    pos.X = (SHORT)current->x;

    WriteConsoleOutputCharacterA(current->outh, buf, len, pos, &n);
    current->x += len;
#endif

    return 0;
}
Пример #3
0
VOID
WriteStringAt(LPWSTR lpString,
              COORD  xy,
              WORD   wColor)
{
    DWORD cWritten = 0;
    WORD  wLen;

    if (!lpString || *lpString == 0) return;

    wLen = wcslen(lpString);

    /* Don't bother writing text when erasing */
    if (wColor)
    {
        WriteConsoleOutputCharacterW(ScreenBuffer,
                                     lpString,
                                     wLen,
                                     xy,
                                     &cWritten);
    }

    FillConsoleOutputAttribute(ScreenBuffer,
                               wColor,
                               wLen,
                               xy,
                               &cWritten);
}
void DisplayKeyVolumeEnvelope::Init(HANDLE hOut)
{
	// show the note keys
	DWORD written;
	WriteConsoleOutputCharacterW(hOut, LPCWSTR(keys), KEYS, key_pos, &written);
	FillConsoleOutputAttribute(hOut, env_attrib[EnvelopeState::OFF], KEYS, key_pos, &written);

	// voice indicators
	CHAR voice[VOICES];
	memset(voice, 7, VOICES);
	WriteConsoleOutputCharacter(hOut, voice, VOICES, voice_pos, &written);
}
Пример #5
0
static inline void WCEL_Update(WCEL_Context* ctx, int beg, int len)
{
    int         i, last;
    DWORD       count;
    WCHAR       tmp[2];

    /* bare console case is handled in CONSOLE_ReadLine (we always reprint the whole string) */
    if (!ctx->shall_echo || !ctx->can_pos_cursor) return;

    for (i = last = beg; i < beg + len; i++)
    {
        if (ctx->line[i] < ' ')
        {
            if (last != i)
            {
                WriteConsoleOutputCharacterW(ctx->hConOut, &ctx->line[last], i - last,
                                             WCEL_GetCoord(ctx, last), &count);
                FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, i - last,
                                           WCEL_GetCoord(ctx, last), &count);
            }
            tmp[0] = '^';
            tmp[1] = '@' + ctx->line[i];
            WriteConsoleOutputCharacterW(ctx->hConOut, tmp, 2,
                                         WCEL_GetCoord(ctx, i), &count);
            FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, 2,
                                       WCEL_GetCoord(ctx, i), &count);
            last = i + 1;
        }
    }
    if (last != beg + len)
    {
        WriteConsoleOutputCharacterW(ctx->hConOut, &ctx->line[last], i - last,
                                     WCEL_GetCoord(ctx, last), &count);
        FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, i - last,
                                   WCEL_GetCoord(ctx, last), &count);
    }
}
Пример #6
0
static LONG_PTR WINAPI NameDlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
  Splited *DlgParams=(Splited *)Info.SendDlgMessage(hDlg,DM_GETDLGDATA,0,0);
  switch(Msg)
  {
    case DN_DRAWDLGITEM:
      if(Param1>0)
      {
        DWORD written; COORD coord;
        SMALL_RECT Rect;
        Info.SendDlgMessage(hDlg,DM_GETDLGRECT,0,(LONG_PTR)&Rect);
        coord.X=Rect.Left+((FarDialogItem *)Param2)->X1;
        coord.Y=Rect.Top+((FarDialogItem *)Param2)->Y1;
        wchar_t *string=DlgParams->Name[Param1-1];
        DWORD string_len=(DWORD)wcslen(string);
        WriteConsoleOutputCharacterW(DlgParams->Console,string,string_len,coord,&written);
      }
      break;
    case DN_ENTERIDLE:
      Info.SendDlgMessage(hDlg,DM_SETREDRAW,0,0);
      break;
  }
  return Info.DefDlgProc(hDlg,Msg,Param1,Param2);
}
LONG_PTR FastRedrawDefDlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
  BasicDialogData *DlgParams=(BasicDialogData *)Info.SendDlgMessage(hDlg,DM_GETDLGDATA,0,0);
  FILETIME CurrentTimeFT; unsigned long long CurrentTime;
  GetSystemTimeAsFileTime(&CurrentTimeFT);
  memcpy(&CurrentTime,&CurrentTimeFT,sizeof(CurrentTime));
  switch(Msg)
  {
    case DN_INITDIALOG:
      if(DlgParams->Thread->Process) Info.SendDlgMessage(hDlg,DM_SETMOUSEEVENTNOTIFY,1,0);
      break;
    case DN_MOUSEEVENT:
      if(DlgParams->Thread->Process) Info.SendDlgMessage(hDlg,DM_CHECK_STATE,0,0);
      break;
    case DN_ENTERIDLE:
      DlgParams->InMacro=false;
      if(!DlgParams->Thread->Process) Info.SendDlgMessage(hDlg,DN_TIMER,0,0);
      else Info.SendDlgMessage(hDlg,DM_CHECK_STATE,0,0);
      break;
    case DN_DRAWDLGITEM:
      if(DlgParams->Console!=INVALID_HANDLE_VALUE) Info.SendDlgMessage(hDlg,DM_REDRAW_UNICODE,Param1,0);
      break;
    case DN_DRAWDIALOGDONE:
      if(!DlgParams->InRefresh)
      {
        DlgParams->InRefresh=true;
        if(!DlgParams->Thread->Process) Info.SendDlgMessage(hDlg,DM_CHECK_STATE,0,0);
        DlgParams->InRefresh=false;
      }
      break;
    case DM_REDRAW_UNICODE:
      if(DlgParams->Console!=INVALID_HANDLE_VALUE)
      {
        for(int i=0;i<UNICODE_LABEL_COUNT;i++)
        {
          if(DlgParams->UnicodeInicies[i]>=0&&Param1==DlgParams->UnicodeInicies[i])
          {
            DWORD written; COORD coord;
            SMALL_RECT Rect; FarDialogItem DialogItem;
            Info.SendDlgMessage(hDlg,DM_GETDLGRECT,0,(LONG_PTR)&Rect);
            Info.SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,DlgParams->UnicodeInicies[i],(LONG_PTR)&DialogItem);
            coord.X=Rect.Left+DialogItem.X1;
            coord.Y=Rect.Top+DialogItem.Y1;
            WriteConsoleOutputCharacterW(DlgParams->Console,&(DlgParams->FileNameW[i][0]),(DWORD)wcslen(&(DlgParams->FileNameW[i][0])),coord,&written);
          }
        }
      }
      break;
    case DN_KEY:
      if(Param2==(KEY_BS|KEY_CTRL|KEY_ALT|KEY_SHIFT))
      {
        DlgParams->StartTime=CurrentTime;
        if(DlgParams->State)
          Info.SendDlgMessage(hDlg,DN_TIMER,0,0);
        else
          Info.SendDlgMessage(hDlg,DM_CHECK_STATE,0,0);
        DlgParams->State=!DlgParams->State;
        return TRUE;
      }
      else if(!DlgParams->InMacro&&run_macro_2(DlgParams->MacroIndex,(DWORD)Param2))
      {
        DlgParams->InMacro=true;
        return TRUE;
      }
      else if(DlgParams->KeyProc) DlgParams->KeyProc(hDlg,Msg,Param1,Param2);
      if(!DlgParams->InMacro) Info.SendDlgMessage(hDlg,DM_CHECK_STATE,0,0);
      break;
    case DN_MACRO_DISABLE:
      return TRUE;
  }
  return Info.DefDlgProc(hDlg,Msg,Param1,Param2);
}