ReactOS  0.4.12-dev-75-g00dd17e
main.h File Reference
#include "notepad_res.h"
Include dependency graph for main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NOTEPAD_GLOBALS
 

Macros

#define ARRAY_SIZE(a)   (sizeof(a)/sizeof((a)[0]))
 
#define EDIT_STYLE_WRAP
 
#define EDIT_STYLE   (EDIT_STYLE_WRAP | WS_HSCROLL | ES_AUTOHSCROLL)
 
#define EDIT_CLASS   _T("EDIT")
 
#define MAX_STRING_LEN   255
 
#define ENCODING_UNICODE   1
 
#define ENCODING_UNICODE_BE   2
 
#define EOLN_CRLF   0
 
#define EOLN_LF   1
 
#define EOLN_CR   2
 

Enumerations

enum  ENCODING {
  ENCODING_ANSI = 0, ENCODING_UTF16LE = 1, ENCODING_UTF16BE = 2, ENCODING_UTF8 = 3,
  ENCODING_AUTO = -1, ENCODING_ANSI = 0, ENCODING_UTF16LE = 1, ENCODING_UTF16BE = 2,
  ENCODING_UTF8 = 3, ENCODING_ANSI = 1, ENCODING_UTF8, ENCODING_UTF16LE,
  ENCODING_UTF16BE
}
 

Functions

VOID SetFileName (LPCTSTR szFileName)
 
BOOL ReadText (HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int *piEoln)
 
BOOL WriteText (HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int iEoln)
 
void NOTEPAD_LoadSettingsFromRegistry (void)
 
void NOTEPAD_SaveSettingsToRegistry (void)
 
BOOL NOTEPAD_FindNext (FINDREPLACE *, BOOL, BOOL)
 
VOID NOTEPAD_EnableSearchMenu (VOID)
 

Variables

NOTEPAD_GLOBALS Globals
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a)/sizeof((a)[0]))

Definition at line 24 of file main.h.

