static void TabLogAdd( LPTSTR str ) { int size; size = Edit_GetTextLength( g_hLogEdit ); Edit_SetSel( g_hLogEdit,size, size ); Edit_ReplaceSel( g_hLogEdit, str ); Edit_ScrollCaret( g_hLogEdit ); }
static void append_output_window_real(const char *astring) { int len; len=Edit_GetTextLength(logoutput_win); Edit_SetSel(logoutput_win,len,len); Edit_ReplaceSel(logoutput_win,astring); Edit_ScrollCaret(logoutput_win); }
// // Console window // void ConsoleTabWindow::print(TCHAR *buf, BOOL force_display) { int cr; TCHAR *p; if (force_display) goto display; if (_filesave) { if (_logfile == INVALID_HANDLE_VALUE && !_open_log_file()) { _filesave = FALSE; _set_check(IDC_CONS_FILESAVE, _filesave); EnableWindow(_filename_edit, _filesave); goto display; } DWORD cnt; char c; for (int i = 0; *buf != TEXT('\0'); buf++) { c = *buf & 0x7f; WriteFile(_logfile, &c, 1, &cnt, 0); } FlushFileBuffers(_logfile); return; } display: // count number of '\n' for (cr = 0, p = buf; p = wcschr(p, TEXT('\n')); cr++, p++) continue; // total length of new buffer ('\n' -> "\r\n" + '\0') size_t sz = (wcslen(buf) + cr + 1) * sizeof(TCHAR); p = reinterpret_cast <TCHAR *>(malloc(sz)); if (p == NULL) return; // convert newlines TCHAR *d = p; while (*buf != TEXT('\0')) { TCHAR c = *buf++; if (c == TEXT('\n')) *d++ = TEXT('\r'); *d++ = c; } *d = TEXT('\0'); // append the text and scroll int end = Edit_GetTextLength(_edit); Edit_SetSel(_edit, end, end); Edit_ReplaceSel(_edit, p); Edit_ScrollCaret(_edit); UpdateWindow(_edit); free(p); }
/* * mswin_tw_puts_lptstr() - Stuffs a LPTSTR string at the end of our edit * control. */ int mswin_tw_puts_lptstr(MSWIN_TEXTWINDOW *mswin_tw, LPTSTR msg) { if(mswin_tw && mswin_tw->hwnd_edit) { TCHAR lf_str[] = TEXT("\n"); Edit_ExSetSel(mswin_tw->hwnd_edit, -1, -1); Edit_ReplaceSel(mswin_tw->hwnd_edit, msg); Edit_ReplaceSel(mswin_tw->hwnd_edit, lf_str); Edit_ScrollCaret(mswin_tw->hwnd_edit); return 1; } return 0; }
/* This function writes the appropriate signature for the specified * topic. */ void FASTCALL SetEditSignature( HWND hwndEdit, PTL ptl ) { LPSTR lpszSignature; char * pszSig; pszSig = NULL; if( NULL == ptl ) pszSig = szGlobalSig; else { TOPICINFO topicinfo; Amdb_GetTopicInfo( ptl, &topicinfo ); if( topicinfo.szSigFile[ 0 ] ) pszSig = topicinfo.szSigFile; } if( NULL != pszSig ) if( NULL != ( lpszSignature = GetEditSignature( pszSig ) ) ) { DWORD dwSig1Sel; /* Save the caret position and append the signature to the end of the * current text. Then put the caret back where it was. */ dwSig1Sel = Edit_GetSel( hwndEdit ); if( fEditAtTop ) { Edit_SetSel( hwndEdit, 0, 0 ); Edit_ReplaceSel( hwndEdit, lpszSignature ); Edit_SetSel( hwndEdit, 0, 0 ); Edit_ScrollCaret( hwndEdit ); } else { Edit_SetSel( hwndEdit, USHRT_MAX, USHRT_MAX ); Edit_ReplaceSel( hwndEdit, lpszSignature ); Edit_SetSel( hwndEdit, LOWORD(dwSig1Sel), HIWORD(dwSig1Sel) ); } FreeMemory( &lpszSignature ); } }
/* This function handles the WM_COMMAND message. */ void FASTCALL NewSig_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EDIT: if( codeNotify == EN_CHANGE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPSTR lpText; HWND hwndEdit; register int c; lpText = (LPSTR)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); Edit_GetText( hwndEdit, lpText, 9 ); for( c = 0; lpText[ c ]; ++c ) if( !ValidFileNameChr( lpText[ c ] ) ) { wsprintf( lpTmpBuf, GS( IDS_STR136 ), lpText[ c ] ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION ); break; } if( lpText[ c ] ) { SetFocus( hwndEdit ); Edit_SetSel( hwndEdit, c, c + 1 ); Edit_ScrollCaret( hwndEdit ); break; } } case IDCANCEL: EndDialog( hwnd, id == IDOK ); break; } }
void pTextEdit::setCursorPosition(unsigned position) { if(position == ~0) position >>= 1; //Edit_SetSel takes signed type Edit_SetSel(hwnd, position, position); Edit_ScrollCaret(hwnd); }