Referenced by _dump_cf_flags(), _enumeratorRememberedW(), _tryLoadProvider(), acquire_graphics_pipeline_resources(), acquire_tests(), add_cert_columns(), add_cert_to_view(), add_date_string_to_control(), add_ms_root_certs(), add_properties(), add_purpose_dlg_proc(), add_string_id_and_value_to_list(), add_tb_button(), add_tbs_to_menu(), add_v1_fields(), ADPCM_FormatDetails(), ADPCM_FormatTagDetails(), ADPCM_GetFormatIndex(), AlertFileNotSaved(), AlertPrintError(), AppendFullPathURL(), apply_general_changes(), ask_confirm(), AtlModuleRegisterWndClassInfoW(), AVIBuildFilterW(), AVIFILE_GetFileHandlerByExtension(), AVIFILE_LoadFile(), AVIFileCreateStreamA(), AVISaveOptionsUpdate(), AX_ConvertDialogTemplate(), BrowseSelectedFolder(), call_wnd_proc_filter(), callback_providersA(), callback_providersW(), CC_CheckDigitsInEdit(), cert_mgr_do_remove(), cert_mgr_show_cert_usages(), cert_mgr_sort_by_text(), CertEnumSystemStore(), CertGetNameStringW(), CFn_WMCommand(), CFn_WMInitDialog(), check_fbo_compat(), cleanup(), COMCTL32_DrawInsertMark(), COMDLG32_DumpSBSPFlags(), connections_on_notify(), container_matches_cert(), context_alloc_pipeline_statistics_query(), context_alloc_so_statistics_query(), context_apply_compute_state(), context_create(), context_destroy_gl_resources(), context_draw_shaded_quad(), context_dump_fbo_attachment(), context_generate_fbo_key(), context_load_stream_output_buffers(), convert_to_wined3d_declaration(), create_device(), create_dummy_textures(), create_listview_columns(), create_moniker(), create_rebar(), create_show_list(), create_taskdialog_template(), create_uri(), CreateHelpViewer(), CredDialogCreateBalloonTip(), CredDialogInit(), CredDialogShowCapsLockBalloon(), CredDialogShowIncorrectPasswordBalloon(), CRYPT_AsnDecodeAccessDescription(), CRYPT_AsnDecodeAlgorithmId(), CRYPT_AsnDecodeAuthorityKeyId(), CRYPT_AsnDecodeAuthorityKeyId2(), CRYPT_AsnDecodeBasicConstraints(), CRYPT_AsnDecodeBasicConstraints2(), CRYPT_AsnDecodeCertInfo(), CRYPT_AsnDecodeCertPolicy(), CRYPT_AsnDecodeCertPolicyConstraints(), CRYPT_AsnDecodeCertPolicyMapping(), CRYPT_AsnDecodeCertSignedContent(), CRYPT_AsnDecodeCMSSignedInfo(), CRYPT_AsnDecodeCMSSignerInfoInternal(), CRYPT_AsnDecodeCRLEntry(), CRYPT_AsnDecodeCRLInfo(), CRYPT_AsnDecodeCTL(), CRYPT_AsnDecodeCTLEntry(), CRYPT_AsnDecodeDistPoint(), CRYPT_AsnDecodeEccSignature(), CRYPT_AsnDecodeEncryptedContentInfo(), CRYPT_AsnDecodeExtension(), CRYPT_AsnDecodeIssuerSerialNumber(), CRYPT_AsnDecodeIssuingDistPoint(), CRYPT_AsnDecodeNameConstraints(), CRYPT_AsnDecodeNoticeReference(), CRYPT_AsnDecodePKCSAttributeInternal(), CRYPT_AsnDecodePKCSContentInfoInternal(), CRYPT_AsnDecodePKCSDigestedData(), CRYPT_AsnDecodePKCSEnvelopedData(), CRYPT_AsnDecodePKCSSignerInfoInternal(), CRYPT_AsnDecodePolicyQualifier(), CRYPT_AsnDecodePolicyQualifierUserNoticeInternal(), CRYPT_AsnDecodePubKeyInfoInternal(), CRYPT_AsnDecodeRdnAttr(), CRYPT_AsnDecodeRecipientInfo(), CRYPT_AsnDecodeRsaPrivKey(), CRYPT_AsnDecodeRsaPubKey(), CRYPT_AsnDecodeSMIMECapability(), CRYPT_AsnDecodeSubtree(), CRYPT_AsnDecodeUnicodeRdnAttr(), CRYPT_AsnDecodeValidity(), CRYPT_AsnEncodeAccessDescription(), CRYPT_AsnEncodeAlgorithmId(), CRYPT_AsnEncodeAlgorithmIdWithNullParams(), CRYPT_AsnEncodeCert(), CRYPT_AsnEncodeCertPolicy(), CRYPT_AsnEncodeCertPolicyMapping(), CRYPT_AsnEncodeCertPolicyQualifiers(), CRYPT_AsnEncodeCTLEntry(), CRYPT_AsnEncodeEncryptedContentInfo(), CRYPT_AsnEncodeIssuerSerialNumber(), CRYPT_AsnEncodeNoticeReference(), CRYPT_AsnEncodePKCSAttribute(), CRYPT_AsnEncodePKCSDigestedData(), CRYPT_AsnEncodePKCSEnvelopedData(), CRYPT_AsnEncodePubKeyInfo(), CRYPT_AsnEncodePubKeyInfoNoNull(), CRYPT_AsnEncodeRecipientInfo(), CRYPT_AsnEncodeRsaPubKey(), CRYPT_AsnEncodeSMIMECapability(), CRYPT_AsnEncodeValidity(), CRYPT_CreateChainEngine(), CRYPT_CreateFileStore(), CRYPT_EncodeDataContentInfoHeader(), CRYPT_FormatAltNameEntry(), CRYPT_FormatAuthorityInfoAccess(), CRYPT_FormatBasicConstraints2(), CRYPT_FormatCertIssuer(), CRYPT_FormatCRLDistPoints(), CRYPT_FormatEnhancedKeyUsage(), CRYPT_FormatHexStringWithPrefix(), CRYPT_FormatKeyUsage(), CRYPT_FormatNetscapeCertType(), CRYPT_FormatReason(), CRYPT_FormatSpcFinancialCriteria(), CRYPT_InitializeKeynameKeeper(), CRYPT_MsgOpenStore(), CRYPT_RegOpenStore(), CRYPT_RegReadFromReg(), CRYPT_RegReadSerializedFromReg(), CRYPT_RegWriteToReg(), CryptFindLocalizedName(), CryptSIPRetrieveSubjectGuid(), d3d7_EnumDevices(), d3d7_EnumZBufferFormats(), d3d9_device_GetTextureStageState(), d3d9_device_reset(), d3d9_device_SetTextureStageState(), d3d9_rts_flag_auto_gen_mipmap(), d3d_device2_EnumTextureFormats(), d3d_device7_EnumTextureFormats(), d3d_device7_GetClipPlane(), d3d_device7_SetClipPlane(), d3dformat_to_dds_pixel_format(), d3dformat_to_wic_guid(), d3drm3_CreateObject(), d3dx9_apply_pass_states(), D3DXGetDeclVertexSize(), DATETIME_GetText(), DATETIME_Refresh(), DATETIME_ReturnTxt(), DATETIME_SetFormatW(), ddraw7_EnumDisplayModes(), ddraw7_GetFourCCCodes(), DDRAW_dump_cooperativelevel(), DDRAW_dump_DDCAPS(), DDRAW_dump_DDSCAPS2(), DDRAW_dump_pixelformat_flag(), DDRAW_dump_surface_desc(), ddraw_match_surface_desc(), dds_fourcc_to_d3dformat(), dds_rgb_to_d3dformat(), debug_append(), debug_d3dshaderinstructionhandler(), debug_node_type(), decode_base64(), default_page_paint_hook(), delete_test_key(), delnode_test(), detail_dlg_proc(), device_init(), DIALOG_FileOpen(), DIALOG_FileSaveAs(), DIALOG_FileSaveAs_Hook(), DIALOG_GoTo_DialogProc(), DIALOG_HelpAboutNotepad(), DIALOG_PAGESETUP_Hook(), DIALOG_SearchDialog(), DIALOG_StringMsgBox(), DirectPlayEnumerateAW(), Dispatch_Invoke(), DllGetClassObject(), DMOUnregister(), do_process_root_key(), DocObjectService_FireBeforeNavigate2(), DoOpenFile(), DP_LoadSP(), draw_primitive_arrays(), drive_get_FileSystem(), drive_get_VolumeName(), EditStreamSetNameA(), EditStreamSetNameW(), effect_from_guid(), EnumAddress_cb2(), EnumJoysticks(), EnumOLEVERB_Next(), ExecuteCabA(), expect_guid(), export_file_dlg_proc(), export_finish_dlg_proc(), export_password_mismatch(), export_private_key_dlg_proc(), export_validate_filename(), export_welcome_dlg_proc(), expr_common_base_type(), FD31_MapOfnStructA(), FD31_StripEditControl(), FD31_TestPath(), FD31_Validate(), field_format_extension_hex_with_ascii(), field_format_public_key(), FileDialog_constructor(), FILEDLG95_InitControls(), FILEDLG95_MRU_load_filename(), FILEDLG95_MRU_save_filename(), FILEDLG95_OnOpenMessage(), filedlg_collect_places_pidls(), filesys_GetSpecialFolder(), filetime_to_str(), find_class(), find_converter(), find_html_symbol(), findSupportedOID(), fixup_extensions(), format_clear_flag(), format_long_date(), format_set_flag(), general_on_notify(), generate_effects(), get_alpha_replacement_format(), get_assembly_directory(), get_char_script(), get_decimal_sep(), get_dialog_font_point_size(), get_driver_version_info(), get_encoding_from_codepage(), get_engine_clsid(), get_escaped_string(), get_format_idx(), get_format_info_idx(), get_gpu_description(), get_hatch_data(), get_long_key(), get_luminance_replacement_format(), get_msg_filter(), get_msxml_version(), get_opcode_info(), get_root_key(), get_shader_semantics(), get_target_info(), get_temp_ini_path(), get_texture_view_target(), GetCachePath(), GetFileDialog95(), glsl_blitter_generate_program(), Host_get_FullName(), Host_get_Path(), I_CertUpdateStore(), IAssemblyCacheImpl_InstallAssembly(), IDirectInput8AImpl_EnumDevicesBySemantics(), IDirectInput8WImpl_EnumDevicesBySemantics(), IDirectInputAImpl_EnumDevices(), IDirectInputWImpl_EnumDevices(), IDirectPlay4AImpl_EnumConnections(), IDirectPlayLobby3AImpl_EnumAddressTypes(), IDirectPlayLobby3AImpl_EnumLocalApplications(), IFileDialog2_fnSetOptions(), ImmCreateContext(), ImmGetCandidateListA(), ImmGetCandidateListW(), ImmGetCandidateWindow(), ImmGetIMEFileNameW(), ImmInstallIMEW(), ImmSetCandidateWindow(), import_file_dlg_proc(), import_finish_dlg_proc(), import_store_dlg_proc(), import_validate_filename(), import_warning(), import_welcome_dlg_proc(), index_from_urltemplate(), init_debug_buffer(), init_format_base_info(), init_format_block_info(), init_format_fbo_compat_info(), init_format_filter_info(), init_format_gen_mipmap_info(), init_format_texture_info(), init_format_vertex_info(), init_oid_info(), init_set_constants_param(), init_typeless_formats(), initialize_purpose_selection(), IPersistFile_fnLoad(), is_ime_window_proc(), is_local_machineA(), is_local_machineW(), IShellBrowserImpl_ICommDlgBrowser_OnStateChange(), iterate_section_fields(), ITS_IParseDisplayNameImpl_ParseDisplayName(), JoyConfig8Impl_GetConfig(), LISTVIEW_Command(), load_graphics_driver(), lookup_gl_view_class(), make_import_file_filter(), map_register(), margin_edit_notification(), match_dns_to_subject_dn(), match_name_table_language(), MenuHelp(), METAFILE_Free(), MimeHtmlProtocolInfo_CombineUrl(), MimeOleObjectFromMoniker(), MONTHCAL_LButtonDown(), MONTHCAL_PaintCalendar(), MONTHCAL_PaintTitle(), MONTHCAL_PaintTodayTitle(), MONTHCAL_PaintWeeknumbers(), MONTHCAL_RButtonUp(), MONTHCAL_SetFirstDayOfWeek(), MONTHCAL_UpdateSize(), msg_spy_find_next_msg(), navigate_url(), needs_ime_window(), NOTEPAD_FindNext(), NOTEPAD_InitData(), NOTEPAD_LoadSettingsFromRegistry(), NOTEPAD_WndProc(), oid_init_localizednames(), on_before_navigate2(), on_default_action(), output_message(), output_value(), pagesetup_set_devnames(), parse_encoding_name(), parse_mhtml_url(), parse_pres_ins(), parse_pres_reg(), parse_win31_line_state(), path_get_rootkey(), per_user_install_callback(), png_metadata_reader(), print_string(), PRINTDLG_CreateDevNames(), PRINTDLG_CreateDevNamesW(), PRINTDLG_OpenDefaultPrinter(), PRINTDLG_SetUpPrinterListComboA(), PRINTDLG_SetUpPrinterListComboW(), PRINTDLG_UpdatePrintDlgW(), PRINTDLG_WMInitDialog(), PRINTDLG_WMInitDialogW(), PROPSHEET_CollectPageInfo(), PROPSHEET_DialogProc(), PROPSHEET_SetTitleA(), PROPSHEET_SetTitleW(), query_format_flag(), query_internal_format(), query_prop(), read_trusted_roots_from_known_locations(), reader_get_attribute_ns_uri(), ReadText(), REBAR_MoveChildWindows(), reg_type_to_wchar(), register_ocxs_callback(), release_typelib(), remove_vbos(), resource_init(), run_winemenubuilder(), SAXContentHandler_processingInstruction(), SAXDeclHandler_attributeDecl(), SAXDeclHandler_elementDecl(), SAXDeclHandler_externalEntityDecl(), SAXDeclHandler_internalEntityDecl(), SAXDTDHandler_notationDecl(), SAXLexicalHandler_comment(), SAXLexicalHandler_endCDATA(), SAXLexicalHandler_endDTD(), SAXLexicalHandler_startCDATA(), SAXLexicalHandler_startDTD(), ScriptGetProperties(), select_store_dlg_proc(), selected_item_to_store(), set_fields_selection(), set_margin_groupbox_title(), set_status_text(), SetFileName(), SetFontSizesToCombo3(), SetPerUserSecValuesA(), shader_dump_shader_input_sysval_semantic(), shader_generate_glsl_declarations(), shader_get_registers_used(), shader_glsl_atomic(), shader_glsl_gather4(), shader_glsl_generate_ffp_vertex_shader(), shader_glsl_get_resource_info(), shader_glsl_get_sample_function(), shader_glsl_init_transform_feedback(), shader_glsl_ld(), shader_glsl_ld_raw_structured(), shader_glsl_ld_uav(), shader_glsl_resinfo(), shader_glsl_sample_info(), shader_glsl_store_raw_structured(), shader_glsl_store_uav(), shader_glsl_swapc(), shader_resource_view_bind_and_dirtify(), shader_semantic_name_from_usage(), shader_sm1_read_semantic(), shader_sm4_init(), shader_sm4_read_dcl_input_primitive(), shader_sm4_read_dcl_output_topology(), shader_sm4_read_dcl_resource(), shader_sm4_read_param(), shader_usage_from_semantic_name(), show_cert_stores(), show_export_details(), show_import_details(), ShowLastError(), skip_schema(), SnmpExtensionInit(), sqliteKeywordCode(), SspiPromptForCredentialsW(), START_TEST(), state_so(), stateblock_savedstates_set_pixel(), stateblock_savedstates_set_vertex(), strcmp_wa(), SYSLINK_ParseText(), taskkill_message(), taskkill_message_printfW(), taskkill_vprintfW(), test_addclosedcurve(), test_addcurve(), test_addpie(), test_arc(), test_basics(), test_bitmapbits(), test_CertRDNValueToStrA(), test_CertRDNValueToStrW(), test_CertStrToNameA(), test_CertStrToNameW(), test_createeffect(), test_CredUIPromptForCredentials(), test_CryptBinaryToString(), test_decodeBasicConstraints(), test_decodeBits(), test_decodeCertPolicyMappings(), test_decodeCertToBeSigned(), test_decodeCRLToBeSigned(), test_decodeEnhancedKeyUsage(), test_decodeEnumerated(), test_decodeExtensions(), test_decodeFiletime(), test_decodeInt(), test_decodeName(), test_decodeNameConstraints(), test_decodeNameValue(), test_decodeOctets(), test_decodePKCSContentInfo(), test_decodePublicKeyInfo(), test_decodeRsaPublicKey(), test_decodeSequenceOfAny(), test_decodeUnicodeName(), test_decodeUnicodeNameValue(), test_default_ime_window_creation(), test_digit_substitution(), test_dik_codes(), test_DirectInputCreateEx(), test_DrawImage_scale(), test_ellipse(), test_encodeBasicConstraints(), test_encodeBits(), test_encodeCertPolicyMappings(), test_encodeEnhancedKeyUsage(), test_encodeEnumerated(), test_encodeExtensions(), test_encodeFiletime(), test_encodeInt(), test_encodeName(), test_encodeNameValue(), test_encodeOctets(), test_encodePublicKeyInfo(), test_encodeRsaPublicKey(), test_encodeSequenceOfAny(), test_encodeUnicodeNameValue(), test_encoding_detection(), test_extension(), test_findAttribute(), test_findOIDInfo(), test_findRDNAttr(), test_flatten(), test_GdipGetAllPropertyItems(), test_GdipMeasureString(), test_gif_properties(), test_histogram(), test_image_format(), test_image_properties(), test_Initialize(), test_its_protocol_info(), test_line2(), test_linei(), test_mhtml_protocol(), test_mhtml_protocol_binding(), test_mhtml_protocol_info(), test_MimeOleObjectFromMoniker(), test_namespaceuri(), test_NameToStrConversionW(), test_object_info(), test_pathpath(), test_pbo_functionality(), test_pen_thickness(), test_png_color_formats(), test_polygon(), test_prefix(), test_preinitialization(), test_QueryInterface(), test_readvaluechunk(), Test_RealGetWindowClass(), test_rect(), test_registerDefaultOIDFunction(), test_reverse(), test_ScriptGetFontFunctions(), test_ScriptGetLogicalWidths(), test_ScriptIsComplex(), test_ScriptItemIzeShapePlace(), test_ScriptLayout(), test_ScriptShape(), test_ScriptString(), test_ScriptStringXtoCP_CPtoX(), test_ScriptTextOut(), test_ScriptTextOut2(), test_ScriptTextOut3(), test_SIPRetrieveSubjectGUID(), test_supported_encoders(), test_tiff_properties(), test_transform(), test_widen(), test_WNetGetRemoteName(), test_WNetGetUniversalName(), testAlgIDToOID(), testCertRegisterSystemStore(), testCompareIntegerBlob(), testGetCertChain(), testOIDToAlgID(), testRegStoreSavedCerts(), testStringToBinaryA(), THEMING_DialogSubclassProc(), TOOLBAR_Restore(), TOOLBAR_TTGetDispInfo(), TOOLTIPS_Show(), TRACKBAR_FillThumb(), TREEVIEW_Command(), TREEVIEW_ProcessLetterKeys(), try_application_url(), UniformResourceLocatorW_InvokeCommand(), unregister_versioned_classes(), update_security_level(), update_travellog(), update_zone_info(), UpdateWindowCaption(), UPDOWN_GetBuddyInt(), UPDOWN_SetBuddy(), UPDOWN_SetBuddyInt(), url_matches(), validate_state_table(), verify_authenticode_policy(), verify_ms_root_policy(), vt_to_itemtype(), wchar_get_type(), wic_guid_to_d3dformat(), wined3d_adapter_init(), wined3d_adapter_init_gl_caps(), wined3d_caps_gl_ctx_test_viewport_subpixel_bits(), wined3d_cs_exec_draw(), wined3d_cs_queue_check_space(), wined3d_cs_queue_require_space(), wined3d_device_decref(), wined3d_device_get_sampler_state(), wined3d_device_get_texture(), wined3d_device_set_sampler_state(), wined3d_device_set_texture(), wined3d_format_convert_from_float(), wined3d_format_get_color_key_conversion(), wined3d_format_is_depth_view(), wined3d_formats_are_srgb_variants(), wined3d_get_format(), wined3d_guess_card(), wined3d_pipeline_query_ops_poll(), wined3d_swapchain_cs_init(), wined3d_texture_bind_and_dirtify(), WNetGetConnectionA(), write_cdata_section(), write_escaped_string(), write_node_indent(), write_output_buffer_quoted(), write_output_qname(), write_predefined_strings(), write_prolog_buffer(), write_xmldecl(), writer_close_starttag(), WshShortcut_get_Arguments(), WshShortcut_get_IconLocation(), WshShortcut_get_WorkingDirectory(), wWinMain(), XCOPY_LoadMessage(), XCOPY_ParseCommandLine(), XCOPY_ProcessExcludeFile(), XCOPY_ProcessSourceParm(), xmlwriter_WriteAttributeString(), xmlwriter_WriteComment(), xmlwriter_WriteElementString(), xmlwriter_WriteEndElement(), xmlwriter_WriteFullEndElement(), xmlwriter_WriteProcessingInstruction(), and xmlwriter_WriteStartElement().

◆ EDIT_CLASS

#define EDIT_CLASS   _T("EDIT")

Definition at line 32 of file main.h.

Referenced by DoCreateEditWindow().

◆ EDIT_STYLE

Definition at line 30 of file main.h.

Referenced by DoCreateEditWindow().

◆ EDIT_STYLE_WRAP

#define EDIT_STYLE_WRAP
Value:
#define ES_MULTILINE
Definition: pedump.c:667
#define WS_CHILD
Definition: pedump.c:617
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_VSCROLL
Definition: pedump.c:627

Definition at line 28 of file main.h.

Referenced by DoCreateEditWindow().

◆ ENCODING_UNICODE

#define ENCODING_UNICODE   1

Definition at line 46 of file main.h.

Referenced by ReadText(), and WriteEncodedText().

◆ ENCODING_UNICODE_BE

#define ENCODING_UNICODE_BE   2

Definition at line 47 of file main.h.

Referenced by ReadText(), and WriteEncodedText().

◆ EOLN_CR

#define EOLN_CR   2

Definition at line 55 of file main.h.

Referenced by ReadText(), and WriteText().

◆ EOLN_CRLF

#define EOLN_CRLF   0

Definition at line 53 of file main.h.

Referenced by ReadText(), and WriteText().

◆ EOLN_LF

#define EOLN_LF   1

Definition at line 54 of file main.h.

Referenced by ReadText(), and WriteText().

◆ MAX_STRING_LEN

#define MAX_STRING_LEN   255

Definition at line 34 of file main.h.

Enumeration Type Documentation

◆ ENCODING

Enumerator
ENCODING_ANSI 
ENCODING_UTF16LE 
ENCODING_UTF16BE 
ENCODING_UTF8 
ENCODING_AUTO 
ENCODING_ANSI 
ENCODING_UTF16LE 
ENCODING_UTF16BE 
ENCODING_UTF8 
ENCODING_ANSI 
ENCODING_UTF8 
ENCODING_UTF16LE 
ENCODING_UTF16BE 

Definition at line 37 of file main.h.

38 {
39  ENCODING_AUTO = -1,
40  ENCODING_ANSI = 0,
41  ENCODING_UTF16LE = 1,
42  ENCODING_UTF16BE = 2,
43  ENCODING_UTF8 = 3
44 } ENCODING;
ENCODING
Definition: main.h:37

Function Documentation

◆ NOTEPAD_EnableSearchMenu()

VOID NOTEPAD_EnableSearchMenu ( VOID  )

◆ NOTEPAD_FindNext()

BOOL NOTEPAD_FindNext ( FINDREPLACE ,
BOOL  ,
BOOL   
)

Definition at line 138 of file main.c.

Referenced by DIALOG_SearchNext(), NOTEPAD_ReplaceAll(), and NOTEPAD_WndProc().

139 {
140  int iTextLength, iTargetLength;
141  size_t iAdjustment = 0;
142  LPTSTR pszText = NULL;
143  DWORD dwPosition, dwBegin, dwEnd;
144  BOOL bMatches = FALSE;
145  TCHAR szResource[128], szText[128];
146  BOOL bSuccess;
147 
148  iTargetLength = (int) _tcslen(pFindReplace->lpstrFindWhat);
149 
150  /* Retrieve the window text */
151  iTextLength = GetWindowTextLength(Globals.hEdit);
152  if (iTextLength > 0)
153  {
154  pszText = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (iTextLength + 1) * sizeof(TCHAR));
155  if (!pszText)
156  return FALSE;
157 
158  GetWindowText(Globals.hEdit, pszText, iTextLength + 1);
159  }
160 
161  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwBegin, (LPARAM) &dwEnd);
162  if (bReplace && ((dwEnd - dwBegin) == (DWORD) iTargetLength))
163  {
164  if (NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwBegin))
165  {
166  SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM) pFindReplace->lpstrReplaceWith);
167  iAdjustment = _tcslen(pFindReplace->lpstrReplaceWith) - (dwEnd - dwBegin);
168  }
169  }
170 
171  if (pFindReplace->Flags & FR_DOWN)
172  {
173  /* Find Down */
174  dwPosition = dwEnd;
175  while(dwPosition < (DWORD) iTextLength)
176  {
177  bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition);
178  if (bMatches)
179  break;
180  dwPosition++;
181  }
182  }
183  else
184  {
185  /* Find Up */
186  dwPosition = dwBegin;
187  while(dwPosition > 0)
188  {
189  dwPosition--;
190  bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition);
191  if (bMatches)
192  break;
193  }
194  }
195 
196  if (bMatches)
197  {
198  /* Found target */
199  if (dwPosition > dwBegin)
200  dwPosition += (DWORD) iAdjustment;
201  SendMessage(Globals.hEdit, EM_SETSEL, dwPosition, dwPosition + iTargetLength);
203  bSuccess = TRUE;
204  }
205  else
206  {
207  /* Can't find target */
208  if (bShowAlert)
209  {
210  LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, ARRAY_SIZE(szResource));
211  _sntprintf(szText, ARRAY_SIZE(szText), szResource, pFindReplace->lpstrFindWhat);
212  LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource));
213  MessageBox(Globals.hFindReplaceDlg, szText, szResource, MB_OK);
214  }
215  bSuccess = FALSE;
216  }
217 
218  if (pszText)
219  HeapFree(GetProcessHeap(), 0, pszText);
220  return bSuccess;
221 }
HWND hFindReplaceDlg
Definition: main.h:61
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define DWORD
Definition: msvc.h:34
LPCWSTR pszText
Definition: msvc.h:103
static BOOLEAN bSuccess
Definition: drive.cpp:417
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5664
UINT_PTR WPARAM
Definition: windef.h:207
HINSTANCE hInstance
Definition: main.h:59
#define EM_GETSEL
Definition: winuser.h:1958
#define STRING_NOTEPAD
Definition: notepad_res.h:74
static const WCHAR szText[]
Definition: dialog.c:139
static BOOL NOTEPAD_FindTextAt(FINDREPLACE *pFindReplace, LPCTSTR pszText, int iTextLength, DWORD dwPosition)
Definition: main.c:104
LONG_PTR LPARAM
Definition: windef.h:208
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define EM_SETSEL
Definition: winuser.h:1979
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _sntprintf
Definition: xmlstorage.h:201
#define MessageBox
Definition: winuser.h:5688
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MB_OK
Definition: winuser.h:784
#define FR_DOWN
Definition: commdlg.h:127
#define STRING_CANNOTFIND
Definition: notepad_res.h:88
#define SendMessage
Definition: winuser.h:5709
#define GetWindowTextLength
Definition: winuser.h:5665
HWND hEdit
Definition: main.h:62
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LoadString
Definition: winuser.h:5685
#define EM_REPLACESEL
Definition: winuser.h:1967
#define EM_SCROLLCARET
Definition: richedit.h:81
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ NOTEPAD_LoadSettingsFromRegistry()

void NOTEPAD_LoadSettingsFromRegistry ( void  )

Definition at line 114 of file settings.c.

Referenced by _tWinMain().

115 {
116  HKEY hKey = NULL;
117  HFONT hFont;
118  DWORD dwPointSize = 0;
119  INT base_length, dx, dy;
120 
123 
124  dx = (INT)(base_length * .95);
125  dy = dx * 3 / 4;
126  SetRect(&Globals.main_rect, 0, 0, dx, dy);
127 
129  {
130  QueryByte(hKey, _T("lfCharSet"), &Globals.lfFont.lfCharSet);
131  QueryByte(hKey, _T("lfClipPrecision"), &Globals.lfFont.lfClipPrecision);
132  QueryDword(hKey, _T("lfEscapement"), (DWORD*)&Globals.lfFont.lfEscapement);
133  QueryString(hKey, _T("lfFaceName"), Globals.lfFont.lfFaceName, ARRAY_SIZE(Globals.lfFont.lfFaceName));
134  QueryByte(hKey, _T("lfItalic"), &Globals.lfFont.lfItalic);
135  QueryDword(hKey, _T("lfOrientation"), (DWORD*)&Globals.lfFont.lfOrientation);
136  QueryByte(hKey, _T("lfOutPrecision"), &Globals.lfFont.lfOutPrecision);
137  QueryByte(hKey, _T("lfPitchAndFamily"), &Globals.lfFont.lfPitchAndFamily);
138  QueryByte(hKey, _T("lfQuality"), &Globals.lfFont.lfQuality);
139  QueryByte(hKey, _T("lfStrikeOut"), &Globals.lfFont.lfStrikeOut);
140  QueryByte(hKey, _T("lfUnderline"), &Globals.lfFont.lfUnderline);
141  QueryDword(hKey, _T("lfWeight"), (DWORD*)&Globals.lfFont.lfWeight);
142  QueryDword(hKey, _T("iPointSize"), &dwPointSize);
143  QueryBool(hKey, _T("fWrap"), &Globals.bWrapLongLines);
144  QueryBool(hKey, _T("fStatusBar"), &Globals.bShowStatusBar);
145  QueryString(hKey, _T("szHeader"), Globals.szHeader, ARRAY_SIZE(Globals.szHeader));
146  QueryString(hKey, _T("szTrailer"), Globals.szFooter, ARRAY_SIZE(Globals.szFooter));
147  QueryDword(hKey, _T("iMarginLeft"), (DWORD*)&Globals.lMargins.left);
148  QueryDword(hKey, _T("iMarginTop"), (DWORD*)&Globals.lMargins.top);
149  QueryDword(hKey, _T("iMarginRight"), (DWORD*)&Globals.lMargins.right);
150  QueryDword(hKey, _T("iMarginBottom"), (DWORD*)&Globals.lMargins.bottom);
151 
152  QueryDword(hKey, _T("iWindowPosX"), (DWORD*)&Globals.main_rect.left);
153  QueryDword(hKey, _T("iWindowPosY"), (DWORD*)&Globals.main_rect.top);
154  QueryDword(hKey, _T("iWindowPosDX"), (DWORD*)&dx);
155  QueryDword(hKey, _T("iWindowPosDY"), (DWORD*)&dy);
156 
157  Globals.main_rect.right = Globals.main_rect.left + dx;
158  Globals.main_rect.bottom = Globals.main_rect.top + dy;
159 
160  /* invert value because DIALOG_ViewStatusBar will be called to show it */
161  Globals.bShowStatusBar = !Globals.bShowStatusBar;
162 
163  if (dwPointSize != 0)
164  Globals.lfFont.lfHeight = HeightFromPointSize(dwPointSize);
165  else
166  Globals.lfFont.lfHeight = HeightFromPointSize(100);
167 
168  RegCloseKey(hKey);
169  }
170  else
171  {
172  /* If no settings are found in the registry, then use default values */
173  Globals.bShowStatusBar = FALSE;
174  Globals.bWrapLongLines = FALSE;
175  SetRect(&Globals.lMargins, 750, 1000, 750, 1000);
176 
177  /* FIXME: Globals.fSaveWindowPositions = FALSE; */
178  /* FIXME: Globals.fMLE_is_broken = FALSE; */
179 
181  ARRAY_SIZE(Globals.szHeader));
183  ARRAY_SIZE(Globals.szFooter));
184 
185  ZeroMemory(&Globals.lfFont, sizeof(Globals.lfFont));
186  Globals.lfFont.lfCharSet = ANSI_CHARSET;
187  Globals.lfFont.lfClipPrecision = CLIP_STROKE_PRECIS;
188  Globals.lfFont.lfEscapement = 0;
189  _tcscpy(Globals.lfFont.lfFaceName, _T("Lucida Console"));
190  Globals.lfFont.lfItalic = FALSE;
191  Globals.lfFont.lfOrientation = 0;
192  Globals.lfFont.lfOutPrecision = OUT_STRING_PRECIS;
193  Globals.lfFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
194  Globals.lfFont.lfQuality = PROOF_QUALITY;
195  Globals.lfFont.lfStrikeOut = FALSE;
196  Globals.lfFont.lfUnderline = FALSE;
197  Globals.lfFont.lfWeight = FW_NORMAL;
198  Globals.lfFont.lfHeight = HeightFromPointSize(100);
199  }
200 
201  hFont = CreateFontIndirect(&Globals.lfFont);
202  SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
203  if (hFont)
204  {
205  if (Globals.hFont)
206  DeleteObject(Globals.hFont);
207  Globals.hFont = hFont;
208  }
209 }
static BOOL QueryByte(HKEY hKey, LPCTSTR pszValueName, BYTE *pbResult)
Definition: settings.c:83
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PROOF_QUALITY
Definition: wingdi.h:436
int32_t INT
Definition: typedefs.h:56
HFONT hFont
Definition: main.c:53
#define STRING_PAGESETUP_HEADERVALUE
Definition: notepad_res.h:67
UINT_PTR WPARAM
Definition: windef.h:207
local int base_length[LENGTH_CODES]
Definition: trees.c:107
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SM_CXSCREEN
Definition: winuser.h:949
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG_PTR LPARAM
Definition: windef.h:208
#define FIXED_PITCH
Definition: wingdi.h:442
#define OUT_STRING_PRECIS
Definition: wingdi.h:414
#define INT(a)
Definition: assyntax.h:463
smooth NULL
Definition: ftsmooth.c:416
static BOOL QueryBool(HKEY hKey, LPCTSTR pszValueName, BOOL *pbResult)
Definition: settings.c:94
#define SM_CYSCREEN
Definition: winuser.h:950
#define _T(x)
Definition: vfdio.h:22
static BOOL QueryDword(HKEY hKey, LPCTSTR pszValueName, DWORD *pdwResult)
Definition: settings.c:78
static BOOL QueryString(HKEY hKey, LPCTSTR pszValueName, LPTSTR pszResult, DWORD dwResultSize)
Definition: settings.c:103
#define STRING_PAGESETUP_FOOTERVALUE
Definition: notepad_res.h:68
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPCTSTR s_szRegistryKey
Definition: settings.c:27
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
INT INT dy
Definition: msvc.h:65
#define ARRAY_SIZE(a)
Definition: main.h:24
#define FF_MODERN
Definition: wingdi.h:447
#define CreateFontIndirect
Definition: wingdi.h:4421
#define WM_SETFONT
Definition: winuser.h:1632
#define FW_NORMAL
Definition: wingdi.h:371
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define SendMessage
Definition: winuser.h:5709
static LONG HeightFromPointSize(DWORD dwPointSize)
Definition: settings.c:30
#define ANSI_CHARSET
Definition: wingdi.h:381
HINSTANCE hInstance
Definition: precomp.h:43
#define RegOpenKey
Definition: winreg.h:519
#define CLIP_STROKE_PRECIS
Definition: wingdi.h:426
#define LoadString
Definition: winuser.h:5685
INT dx
Definition: msvc.h:65

◆ NOTEPAD_SaveSettingsToRegistry()

void NOTEPAD_SaveSettingsToRegistry ( void  )

Definition at line 227 of file settings.c.

Referenced by NOTEPAD_WndProc().

228 {
229  HKEY hKey;
230  DWORD dwDisposition;
231 
232  GetWindowRect(Globals.hMainWnd, &Globals.main_rect);
233 
235  0, NULL, 0, KEY_SET_VALUE, NULL,
236  &hKey, &dwDisposition) == ERROR_SUCCESS)
237  {
238  SaveDword(hKey, _T("lfCharSet"), Globals.lfFont.lfCharSet);
239  SaveDword(hKey, _T("lfClipPrecision"), Globals.lfFont.lfClipPrecision);
240  SaveDword(hKey, _T("lfEscapement"), Globals.lfFont.lfEscapement);
241  SaveString(hKey, _T("lfFaceName"), Globals.lfFont.lfFaceName);
242  SaveDword(hKey, _T("lfItalic"), Globals.lfFont.lfItalic);
243  SaveDword(hKey, _T("lfOrientation"), Globals.lfFont.lfOrientation);
244  SaveDword(hKey, _T("lfOutPrecision"), Globals.lfFont.lfOutPrecision);
245  SaveDword(hKey, _T("lfPitchAndFamily"), Globals.lfFont.lfPitchAndFamily);
246  SaveDword(hKey, _T("lfQuality"), Globals.lfFont.lfQuality);
247  SaveDword(hKey, _T("lfStrikeOut"), Globals.lfFont.lfStrikeOut);
248  SaveDword(hKey, _T("lfUnderline"), Globals.lfFont.lfUnderline);
249  SaveDword(hKey, _T("lfWeight"), Globals.lfFont.lfWeight);
250  SaveDword(hKey, _T("iPointSize"), PointSizeFromHeight(Globals.lfFont.lfHeight));
251  SaveDword(hKey, _T("fWrap"), Globals.bWrapLongLines ? 1 : 0);
252  SaveDword(hKey, _T("fStatusBar"), Globals.bShowStatusBar ? 1 : 0);
253  SaveString(hKey, _T("szHeader"), Globals.szHeader);
254  SaveString(hKey, _T("szTrailer"), Globals.szFooter);
255  SaveDword(hKey, _T("iMarginLeft"), Globals.lMargins.left);
256  SaveDword(hKey, _T("iMarginTop"), Globals.lMargins.top);
257  SaveDword(hKey, _T("iMarginRight"), Globals.lMargins.right);
258  SaveDword(hKey, _T("iMarginBottom"), Globals.lMargins.bottom);
259  SaveDword(hKey, _T("iWindowPosX"), Globals.main_rect.left);
260  SaveDword(hKey, _T("iWindowPosY"), Globals.main_rect.top);
261  SaveDword(hKey, _T("iWindowPosDX"), Globals.main_rect.right - Globals.main_rect.left);
262  SaveDword(hKey, _T("iWindowPosDY"), Globals.main_rect.bottom - Globals.main_rect.top);
263 
264  RegCloseKey(hKey);
265  }
266 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL SaveDword(HKEY hKey, LPCTSTR pszValueNameT, DWORD dwValue)
Definition: settings.c:211
static LPCTSTR s_szRegistryKey
Definition: settings.c:27
static DWORD PointSizeFromHeight(LONG lHeight)
Definition: settings.c:42
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
static BOOL SaveString(HKEY hKey, LPCTSTR pszValueNameT, LPCTSTR pszValue)
Definition: settings.c:216
#define RegCreateKeyEx
Definition: winreg.h:501

◆ ReadText()

BOOL ReadText ( HANDLE  hFile,
LPWSTR ppszText,
DWORD pdwTextLen,
ENCODING pencFile,
int piEoln 
)

Definition at line 51 of file text.c.

Referenced by DoOpenFile().

52 {
53  DWORD dwSize;
54  LPBYTE pBytes = NULL;
56  LPWSTR pszAllocText = NULL;
57  DWORD dwPos, i;
58  DWORD dwCharCount;
60  BYTE b = 0;
61  ENCODING encFile = ENCODING_ANSI;
62  int iCodePage = 0;
63  WCHAR szCrlf[2] = {'\r', '\n'};
64  DWORD adwEolnCount[3] = {0, 0, 0};
65 
66  *ppszText = NULL;
67  *pdwTextLen = 0;
68 
69  dwSize = GetFileSize(hFile, NULL);
70  if (dwSize == INVALID_FILE_SIZE)
71  goto done;
72 
73  pBytes = HeapAlloc(GetProcessHeap(), 0, dwSize + 2);
74  if (!pBytes)
75  goto done;
76 
77  if (!ReadFile(hFile, pBytes, dwSize, &dwSize, NULL))
78  goto done;
79  dwPos = 0;
80 
81  /* Make sure that there is a NUL character at the end, in any encoding */
82  pBytes[dwSize + 0] = '\0';
83  pBytes[dwSize + 1] = '\0';
84 
85  /* Look for Byte Order Marks */
86  if ((dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE))
87  {
88  encFile = ENCODING_UNICODE;
89  dwPos += 2;
90  }
91  else if ((dwSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF))
92  {
93  encFile = ENCODING_UNICODE_BE;
94  dwPos += 2;
95  }
96  else if ((dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF))
97  {
98  encFile = ENCODING_UTF8;
99  dwPos += 3;
100  }
101 
102  switch(encFile)
103  {
104  case ENCODING_UNICODE_BE:
105  for (i = dwPos; i < dwSize-1; i += 2)
106  {
107  b = pBytes[i+0];
108  pBytes[i+0] = pBytes[i+1];
109  pBytes[i+1] = b;
110  }
111  /* fall through */
112 
113  case ENCODING_UNICODE:
114  pszText = (LPWSTR) &pBytes[dwPos];
115  dwCharCount = (dwSize - dwPos) / sizeof(WCHAR);
116  break;
117 
118  case ENCODING_ANSI:
119  case ENCODING_UTF8:
120  if (encFile == ENCODING_ANSI)
121  iCodePage = CP_ACP;
122  else if (encFile == ENCODING_UTF8)
123  iCodePage = CP_UTF8;
124 
125  if ((dwSize - dwPos) > 0)
126  {
127  dwCharCount = MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, NULL, 0);
128  if (dwCharCount == 0)
129  goto done;
130  }
131  else
132  {
133  /* special case for files with no characters (other than BOMs) */
134  dwCharCount = 0;
135  }
136 
137  pszAllocText = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (dwCharCount + 1) * sizeof(WCHAR));
138  if (!pszAllocText)
139  goto done;
140 
141  if ((dwSize - dwPos) > 0)
142  {
143  if (!MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, pszAllocText, dwCharCount))
144  goto done;
145  }
146 
147  pszAllocText[dwCharCount] = '\0';
148  pszText = pszAllocText;
149  break;
151  }
152 
153  dwPos = 0;
154  for (i = 0; i < dwCharCount; i++)
155  {
156  switch(pszText[i])
157  {
158  case '\r':
159  if ((i < dwCharCount-1) && (pszText[i+1] == '\n'))
160  {
161  i++;
162  adwEolnCount[EOLN_CRLF]++;
163  break;
164  }
165  /* fall through */
166 
167  case '\n':
168  if (!Append(ppszText, pdwTextLen, &pszText[dwPos], i - dwPos))
169  return FALSE;
170  if (!Append(ppszText, pdwTextLen, szCrlf, ARRAY_SIZE(szCrlf)))
171  return FALSE;
172  dwPos = i + 1;
173 
174  if (pszText[i] == '\r')
175  adwEolnCount[EOLN_CR]++;
176  else
177  adwEolnCount[EOLN_LF]++;
178  break;
179 
180  case '\0':
181  pszText[i] = ' ';
182  break;
183  }
184  }
185 
186  if (!*ppszText && (pszText == pszAllocText))
187  {
188  /* special case; don't need to reallocate */
189  *ppszText = pszAllocText;
190  *pdwTextLen = dwCharCount;
191  pszAllocText = NULL;
192  }
193  else
194  {
195  /* append last remaining text */
196  if (!Append(ppszText, pdwTextLen, &pszText[dwPos], i - dwPos + 1))
197  return FALSE;
198  }
199 
200  /* chose which eoln to use */
201  *piEoln = EOLN_CRLF;
202  if (adwEolnCount[EOLN_LF] > adwEolnCount[*piEoln])
203  *piEoln = EOLN_LF;
204  if (adwEolnCount[EOLN_CR] > adwEolnCount[*piEoln])
205  *piEoln = EOLN_CR;
206  *pencFile = encFile;
207 
208  bSuccess = TRUE;
209 
210 done:
211  if (pBytes)
212  HeapFree(GetProcessHeap(), 0, pBytes);
213  if (pszAllocText)
214  HeapFree(GetProcessHeap(), 0, pszAllocText);
215 
216  if (!bSuccess && *ppszText)
217  {
218  HeapFree(GetProcessHeap(), 0, *ppszText);
219  *ppszText = NULL;
220  *pdwTextLen = 0;
221  }
222  return bSuccess;
223 }
#define DEFAULT_UNREACHABLE
#define TRUE
Definition: types.h:120
#define ENCODING_UNICODE_BE
Definition: main.h:47
#define EOLN_CR
Definition: main.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
LPCWSTR pszText
Definition: msvc.h:103
static BOOL Append(LPWSTR *ppszText, DWORD *pdwTextLen, LPCWSTR pszAppendText, DWORD dwAppendLen)
Definition: text.c:25
#define INVALID_FILE_SIZE
Definition: winbase.h:529
static BOOLEAN bSuccess
Definition: drive.cpp:417
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char * LPBYTE
Definition: typedefs.h:52
#define CP_UTF8
Definition: nls.h:20
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EOLN_CRLF
Definition: main.h:53
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define EOLN_LF
Definition: main.h:54
unsigned char BYTE
Definition: ntddk_ex.h:96
#define ENCODING_UNICODE
Definition: main.h:46
ENCODING
Definition: more.c:155
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ SetFileName()

VOID SetFileName ( LPCTSTR  szFileName)

Definition at line 46 of file main.c.

47 {
49  Globals.szFileTitle[0] = 0;
51 }
NOTEPAD_GLOBALS Globals
Definition: main.c:29
TCHAR szFileName[MAX_PATH]
Definition: main.h:73
#define GetFileTitle
Definition: commdlg.h:664
#define StringCchCopy
Definition: strsafe.h:139
#define ARRAY_SIZE(a)
Definition: main.h:24
TCHAR szFileTitle[MAX_PATH]
Definition: main.h:74

◆ WriteText()

BOOL WriteText ( HANDLE  hFile,
LPCWSTR  pszText,
DWORD  dwTextLen,
ENCODING  encFile,
int  iEoln 
)

Definition at line 319 of file text.c.

Referenced by DoSaveFile().

320 {
321  WCHAR wcBom;
322  LPCWSTR pszLF = L"\n";
323  DWORD dwPos, dwNext;
324 
325  /* Write the proper byte order marks if not ANSI */
326  if (encFile != ENCODING_ANSI)
327  {
328  wcBom = 0xFEFF;
329  if (!WriteEncodedText(hFile, &wcBom, 1, encFile))
330  return FALSE;
331  }
332 
333  dwPos = 0;
334 
335  /* pszText eoln are always \r\n */
336 
337  do
338  {
339  /* Find the next eoln */
340  dwNext = dwPos;
341  while(dwNext < dwTextLen)
342  {
343  if (pszText[dwNext] == '\r' && pszText[dwNext + 1] == '\n')
344  break;
345  dwNext++;
346  }
347 
348  if (dwNext != dwTextLen)
349  {
350  switch (iEoln)
351  {
352  case EOLN_LF:
353  /* Write text (without eoln) */
354  if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos, encFile))
355  return FALSE;
356  /* Write eoln */
357  if (!WriteEncodedText(hFile, pszLF, 1, encFile))
358  return FALSE;
359  break;
360  case EOLN_CR:
361  /* Write text (including \r as eoln) */
362  if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos + 1, encFile))
363  return FALSE;
364  break;
365  case EOLN_CRLF:
366  /* Write text (including \r\n as eoln) */
367  if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos + 2, encFile))
368  return FALSE;
369  break;
370  default:
371  return FALSE;
372  }
373  }
374  else
375  {
376  /* Write text (without eoln, since this is the end of the file) */
377  if (!WriteEncodedText(hFile, &pszText[dwPos], dwNext - dwPos, encFile))
378  return FALSE;
379  }
380 
381  /* Skip \r\n */
382  dwPos = dwNext + 2;
383  }
384  while (dwPos < dwTextLen);
385 
386  return TRUE;
387 }
#define TRUE
Definition: types.h:120
#define EOLN_CR
Definition: main.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPCWSTR pszText
Definition: msvc.h:103
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile)
Definition: text.c:225
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EOLN_CRLF
Definition: main.h:53
#define EOLN_LF
Definition: main.h:54
static const WCHAR L[]
Definition: oid.c:1087

Variable Documentation

◆ Globals

NOTEPAD_GLOBALS Globals

Definition at line 13 of file clipbrd.c.