diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7867892e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,53 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = crlf +insert_final_newline = true +trim_trailing_whitespace = false + +# Preserve legacy source encodings; only these known formats default to UTF-8. +[*.{md,ps1,sh,yml,yaml}] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true + +[*.ps1] +indent_size = 4 + +[*.{vcxproj,filters,props}] +charset = utf-8 + +[{.editorconfig,.gitattributes,.gitignore}] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true + +[.githooks/*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true + +[{src/Notepad2.rc,Notepad2.ini,distrib/Notepad2.ini}] +charset = utf-16le + +# Do not rewrite vendor formatting, encodings or line endings. +[scintilla/**] +charset = unset +indent_style = tab +indent_size = tab +tab_width = 4 +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset + +[scintilla/*.{vcxproj,filters}] +indent_style = space +indent_size = 2 +end_of_line = crlf + +[scintilla/README.notepad2-mod.txt] +charset = utf-8 +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 4df4f35f..cf59f17e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,43 @@ -*.sh eol=lf +# Git stores declared text as LF; checkout endings ignore global defaults. +* text=auto +*.c text eol=crlf +*.cpp text eol=crlf +*.h text eol=crlf +*.bat text eol=crlf +*.sln text eol=crlf +*.vcxproj text eol=crlf +*.filters text eol=crlf +*.props text eol=crlf +*.md text eol=lf +*.ps1 text eol=lf +*.sh text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +.editorconfig text eol=lf +.gitattributes text eol=lf +.gitignore text eol=lf +.githooks/* text eol=lf + +# Preserve legacy encodings and UTF-16 BOMs; never normalize these as UTF-8. +*.rc -text +*.ini -text +*.txt -text +*.ver -text +*.iss -text +*.js -text +*.conf -text +*.ico binary +*.bmp binary +*.cur binary +*.png binary +*.exe binary +*.dll binary +*.lib binary +*.pdb binary +*.zip binary + +# Vendor bytes, including line endings, stay upstream-compatible. +/scintilla/** -text !eol +# These build files belong to the fork, rather than the upstream source archive. +/scintilla/*.vcxproj text eol=crlf +/scintilla/*.filters text eol=crlf diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..6bd6e1ef --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,9 @@ +#!/bin/sh +if command -v pwsh >/dev/null 2>&1; then + exec pwsh -NoProfile -File build/check-staged.ps1 +elif command -v powershell.exe >/dev/null 2>&1; then + exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File build/check-staged.ps1 +else + echo "PowerShell is required to run build/check-staged.ps1." >&2 + exit 1 +fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..bd4c6bca --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: Build and release +on: + push: + branches: ['**'] + tags: ['v*'] + pull_request: +permissions: + contents: read +concurrency: + group: build-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }} +defaults: + run: + shell: pwsh +jobs: + build: + name: ${{ matrix.configuration }} ${{ matrix.architecture }} + runs-on: windows-2022 + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + configuration: [Release, Debug] + architecture: [x86, x64] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Build + run: | + New-Item -ItemType Directory -Path bin -Force | Out-Null + ./build/build.ps1 -Architecture '${{ matrix.architecture }}' -Configuration '${{ matrix.configuration }}' *> bin/build.log + if ($LASTEXITCODE -ne 0) { Get-Content bin/build.log -Tail 80; exit 1 } + - name: Test editor themes + run: | + try { + ./build/test-themes.ps1 -Executable './bin/VS2022/${{ matrix.configuration }}_${{ matrix.architecture }}/Notepad2.exe' *> bin/tests.log + } catch { + Get-Content bin/tests.log -Tail 80 + throw + } + Get-Content bin/tests.log + - name: Package portable release + if: matrix.configuration == 'Release' + env: + RELEASE_TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }} + run: ./build/package.ps1 -Architecture '${{ matrix.architecture }}' -Tag $env:RELEASE_TAG + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: success() + with: + name: executable-${{ matrix.configuration }}-${{ matrix.architecture }} + path: bin/VS2022/${{ matrix.configuration }}_${{ matrix.architecture }}/Notepad2.exe + if-no-files-found: error + retention-days: 14 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: success() && matrix.configuration == 'Release' + with: + name: release-package-${{ matrix.architecture }} + path: bin/packages/*.zip + if-no-files-found: error + retention-days: 14 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: always() + with: + name: logs-${{ matrix.configuration }}-${{ matrix.architecture }} + path: bin/*.log + retention-days: 14 + release: + name: Publish release + needs: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'itlezy/notepad2-mod' + runs-on: windows-2022 + timeout-minutes: 10 + permissions: + contents: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: release-package-* + merge-multiple: true + path: bin/packages + - name: Verify and publish + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RELEASE_TAG: ${{ github.ref_name }} + run: ./build/publish-release.ps1 -Tag $env:RELEASE_TAG -PackageDirectory bin/packages diff --git a/.gitignore b/.gitignore index 0d2c59ba..289c2296 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,11 @@ /res/Notepad2.exe.manifest /signinfo.txt /src/VersionRev.h +/.vs/ +/.vscode/ +/.idea/ +*.log +*.pfx +*.p12 +/.env +/.env.* diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..f49a12ea --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,34 @@ +# Repository working rules + +- Product direction: stay as close to Notepad2-mod as practical. Preserve its + fast startup, responsive editing, small footprint, native UI, and simple deployment. + Evolve through minimal, focused patches; do not rebase onto Notepad3/Notepad4 + or adopt their feature stacks or theme frameworks. +- Prefer the existing native style/configuration model. Each dependency bump, + abstraction, background task, or feature expansion needs a concrete benefit + that justifies its maintenance and performance cost. Latest-version parity + is not a goal. Keep Scintilla at 3.7.6 unless a specific need is established. +- For runtime changes, assess startup, editing responsiveness, memory, and idle + work where affected. Compare against the current fork; never assume a patch + is faster or claim a regression without measurements. +- Theme scope is the editor only: text, syntax colors, margins, caret, selections, + folding and highlights. Application chrome (menus, dialogs, toolbar, status bar, + title bar and scrollbars) is out of scope, not a planned follow-up. +- Finish each logical change with a granular commit after relevant validation. + Do not ask again whether to commit completed, authorized work. Stage explicit + paths/hunks and inspect the staged diff. Keep dependency updates, build changes, + policy changes, formatting, and features in separate commits. +- Use a short-lived branch. Do not rewrite published commits or force-push shared + branches. Publishing, merging, or changing hosting settings requires authorization. +- Run `build/check-staged.ps1` before each commit. Use the build instructions in + Readme.md for code changes; report checks that were not run. Do not add tests + that merely repeat implementation details or repeat expensive checks without cause. +- Follow .editorconfig and .gitattributes. Preserve legacy encodings and UTF-16 BOMs. + Do not bulk-format source or normalize vendor files. Isolate any intended + first-party line-ending normalization from semantic changes. +- Keep Scintilla changes minimal. Preserve the customizations documented in + scintilla/README.notepad2-mod.txt and record the upstream version/source. +- Never stage generated output, private configuration, credentials, or signing + material. Keep origin pointing to itlezy/notepad2-mod and upstream to + XhmikosR/notepad2-mod. Change Git settings locally, never globally. +- Follow CONTRIBUTING.md for validation, local Git setup, and the Git/editor policy. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8401a6da..15818484 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,17 @@ The original upstream is archived; this fork owns its ongoing maintenance. ## Keep changes focused +Preserve the Notepad2-mod experience: fast startup, responsive editing, a small +footprint, native controls, and simple deployment. Prefer a small patch to the +existing code over a new framework or subsystem. Notepad3/Notepad4 are not migration +targets or feature-stack templates for this fork. Dependency updates require a +specific benefit rather than version parity. + +For runtime changes, describe the expected maintenance and performance impact. +Measure startup, memory, editing latency, or idle work when the change affects +them, using the current fork as the baseline. Report measurements and limitations; +do not assume small code changes are automatically cheap at runtime. + * Use a short-lived branch for each fix or feature and open a pull request against `master`. * Prefer small, reviewable changes. Discuss broad refactors, dependency upgrades, and compatibility changes before combining them with feature work. @@ -15,15 +26,15 @@ The original upstream is archived; this fork owns its ongoing maintenance. ## Validate changes -Follow the inherited build instructions in [Readme.md](Readme.md). For application +Follow the build instructions in [Readme.md](Readme.md). For application changes, build Release for Win32 and x64 and smoke-test the affected behavior. Include reproduction steps, validation results, and any unavailable checks in the pull request. Add targeted tests when they can meaningfully verify the behavior. Documentation-only changes require reviewing links and `git diff --check`, not a full application build. -The initial setup has not verified the legacy build. Do not describe build or -runtime checks as passing unless you actually ran them. +Use the current VS 2022 / v143 build rather than the inherited XP toolset. Do not +describe build or runtime checks as passing unless you actually ran them. ## Remotes and history @@ -41,3 +52,32 @@ with attribution and license checks. See [ROADMAP.md](ROADMAP.md) for planned work; listing a feature there does not mean it is implemented or validated. + +## Git and editor policy + +Run `./build/setup-git.ps1` once per clone to install repository-local settings +and the tracked pre-commit hook. This does not change global settings or author +identity. Check `git config --local user.name` and `git config --local user.email` +before committing; configure your own identity locally if needed. + +Commits must each cover one logical change, with matching documentation and +relevant validation. Separate dependency upgrades, build work, policy, formatting, +and features. Stage explicit paths or hunks and inspect `git diff --cached`. +Run `./build/check-staged.ps1` before each commit; the hook also runs it. This +checks staged whitespace and rejects known generated/private file types, including +force-added ignored files. It does not replace review or detect every secret. +Commit completed work without accumulating unrelated changes. Use short subjects +such as `fix(scintilla): ...`, `build: ...`, or `chore: ...`. + +Pulls are fast-forward-only, pushes use `simple`, and fetch prunes stale remote +tracking branches. Never rewrite published history or force-push shared branches. +Local hooks are a convenience, not server-side enforcement; do not bypass them +to hide failures. Review merges and publishing separately. + +Use an editor with EditorConfig support. Application source uses two-space +indentation; vendored Scintilla retains its tab conventions. Git normalizes declared +first-party text to LF in the index, with CRLF checkouts for C/C++ and Windows +build files and LF for docs/scripts. Legacy encodings, UTF-16 resources/INI files, +and vendor bytes are preserved. Do not run whole-file formatting or blanket +UTF-8 conversion. Put any deliberate first-party line-ending normalization in +its own commit; never mix it with behavior changes. diff --git a/ROADMAP.md b/ROADMAP.md index 8997daf3..ad4f6fc0 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,41 +4,76 @@ This fork preserves the original Notepad2-mod editor while adding small, practic improvements. The original upstream is archived and was last updated in July 2018; ongoing maintenance is the responsibility of this fork. +## Product direction + +Stay close to Notepad2-mod and evolve through minimal, focused patches. Preserve +fast startup, responsive editing, a small footprint, native Windows behavior, +and simple deployment. Notepad3/Notepad4 are not migration targets or sources for +adopting whole feature stacks or theme frameworks. Backlog items are candidates, +not commitments to expand the editor. New dependencies and larger changes need +a concrete benefit and an assessment of maintenance and performance costs. + ## Initial setup -Establish `itlezy/notepad2-mod`, retain upstream history and attribution, document -the inherited build, and provide contribution guidance. This milestone changes -documentation only; application code, configuration formats, branding, and runtime -behavior remain inherited from upstream. It does not verify an application build. +The initial documentation-only setup established `itlezy/notepad2-mod`, retained +upstream history and attribution, and added contribution guidance. Build/tooling +and the Scintilla 3.7.6 update followed in separate commits. ## Build modernization and automation -Establish a reproducible baseline, then migrate from the inherited Visual Studio -2017 / `v141_xp` setup to supported build tooling. Decide and document the Windows -support baseline as part of that migration rather than silently dropping legacy -support. Add GitHub Actions for Win32 and x64 builds, followed by versioned, -downloadable releases after build and runtime validation. +Local build modernization is complete: both projects use Visual Studio 2022 / +`v143`, with a PowerShell build entrypoint and Windows 10/11 as the target baseline. +Release and Debug builds for x86 and x64 have been verified locally. XP toolset +support is retired. GitHub Actions now builds/tests all four configurations and +packages portable x86/x64 ZIPs with source metadata and checksums. Version tags +publish releases after required checks pass; RC tags publish prereleases. +Legacy installer/signing scripts remain outside the portable release workflow. ## Easy light/dark switching -Provide an accessible light/dark switch and persist the user's choice. Cover both -syntax/editor colors and application surfaces, including menus, dialogs, toolbar, -and status bar where supported by the chosen Windows baseline. Keep selection, -caret, search highlights, and error states readable in both modes. Validate -switching, reopening the application, and editing representative file types. +Track implementation in [#6: native Light/Dark editor themes](https://github.com/itlezy/notepad2-mod/issues/6). +Original/Dark palettes are implemented on Scintilla 3.7.6 using the existing native +style model. Original retains legacy settings; Dark has separate color storage +with shared typography. All 38 schemes, repeated switching, restart persistence, +disabled settings saving, and customization Preview/Cancel/Reset are covered by +native integration checks in Release/Debug x86/x64. Visual contrast review remains +useful across real documents; the checks do not establish large-file performance. + +Theme state is resolved when loading/switching, outside the per-character editing +path. No dependencies, background work, external theme loading, or vendor changes +were added. A seven-run x64 small-file comparison during implementation measured +median startup at 71.8 ms baseline / 73.1 ms Original / 71.7 ms Dark, with about +236 KiB additional private memory. Numeric edit-loop times were 30.2 / 31.2 / 29.6 +ms per 100 delete/undo pairs; sampled 200 ms idle CPU deltas were zero. These are +indicative local measurements, not a guarantee of equivalent performance on all files. + +Only the editor is in scope: text and syntax colors, margins, caret, selections, +folding, bookmarks, and occurrence highlights. Application chrome (menus, dialogs, +toolbar, status bar, title bar, and scrollbars) is out of scope, not a planned +follow-up. Completing editor themes completes this appearance milestone. + +The five fork candidates below did not show a dark-mode implementation in the +checked default-branch application paths. This is source inspection, not an +exhaustive audit of historical branches. Notepad3/Notepad4 implementations are +excluded from the proposed implementation direction; build on this editor's +existing scheme system instead. -This requires application UI work as well as a syntax palette; changing only the -editor background does not complete this milestone. +The older [Solarized Notepad2 INI scheme](https://github.com/achbed/notepad2-colors-solarized) +is a palette reference only: its documented coverage is Default Text, Web Source +Code, CSS, and JavaScript. It uses the second-default toggle and does not theme +the whole application. Notepad++ XML import is out of scope unless a later review +demonstrates a concrete benefit. -## Notepad++ XML theme imports +## Fork review backlog -Add explicit import of Notepad++ XML theme files. Start by examining the existing -style import/export code in `src/Styles.c` and its declarations in `src/Styles.h`. -Map global editor styles and supported lexer styles into Notepad2-mod's style -model; report unsupported mappings so users understand partial imports. +GitHub issues hold the review notes, source commit links, acceptance criteria, +and eventual decisions. These are candidates for selective changes, not approved +imports; none was built or runtime-tested during the initial review. -Validate with representative light and dark themes, multiple supported languages, -unknown lexer/style entries, and malformed XML. Preserve usable existing styles -when an import cannot be applied. Define the mapping and persistence details -before implementation; Notepad++ theme compatibility is not available in this -initial setup. +| Issue | Candidate | Review focus | +| --- | --- | --- | +| [#1](https://github.com/itlezy/notepad2-mod/issues/1) | antiufo | Recovery/autosave; preserve upstream fixes and recovery buffer-fix chain. | +| [#2](https://github.com/itlezy/notepad2-mod/issues/2) | johnwait | Selective editor fixes; exclude wholesale regex/Scintilla migration. | +| [#3](https://github.com/itlezy/notepad2-mod/issues/3) | mercury233 | Small find/replace, reload, and context-menu improvements. | +| [#4](https://github.com/itlezy/notepad2-mod/issues/4) | tnotstar | Initial CMake build; Debug support was explicitly unfinished. | +| [#5](https://github.com/itlezy/notepad2-mod/issues/5) | waskosky | Aggressive reload/append merging; require data-preservation review. | diff --git a/Readme.md b/Readme.md index 57b5d696..584993fd 100644 --- a/Readme.md +++ b/Readme.md @@ -6,14 +6,37 @@ This fork is maintained by [itlezy](https://github.com/itlezy) at [itlezy/notepad2-mod](https://github.com/itlezy/notepad2-mod), with a focus on small, practical improvements to the original editor. +The product direction is to stay close to Notepad2-mod: fast startup, responsive +editing, a small footprint, and simple native Windows behavior. Changes should be +minimal, focused patches with a clear benefit. This fork will not move to +Notepad3/Notepad4 or adopt their feature stacks; matching newer editors or +dependency versions is not a goal. + The upstream repository, [XhmikosR/notepad2-mod](https://github.com/XhmikosR/notepad2-mod), is archived and was last updated in July 2018. Ongoing maintenance for this fork happens here; upstream history, licensing, and contributor credits are preserved. -The initial fork setup changes documentation only. Easy light/dark switching and -Notepad++ XML theme imports are planned features, not implemented additions. +This fork builds with Visual Studio 2022 and includes native Original/Dark editor +palettes. Choose **View > Editor Theme > Original / Dark**. Original preserves +existing custom colors; Dark supplies syntax and editor colors across all 38 schemes. +Theme work covers the editor only; application chrome is out of scope. See the [roadmap](ROADMAP.md) and [contributor guide](CONTRIBUTING.md). +The bundled editor engine is Scintilla 3.7.6 (LongTerm3), with the original +Notepad2-mod customizations preserved. See its +[vendor notes](scintilla/README.notepad2-mod.txt) for the source and local changes. + +Customize the active palette using **View > Customize Schemes**. Colors are kept +separately for Original and Dark; fonts and other non-color preferences remain +shared. Preview, Cancel, and Reset work with the active palette. The existing +second-default scheme toggle remains independent. Theme selection follows the +existing Save Settings preference; explicit Save Settings also saves it. + +There are no external theme files or automatic system-theme synchronization. +Scintilla's native autocomplete list and the existing bookmark pixmap retain +their original appearance. Scheme import/export remains an explicit full-scheme +operation, including file associations; it is not used to switch themes. + ## Changes compared to the official Notepad2: * Code folding @@ -30,8 +53,9 @@ See the [roadmap](ROADMAP.md) and [contributor guide](CONTRIBUTING.md). * XP (SP3, SP2 might or might not work), Vista, 7, 8, 8.1 and 10 both 32-bit and 64-bit -This is the inherited upstream support list, not a newly verified compatibility -matrix for this fork. +This is the historical upstream support list. Current fork builds target Windows +10/11 using the modern MSVC toolset; XP compatibility is no longer a build goal. +Compatibility with other Windows versions has not been verified. ## [Screenshots](https://xhmikosr.github.io/notepad2-mod/screenshots) @@ -62,18 +86,81 @@ matrix for this fork. ## Building -The inherited build uses Visual Studio 2017 with C++ desktop tools, ATL/MFC, and -the `v141_xp` platform toolset (including its required SDK components). Open -`build/Notepad2.sln`, or run this command from the repository root in Command Prompt: +Install Visual Studio 2022 (or its Build Tools) with Desktop development with C++, +MSVC v143 x86/x64 tools, C++ ATL/MFC, and a Windows 10/11 SDK. Install Git for +Windows as well; revision generation uses its Bash and Git executables. + +From the repository root in PowerShell: + +```powershell +.\build\build.ps1 +``` + +The default builds Release for both x86 and x64. To build and run only x64: -```bat -build\build_vs2017.bat Build All Release +```powershell +.\build\build.ps1 -Architecture x64 +.\bin\VS2022\Release_x64\Notepad2.exe ``` -This requests Release builds for both Win32 and x64. The wrapper uses `vswhere` -to locate Visual Studio; the selected installation must contain the required -legacy toolset. Installing a newer Visual Studio alone does not retarget the projects. +Use `-Configuration Debug` for Debug builds and `-Target Rebuild` or `-Target Clean` +as needed. Outputs are in `bin/VS2022/Release_x86`, `Release_x64`, `Debug_x86`, +and `Debug_x64`. No Developer PowerShell session is required: the script finds +MSBuild using `vswhere`. Alternatively, open `build/Notepad2.sln` in VS 2022 and +select Release/Debug and Win32/x64. The projects select the latest installed +Windows 10/11 SDK via `WindowsTargetPlatformVersion=10.0`. + +Release and Debug builds for x86 and x64 have been verified locally with Visual +Studio 2022 17.14, MSVC 14.44, and Windows SDK 10.0.26100.0. Legacy packaging and +signing scripts are separate from this build command and have not been validated. +GitHub Actions builds and tests Release/Debug x86/x64 on Windows Server 2022. +Successful runs retain executable artifacts and portable Release ZIPs for 14 days; +failure logs are uploaded as well. Download published portable builds from +[Releases](https://github.com/itlezy/notepad2-mod/releases). Initial testing builds +are marked as prereleases. Binaries are unsigned. + +Portable archives contain the executable, a default INI, usage documentation, +licenses, and source/version metadata. Extract into a writable directory. When +upgrading an existing installation, preserve its INI and redirected user settings. +Release setup does not change system-wide Notepad replacement or file associations. + +## Publishing a release + +Merge validated changes into `master` with granular history preserved, wait for +master CI to pass, and build that exact clean commit to obtain its file version: + +```powershell +.\build\build.ps1 +$releaseVersion = (Get-Item .\bin\VS2022\Release_x64\Notepad2.exe).VersionInfo.FileVersion.Trim() +git tag "v$releaseVersion-rc.1" +git push origin "v$releaseVersion-rc.1" +``` + +Stable tags omit `-rc.N`. Tags use the existing four-part file version; full Git +history determines its final revision component. The workflow checks both binary +versions against the tag, tests all four configurations, then publishes x86/x64 +ZIPs and SHA256SUMS.txt. A prerelease does not replace the latest stable release. + +Only the publishing job has repository write permission, using GITHUB_TOKEN. +There are no signing secrets or installer dependencies. Published release assets +must not be overwritten: use a new tag/commit for corrections. If publishing fails +after creating a draft, inspect its logs and rerun the failed job on the same tag; +draft assets are replaceable until publication. Never move an existing release tag. + +The packaging command is `./build/package.ps1 -Architecture x64` (or `x86`). It +uses Release output and writes into ignored `bin/packages`; supply a fresh +`-OutputDirectory` when repackaging an already-created version locally. + +To run the native theme integration checks against a built executable: + +```powershell +.\build\test-themes.ps1 +.\build\test-themes.ps1 -Executable .\bin\VS2022\Release_x86\Notepad2.exe +``` -These instructions describe the checked-in build configuration. No application -build or runtime validation was performed for the initial documentation setup. -Build modernization, GitHub Actions, and fork releases are future milestones. +The checks launch isolated instances with temporary settings, exercise all 38 +schemes and customization Preview/Cancel/Reset, and verify palette/font separation, +switching, restart persistence, invalid defaults, and disabled settings saving. +Use `-BaselineExecutable ` for a seven-run small-file startup/private-memory/ +numeric edit/idle comparison. These checks do not replace visual contrast review +or establish large-file performance. diff --git a/appveyor.yml b/appveyor.yml index ad674844..66cc2a5b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,11 @@ -image: Visual Studio 2017 +image: Visual Studio 2022 version: "{build}" #clone_depth: 10 build_script: - - CALL "build\build_vs2017.bat" Build All Release + - ps: .\build\build.ps1 test: off diff --git a/build/Notepad2.sln b/build/Notepad2.sln index 82ddbceb..abb0f120 100644 --- a/build/Notepad2.sln +++ b/build/Notepad2.sln @@ -1,37 +1,37 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Notepad2", "..\src\Notepad2.vcxproj", "{BAAD32AB-CD47-12FD-873C-0BBC204B7641}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scintilla", "..\scintilla\Scintilla.vcxproj", "{5877B917-512B-49F5-B514-1B4159E7A9CA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|Win32.ActiveCfg = Debug|Win32 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|Win32.Build.0 = Debug|Win32 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|x64.ActiveCfg = Debug|x64 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|x64.Build.0 = Debug|x64 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|Win32.ActiveCfg = Release|Win32 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|Win32.Build.0 = Release|Win32 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|x64.ActiveCfg = Release|x64 - {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|x64.Build.0 = Release|x64 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|Win32.ActiveCfg = Debug|Win32 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|Win32.Build.0 = Debug|Win32 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|x64.ActiveCfg = Debug|x64 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|x64.Build.0 = Debug|x64 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|Win32.ActiveCfg = Release|Win32 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|Win32.Build.0 = Release|Win32 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|x64.ActiveCfg = Release|x64 - {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Notepad2", "..\src\Notepad2.vcxproj", "{BAAD32AB-CD47-12FD-873C-0BBC204B7641}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scintilla", "..\scintilla\Scintilla.vcxproj", "{5877B917-512B-49F5-B514-1B4159E7A9CA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|Win32.ActiveCfg = Debug|Win32 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|Win32.Build.0 = Debug|Win32 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|x64.ActiveCfg = Debug|x64 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Debug|x64.Build.0 = Debug|x64 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|Win32.ActiveCfg = Release|Win32 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|Win32.Build.0 = Release|Win32 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|x64.ActiveCfg = Release|x64 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641}.Release|x64.Build.0 = Release|x64 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|Win32.ActiveCfg = Debug|Win32 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|Win32.Build.0 = Debug|Win32 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|x64.ActiveCfg = Debug|x64 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Debug|x64.Build.0 = Debug|x64 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|Win32.ActiveCfg = Release|Win32 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|Win32.Build.0 = Release|Win32 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|x64.ActiveCfg = Release|x64 + {5877B917-512B-49F5-B514-1B4159E7A9CA}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/build.ps1 b/build/build.ps1 new file mode 100644 index 00000000..f0a2e534 --- /dev/null +++ b/build/build.ps1 @@ -0,0 +1,25 @@ +[CmdletBinding()] +param( + [ValidateSet('Build', 'Rebuild', 'Clean')] + [string]$Target = 'Build', + [ValidateSet('x86', 'x64', 'All')] + [string]$Architecture = 'All', + [ValidateSet('Release', 'Debug')] + [string]$Configuration = 'Release' +) + +$ErrorActionPreference = 'Stop' +$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +if (-not (Test-Path -LiteralPath $vswhere)) { + throw 'Install Visual Studio 2022 or Build Tools with the Desktop development with C++ workload and ATL/MFC.' +} +$installation = & $vswhere -latest -version '[17.0,18.0)' -products '*' -requires Microsoft.Component.MSBuild Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.VC.ATLMFC -property installationPath +if (-not $installation) { + throw 'Visual Studio 2022 with MSBuild, x86/x64 C++ tools, and ATL/MFC was not found.' +} +$msbuild = Join-Path $installation 'MSBuild\Current\Bin\MSBuild.exe' +$platforms = if ($Architecture -eq 'All') { @('Win32', 'x64') } elseif ($Architecture -eq 'x86') { @('Win32') } else { @('x64') } +foreach ($platform in $platforms) { + & $msbuild (Join-Path $PSScriptRoot 'Notepad2.sln') /nologo "/t:$Target" "/p:Configuration=$Configuration" "/p:Platform=$platform" /m /v:minimal + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +} diff --git a/build/check-staged.ps1 b/build/check-staged.ps1 new file mode 100644 index 00000000..2b9f30e2 --- /dev/null +++ b/build/check-staged.ps1 @@ -0,0 +1,32 @@ +[CmdletBinding()] +param() + +$ErrorActionPreference = 'Stop' +Push-Location (Join-Path $PSScriptRoot '..') +try { + & git diff --cached --ignore-cr-at-eol --check + if ($LASTEXITCODE -ne 0) { throw 'Staged whitespace errors must be fixed.' } + + # NUL-delimited paths handle spaces and Unicode without Git quoting. + $start = New-Object Diagnostics.ProcessStartInfo + $start.FileName = 'git' + $start.WorkingDirectory = (Get-Location).ProviderPath + $start.Arguments = 'diff --cached --name-only --diff-filter=ACMR -z' + $start.UseShellExecute = $false + $start.RedirectStandardOutput = $true + $start.StandardOutputEncoding = [Text.Encoding]::UTF8 + $process = [Diagnostics.Process]::Start($start) + $paths = $process.StandardOutput.ReadToEnd().Split([char]0) + $process.WaitForExit() + if ($process.ExitCode -ne 0) { throw 'Could not inspect the Git index.' } + $process.Dispose() + foreach ($path in $paths) { + if (-not $path) { continue } + if ($path -match '(?i)(^|/)(bin|obj|\.vs|\.cache|__pycache__)/|(^|/)(build\.user\.bat|signinfo\.txt|VersionRev\.h|Notepad2\.exe\.manifest)$|\.(exe|dll|lib|obj|pdb|ilk|pch|aps|suo|user|sdf|opensdf|pyc|pfx|p12|key|pem|log)$|(^|/)\.env($|\.)') { + throw "Generated or private file is staged: $path" + } + } + Write-Output 'Staged checks passed.' +} finally { + Pop-Location +} diff --git a/build/make_installer.bat b/build/make_installer.bat index 5569381f..166c847f 100644 --- a/build/make_installer.bat +++ b/build/make_installer.bat @@ -1,152 +1,152 @@ -@ECHO OFF -rem ****************************************************************************** -rem * -rem * Notepad2-mod -rem * -rem * make_installer.bat -rem * Batch file for building the installer for Notepad2-mod -rem * -rem * See License.txt for details about distribution and modification. -rem * -rem * (c) XhmikosR 2010-2017 -rem * https://github.com/XhmikosR/notepad2-mod -rem * -rem ****************************************************************************** - -SETLOCAL ENABLEEXTENSIONS -CD /D %~dp0 - -rem Check for the help switches -IF /I "%~1" == "help" GOTO SHOWHELP -IF /I "%~1" == "/help" GOTO SHOWHELP -IF /I "%~1" == "-help" GOTO SHOWHELP -IF /I "%~1" == "--help" GOTO SHOWHELP -IF /I "%~1" == "/?" GOTO SHOWHELP - - -rem You can set here the Inno Setup path if for example you have Inno Setup Unicode -rem installed and you want to use the ANSI Inno Setup which is in another location -IF NOT DEFINED InnoSetupPath SET "InnoSetupPath=H:\progs\thirdparty\isetup" - -rem Check the building environment -CALL :SubDetectInnoSetup - - -rem Check for the first switch -IF "%~1" == "" ( - SET "COMPILER=VS2017" -) ELSE ( - IF /I "%~1" == "VS2017" SET "COMPILER=VS2017" & GOTO START - IF /I "%~1" == "/VS2017" SET "COMPILER=VS2017" & GOTO START - IF /I "%~1" == "-VS2017" SET "COMPILER=VS2017" & GOTO START - IF /I "%~1" == "--VS2017" SET "COMPILER=VS2017" & GOTO START - - ECHO. - ECHO Unsupported commandline switch! - ECHO Run "%~nx0 help" for details about the commandline switches. - CALL :SUBMSG "ERROR" "Compilation failed!" -) - - -:START -IF EXIST "%~dp0..\signinfo.txt" SET "SIGN=True" - -SET INPUTDIRx86=bin\%COMPILER%\Release_x86 -SET INPUTDIRx64=bin\%COMPILER%\Release_x64 -IF /I NOT "%COMPILER%" == "VS2017" SET SUFFIX=_%COMPILER% -SET "TEMP_NAME=temp_zip%SUFFIX%" - -IF NOT EXIST "..\%INPUTDIRx86%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x86 first!" -IF NOT EXIST "..\%INPUTDIRx64%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x64 first!" - -IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx86% -IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx64% - -CALL :SubInstaller %COMPILER% - - -:END -TITLE Finished! -ECHO. -ENDLOCAL -EXIT /B - - -:SubInstaller -TITLE Building %1 installer... -CALL :SUBMSG "INFO" "Building %1 installer using %InnoSetupPath%\ISCC.exe..." - -"%InnoSetupPath%\ISCC.exe" /SMySignTool="cmd /c "%~dp0sign.bat" $f" /Q /O"packages" "..\distrib\notepad2_setup.iss" /D%1 -IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" - -EXIT /B - - -:SubDetectInnoSetup -rem Detect if we are running on 64bit Windows and use Wow6432Node since Inno Setup is -rem a 32-bit application, and set the registry key of Inno Setup accordingly -IF DEFINED PROGRAMFILES(x86) ( - SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" -) ELSE ( - SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" -) - -IF DEFINED InnoSetupPath IF NOT EXIST "%InnoSetupPath%" ( - CALL :SUBMSG "INFO" ""%InnoSetupPath%" wasn't found on this machine! I will try to detect Inno Setup's path from the registry..." -) - -IF NOT EXIST "%InnoSetupPath%" ( - FOR /F "delims=" %%a IN ( - 'REG QUERY "%U_%\Inno Setup 5_is1" /v "Inno Setup: App Path"2^>Nul^|FIND "REG_"') DO ( - SET "InnoSetupPath=%%a" & CALL :SubInnoSetupPath %%InnoSetupPath:*Z=%%) -) - -IF NOT EXIST "%InnoSetupPath%" CALL :SUBMSG "ERROR" "Inno Setup wasn't found!" -EXIT /B - - -:SubInnoSetupPath -SET "InnoSetupPath=%*" -EXIT /B - - -:SubSign -IF %ERRORLEVEL% NEQ 0 EXIT /B -REM %1 is the subfolder - -CALL "%~dp0sign.bat" "..\%1\Notepad2.exe" || (CALL :SUBMSG "ERROR" "Problem signing ..\%1\Notepad2.exe" & GOTO Break) - -CALL :SUBMSG "INFO" "..\%1\Notepad2.exe signed successfully." - -:Break -EXIT /B - - -:SHOWHELP -TITLE %~nx0 %1 -ECHO. & ECHO. -ECHO Usage: %~nx0 [VS2017] -ECHO. -ECHO Notes: You can also prefix the commands with "-", "--" or "/". -ECHO The arguments are not case sensitive. -ECHO. -ECHO You can use another Inno Setup location by defining %%InnoSetupPath%%. -ECHO This is usefull if you have the Unicode build installed -ECHO and you want to use the ANSI one. -ECHO. & ECHO. -ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 VS2017" -ECHO. -ENDLOCAL -EXIT /B - - -:SUBMSG -ECHO. & ECHO ______________________________ -ECHO [%~1] %~2 -ECHO ______________________________ & ECHO. -IF /I "%~1" == "ERROR" ( - PAUSE - EXIT -) ELSE ( - EXIT /B -) +@ECHO OFF +rem ****************************************************************************** +rem * +rem * Notepad2-mod +rem * +rem * make_installer.bat +rem * Batch file for building the installer for Notepad2-mod +rem * +rem * See License.txt for details about distribution and modification. +rem * +rem * (c) XhmikosR 2010-2017 +rem * https://github.com/XhmikosR/notepad2-mod +rem * +rem ****************************************************************************** + +SETLOCAL ENABLEEXTENSIONS +CD /D %~dp0 + +rem Check for the help switches +IF /I "%~1" == "help" GOTO SHOWHELP +IF /I "%~1" == "/help" GOTO SHOWHELP +IF /I "%~1" == "-help" GOTO SHOWHELP +IF /I "%~1" == "--help" GOTO SHOWHELP +IF /I "%~1" == "/?" GOTO SHOWHELP + + +rem You can set here the Inno Setup path if for example you have Inno Setup Unicode +rem installed and you want to use the ANSI Inno Setup which is in another location +IF NOT DEFINED InnoSetupPath SET "InnoSetupPath=H:\progs\thirdparty\isetup" + +rem Check the building environment +CALL :SubDetectInnoSetup + + +rem Check for the first switch +IF "%~1" == "" ( + SET "COMPILER=VS2017" +) ELSE ( + IF /I "%~1" == "VS2017" SET "COMPILER=VS2017" & GOTO START + IF /I "%~1" == "/VS2017" SET "COMPILER=VS2017" & GOTO START + IF /I "%~1" == "-VS2017" SET "COMPILER=VS2017" & GOTO START + IF /I "%~1" == "--VS2017" SET "COMPILER=VS2017" & GOTO START + + ECHO. + ECHO Unsupported commandline switch! + ECHO Run "%~nx0 help" for details about the commandline switches. + CALL :SUBMSG "ERROR" "Compilation failed!" +) + + +:START +IF EXIST "%~dp0..\signinfo.txt" SET "SIGN=True" + +SET INPUTDIRx86=bin\%COMPILER%\Release_x86 +SET INPUTDIRx64=bin\%COMPILER%\Release_x64 +IF /I NOT "%COMPILER%" == "VS2017" SET SUFFIX=_%COMPILER% +SET "TEMP_NAME=temp_zip%SUFFIX%" + +IF NOT EXIST "..\%INPUTDIRx86%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x86 first!" +IF NOT EXIST "..\%INPUTDIRx64%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x64 first!" + +IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx86% +IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx64% + +CALL :SubInstaller %COMPILER% + + +:END +TITLE Finished! +ECHO. +ENDLOCAL +EXIT /B + + +:SubInstaller +TITLE Building %1 installer... +CALL :SUBMSG "INFO" "Building %1 installer using %InnoSetupPath%\ISCC.exe..." + +"%InnoSetupPath%\ISCC.exe" /SMySignTool="cmd /c "%~dp0sign.bat" $f" /Q /O"packages" "..\distrib\notepad2_setup.iss" /D%1 +IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" + +EXIT /B + + +:SubDetectInnoSetup +rem Detect if we are running on 64bit Windows and use Wow6432Node since Inno Setup is +rem a 32-bit application, and set the registry key of Inno Setup accordingly +IF DEFINED PROGRAMFILES(x86) ( + SET "U_=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" +) ELSE ( + SET "U_=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" +) + +IF DEFINED InnoSetupPath IF NOT EXIST "%InnoSetupPath%" ( + CALL :SUBMSG "INFO" ""%InnoSetupPath%" wasn't found on this machine! I will try to detect Inno Setup's path from the registry..." +) + +IF NOT EXIST "%InnoSetupPath%" ( + FOR /F "delims=" %%a IN ( + 'REG QUERY "%U_%\Inno Setup 5_is1" /v "Inno Setup: App Path"2^>Nul^|FIND "REG_"') DO ( + SET "InnoSetupPath=%%a" & CALL :SubInnoSetupPath %%InnoSetupPath:*Z=%%) +) + +IF NOT EXIST "%InnoSetupPath%" CALL :SUBMSG "ERROR" "Inno Setup wasn't found!" +EXIT /B + + +:SubInnoSetupPath +SET "InnoSetupPath=%*" +EXIT /B + + +:SubSign +IF %ERRORLEVEL% NEQ 0 EXIT /B +REM %1 is the subfolder + +CALL "%~dp0sign.bat" "..\%1\Notepad2.exe" || (CALL :SUBMSG "ERROR" "Problem signing ..\%1\Notepad2.exe" & GOTO Break) + +CALL :SUBMSG "INFO" "..\%1\Notepad2.exe signed successfully." + +:Break +EXIT /B + + +:SHOWHELP +TITLE %~nx0 %1 +ECHO. & ECHO. +ECHO Usage: %~nx0 [VS2017] +ECHO. +ECHO Notes: You can also prefix the commands with "-", "--" or "/". +ECHO The arguments are not case sensitive. +ECHO. +ECHO You can use another Inno Setup location by defining %%InnoSetupPath%%. +ECHO This is usefull if you have the Unicode build installed +ECHO and you want to use the ANSI one. +ECHO. & ECHO. +ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 VS2017" +ECHO. +ENDLOCAL +EXIT /B + + +:SUBMSG +ECHO. & ECHO ______________________________ +ECHO [%~1] %~2 +ECHO ______________________________ & ECHO. +IF /I "%~1" == "ERROR" ( + PAUSE + EXIT +) ELSE ( + EXIT /B +) diff --git a/build/make_zip.bat b/build/make_zip.bat index ae6d7368..d8dcb37a 100644 --- a/build/make_zip.bat +++ b/build/make_zip.bat @@ -1,187 +1,187 @@ -@ECHO OFF -rem ****************************************************************************** -rem * -rem * Notepad2-mod -rem * -rem * make_zip.bat -rem * Batch file for creating the zip packages -rem * -rem * See License.txt for details about distribution and modification. -rem * -rem * (c) XhmikosR 2010-2017 -rem * https://github.com/XhmikosR/notepad2-mod -rem * -rem ****************************************************************************** - -SETLOCAL ENABLEEXTENSIONS -CD /D %~dp0 - - -rem Check for the help switches -IF /I "%~1" == "help" GOTO SHOWHELP -IF /I "%~1" == "/help" GOTO SHOWHELP -IF /I "%~1" == "-help" GOTO SHOWHELP -IF /I "%~1" == "--help" GOTO SHOWHELP -IF /I "%~1" == "/?" GOTO SHOWHELP - - -rem Check for the first switch -IF "%~1" == "" ( - SET "COMPILER=VS2017" -) ELSE ( - IF /I "%~1" == "VS2017" (SET "COMPILER=VS2017" & GOTO START) - IF /I "%~1" == "/VS2017" (SET "COMPILER=VS2017" & GOTO START) - IF /I "%~1" == "-VS2017" (SET "COMPILER=VS2017" & GOTO START) - IF /I "%~1" == "--VS2017" (SET "COMPILER=VS2017" & GOTO START) - - ECHO. - ECHO Unsupported commandline switch! - ECHO Run "%~nx0 help" for details about the commandline switches. - CALL :SUBMSG "ERROR" "Compilation failed!" -) - - -:START -IF EXIST "%~dp0..\signinfo.txt" SET "SIGN=True" - -SET INPUTDIRx86=bin\%COMPILER%\Release_x86 -SET INPUTDIRx64=bin\%COMPILER%\Release_x64 -IF /I NOT "%COMPILER%" == "VS2017" SET SUFFIX=_%COMPILER% -SET "TEMP_NAME=temp_zip%SUFFIX%" - -IF NOT EXIST "..\%INPUTDIRx86%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x86 first!" -IF NOT EXIST "..\%INPUTDIRx64%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x64 first!" - -CALL :SubGetVersion -CALL :SubDetectSevenzipPath - -IF /I "%SEVENZIP%" == "" CALL :SUBMSG "ERROR" "7za wasn't found!" - -IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx86% -IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx64% - -CALL :SubZipFiles %INPUTDIRx86% x86 -CALL :SubZipFiles %INPUTDIRx64% x64 - -rem Compress everything into a single ZIP file -PUSHD "packages" -IF EXIST "Notepad2-mod.zip" DEL "Notepad2-mod.zip" -IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" -IF NOT EXIST "%TEMP_NAME%" MD "%TEMP_NAME%" - -IF EXIST "Notepad2-mod.%NP2_VER%*.exe" COPY /Y /V "Notepad2-mod.%NP2_VER%*.exe" "%TEMP_NAME%\" >NUL -IF EXIST "Notepad2-mod.%NP2_VER%*.zip" COPY /Y /V "Notepad2-mod.%NP2_VER%*.zip" "%TEMP_NAME%\" >NUL - -PUSHD "%TEMP_NAME%" - -"%SEVENZIP%" a -tzip -mx=9 Notepad2-mod.zip * >NUL -IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" - -CALL :SUBMSG "INFO" "Notepad2-mod.zip created successfully!" - -MOVE /Y "Notepad2-mod.zip" ".." >NUL - -POPD -IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" - -POPD - - -:END -TITLE Finished! -ECHO. -ENDLOCAL -EXIT /B - - -:SubZipFiles -SET "ZIP_NAME=Notepad2-mod.%NP2_VER%_%2%SUFFIX%" -TITLE Creating %ZIP_NAME%.zip... -CALL :SUBMSG "INFO" "Creating %ZIP_NAME%.zip..." - -IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" -IF NOT EXIST "%TEMP_NAME%" MD "%TEMP_NAME%" -IF NOT EXIST "packages" MD "packages" - -FOR %%A IN ("..\License.txt" "..\%1\Notepad2.exe"^ - "..\distrib\Notepad2.ini" "..\Notepad2.txt" "..\Readme-mod.txt" -) DO COPY /Y /V "%%A" "%TEMP_NAME%\" - -PUSHD "%TEMP_NAME%" -"%SEVENZIP%" a -tzip -mx=9^ - "%ZIP_NAME%.zip" "License.txt" "Notepad2.exe"^ - "Notepad2.ini" "Notepad2.txt" "Readme-mod.txt" >NUL -IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" - -CALL :SUBMSG "INFO" "%ZIP_NAME%.zip created successfully!" - -MOVE /Y "%ZIP_NAME%.zip" "..\packages" >NUL -POPD -IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" -EXIT /B - - -:SubDetectSevenzipPath -FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") -IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) - -FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") -IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) - -FOR /F "tokens=2*" %%A IN ( - 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^| - REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe" -EXIT /B - - -:SubGetVersion -rem Get the version -FOR /F "tokens=3,4 delims= " %%K IN ( - 'FINDSTR /I /L /C:"define VERSION_MAJOR" "..\src\Version.h"') DO (SET "VerMajor=%%K") -FOR /F "tokens=3,4 delims= " %%K IN ( - 'FINDSTR /I /L /C:"define VERSION_MINOR" "..\src\Version.h"') DO (SET "VerMinor=%%K") -FOR /F "tokens=3,4 delims= " %%K IN ( - 'FINDSTR /I /L /C:"define VERSION_BUILD" "..\src\Version.h"') DO (SET "VerBuild=%%K") -FOR /F "tokens=3,4 delims= " %%K IN ( - 'FINDSTR /I /L /C:"define VERSION_REV " "..\src\VersionRev.h"') DO (SET "VerRev=%%K") - -SET NP2_VER=%VerMajor%.%VerMinor%.%VerBuild%.%VerRev% -EXIT /B - - -:SubSign -IF %ERRORLEVEL% NEQ 0 EXIT /B -REM %1 is the subfolder - -CALL "%~dp0sign.bat" "..\%1\Notepad2.exe" || (CALL :SUBMSG "ERROR" "Problem signing ..\%1\Notepad2.exe" & GOTO Break) - -CALL :SUBMSG "INFO" "..\%1\Notepad2.exe signed successfully." - -:Break -EXIT /B - - -:SHOWHELP -TITLE %~nx0 %1 -ECHO. & ECHO. -ECHO Usage: %~nx0 [VS2017] -ECHO. -ECHO Notes: You can also prefix the commands with "-", "--" or "/". -ECHO The arguments are not case sensitive. -ECHO. & ECHO. -ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 VS2017" -ECHO. -ENDLOCAL -EXIT /B - - -:SUBMSG -ECHO. & ECHO ______________________________ -ECHO [%~1] %~2 -ECHO ______________________________ & ECHO. -IF /I "%~1" == "ERROR" ( - PAUSE - EXIT -) ELSE ( - EXIT /B -) +@ECHO OFF +rem ****************************************************************************** +rem * +rem * Notepad2-mod +rem * +rem * make_zip.bat +rem * Batch file for creating the zip packages +rem * +rem * See License.txt for details about distribution and modification. +rem * +rem * (c) XhmikosR 2010-2017 +rem * https://github.com/XhmikosR/notepad2-mod +rem * +rem ****************************************************************************** + +SETLOCAL ENABLEEXTENSIONS +CD /D %~dp0 + + +rem Check for the help switches +IF /I "%~1" == "help" GOTO SHOWHELP +IF /I "%~1" == "/help" GOTO SHOWHELP +IF /I "%~1" == "-help" GOTO SHOWHELP +IF /I "%~1" == "--help" GOTO SHOWHELP +IF /I "%~1" == "/?" GOTO SHOWHELP + + +rem Check for the first switch +IF "%~1" == "" ( + SET "COMPILER=VS2017" +) ELSE ( + IF /I "%~1" == "VS2017" (SET "COMPILER=VS2017" & GOTO START) + IF /I "%~1" == "/VS2017" (SET "COMPILER=VS2017" & GOTO START) + IF /I "%~1" == "-VS2017" (SET "COMPILER=VS2017" & GOTO START) + IF /I "%~1" == "--VS2017" (SET "COMPILER=VS2017" & GOTO START) + + ECHO. + ECHO Unsupported commandline switch! + ECHO Run "%~nx0 help" for details about the commandline switches. + CALL :SUBMSG "ERROR" "Compilation failed!" +) + + +:START +IF EXIST "%~dp0..\signinfo.txt" SET "SIGN=True" + +SET INPUTDIRx86=bin\%COMPILER%\Release_x86 +SET INPUTDIRx64=bin\%COMPILER%\Release_x64 +IF /I NOT "%COMPILER%" == "VS2017" SET SUFFIX=_%COMPILER% +SET "TEMP_NAME=temp_zip%SUFFIX%" + +IF NOT EXIST "..\%INPUTDIRx86%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x86 first!" +IF NOT EXIST "..\%INPUTDIRx64%\Notepad2.exe" CALL :SUBMSG "ERROR" "Compile Notepad2 x64 first!" + +CALL :SubGetVersion +CALL :SubDetectSevenzipPath + +IF /I "%SEVENZIP%" == "" CALL :SUBMSG "ERROR" "7za wasn't found!" + +IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx86% +IF /I "%SIGN%" == "True" CALL :SubSign %INPUTDIRx64% + +CALL :SubZipFiles %INPUTDIRx86% x86 +CALL :SubZipFiles %INPUTDIRx64% x64 + +rem Compress everything into a single ZIP file +PUSHD "packages" +IF EXIST "Notepad2-mod.zip" DEL "Notepad2-mod.zip" +IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" +IF NOT EXIST "%TEMP_NAME%" MD "%TEMP_NAME%" + +IF EXIST "Notepad2-mod.%NP2_VER%*.exe" COPY /Y /V "Notepad2-mod.%NP2_VER%*.exe" "%TEMP_NAME%\" >NUL +IF EXIST "Notepad2-mod.%NP2_VER%*.zip" COPY /Y /V "Notepad2-mod.%NP2_VER%*.zip" "%TEMP_NAME%\" >NUL + +PUSHD "%TEMP_NAME%" + +"%SEVENZIP%" a -tzip -mx=9 Notepad2-mod.zip * >NUL +IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" + +CALL :SUBMSG "INFO" "Notepad2-mod.zip created successfully!" + +MOVE /Y "Notepad2-mod.zip" ".." >NUL + +POPD +IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" + +POPD + + +:END +TITLE Finished! +ECHO. +ENDLOCAL +EXIT /B + + +:SubZipFiles +SET "ZIP_NAME=Notepad2-mod.%NP2_VER%_%2%SUFFIX%" +TITLE Creating %ZIP_NAME%.zip... +CALL :SUBMSG "INFO" "Creating %ZIP_NAME%.zip..." + +IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" +IF NOT EXIST "%TEMP_NAME%" MD "%TEMP_NAME%" +IF NOT EXIST "packages" MD "packages" + +FOR %%A IN ("..\License.txt" "..\%1\Notepad2.exe"^ + "..\distrib\Notepad2.ini" "..\Notepad2.txt" "..\Readme-mod.txt" +) DO COPY /Y /V "%%A" "%TEMP_NAME%\" + +PUSHD "%TEMP_NAME%" +"%SEVENZIP%" a -tzip -mx=9^ + "%ZIP_NAME%.zip" "License.txt" "Notepad2.exe"^ + "Notepad2.ini" "Notepad2.txt" "Readme-mod.txt" >NUL +IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!" + +CALL :SUBMSG "INFO" "%ZIP_NAME%.zip created successfully!" + +MOVE /Y "%ZIP_NAME%.zip" "..\packages" >NUL +POPD +IF EXIST "%TEMP_NAME%" RD /S /Q "%TEMP_NAME%" +EXIT /B + + +:SubDetectSevenzipPath +FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") +IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) + +FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") +IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) + +FOR /F "tokens=2*" %%A IN ( + 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^| + REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe" +EXIT /B + + +:SubGetVersion +rem Get the version +FOR /F "tokens=3,4 delims= " %%K IN ( + 'FINDSTR /I /L /C:"define VERSION_MAJOR" "..\src\Version.h"') DO (SET "VerMajor=%%K") +FOR /F "tokens=3,4 delims= " %%K IN ( + 'FINDSTR /I /L /C:"define VERSION_MINOR" "..\src\Version.h"') DO (SET "VerMinor=%%K") +FOR /F "tokens=3,4 delims= " %%K IN ( + 'FINDSTR /I /L /C:"define VERSION_BUILD" "..\src\Version.h"') DO (SET "VerBuild=%%K") +FOR /F "tokens=3,4 delims= " %%K IN ( + 'FINDSTR /I /L /C:"define VERSION_REV " "..\src\VersionRev.h"') DO (SET "VerRev=%%K") + +SET NP2_VER=%VerMajor%.%VerMinor%.%VerBuild%.%VerRev% +EXIT /B + + +:SubSign +IF %ERRORLEVEL% NEQ 0 EXIT /B +REM %1 is the subfolder + +CALL "%~dp0sign.bat" "..\%1\Notepad2.exe" || (CALL :SUBMSG "ERROR" "Problem signing ..\%1\Notepad2.exe" & GOTO Break) + +CALL :SUBMSG "INFO" "..\%1\Notepad2.exe signed successfully." + +:Break +EXIT /B + + +:SHOWHELP +TITLE %~nx0 %1 +ECHO. & ECHO. +ECHO Usage: %~nx0 [VS2017] +ECHO. +ECHO Notes: You can also prefix the commands with "-", "--" or "/". +ECHO The arguments are not case sensitive. +ECHO. & ECHO. +ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 VS2017" +ECHO. +ENDLOCAL +EXIT /B + + +:SUBMSG +ECHO. & ECHO ______________________________ +ECHO [%~1] %~2 +ECHO ______________________________ & ECHO. +IF /I "%~1" == "ERROR" ( + PAUSE + EXIT +) ELSE ( + EXIT /B +) diff --git a/build/package.ps1 b/build/package.ps1 new file mode 100644 index 00000000..1b483171 --- /dev/null +++ b/build/package.ps1 @@ -0,0 +1,54 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory)][ValidateSet('x86','x64')][string]$Architecture, + [string]$Tag, + [string]$OutputDirectory = "$PSScriptRoot/../bin/packages" +) +$ErrorActionPreference = 'Stop' +$repo = (Resolve-Path "$PSScriptRoot/..").Path +$exe = Join-Path $repo "bin/VS2022/Release_$Architecture/Notepad2.exe" +$version = (Get-Item -LiteralPath $exe).VersionInfo.FileVersion.Trim() +if (-not $Tag) { $Tag = "v$version" } +if ($Tag -notmatch '^v(\d+\.\d+\.\d+\.\d+)(-rc\.[1-9]\d*)?$' -or $Matches[1] -ne $version) { + throw "Release tag must match executable version $version (optional -rc.N suffix)." +} +$stream = [IO.File]::OpenRead($exe) +$reader = [IO.BinaryReader]::new($stream) +try { + $stream.Position = 0x3C + $pe = $reader.ReadInt32() + $stream.Position = $pe + 4 + $machine = $reader.ReadUInt16() + $expected = if ($Architecture -eq 'x64') { 0x8664 } else { 0x14C } + if ($machine -ne $expected) { throw 'Executable architecture mismatch.' } +} finally { $reader.Dispose() } +$null = New-Item -ItemType Directory -Path $OutputDirectory -Force +$output = (Resolve-Path $OutputDirectory).Path +$stage = Join-Path $output ([Guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $stage +Copy-Item -LiteralPath $exe -Destination "$stage/Notepad2.exe" +foreach ($name in @('License.txt','Readme.md','Notepad2.txt','Readme-mod.txt')) { + Copy-Item -LiteralPath (Join-Path $repo $name) -Destination $stage +} +Copy-Item -LiteralPath "$repo/distrib/Notepad2.ini" -Destination $stage +Copy-Item -LiteralPath "$repo/scintilla/License.txt" -Destination "$stage/Scintilla-License.txt" +$commit = & git -C $repo rev-parse HEAD +if ($LASTEXITCODE -ne 0) { throw 'Cannot determine source commit.' } +$metadata = [ordered]@{ version=$version; tag=$Tag; architecture=$Architecture; commit=$commit; executableSHA256=(Get-FileHash $exe -Algorithm SHA256).Hash; signed=$false } +$metadata | ConvertTo-Json | Set-Content "$stage/build-info.json" -Encoding utf8 +$zipPath = Join-Path $output "Notepad2-mod-$Tag-$Architecture.zip" +if (Test-Path -LiteralPath $zipPath) { throw "Package already exists: $zipPath" } +Compress-Archive -Path "$stage/*" -DestinationPath $zipPath +Add-Type -AssemblyName System.IO.Compression.FileSystem +$archive = [IO.Compression.ZipFile]::OpenRead($zipPath) +try { + $expectedFiles = @('Notepad2.exe','Notepad2.ini','License.txt','Scintilla-License.txt','Readme.md','Notepad2.txt','Readme-mod.txt','build-info.json') | Sort-Object + if (Compare-Object $expectedFiles @($archive.Entries.FullName | Sort-Object)) { throw 'Unexpected archive contents.' } + $entry = $archive.GetEntry('Notepad2.exe').Open() + $sha = [Security.Cryptography.SHA256]::Create() + try { $actualHash = [BitConverter]::ToString($sha.ComputeHash($entry)).Replace('-','') } + finally { $entry.Dispose(); $sha.Dispose() } + if ($actualHash -ne $metadata.executableSHA256) { throw 'Packaged executable hash mismatch.' } +} finally { $archive.Dispose() } +# Keep the staging directory as an ignored build artifact; never delete computed trees. +Write-Output $zipPath diff --git a/build/publish-release.ps1 b/build/publish-release.ps1 new file mode 100644 index 00000000..496aaeeb --- /dev/null +++ b/build/publish-release.ps1 @@ -0,0 +1,56 @@ +[CmdletBinding()] +param([Parameter(Mandatory)][string]$Tag, [Parameter(Mandatory)][string]$PackageDirectory) +$ErrorActionPreference = 'Stop' +function Invoke-Gh([string[]]$Arguments) { + $result = & gh @Arguments + if ($LASTEXITCODE -ne 0) { throw "GitHub command failed: $($Arguments[0])" } + return $result +} +if ($Tag -notmatch '^v(\d+\.\d+\.\d+\.\d+)(-rc\.[1-9]\d*)?$') { throw 'Invalid release tag.' } +$version = $Matches[1] +$prerelease = $Tag.Contains('-rc.') +$null = & git merge-base --is-ancestor HEAD origin/master +if ($LASTEXITCODE -ne 0) { throw 'Release commit must belong to master.' } +$commit = & git rev-parse HEAD +Add-Type -AssemblyName System.IO.Compression.FileSystem +$packages = foreach ($arch in @('x86','x64')) { + $path = (Resolve-Path (Join-Path $PackageDirectory "Notepad2-mod-$Tag-$arch.zip")).Path + $archive = [IO.Compression.ZipFile]::OpenRead($path) + try { + $reader = [IO.StreamReader]::new($archive.GetEntry('build-info.json').Open()) + try { $info = $reader.ReadToEnd() | ConvertFrom-Json } finally { $reader.Dispose() } + if ($info.commit -ne $commit -or $info.version -ne $version -or $info.architecture -ne $arch -or $info.tag -ne $Tag) { + throw "Package metadata mismatch: $arch" + } + } finally { $archive.Dispose() } + $path +} +$sums = Join-Path $PackageDirectory 'SHA256SUMS.txt' +$packages | ForEach-Object { '{0} {1}' -f (Get-FileHash -LiteralPath $_ -Algorithm SHA256).Hash.ToLowerInvariant(), [IO.Path]::GetFileName($_) } | Set-Content $sums -Encoding ascii +$notes = Join-Path $PackageDirectory 'release-notes.txt' +@" +Native Original/Dark editor palettes on Scintilla 3.7.6, with a VS 2022 build. + +Choose View > Editor Theme > Dark. Existing Original colors and font preferences are retained. Application chrome is unchanged. + +Download the portable ZIP for your architecture and extract it into a writable folder. Preserve your existing Notepad2.ini when upgrading. These binaries are unsigned. SHA256SUMS.txt provides archive integrity checks. + +Source commit: $commit +Executable version: $version +Validation: Release/Debug x86/x64 builds and native theme integration tests, including all 38 schemes and customization/persistence checks. +"@ | Set-Content $notes -Encoding utf8 +$existing = & gh release view $Tag --json isDraft 2>$null +if ($LASTEXITCODE -eq 0) { + if (-not ($existing | ConvertFrom-Json).isDraft) { throw 'Published releases are immutable; use a new tag.' } +} else { + $null = Invoke-Gh @('release','create',$Tag,'--verify-tag','--draft','--title',"Notepad2-mod $Tag",'--notes-file',$notes) +} +$null = Invoke-Gh (@('release','upload',$Tag) + @($packages) + @($sums,'--clobber')) +$assets = (Invoke-Gh @('release','view',$Tag,'--json','assets') | ConvertFrom-Json).assets +foreach ($path in @($packages) + @($sums)) { + $asset = @($assets | Where-Object name -eq ([IO.Path]::GetFileName($path))) + if ($asset.Count -ne 1 -or $asset[0].size -ne (Get-Item $path).Length) { throw 'Release asset verification failed.' } +} +$flags = if ($prerelease) { @('--prerelease','--latest=false') } else { @('--prerelease=false','--latest') } +$null = Invoke-Gh (@('release','edit',$Tag,'--draft=false','--notes-file',$notes) + $flags) +Write-Output "Published $Tag" diff --git a/build/setup-git.ps1 b/build/setup-git.ps1 new file mode 100644 index 00000000..923cf1de --- /dev/null +++ b/build/setup-git.ps1 @@ -0,0 +1,25 @@ +[CmdletBinding()] +param() + +$ErrorActionPreference = 'Stop' +Push-Location (Join-Path $PSScriptRoot '..') +try { + $settings = [ordered]@{ + 'core.autocrlf' = 'false' + 'core.safecrlf' = 'true' + 'core.whitespace' = 'blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol' + 'core.hooksPath' = '.githooks' + 'pull.ff' = 'only' + 'pull.rebase' = 'false' + 'push.default' = 'simple' + 'push.autoSetupRemote' = 'false' + 'fetch.prune' = 'true' + } + foreach ($entry in $settings.GetEnumerator()) { + & git config --local $entry.Key $entry.Value + if ($LASTEXITCODE -ne 0) { throw "Could not set $($entry.Key)." } + } + Write-Output 'Repository-local Git settings and pre-commit hook installed. Author identity is unchanged.' +} finally { + Pop-Location +} diff --git a/build/test-themes.ps1 b/build/test-themes.ps1 new file mode 100644 index 00000000..8fc6a9e2 --- /dev/null +++ b/build/test-themes.ps1 @@ -0,0 +1,225 @@ +[CmdletBinding()] +param( + [string]$Executable = "$PSScriptRoot/../bin/VS2022/Release_x64/Notepad2.exe", + [string]$BaselineExecutable +) + +$ErrorActionPreference = 'Stop' +Add-Type @' +using System; +using System.Text; +using System.Runtime.InteropServices; +public static class ThemeTestNative { + public delegate bool Callback(IntPtr hwnd, IntPtr state); + [DllImport("user32.dll")] public static extern bool EnumWindows(Callback cb, IntPtr state); + [DllImport("user32.dll")] public static extern bool EnumChildWindows(IntPtr hwnd, Callback cb, IntPtr state); + [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hwnd, out uint pid); + [DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetClassName(IntPtr hwnd, StringBuilder text, int size); + [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr w, IntPtr l); + [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr hwnd, uint msg, IntPtr w, IntPtr l); + [DllImport("user32.dll")] public static extern IntPtr GetDlgItem(IntPtr hwnd, int id); + [DllImport("user32.dll", CharSet=CharSet.Unicode, EntryPoint="SendMessageW")] public static extern IntPtr SendText(IntPtr hwnd, uint msg, IntPtr w, string text); +} +'@ + +function Assert($condition, $message) { if (-not $condition) { throw $message } } +function Sci($message, $w = 0, $l = 0) { + [ThemeTestNative]::SendMessage($script:editor, $message, [IntPtr]$w, [IntPtr]$l).ToInt64() +} +function Select-Theme($dark) { + $command = if ($dark) { 40981 } else { 40980 } + $null = [ThemeTestNative]::SendMessage($script:window, 0x111, [IntPtr]$command, [IntPtr]::Zero) +} +function Start-Editor($ini, $document, $scheme = 'cpp') { + $script:app = Start-Process -FilePath $Executable -ArgumentList @('/n', '/f', ('"'+$ini+'"'), '/s', $scheme, ('"'+$document+'"')) -WindowStyle Hidden -PassThru + Assert ($script:app.WaitForInputIdle(10000)) 'Editor startup timed out' + $script:window = [IntPtr]::Zero + $script:editor = [IntPtr]::Zero + $processId = $script:app.Id + $callback = [ThemeTestNative+Callback]{ param($handle, $state) + [uint32]$owner = 0 + $null = [ThemeTestNative]::GetWindowThreadProcessId($handle, [ref]$owner) + $name = New-Object Text.StringBuilder 128 + $null = [ThemeTestNative]::GetClassName($handle, $name, 128) + if ($owner -eq $processId -and $name.ToString() -like 'Notepad2*') { $script:window = $handle } + return $true + } + $null = [ThemeTestNative]::EnumWindows($callback, [IntPtr]::Zero) + Assert ($script:window -ne [IntPtr]::Zero) 'Main window missing' + $child = [ThemeTestNative+Callback]{ param($handle, $state) + $name = New-Object Text.StringBuilder 128 + $null = [ThemeTestNative]::GetClassName($handle, $name, 128) + if ($name.ToString() -eq 'Scintilla') { $script:editor = $handle } + return $true + } + $null = [ThemeTestNative]::EnumChildWindows($script:window, $child, [IntPtr]::Zero) + Assert ($script:editor -ne [IntPtr]::Zero) 'Scintilla window missing' +} +function Stop-Editor { + $null = Sci 2014 + $null = [ThemeTestNative]::PostMessage($script:window, 0x10, [IntPtr]::Zero, [IntPtr]::Zero) + Assert ($script:app.WaitForExit(10000)) 'Editor did not exit normally' +} + +function Open-Customization { + $null = [ThemeTestNative]::PostMessage($script:window, 0x111, [IntPtr]40402, [IntPtr]::Zero) + $script:dialog = [IntPtr]::Zero + $processId = $script:app.Id + $callback = [ThemeTestNative+Callback]{ param($handle, $state) + [uint32]$owner = 0 + $null = [ThemeTestNative]::GetWindowThreadProcessId($handle, [ref]$owner) + $name = New-Object Text.StringBuilder 128 + $null = [ThemeTestNative]::GetClassName($handle, $name, 128) + if ($owner -eq $processId -and $name.ToString() -eq '#32770') { $script:dialog = $handle } + return $true + } + for ($attempt = 0; $attempt -lt 50 -and $script:dialog -eq [IntPtr]::Zero; ++$attempt) { + Start-Sleep -Milliseconds 20 + $null = [ThemeTestNative]::EnumWindows($callback, [IntPtr]::Zero) + } + Assert ($script:dialog -ne [IntPtr]::Zero) 'Customize Schemes dialog missing' + # Window enumeration can see the dialog before WM_INITDIALOG populates it. + $first = [IntPtr]::Zero + for ($attempt = 0; $attempt -lt 500 -and $first -eq [IntPtr]::Zero; ++$attempt) { + $tree = [ThemeTestNative]::GetDlgItem($script:dialog, 100) + $root = [ThemeTestNative]::SendMessage($tree, 0x110A, [IntPtr]::Zero, [IntPtr]::Zero) + if ($root -ne [IntPtr]::Zero) { $first = [ThemeTestNative]::SendMessage($tree, 0x110A, [IntPtr]4, $root) } + if ($first -eq [IntPtr]::Zero) { Start-Sleep -Milliseconds 20 } + } + Assert ($first -ne [IntPtr]::Zero) 'Customize Schemes tree was not populated' + $null = [ThemeTestNative]::SendMessage($tree, 0x110B, [IntPtr]9, $first) +} + +$Executable = (Resolve-Path $Executable).Path +$testDir = Join-Path ([IO.Path]::GetTempPath()) ('np2-themes-' + [Guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $testDir +$ini = Join-Path $testDir 'settings.ini' +$document = Join-Path $testDir 'sample.cpp' +[IO.File]::WriteAllText($document, "// comment`r`nint main() { return 42; }`r`n") +$settings = "[Settings]`r`nSaveSettings=1`r`n[Default Text]`r`nDefault Style=font:Consolas; size:13; fore:#123456; back:#EEDDCC`r`n" +[IO.File]::WriteAllText($ini, $settings, [Text.Encoding]::Unicode) +try { + Start-Editor $ini $document + $original = Sci 2482 32 + $fontSize = Sci 2485 32 + $lexer = Sci 4002 + $null = Sci 2645 0 1 # Create a real undo record, with numeric-only cross-process messages. + $null = Sci 2160 2 7 + $snapshot = @((Sci 2006), (Sci 2008), (Sci 2009), (Sci 2152), (Sci 2174)) + $timer = [Diagnostics.Stopwatch]::StartNew() + for ($i = 0; $i -lt 20; ++$i) { + Select-Theme $true + Assert ((Sci 2482 32) -eq 0x1E1E1E) 'Dark background not applied' + Assert ((Sci 2485 32) -eq $fontSize) 'Theme changed font size' + Select-Theme $false + Assert ((Sci 2482 32) -eq $original) 'Original custom background lost' + } + $timer.Stop() + Assert ((Sci 4002) -eq $lexer) 'Theme changed lexer' + $after = @((Sci 2006), (Sci 2008), (Sci 2009), (Sci 2152), (Sci 2174)) + Assert (($snapshot -join ',') -eq ($after -join ',')) 'Theme changed document/selection/viewport/undo state' + Select-Theme $true + Stop-Editor + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq 0x1E1E1E) 'Theme selection did not persist' + Select-Theme $false + Assert ((Sci 2482 32) -eq $original) 'Original settings changed after restart' + Stop-Editor + [IO.File]::WriteAllText($ini, $settings.Replace('SaveSettings=1','SaveSettings=0'), [Text.Encoding]::Unicode) + Start-Editor $ini $document + Select-Theme $true + Stop-Editor + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq $original) 'Disabled settings saving was ignored' + Stop-Editor + # Saved Dark colors are independent; typography embedded in a color section is ignored. + $custom = $settings + "[Styles]`r`nEditorTheme=1`r`n[Theme.Dark.Default Text]`r`nDefault Style=font:Ignored; size:99; fore:#ABCDEF; back:#222222`r`n" + [IO.File]::WriteAllText($ini, $custom, [Text.Encoding]::Unicode) + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq 0x222222) 'Custom Dark color not loaded' + Assert ((Sci 2485 32) -eq $fontSize) 'Dark color section changed shared typography' + Select-Theme $false + Assert ((Sci 2482 32) -eq $original) 'Dark customization overwrote Original' + Select-Theme $true + Assert ((Sci 2482 32) -eq 0x222222) 'Dark customization lost on round trip' + Stop-Editor + [IO.File]::WriteAllText($ini, $settings + "[Styles]`r`nEditorTheme=99`r`n", [Text.Encoding]::Unicode) + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq $original) 'Unknown theme did not fall back to Original' + Stop-Editor + [IO.File]::WriteAllText($ini, $settings + "[Styles]`r`nEditorTheme=1`r`n[Theme.Dark.Default Text]`r`nDefault Style=back:invalid`r`n", [Text.Encoding]::Unicode) + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq 0x1E1E1E) 'Invalid saved Dark default did not fall back safely' + Stop-Editor + $source = [IO.File]::ReadAllText((Join-Path $PSScriptRoot '../src/Styles.c')) + $lexers = [regex]::Matches($source, 'EDITLEXER\s+\w+\s*=\s*\{[^\r\n]*?L"([^"]+)",\s*L"([^"]*)"') + Assert ($lexers.Count -eq 38) 'Lexer coverage inventory changed' + foreach ($entry in $lexers) { + [IO.File]::WriteAllText($ini, $settings, [Text.Encoding]::Unicode) + $scheme = $entry.Groups[2].Value.Split(';')[0].Trim() + Start-Editor $ini $document $scheme + Select-Theme $true + Assert ((Sci 2482 32) -eq 0x1E1E1E) "Dark background failed for $scheme" + Select-Theme $false + Stop-Editor + } + [IO.File]::WriteAllText($ini, $settings, [Text.Encoding]::Unicode) + Start-Editor $ini $document + Select-Theme $true + Open-Customization + $field = [ThemeTestNative]::GetDlgItem($script:dialog, 102) + $null = [ThemeTestNative]::SendText($field, 0xC, [IntPtr]::Zero, 'font:Consolas; size:15; fore:#EEEEEE; back:#111111') + $null = [ThemeTestNative]::SendMessage($script:dialog, 0x111, [IntPtr]106, [IntPtr]::Zero) + Assert ((Sci 2482 32) -eq 0x111111) 'Customization preview did not apply' + $null = [ThemeTestNative]::SendMessage($script:dialog, 0x111, [IntPtr]107, [IntPtr]::Zero) + $null = [ThemeTestNative]::SendMessage($script:dialog, 0x111, [IntPtr]106, [IntPtr]::Zero) + Assert ((Sci 2482 32) -eq 0x1E1E1E) 'Reset restored light colors in Dark' + $null = [ThemeTestNative]::SendMessage($script:dialog, 0x111, [IntPtr]2, [IntPtr]::Zero) + Assert ((Sci 2482 32) -eq 0x1E1E1E -and (Sci 2485 32) -eq $fontSize) 'Cancel did not restore preview' + Open-Customization + $field = [ThemeTestNative]::GetDlgItem($script:dialog, 102) + $null = [ThemeTestNative]::SendText($field, 0xC, [IntPtr]::Zero, 'font:Consolas; size:15; fore:#EEEEEE; back:#111111') + $null = [ThemeTestNative]::SendMessage($script:dialog, 0x111, [IntPtr]1, [IntPtr]::Zero) + Select-Theme $false + Assert ((Sci 2485 32) -eq 15 -and (Sci 2482 32) -eq $original) 'Customization did not share typography and isolate colors' + Select-Theme $true + $null = [ThemeTestNative]::SendMessage($script:window, 0x111, [IntPtr]40401, [IntPtr]::Zero) + Assert ((Sci 2482 32) -eq 0x1E1E1E) 'Second default was not themed' + $null = [ThemeTestNative]::SendMessage($script:window, 0x111, [IntPtr]40401, [IntPtr]::Zero) + Stop-Editor + Start-Editor $ini $document + Assert ((Sci 2482 32) -eq 0x111111 -and (Sci 2485 32) -eq 15) 'Customized theme did not persist' + Stop-Editor + Write-Output "Theme integration passed. 40 switches: $($timer.ElapsedMilliseconds) ms. Fixtures: $testDir" + if ($BaselineExecutable) { + $currentExecutable = $Executable + foreach ($mode in @('Baseline', 'Original', 'Dark')) { + $Executable = if ($mode -eq 'Baseline') { (Resolve-Path $BaselineExecutable).Path } else { $currentExecutable } + $samples = for ($run = 0; $run -lt 7; ++$run) { + $theme = if ($mode -eq 'Dark') { 1 } else { 0 } + [IO.File]::WriteAllText($ini, $settings + "[Styles]`r`nEditorTheme=$theme`r`n", [Text.Encoding]::Unicode) + $startup = [Diagnostics.Stopwatch]::StartNew() + Start-Editor $ini $document + $startup.Stop() + $script:app.Refresh() + $privateBytes = $script:app.PrivateMemorySize64 + $editing = [Diagnostics.Stopwatch]::StartNew() + for ($op = 0; $op -lt 100; ++$op) { $null = Sci 2645 0 1; $null = Sci 2176 } + $editing.Stop() + $cpuBefore = $script:app.TotalProcessorTime.TotalMilliseconds + Start-Sleep -Milliseconds 200 + $script:app.Refresh() + $idle = $script:app.TotalProcessorTime.TotalMilliseconds - $cpuBefore + Stop-Editor + [pscustomobject]@{ StartupMs=$startup.Elapsed.TotalMilliseconds; PrivateKiB=$privateBytes/1024; Edit100Ms=$editing.Elapsed.TotalMilliseconds; Idle200Ms=$idle } + } + $median = [ordered]@{ Mode=$mode } + foreach ($metric in @('StartupMs','PrivateKiB','Edit100Ms','Idle200Ms')) { + $median[$metric] = [Math]::Round(($samples.$metric | Sort-Object)[3], 2) + } + [pscustomobject]$median + } + } +} finally { + if ($script:app -and -not $script:app.HasExited) { Stop-Process -Id $script:app.Id } +} diff --git a/scintilla/README.notepad2-mod.txt b/scintilla/README.notepad2-mod.txt new file mode 100644 index 00000000..260db546 --- /dev/null +++ b/scintilla/README.notepad2-mod.txt @@ -0,0 +1,24 @@ +Scintilla vendor baseline: 3.7.6 (LongTerm3) + +Source: https://www.scintilla.org/scintilla376.zip +Archive SHA256: +4FEFB8B4D4A4A66801A26B1F6258BBBAB5077BEFB984ADDBEDF23FB086CBC3CA + +This is a reduced Windows source bundle, with Notepad2-mod customizations. +The 3.7.5 -> 3.7.6 update applies the upstream LexBaan.cxx fix and version +change. The other upstream changes concern omitted Cocoa code and Mercurial +metadata. Neither common editor code nor Windows code changed upstream. + +Preserved differences from stock 3.7.6: +- lexers/LexAHK.cxx: custom AutoHotkey lexer. +- include/SciLexer.h and include/Scintilla.iface: AutoHotkey constants. +- src/Catalogue.cxx: selected lexer registrations, including AutoHotkey. +- src/Editor.cxx: Alt+arrow notifications for folding keyboard commands. +- scripts/LexGen.py: disabled regeneration of omitted build/platform files + and headers. The root lexlink.js also filters lexer registrations. +- Scintilla.vcxproj and Scintilla.vcxproj.filters: fork-specific build files; + the project is locally retargeted to VS 2022 / v143. +- src/UniConversion.h: explicit include for the current compiler. + +Do not replace this directory with an unmodified upstream archive: preserve +these changes and the deliberately reduced source/build layout. diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index 0be3d2b5..42ebf075 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -1,5 +1,5 @@ - - + + Debug @@ -20,6 +20,7 @@ Win32Proj + 10.0 {5877B917-512B-49F5-B514-1B4159E7A9CA} Scintilla Scintilla @@ -28,23 +29,23 @@ Unicode StaticLibrary - v141_xp + v143 Unicode StaticLibrary - v141_xp + v143 Unicode StaticLibrary - v141_xp + v143 true Unicode StaticLibrary - v141_xp + v143 true @@ -65,14 +66,14 @@ <_ProjectFileVersion>10.0.30319.1 - ..\bin\VS2017\$(Configuration)_x86\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x64\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x86\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x64\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x86\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x64\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x86\obj\scintilla\ - ..\bin\VS2017\$(Configuration)_x64\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x86\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x64\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x86\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x64\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x86\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x64\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x86\obj\scintilla\ + ..\bin\VS2022\$(Configuration)_x64\obj\scintilla\ false false diff --git a/scintilla/lexers/LexBaan.cxx b/scintilla/lexers/LexBaan.cxx index c8afa3d6..cb4085d0 100644 --- a/scintilla/lexers/LexBaan.cxx +++ b/scintilla/lexers/LexBaan.cxx @@ -523,7 +523,7 @@ void SCI_METHOD LexerBaan::Lex(Sci_PositionU startPos, Sci_Position length, int sc.SetState(SCE_BAAN_DEFAULT); break; case SCE_BAAN_NUMBER: - if (IsASpaceOrTab(sc.ch) || sc.ch == '\r' || sc.ch == '\n') { + if (IsASpaceOrTab(sc.ch) || sc.ch == '\r' || sc.ch == '\n' || IsAnOperator(sc.ch)) { sc.SetState(SCE_BAAN_DEFAULT); } else if ((numberIsHex && !(MakeLowerCase(sc.ch) == 'x' || MakeLowerCase(sc.ch) == 'e' || diff --git a/scintilla/src/UniConversion.h b/scintilla/src/UniConversion.h index e812f558..696faeb5 100644 --- a/scintilla/src/UniConversion.h +++ b/scintilla/src/UniConversion.h @@ -8,6 +8,8 @@ #ifndef UNICONVERSION_H #define UNICONVERSION_H +#include + #ifdef SCI_NAMESPACE namespace Scintilla { #endif diff --git a/scintilla/version.txt b/scintilla/version.txt index 1c4e9d7f..7f63c0a7 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -375 +376 diff --git a/src/Dialogs.c b/src/Dialogs.c index 0d9a6cfb..fcffd0b0 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -1,2348 +1,2348 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Dialogs.c -* Notepad2 dialog boxes implementation -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include -#include -#include "scintilla.h" -#include "notepad2.h" -#include "edit.h" -#include "dlapi.h" -#include "dialogs.h" -#include "helpers.h" -#include "resource.h" -#include "version.h" - - -extern HWND hwndMain; -extern HWND hwndEdit; -extern HINSTANCE g_hInstance; -extern DWORD dwLastIOError; -extern BOOL bSkipUnicodeDetection; -extern BOOL bLoadASCIIasUTF8; -extern BOOL bLoadNFOasOEM; -extern int fNoFileVariables; -extern BOOL bNoEncodingTags; -extern BOOL bFixLineEndings; -extern BOOL bAutoStripBlanks; -extern WCHAR szCurFile[MAX_PATH+40]; - - -//============================================================================= -// -// MsgBox() -// -int MsgBox(int iType,UINT uIdMsg,...) -{ - - WCHAR szText [1024]; - WCHAR szBuf [1024]; - WCHAR szTitle[64]; - int iIcon = 0; - HWND hwnd; - - if (!GetString(uIdMsg,szBuf,COUNTOF(szBuf))) - return(0); - - wvsprintf(szText,szBuf,(LPVOID)((PUINT_PTR)&uIdMsg + 1)); - - if (uIdMsg == IDS_ERR_LOADFILE || uIdMsg == IDS_ERR_SAVEFILE || - uIdMsg == IDS_CREATEINI_FAIL || uIdMsg == IDS_WRITEINI_FAIL || - uIdMsg == IDS_EXPORT_FAIL) { - LPVOID lpMsgBuf; - WCHAR wcht; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - dwLastIOError, - MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, - NULL); - StrTrim(lpMsgBuf,L" \a\b\f\n\r\t\v"); - StrCatBuff(szText,L"\n",COUNTOF(szText)); - StrCatBuff(szText,lpMsgBuf,COUNTOF(szText)); - LocalFree(lpMsgBuf); - wcht = *CharPrev(szText,StrEnd(szText)); - if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'') - StrCatBuff(szText,L".",COUNTOF(szText)); - } - - GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle)); - - switch (iType) { - case MBINFO: iIcon = MB_ICONINFORMATION; break; - case MBWARN: iIcon = MB_ICONEXCLAMATION; break; - case MBYESNO: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break; - case MBYESNOCANCEL: iIcon = MB_ICONEXCLAMATION | MB_YESNOCANCEL; break; - case MBYESNOWARN: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break; - case MBOKCANCEL: iIcon = MB_ICONEXCLAMATION | MB_OKCANCEL; break; - } - - if (!(hwnd = GetFocus())) - hwnd = hwndMain; - - return MessageBoxEx(hwnd, - szText,szTitle, - MB_SETFOREGROUND | iIcon, - MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT)); - -} - - -//============================================================================= -// -// DisplayCmdLineHelp() -// -void DisplayCmdLineHelp(HWND hwnd) -{ - MSGBOXPARAMS mbp; - - WCHAR szTitle[32]; - WCHAR szText[2048]; - - GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle)); - GetString(IDS_CMDLINEHELP,szText,COUNTOF(szText)); - - mbp.cbSize = sizeof(MSGBOXPARAMS); - mbp.hwndOwner = hwnd; - mbp.hInstance = g_hInstance; - mbp.lpszText = szText; - mbp.lpszCaption = szTitle; - mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND; - mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND); - mbp.dwContextHelpId = 0; - mbp.lpfnMsgBoxCallback = NULL; - mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL); - - MessageBoxIndirect(&mbp); -} - - -//============================================================================= -// -// BFFCallBack() -// -int CALLBACK BFFCallBack(HWND hwnd,UINT umsg,LPARAM lParam,LPARAM lpData) -{ - if (umsg == BFFM_INITIALIZED) - SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); - - return(0); - - lParam; -} - - -//============================================================================= -// -// GetDirectory() -// -BOOL GetDirectory(HWND hwndParent,int iTitle,LPWSTR pszFolder,LPCWSTR pszBase,BOOL bNewDialogStyle) -{ - - BROWSEINFO bi; - LPITEMIDLIST pidl; - WCHAR szTitle[256]; - WCHAR szBase[MAX_PATH]; - BOOL fOk = FALSE; - - lstrcpy(szTitle,L""); - GetString(iTitle,szTitle,COUNTOF(szTitle)); - - if (!pszBase || !*pszBase) - GetCurrentDirectory(MAX_PATH,szBase); - else - lstrcpy(szBase,pszBase); - - bi.hwndOwner = hwndParent; - bi.pidlRoot = NULL; - bi.pszDisplayName = pszFolder; - bi.lpszTitle = szTitle; - bi.ulFlags = BIF_RETURNONLYFSDIRS; - if (bNewDialogStyle) - bi.ulFlags |= BIF_NEWDIALOGSTYLE; - bi.lpfn = &BFFCallBack; - bi.lParam = (LPARAM)szBase; - bi.iImage = 0; - - pidl = SHBrowseForFolder(&bi); - if (pidl) { - SHGetPathFromIDList(pidl,pszFolder); - CoTaskMemFree(pidl); - fOk = TRUE; - } - - return fOk; - -} - - -//============================================================================= -// -// AboutDlgProc() -// -INT_PTR CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static HFONT hFontTitle; - - switch(umsg) - { - case WM_INITDIALOG: - { - WCHAR wch[256]; - LOGFONT lf; - - SetDlgItemText(hwnd,IDC_VERSION,VERSION_FILEVERSION_LONG); - SetDlgItemText(hwnd,IDC_COPYRIGHT,VERSION_LEGALCOPYRIGHT_SHORT); - SetDlgItemText(hwnd,IDC_AUTHORNAME,VERSION_AUTHORNAME); - SetDlgItemText(hwnd,IDC_COMPILER,VERSION_COMPILER); - - if (hFontTitle) - DeleteObject(hFontTitle); - - if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_VERSION,WM_GETFONT,0,0))) - hFontTitle = GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFontTitle,sizeof(LOGFONT),&lf); - lf.lfWeight = FW_BOLD; - hFontTitle = CreateFontIndirect(&lf); - SendDlgItemMessage(hwnd,IDC_VERSION,WM_SETFONT,(WPARAM)hFontTitle,TRUE); - - if (GetDlgItem(hwnd,IDC_WEBPAGE) == NULL) { - SetDlgItemText(hwnd,IDC_WEBPAGE2,VERSION_WEBPAGEDISPLAY); - ShowWindow(GetDlgItem(hwnd,IDC_WEBPAGE2),SW_SHOWNORMAL); - } - else { - wsprintf(wch,L"%s",VERSION_WEBPAGEDISPLAY); - SetDlgItemText(hwnd,IDC_WEBPAGE,wch); - } - - if (GetDlgItem(hwnd,IDC_EMAIL) == NULL) { - SetDlgItemText(hwnd,IDC_EMAIL2,VERSION_EMAILDISPLAY); - ShowWindow(GetDlgItem(hwnd,IDC_EMAIL2),SW_SHOWNORMAL); - } - else { - wsprintf(wch,L"%s",VERSION_EMAILDISPLAY); - SetDlgItemText(hwnd,IDC_EMAIL,wch); - } - - if (GetDlgItem(hwnd,IDC_MOD_PAGE) == NULL) { - SetDlgItemText(hwnd,IDC_MOD_PAGE,VERSION_MODPAGEDISPLAY); - ShowWindow(GetDlgItem(hwnd,IDC_MOD_PAGE2),SW_SHOWNORMAL); - } - else { - wsprintf(wch,L"%s",VERSION_MODPAGEDISPLAY); - SetDlgItemText(hwnd,IDC_MOD_PAGE,wch); - } - - CenterDlgInParent(hwnd); - } - return TRUE; - - case WM_NOTIFY: - { - LPNMHDR pnmhdr = (LPNMHDR)lParam; - switch (pnmhdr->code) { - - case NM_CLICK: - case NM_RETURN: - { - if (pnmhdr->idFrom == IDC_WEBPAGE) { - ShellExecute(hwnd,L"open",L"http://www.flos-freeware.ch",NULL,NULL,SW_SHOWNORMAL); - } - else if (pnmhdr->idFrom == IDC_EMAIL) { - ShellExecute(hwnd,L"open",L"mailto:florian.balmer@gmail.com",NULL,NULL,SW_SHOWNORMAL); - } - else if (pnmhdr->idFrom == IDC_MOD_PAGE) { - ShellExecute(hwnd,L"open",L"https://xhmikosr.github.io/notepad2-mod/",NULL,NULL,SW_SHOWNORMAL); - } - } - break; - } - } - break; - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - EndDialog(hwnd,IDOK); - break; - } - return TRUE; - } - return FALSE; -} - - - -//============================================================================= -// -// RunDlgProc() -// -INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - MakeBitmapButton(hwnd,IDC_SEARCHEXE,g_hInstance,IDB_OPEN); - - SendDlgItemMessage(hwnd,IDC_COMMANDLINE,EM_LIMITTEXT,MAX_PATH - 1,0); - SetDlgItemText(hwnd,IDC_COMMANDLINE,(LPCWSTR)lParam); - SHAutoComplete(GetDlgItem(hwnd,IDC_COMMANDLINE),SHACF_FILESYSTEM); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - DeleteBitmapButton(hwnd,IDC_SEARCHEXE); - return FALSE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_SEARCHEXE: - { - WCHAR szArgs[MAX_PATH]; - WCHAR szArg2[MAX_PATH]; - WCHAR szFile[MAX_PATH * 2]; - WCHAR szFilter[256]; - OPENFILENAME ofn; - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - - GetDlgItemText(hwnd,IDC_COMMANDLINE,szArgs,COUNTOF(szArgs)); - ExpandEnvironmentStringsEx(szArgs,COUNTOF(szArgs)); - ExtractFirstArgument(szArgs,szFile,szArg2); - - GetString(IDS_FILTER_EXE,szFilter,COUNTOF(szFilter)); - PrepareFilterStr(szFilter); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile = szFile; - ofn.nMaxFile = COUNTOF(szFile); - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT - | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS; - - if (GetOpenFileName(&ofn)) { - PathQuoteSpaces(szFile); - if (lstrlen(szArg2)) - { - lstrcat(szFile,L" "); - lstrcat(szFile,szArg2); - } - SetDlgItemText(hwnd,IDC_COMMANDLINE,szFile); - } - - PostMessage(hwnd,WM_NEXTDLGCTL,1,0); - } - break; - - - case IDC_COMMANDLINE: - { - BOOL bEnableOK = FALSE; - WCHAR args[MAX_PATH]; - - if (GetDlgItemText(hwnd,IDC_COMMANDLINE,args,MAX_PATH)) - if (ExtractFirstArgument(args,args,NULL)) - if (lstrlen(args)) - bEnableOK = TRUE; - - EnableWindow(GetDlgItem(hwnd,IDOK),bEnableOK); - } - break; - - - case IDOK: - { - WCHAR arg1[MAX_PATH]; - WCHAR arg2[MAX_PATH]; - SHELLEXECUTEINFO sei; - WCHAR wchDirectory[MAX_PATH] = L""; - - if (GetDlgItemText(hwnd,IDC_COMMANDLINE,arg1,MAX_PATH)) - { - BOOL bQuickExit = FALSE; - - ExpandEnvironmentStringsEx(arg1,COUNTOF(arg1)); - ExtractFirstArgument(arg1,arg1,arg2); - - if (lstrcmpi(arg1,L"notepad2") == 0 || - lstrcmpi(arg1,L"notepad2.exe") == 0) { - GetModuleFileName(NULL,arg1,COUNTOF(arg1)); - bQuickExit = TRUE; - } - - if (lstrlen(szCurFile)) { - lstrcpy(wchDirectory,szCurFile); - PathRemoveFileSpec(wchDirectory); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = 0; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = arg1; - sei.lpParameters = arg2; - sei.lpDirectory = wchDirectory; - sei.nShow = SW_SHOWNORMAL; - - if (bQuickExit) { - sei.fMask |= /*SEE_MASK_NOZONECHECKS*/0x00800000; - EndDialog(hwnd,IDOK); - ShellExecuteEx(&sei); - } - - else { - - if (ShellExecuteEx(&sei)) - EndDialog(hwnd,IDOK); - - else - PostMessage(hwnd,WM_NEXTDLGCTL, - (WPARAM)(GetDlgItem(hwnd,IDC_COMMANDLINE)),1); - } - } - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// RunDlg() -// -void RunDlg(HWND hwnd,LPCWSTR lpstrDefault) -{ - - ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_RUN), - hwnd,RunDlgProc,(LPARAM)lpstrDefault); - -} - - -//============================================================================= -// -// OpenWithDlgProc() -// -extern WCHAR tchOpenWithDir[MAX_PATH]; -extern int flagNoFadeHidden; - -extern int cxOpenWithDlg; -extern int cyOpenWithDlg; - -INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - - ResizeDlg_Init(hwnd,cxOpenWithDlg,cyOpenWithDlg,IDC_RESIZEGRIP3); - - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - - //SetExplorerTheme(GetDlgItem(hwnd,IDC_OPENWITHDIR)); - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_OPENWITHDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); - ListView_InsertColumn(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,&lvc); - DirList_Init(GetDlgItem(hwnd,IDC_OPENWITHDIR),NULL); - DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); - DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); - ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - - MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,g_hInstance,IDB_OPEN); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - DirList_Destroy(GetDlgItem(hwnd,IDC_OPENWITHDIR)); - DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR); - - ResizeDlg_Destroy(hwnd,&cxOpenWithDlg,&cyOpenWithDlg); - return FALSE; - - - case WM_SIZE: - { - int dx; - int dy; - HDWP hdwp; - - ResizeDlg_Size(hwnd,lParam,&dx,&dy); - - hdwp = BeginDeferWindowPos(6); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDIR,dx,dy,SWP_NOMOVE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETOPENWITHDIR,0,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDESCR,0,dy,SWP_NOSIZE); - EndDeferWindowPos(hdwp); - - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVSCW_AUTOSIZE_USEHEADER); - } - return TRUE; - - - case WM_GETMINMAXINFO: - ResizeDlg_GetMinMaxInfo(hwnd,lParam); - return TRUE; - - - case WM_NOTIFY: - { - LPNMHDR pnmh = (LPNMHDR)lParam; - - if (pnmh->idFrom == IDC_OPENWITHDIR) - { - switch(pnmh->code) - { - case LVN_GETDISPINFO: - DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden); - break; - - case LVN_DELETEITEM: - DirList_DeleteItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam); - break; - - case LVN_ITEMCHANGED: { - NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam; - EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED)); - } - break; - - case NM_DBLCLK: - if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_OPENWITHDIR))) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - } - } - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_GETOPENWITHDIR: - { - if (GetDirectory(hwnd,IDS_OPENWITH,tchOpenWithDir,tchOpenWithDir,TRUE)) - { - DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); - DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); - ListView_EnsureVisible(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,FALSE); - ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_OPENWITHDIR)),1); - } - break; - - - case IDOK: { - LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER); - lpdli->mask = DLI_FILENAME | DLI_TYPE; - lpdli->ntype = DLE_NONE; - DirList_GetItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),(-1),lpdli); - - if (lpdli->ntype != DLE_NONE) - EndDialog(hwnd,IDOK); - else - MessageBeep(0); - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// OpenWithDlg() -// -BOOL OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile) -{ - - DLITEM dliOpenWith; - dliOpenWith.mask = DLI_FILENAME; - - if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_OPENWITH), - hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith)) - { - SHELLEXECUTEINFO sei; - WCHAR szParam[MAX_PATH]; - WCHAR wchDirectory[MAX_PATH] = L""; - - if (lstrlen(szCurFile)) { - lstrcpy(wchDirectory,szCurFile); - PathRemoveFileSpec(wchDirectory); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = 0; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = dliOpenWith.szFileName; - sei.lpParameters = szParam; - sei.lpDirectory = wchDirectory; - sei.nShow = SW_SHOWNORMAL; - - // resolve links and get short path name - if (!(PathIsLnkFile(lpstrFile) && PathGetLnkPath(lpstrFile,szParam,COUNTOF(szParam)))) - lstrcpy(szParam,lpstrFile); - //GetShortPathName(szParam,szParam,sizeof(WCHAR)*COUNTOF(szParam)); - PathQuoteSpaces(szParam); - - ShellExecuteEx(&sei); - - return(TRUE); - } - - return(FALSE); - -} - - -//============================================================================= -// -// FavoritesDlgProc() -// -extern WCHAR tchFavoritesDir[MAX_PATH]; -//extern int flagNoFadeHidden; - -extern int cxFavoritesDlg; -extern int cyFavoritesDlg; - -INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static HWND hwndLV; - - switch(umsg) - { - - case WM_INITDIALOG: - { - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - - ResizeDlg_Init(hwnd,cxFavoritesDlg,cyFavoritesDlg,IDC_RESIZEGRIP3); - - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - - //SetExplorerTheme(GetDlgItem(hwnd,IDC_FAVORITESDIR)); - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FAVORITESDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); - ListView_InsertColumn(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,&lvc); - DirList_Init(GetDlgItem(hwnd,IDC_FAVORITESDIR),NULL); - DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); - DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); - ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - - MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,g_hInstance,IDB_OPEN); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - DirList_Destroy(GetDlgItem(hwnd,IDC_FAVORITESDIR)); - DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR); - - ResizeDlg_Destroy(hwnd,&cxFavoritesDlg,&cyFavoritesDlg); - return FALSE; - - - case WM_SIZE: - { - int dx; - int dy; - HDWP hdwp; - - ResizeDlg_Size(hwnd,lParam,&dx,&dy); - - hdwp = BeginDeferWindowPos(6); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDIR,dx,dy,SWP_NOMOVE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETFAVORITESDIR,0,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDESCR,0,dy,SWP_NOSIZE); - EndDeferWindowPos(hdwp); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVSCW_AUTOSIZE_USEHEADER); - } - return TRUE; - - - case WM_GETMINMAXINFO: - ResizeDlg_GetMinMaxInfo(hwnd,lParam); - return TRUE; - - - case WM_NOTIFY: - { - LPNMHDR pnmh = (LPNMHDR)lParam; - - if (pnmh->idFrom == IDC_FAVORITESDIR) - { - switch(pnmh->code) - { - case LVN_GETDISPINFO: - DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden); - break; - - case LVN_DELETEITEM: - DirList_DeleteItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),lParam); - break; - - case LVN_ITEMCHANGED: { - NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam; - EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED)); - } - break; - - case NM_DBLCLK: - if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FAVORITESDIR))) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - } - } - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_GETFAVORITESDIR: - { - if (GetDirectory(hwnd,IDS_FAVORITES,tchFavoritesDir,tchFavoritesDir,TRUE)) - { - DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); - DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); - ListView_EnsureVisible(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,FALSE); - ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_FAVORITESDIR)),1); - } - break; - - - case IDOK: { - LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER); - lpdli->mask = DLI_FILENAME | DLI_TYPE; - lpdli->ntype = DLE_NONE; - DirList_GetItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),(-1),lpdli); - - if (lpdli->ntype != DLE_NONE) - EndDialog(hwnd,IDOK); - else - MessageBeep(0); - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// FavoritesDlg() -// -BOOL FavoritesDlg(HWND hwnd,LPWSTR lpstrFile) -{ - - DLITEM dliFavorite; - dliFavorite.mask = DLI_FILENAME; - - if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FAVORITES), - hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite)) - { - lstrcpyn(lpstrFile,dliFavorite.szFileName,MAX_PATH); - return(TRUE); - } - - return(FALSE); - -} - - -//============================================================================= -// -// AddToFavDlgProc() -// -// Controls: 100 Edit -// -INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - WCHAR *pszName; - - case WM_INITDIALOG: - pszName = (LPWSTR)lParam; - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)pszName); - - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,MAX_PATH-1,0); - SetDlgItemText(hwnd,100,pszName); - - CenterDlgInParent(hwnd); - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case 100: - EnableWindow(GetDlgItem(hwnd,IDOK), - GetWindowTextLength(GetDlgItem(hwnd,100))); - break; - - - case IDOK: - pszName = (LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER); - GetDlgItemText(hwnd,100,pszName, - MAX_PATH-1); - EndDialog(hwnd,IDOK); - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// AddToFavDlg() -// -BOOL AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget) -{ - - INT_PTR iResult; - - WCHAR pszName[MAX_PATH]; - lstrcpy(pszName,lpszName); - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(IDD_ADDTOFAV), - hwnd, - AddToFavDlgProc,(LPARAM)pszName); - - if (iResult == IDOK) - { - if (!PathCreateFavLnk(pszName,lpszTarget,tchFavoritesDir)) { - MsgBox(MBWARN,IDS_FAV_FAILURE); - return FALSE; - } - - else { - MsgBox(MBINFO,IDS_FAV_SUCCESS); - return TRUE; - } - } - - else - return FALSE; - -} - - -//============================================================================= -// -// FileMRUDlgProc() -// -// -extern LPMRULIST pFileMRU; -extern BOOL bSaveRecentFiles; -extern int cxFileMRUDlg; -extern int cyFileMRUDlg; -extern int flagNoFadeHidden; - -typedef struct tagIconThreadInfo -{ - HWND hwnd; // HWND of ListView Control - HANDLE hExitThread; // Flag is set when Icon Thread should terminate - HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated - -} ICONTHREADINFO, *LPICONTHREADINFO; - -DWORD WINAPI FileMRUIconThread(LPVOID lpParam) { - - HWND hwnd; - LPICONTHREADINFO lpit; - LV_ITEM lvi; - WCHAR tch[MAX_PATH]; - SHFILEINFO shfi; - DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED; - DWORD dwAttr = 0; - int iItem = 0; - int iMaxItem; - - lpit = (LPICONTHREADINFO)lpParam; - ResetEvent(lpit->hTerminatedThread); - - hwnd = lpit->hwnd; - iMaxItem = ListView_GetItemCount(hwnd); - - CoInitialize(NULL); - - ZeroMemory(&lvi,sizeof(LV_ITEM)); - - while (iItem < iMaxItem && WaitForSingleObject(lpit->hExitThread,0) != WAIT_OBJECT_0) { - - lvi.mask = LVIF_TEXT; - lvi.pszText = tch; - lvi.cchTextMax = COUNTOF(tch); - lvi.iItem = iItem; - if (ListView_GetItem(hwnd,&lvi)) { - - if (PathIsUNC(tch) || !PathFileExists(tch)) { - dwFlags |= SHGFI_USEFILEATTRIBUTES; - dwAttr = FILE_ATTRIBUTE_NORMAL; - shfi.dwAttributes = 0; - SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); - } - - else { - shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE; - SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); - } - - lvi.mask = LVIF_IMAGE; - lvi.iImage = shfi.iIcon; - lvi.stateMask = 0; - lvi.state = 0; - - if (shfi.dwAttributes & SFGAO_LINK) { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_OVERLAYMASK; - lvi.state |= INDEXTOOVERLAYMASK(2); - } - - if (shfi.dwAttributes & SFGAO_SHARE) { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_OVERLAYMASK; - lvi.state |= INDEXTOOVERLAYMASK(1); - } - - if (PathIsUNC(tch)) - dwAttr = FILE_ATTRIBUTE_NORMAL; - else - dwAttr = GetFileAttributes(tch); - - if (!flagNoFadeHidden && - dwAttr != INVALID_FILE_ATTRIBUTES && - dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_CUT; - lvi.state |= LVIS_CUT; - } - - lvi.iSubItem = 0; - ListView_SetItem(hwnd,&lvi); - } - iItem++; - } - - CoUninitialize(); - - SetEvent(lpit->hTerminatedThread); - ExitThread(0); - return(0); -} - -INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - SHFILEINFO shfi; - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - - LPICONTHREADINFO lpit = (LPVOID)GlobalAlloc(GPTR,sizeof(ICONTHREADINFO)); - SetProp(hwnd,L"it",(HANDLE)lpit); - lpit->hwnd = GetDlgItem(hwnd,IDC_FILEMRU); - lpit->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL); - lpit->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL); - - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - - ResizeDlg_Init(hwnd,cxFileMRUDlg,cyFileMRUDlg,IDC_RESIZEGRIP); - - ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), - LVSIL_SMALL); - - ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), - LVSIL_NORMAL); - - //SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU)); - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FILEMRU),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); - ListView_InsertColumn(GetDlgItem(hwnd,IDC_FILEMRU),0,&lvc); - - // Update view - SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0); - - if (bSaveRecentFiles) - CheckDlgButton(hwnd,IDC_SAVEMRU,BST_CHECKED); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - { - LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it"); - SetEvent(lpit->hExitThread); - while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) { - MSG msg; - if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - CloseHandle(lpit->hExitThread); - CloseHandle(lpit->hTerminatedThread); - RemoveProp(hwnd,L"it"); - GlobalFree(lpit); - - bSaveRecentFiles = (IsDlgButtonChecked(hwnd,IDC_SAVEMRU)) ? 1 : 0; - - ResizeDlg_Destroy(hwnd,&cxFileMRUDlg,&cyFileMRUDlg); - } - return FALSE; - - - case WM_SIZE: - { - int dx; - int dy; - HDWP hdwp; - - ResizeDlg_Size(hwnd,lParam,&dx,&dy); - - hdwp = BeginDeferWindowPos(5); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_FILEMRU,dx,dy,SWP_NOMOVE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_SAVEMRU,0,dy,SWP_NOSIZE); - EndDeferWindowPos(hdwp); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER); - } - return TRUE; - - - case WM_GETMINMAXINFO: - ResizeDlg_GetMinMaxInfo(hwnd,lParam); - return TRUE; - - - case WM_NOTIFY: { - if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) { - - switch (((LPNMHDR)(lParam))->code) { - - case NM_DBLCLK: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - - - case LVN_GETDISPINFO: { - /* - LV_DISPINFO *lpdi = (LPVOID)lParam; - - if (lpdi->item.mask & LVIF_IMAGE) { - - WCHAR tch[MAX_PATH]; - LV_ITEM lvi; - SHFILEINFO shfi; - DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED; - DWORD dwAttr = 0; - - ZeroMemory(&lvi,sizeof(LV_ITEM)); - - lvi.mask = LVIF_TEXT; - lvi.pszText = tch; - lvi.cchTextMax = COUNTOF(tch); - lvi.iItem = lpdi->item.iItem; - - ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); - - if (!PathFileExists(tch)) { - dwFlags |= SHGFI_USEFILEATTRIBUTES; - dwAttr = FILE_ATTRIBUTE_NORMAL; - shfi.dwAttributes = 0; - SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); - } - - else { - shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE; - SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); - } - - lpdi->item.iImage = shfi.iIcon; - lpdi->item.mask |= LVIF_DI_SETITEM; - - lpdi->item.stateMask = 0; - lpdi->item.state = 0; - - if (shfi.dwAttributes & SFGAO_LINK) { - lpdi->item.mask |= LVIF_STATE; - lpdi->item.stateMask |= LVIS_OVERLAYMASK; - lpdi->item.state |= INDEXTOOVERLAYMASK(2); - } - - if (shfi.dwAttributes & SFGAO_SHARE) { - lpdi->item.mask |= LVIF_STATE; - lpdi->item.stateMask |= LVIS_OVERLAYMASK; - lpdi->item.state |= INDEXTOOVERLAYMASK(1); - } - - dwAttr = GetFileAttributes(tch); - - if (!flagNoFadeHidden && - dwAttr != INVALID_FILE_ATTRIBUTES && - dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { - lpdi->item.mask |= LVIF_STATE; - lpdi->item.stateMask |= LVIS_CUT; - lpdi->item.state |= LVIS_CUT; - } - } - */ - } - break; - - - case LVN_ITEMCHANGED: - case LVN_DELETEITEM: - EnableWindow(GetDlgItem(hwnd,IDOK),ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))); - break; - } - } - } - - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case 0x00A0: - { - int i; - WCHAR tch[MAX_PATH]; - LV_ITEM lvi; - SHFILEINFO shfi; - - DWORD dwtid; - LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it"); - - SetEvent(lpit->hExitThread); - while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) { - MSG msg; - if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - ResetEvent(lpit->hExitThread); - SetEvent(lpit->hTerminatedThread); - - ListView_DeleteAllItems(GetDlgItem(hwnd,IDC_FILEMRU)); - - ZeroMemory(&lvi,sizeof(LV_ITEM)); - lvi.mask = LVIF_TEXT | LVIF_IMAGE; - - SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), - SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - lvi.iImage = shfi.iIcon; - - for (i = 0; i < MRU_Enum(pFileMRU,0,NULL,0); i++) { - MRU_Enum(pFileMRU,i,tch,COUNTOF(tch)); - PathAbsoluteFromApp(tch,NULL,0,TRUE); - // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); } - // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,FALSE); - lvi.iItem = i; - lvi.pszText = tch; - ListView_InsertItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); - } - - ListView_SetItemState(GetDlgItem(hwnd,IDC_FILEMRU),0,LVIS_FOCUSED,LVIS_FOCUSED); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER); - - CreateThread(NULL,0,FileMRUIconThread,(LPVOID)lpit,0,&dwtid); - } - break; - - case IDC_FILEMRU: - break; - - - case IDOK: - { - WCHAR tch[MAX_PATH]; - //int iItem; - - //if ((iItem = SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETCURSEL,0,0)) != LB_ERR) - if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))) - { - //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETTEXT,(WPARAM)iItem,(LPARAM)tch); - LV_ITEM lvi; - ZeroMemory(&lvi,sizeof(LV_ITEM)); - - lvi.mask = LVIF_TEXT; - lvi.pszText = tch; - lvi.cchTextMax = COUNTOF(tch); - lvi.iItem = ListView_GetNextItem(GetDlgItem(hwnd,IDC_FILEMRU),-1,LVNI_ALL | LVNI_SELECTED); - - ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); - - PathUnquoteSpaces(tch); - - if (!PathFileExists(tch)) { - - // Ask... - if (IDYES == MsgBox(MBYESNO,IDS_ERR_MRUDLG)) { - - MRU_Delete(pFileMRU,lvi.iItem); - MRU_DeleteFileFromStore(pFileMRU,tch); - - //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0); - //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem); - // must use IDM_VIEW_REFRESH, index might change... - SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0); - - //EnableWindow(GetDlgItem(hwnd,IDOK), - // (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0))); - - EnableWindow(GetDlgItem(hwnd,IDOK), - ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))); - } - } - - else { - lstrcpy((LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER),tch); - EndDialog(hwnd,IDOK); - } - } - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// FileMRUDlg() -// -// -BOOL FileMRUDlg(HWND hwnd,LPWSTR lpstrFile) -{ - - if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FILEMRU), - hwnd,FileMRUDlgProc,(LPARAM)lpstrFile)) - return TRUE; - else - return FALSE; - -} - - -//============================================================================= -// -// ChangeNotifyDlgProc() -// -// Controls: 100 Radio Button -// 101 Radio Button -// 102 Radio Button -// 103 Check Box -// -extern int iFileWatchingMode; -extern BOOL bResetFileWatching; - -INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - switch(umsg) - { - case WM_INITDIALOG: - CheckRadioButton(hwnd,100,102,100+iFileWatchingMode); - if (bResetFileWatching) - CheckDlgButton(hwnd,103,BST_CHECKED); - CenterDlgInParent(hwnd); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - if (IsDlgButtonChecked(hwnd,100) == BST_CHECKED) - iFileWatchingMode = 0; - else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) - iFileWatchingMode = 1; - else - iFileWatchingMode = 2; - bResetFileWatching = (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) ? TRUE : FALSE; - EndDialog(hwnd,IDOK); - break; - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// ChangeNotifyDlg() -// -BOOL ChangeNotifyDlg(HWND hwnd) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_CHANGENOTIFY), - hwnd, - ChangeNotifyDlgProc, - 0); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// ColumnWrapDlgProc() -// -// Controls: 100 Edit -// -INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static int *piNumber; - - switch(umsg) - { - - case WM_INITDIALOG: - { - - piNumber = (int*)lParam; - - SetDlgItemInt(hwnd,100,*piNumber,FALSE); - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); - - CenterDlgInParent(hwnd); - - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: { - - BOOL fTranslated; - - int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE); - - if (fTranslated) - { - *piNumber = iNewNumber; - - EndDialog(hwnd,IDOK); - } - - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1); - - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// ColumnWrapDlg() -// -BOOL ColumnWrapDlg(HWND hwnd,UINT uidDlg,int *iNumber) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(uidDlg), - hwnd, - ColumnWrapDlgProc,(LPARAM)iNumber); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// WordWrapSettingsDlgProc() -// -// Controls: 100 Combo -// 101 Combo -// 102 Combo -// 103 Combo -// 200 Text -// 201 Text -// 202 Text -// 203 Text -// -extern int iWordWrapMode; -extern int iWordWrapIndent; -extern int iWordWrapSymbols; -extern BOOL bShowWordWrapSymbols; - -INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - - WCHAR tch[512]; - WCHAR *p1, *p2; - int i; - - for (i = 0; i < 4; i++) { - GetDlgItemText(hwnd,200+i,tch,COUNTOF(tch)); - lstrcat(tch,L"|"); - p1 = tch; - while (p2 = StrChr(p1,L'|')) { - *p2++ = L'\0'; - if (*p1) - SendDlgItemMessage(hwnd,100+i,CB_ADDSTRING,0,(LPARAM)p1); - p1 = p2; - } - - SendDlgItemMessage(hwnd,100+i,CB_SETEXTENDEDUI,TRUE,0); - } - - SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)iWordWrapIndent,0); - SendDlgItemMessage(hwnd,101,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? iWordWrapSymbols%10 : 0,0); - SendDlgItemMessage(hwnd,102,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? ((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10 : 0,0); - SendDlgItemMessage(hwnd,103,CB_SETCURSEL,(WPARAM)iWordWrapMode,0); - - CenterDlgInParent(hwnd); - - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: { - - int iSel, iSel2; - - iSel = (int)SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0); - iWordWrapIndent = iSel; - - bShowWordWrapSymbols = FALSE; - iSel = (int)SendDlgItemMessage(hwnd,101,CB_GETCURSEL,0,0); - iSel2 = (int)SendDlgItemMessage(hwnd,102,CB_GETCURSEL,0,0); - if (iSel > 0 || iSel2 > 0) { - bShowWordWrapSymbols = TRUE; - iWordWrapSymbols = iSel + iSel2*10; - } - - iSel = (int)SendDlgItemMessage(hwnd,103,CB_GETCURSEL,0,0); - iWordWrapMode = iSel; - - EndDialog(hwnd,IDOK); - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// WordWrapSettingsDlg() -// -BOOL WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(uidDlg), - hwnd, - WordWrapSettingsDlgProc,(LPARAM)iNumber); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// LongLineSettingsDlgProc() -// -// Controls: 100 Edit -// 101 Radio1 -// 102 Radio2 -// -extern int iLongLineMode; - -INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static int *piNumber; - - switch(umsg) - { - - case WM_INITDIALOG: - { - - piNumber = (int*)lParam; - - SetDlgItemInt(hwnd,100,*piNumber,FALSE); - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); - - if (iLongLineMode == EDGE_LINE) - CheckRadioButton(hwnd,101,102,101); - else - CheckRadioButton(hwnd,101,102,102); - - CenterDlgInParent(hwnd); - - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: { - - BOOL fTranslated; - - int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE); - - if (fTranslated) - { - *piNumber = iNewNumber; - - iLongLineMode = (IsDlgButtonChecked(hwnd,101)) ? EDGE_LINE : EDGE_BACKGROUND; - - EndDialog(hwnd,IDOK); - } - - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1); - - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// LongLineSettingsDlg() -// -BOOL LongLineSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(uidDlg), - hwnd, - LongLineSettingsDlgProc,(LPARAM)iNumber); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// TabSettingsDlgProc() -// -// Controls: 100 Edit -// 101 Edit -// 102 Check -// 103 Check -// 104 Check -// -extern int iTabWidth; -extern int iIndentWidth; -extern BOOL bTabsAsSpaces; -extern BOOL bTabIndents; -extern BOOL bBackspaceUnindents; - -INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - - SetDlgItemInt(hwnd,100,iTabWidth,FALSE); - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); - - SetDlgItemInt(hwnd,101,iIndentWidth,FALSE); - SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,15,0); - - if (bTabsAsSpaces) - CheckDlgButton(hwnd,102,BST_CHECKED); - - if (bTabIndents) - CheckDlgButton(hwnd,103,BST_CHECKED); - - if (bBackspaceUnindents) - CheckDlgButton(hwnd,104,BST_CHECKED); - - CenterDlgInParent(hwnd); - - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: { - - BOOL fTranslated1,fTranslated2; - - int iNewTabWidth = GetDlgItemInt(hwnd,100,&fTranslated1,FALSE); - int iNewIndentWidth = GetDlgItemInt(hwnd,101,&fTranslated2,FALSE); - - if (fTranslated1 && fTranslated2) - { - iTabWidth = iNewTabWidth; - iIndentWidth = iNewIndentWidth; - - bTabsAsSpaces = (IsDlgButtonChecked(hwnd,102)) ? TRUE : FALSE; - - bTabIndents = (IsDlgButtonChecked(hwnd,103)) ? TRUE : FALSE; - - bBackspaceUnindents = (IsDlgButtonChecked(hwnd,104)) ? TRUE : FALSE; - - EndDialog(hwnd,IDOK); - } - - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(fTranslated1) ? 101 : 100)),1); - - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// TabSettingsDlg() -// -BOOL TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(uidDlg), - hwnd, - TabSettingsDlgProc,(LPARAM)iNumber); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// SelectDefEncodingDlgProc() -// -// -typedef struct encodedlg { - BOOL bRecodeOnly; - int idEncoding; - int cxDlg; - int cyDlg; -} ENCODEDLG, *PENCODEDLG; - -INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static PENCODEDLG pdd; - - switch(umsg) - { - case WM_INITDIALOG: - { - HBITMAP hbmp; - HIMAGELIST himl; - - pdd = (PENCODEDLG)lParam; - - hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); - DeleteObject(hbmp); - SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CBEM_SETIMAGELIST,0,(LPARAM)himl); - SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CB_SETEXTENDEDUI,TRUE,0); - - Encoding_AddToComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),pdd->idEncoding,0); - - if (bSkipUnicodeDetection) - CheckDlgButton(hwnd,IDC_NOUNICODEDETECTION,BST_CHECKED); - - if (bLoadASCIIasUTF8) - CheckDlgButton(hwnd,IDC_ASCIIASUTF8,BST_CHECKED); - - if (bLoadNFOasOEM) - CheckDlgButton(hwnd,IDC_NFOASOEM,BST_CHECKED); - - if (bNoEncodingTags) - CheckDlgButton(hwnd,IDC_ENCODINGFROMFILEVARS,BST_CHECKED); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),&pdd->idEncoding)) { - bSkipUnicodeDetection = (IsDlgButtonChecked(hwnd,IDC_NOUNICODEDETECTION) == BST_CHECKED) ? 1 : 0; - bLoadASCIIasUTF8 = (IsDlgButtonChecked(hwnd,IDC_ASCIIASUTF8) == BST_CHECKED) ? 1 : 0; - bLoadNFOasOEM = (IsDlgButtonChecked(hwnd,IDC_NFOASOEM) == BST_CHECKED) ? 1 : 0; - bNoEncodingTags = (IsDlgButtonChecked(hwnd,IDC_ENCODINGFROMFILEVARS) == BST_CHECKED) ? 1 : 0; - EndDialog(hwnd,IDOK); - } - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1); - } - break; - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// SelectDefEncodingDlg() -// -BOOL SelectDefEncodingDlg(HWND hwnd,int *pidREncoding) -{ - - INT_PTR iResult; - ENCODEDLG dd; - - dd.bRecodeOnly = FALSE; - dd.idEncoding = *pidREncoding; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(IDD_DEFENCODING), - hwnd, - SelectDefEncodingDlgProc, - (LPARAM)&dd); - - if (iResult == IDOK) { - *pidREncoding = dd.idEncoding; - return(TRUE); - } - else - return(FALSE); - -} - - -//============================================================================= -// -// SelectEncodingDlgProc() -// -// -INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static PENCODEDLG pdd; - static HWND hwndLV; - - switch(umsg) - { - - case WM_INITDIALOG: - { - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - HBITMAP hbmp; - HIMAGELIST himl; - - pdd = (PENCODEDLG)lParam; - - ResizeDlg_Init(hwnd,pdd->cxDlg,pdd->cyDlg,IDC_RESIZEGRIP4); - - hwndLV = GetDlgItem(hwnd,IDC_ENCODINGLIST); - - hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); - DeleteObject(hbmp); - ListView_SetImageList(GetDlgItem(hwnd,IDC_ENCODINGLIST),himl,LVSIL_SMALL); - - //SetExplorerTheme(hwndLV); - ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); - ListView_InsertColumn(hwndLV,0,&lvc); - - Encoding_AddToListView(hwndLV,pdd->idEncoding,pdd->bRecodeOnly); - - ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - ResizeDlg_Destroy(hwnd,&pdd->cxDlg,&pdd->cyDlg); - return FALSE; - - - case WM_SIZE: - { - int dx; - int dy; - HDWP hdwp; - - ResizeDlg_Size(hwnd,lParam,&dx,&dy); - - hdwp = BeginDeferWindowPos(4); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP4,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); - hdwp = DeferCtlPos(hdwp,hwnd,IDC_ENCODINGLIST,dx,dy,SWP_NOMOVE); - EndDeferWindowPos(hdwp); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_ENCODINGLIST),0,LVSCW_AUTOSIZE_USEHEADER); - } - return TRUE; - - - case WM_GETMINMAXINFO: - ResizeDlg_GetMinMaxInfo(hwnd,lParam); - return TRUE; - - - case WM_NOTIFY: { - if (((LPNMHDR)(lParam))->idFrom == IDC_ENCODINGLIST) { - - switch (((LPNMHDR)(lParam))->code) { - - case NM_DBLCLK: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - - case LVN_ITEMCHANGED: - case LVN_DELETEITEM: { - int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - EnableWindow(GetDlgItem(hwnd,IDOK),i != -1); - } - break; - } - } - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: - if (Encoding_GetFromListView(hwndLV,&pdd->idEncoding)) - EndDialog(hwnd,IDOK); - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1); - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// SelectEncodingDlg() -// -extern int cxEncodingDlg; -extern int cyEncodingDlg; - -BOOL SelectEncodingDlg(HWND hwnd,int *pidREncoding) -{ - - INT_PTR iResult; - ENCODEDLG dd; - - dd.bRecodeOnly = FALSE; - dd.idEncoding = *pidREncoding; - dd.cxDlg = cxEncodingDlg; - dd.cyDlg = cyEncodingDlg; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(IDD_ENCODING), - hwnd, - SelectEncodingDlgProc, - (LPARAM)&dd); - - cxEncodingDlg = dd.cxDlg; - cyEncodingDlg = dd.cyDlg; - - if (iResult == IDOK) { - *pidREncoding = dd.idEncoding; - return(TRUE); - } - else - return(FALSE); - -} - - -//============================================================================= -// -// RecodeDlg() -// -extern int cxRecodeDlg; -extern int cyRecodeDlg; - -BOOL RecodeDlg(HWND hwnd,int *pidREncoding) -{ - - INT_PTR iResult; - ENCODEDLG dd; - - dd.bRecodeOnly = TRUE; - dd.idEncoding = *pidREncoding; - dd.cxDlg = cxRecodeDlg; - dd.cyDlg = cyRecodeDlg; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(IDD_RECODE), - hwnd, - SelectEncodingDlgProc, - (LPARAM)&dd); - - cxRecodeDlg = dd.cxDlg; - cyRecodeDlg = dd.cyDlg; - - if (iResult == IDOK) { - *pidREncoding = dd.idEncoding; - return(TRUE); - } - else - return(FALSE); - -} - - -//============================================================================= -// -// SelectDefLineEndingDlgProc() -// -// Controls: 100 Combo -// IDC_CONSISTENTEOLS -// IDC_AUTOSTRIPBLANKS -// -INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static int *piOption; - - switch(umsg) - { - case WM_INITDIALOG: - { - int i; - WCHAR wch[128]; - - piOption = (int*)lParam; - - // Load options - for (i = 0; i < 3; i++) { - GetString(IDS_EOLMODENAME0+i,wch,COUNTOF(wch)); - SendDlgItemMessage(hwnd,100,CB_ADDSTRING,0,(LPARAM)wch); - } - - SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)*piOption,0); - SendDlgItemMessage(hwnd,100,CB_SETEXTENDEDUI,TRUE,0); - - if (bFixLineEndings) - CheckDlgButton(hwnd,IDC_CONSISTENTEOLS,BST_CHECKED); - - if (bAutoStripBlanks) - CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, BST_CHECKED); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - *piOption = (int)SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0); - bFixLineEndings = (IsDlgButtonChecked(hwnd,IDC_CONSISTENTEOLS) == BST_CHECKED) ? 1 : 0; - bAutoStripBlanks = (IsDlgButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS) == BST_CHECKED) ? 1 : 0; - EndDialog(hwnd,IDOK); - } - break; - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// SelectDefLineEndingDlg() -// -BOOL SelectDefLineEndingDlg(HWND hwnd,int *iOption) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(IDD_DEFEOLMODE), - hwnd, - SelectDefLineEndingDlgProc, - (LPARAM)iOption); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// InfoBoxDlgProc() -// -// -typedef struct _infobox { - LPWSTR lpstrMessage; - LPWSTR lpstrSetting; - BOOL bDisableCheckBox; -} INFOBOX, *LPINFOBOX; - -INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - LPINFOBOX lpib; - - switch(umsg) - { - case WM_INITDIALOG: - lpib = (LPINFOBOX)lParam; - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - SendDlgItemMessage(hwnd,IDC_INFOBOXICON,STM_SETICON, - (WPARAM)LoadIcon(NULL,IDI_EXCLAMATION),0); - SetDlgItemText(hwnd,IDC_INFOBOXTEXT,lpib->lpstrMessage); - if (lpib->bDisableCheckBox) - EnableWindow(GetDlgItem(hwnd,IDC_INFOBOXCHECK),FALSE); - LocalFree(lpib->lpstrMessage); - CenterDlgInParent(hwnd); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - case IDYES: - case IDNO: - lpib = (LPINFOBOX)GetWindowLongPtr(hwnd,DWLP_USER); - if (IsDlgButtonChecked(hwnd,IDC_INFOBOXCHECK)) - IniSetInt(L"Suppressed Messages",lpib->lpstrSetting,1); - EndDialog(hwnd,LOWORD(wParam)); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// InfoBox() -// -// -extern WCHAR szIniFile[MAX_PATH]; - -INT_PTR InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...) -{ - - HWND hwnd; - int idDlg = IDD_INFOBOX; - INFOBOX ib; - WCHAR wchFormat[512]; - int iMode; - - iMode = IniGetInt(L"Suppressed Messages",lpstrSetting,0); - - if (lstrlen(lpstrSetting) > 0 && iMode == 1) - return (iType == MBYESNO) ? IDYES : IDOK; - - if (!GetString(uidMessage,wchFormat,COUNTOF(wchFormat))) - return(-1); - - ib.lpstrMessage = LocalAlloc(LPTR,1024 * sizeof(WCHAR)); - wvsprintf(ib.lpstrMessage,wchFormat,(LPVOID)((PUINT_PTR)&uidMessage + 1)); - ib.lpstrSetting = (LPWSTR)lpstrSetting; - ib.bDisableCheckBox = (lstrlen(szIniFile) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE; - - if (iType == MBYESNO) - idDlg = IDD_INFOBOX2; - else if (iType == MBOKCANCEL) - idDlg = IDD_INFOBOX3; - - if (!(hwnd = GetFocus())) - hwnd = hwndMain; - - MessageBeep(MB_ICONEXCLAMATION); - - return ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCE(idDlg), - hwnd, - InfoBoxDlgProc, - (LPARAM)&ib); - -} - - - -// End of Dialogs.c +/****************************************************************************** +* +* +* Notepad2 +* +* Dialogs.c +* Notepad2 dialog boxes implementation +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include +#include +#include "scintilla.h" +#include "notepad2.h" +#include "edit.h" +#include "dlapi.h" +#include "dialogs.h" +#include "helpers.h" +#include "resource.h" +#include "version.h" + + +extern HWND hwndMain; +extern HWND hwndEdit; +extern HINSTANCE g_hInstance; +extern DWORD dwLastIOError; +extern BOOL bSkipUnicodeDetection; +extern BOOL bLoadASCIIasUTF8; +extern BOOL bLoadNFOasOEM; +extern int fNoFileVariables; +extern BOOL bNoEncodingTags; +extern BOOL bFixLineEndings; +extern BOOL bAutoStripBlanks; +extern WCHAR szCurFile[MAX_PATH+40]; + + +//============================================================================= +// +// MsgBox() +// +int MsgBox(int iType,UINT uIdMsg,...) +{ + + WCHAR szText [1024]; + WCHAR szBuf [1024]; + WCHAR szTitle[64]; + int iIcon = 0; + HWND hwnd; + + if (!GetString(uIdMsg,szBuf,COUNTOF(szBuf))) + return(0); + + wvsprintf(szText,szBuf,(LPVOID)((PUINT_PTR)&uIdMsg + 1)); + + if (uIdMsg == IDS_ERR_LOADFILE || uIdMsg == IDS_ERR_SAVEFILE || + uIdMsg == IDS_CREATEINI_FAIL || uIdMsg == IDS_WRITEINI_FAIL || + uIdMsg == IDS_EXPORT_FAIL) { + LPVOID lpMsgBuf; + WCHAR wcht; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dwLastIOError, + MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), + (LPTSTR)&lpMsgBuf, + 0, + NULL); + StrTrim(lpMsgBuf,L" \a\b\f\n\r\t\v"); + StrCatBuff(szText,L"\n",COUNTOF(szText)); + StrCatBuff(szText,lpMsgBuf,COUNTOF(szText)); + LocalFree(lpMsgBuf); + wcht = *CharPrev(szText,StrEnd(szText)); + if (IsCharAlphaNumeric(wcht) || wcht == '"' || wcht == '\'') + StrCatBuff(szText,L".",COUNTOF(szText)); + } + + GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle)); + + switch (iType) { + case MBINFO: iIcon = MB_ICONINFORMATION; break; + case MBWARN: iIcon = MB_ICONEXCLAMATION; break; + case MBYESNO: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break; + case MBYESNOCANCEL: iIcon = MB_ICONEXCLAMATION | MB_YESNOCANCEL; break; + case MBYESNOWARN: iIcon = MB_ICONEXCLAMATION | MB_YESNO; break; + case MBOKCANCEL: iIcon = MB_ICONEXCLAMATION | MB_OKCANCEL; break; + } + + if (!(hwnd = GetFocus())) + hwnd = hwndMain; + + return MessageBoxEx(hwnd, + szText,szTitle, + MB_SETFOREGROUND | iIcon, + MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT)); + +} + + +//============================================================================= +// +// DisplayCmdLineHelp() +// +void DisplayCmdLineHelp(HWND hwnd) +{ + MSGBOXPARAMS mbp; + + WCHAR szTitle[32]; + WCHAR szText[2048]; + + GetString(IDS_APPTITLE,szTitle,COUNTOF(szTitle)); + GetString(IDS_CMDLINEHELP,szText,COUNTOF(szText)); + + mbp.cbSize = sizeof(MSGBOXPARAMS); + mbp.hwndOwner = hwnd; + mbp.hInstance = g_hInstance; + mbp.lpszText = szText; + mbp.lpszCaption = szTitle; + mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND; + mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND); + mbp.dwContextHelpId = 0; + mbp.lpfnMsgBoxCallback = NULL; + mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL); + + MessageBoxIndirect(&mbp); +} + + +//============================================================================= +// +// BFFCallBack() +// +int CALLBACK BFFCallBack(HWND hwnd,UINT umsg,LPARAM lParam,LPARAM lpData) +{ + if (umsg == BFFM_INITIALIZED) + SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); + + return(0); + + lParam; +} + + +//============================================================================= +// +// GetDirectory() +// +BOOL GetDirectory(HWND hwndParent,int iTitle,LPWSTR pszFolder,LPCWSTR pszBase,BOOL bNewDialogStyle) +{ + + BROWSEINFO bi; + LPITEMIDLIST pidl; + WCHAR szTitle[256]; + WCHAR szBase[MAX_PATH]; + BOOL fOk = FALSE; + + lstrcpy(szTitle,L""); + GetString(iTitle,szTitle,COUNTOF(szTitle)); + + if (!pszBase || !*pszBase) + GetCurrentDirectory(MAX_PATH,szBase); + else + lstrcpy(szBase,pszBase); + + bi.hwndOwner = hwndParent; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszFolder; + bi.lpszTitle = szTitle; + bi.ulFlags = BIF_RETURNONLYFSDIRS; + if (bNewDialogStyle) + bi.ulFlags |= BIF_NEWDIALOGSTYLE; + bi.lpfn = &BFFCallBack; + bi.lParam = (LPARAM)szBase; + bi.iImage = 0; + + pidl = SHBrowseForFolder(&bi); + if (pidl) { + SHGetPathFromIDList(pidl,pszFolder); + CoTaskMemFree(pidl); + fOk = TRUE; + } + + return fOk; + +} + + +//============================================================================= +// +// AboutDlgProc() +// +INT_PTR CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static HFONT hFontTitle; + + switch(umsg) + { + case WM_INITDIALOG: + { + WCHAR wch[256]; + LOGFONT lf; + + SetDlgItemText(hwnd,IDC_VERSION,VERSION_FILEVERSION_LONG); + SetDlgItemText(hwnd,IDC_COPYRIGHT,VERSION_LEGALCOPYRIGHT_SHORT); + SetDlgItemText(hwnd,IDC_AUTHORNAME,VERSION_AUTHORNAME); + SetDlgItemText(hwnd,IDC_COMPILER,VERSION_COMPILER); + + if (hFontTitle) + DeleteObject(hFontTitle); + + if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_VERSION,WM_GETFONT,0,0))) + hFontTitle = GetStockObject(DEFAULT_GUI_FONT); + GetObject(hFontTitle,sizeof(LOGFONT),&lf); + lf.lfWeight = FW_BOLD; + hFontTitle = CreateFontIndirect(&lf); + SendDlgItemMessage(hwnd,IDC_VERSION,WM_SETFONT,(WPARAM)hFontTitle,TRUE); + + if (GetDlgItem(hwnd,IDC_WEBPAGE) == NULL) { + SetDlgItemText(hwnd,IDC_WEBPAGE2,VERSION_WEBPAGEDISPLAY); + ShowWindow(GetDlgItem(hwnd,IDC_WEBPAGE2),SW_SHOWNORMAL); + } + else { + wsprintf(wch,L"%s",VERSION_WEBPAGEDISPLAY); + SetDlgItemText(hwnd,IDC_WEBPAGE,wch); + } + + if (GetDlgItem(hwnd,IDC_EMAIL) == NULL) { + SetDlgItemText(hwnd,IDC_EMAIL2,VERSION_EMAILDISPLAY); + ShowWindow(GetDlgItem(hwnd,IDC_EMAIL2),SW_SHOWNORMAL); + } + else { + wsprintf(wch,L"%s",VERSION_EMAILDISPLAY); + SetDlgItemText(hwnd,IDC_EMAIL,wch); + } + + if (GetDlgItem(hwnd,IDC_MOD_PAGE) == NULL) { + SetDlgItemText(hwnd,IDC_MOD_PAGE,VERSION_MODPAGEDISPLAY); + ShowWindow(GetDlgItem(hwnd,IDC_MOD_PAGE2),SW_SHOWNORMAL); + } + else { + wsprintf(wch,L"%s",VERSION_MODPAGEDISPLAY); + SetDlgItemText(hwnd,IDC_MOD_PAGE,wch); + } + + CenterDlgInParent(hwnd); + } + return TRUE; + + case WM_NOTIFY: + { + LPNMHDR pnmhdr = (LPNMHDR)lParam; + switch (pnmhdr->code) { + + case NM_CLICK: + case NM_RETURN: + { + if (pnmhdr->idFrom == IDC_WEBPAGE) { + ShellExecute(hwnd,L"open",L"http://www.flos-freeware.ch",NULL,NULL,SW_SHOWNORMAL); + } + else if (pnmhdr->idFrom == IDC_EMAIL) { + ShellExecute(hwnd,L"open",L"mailto:florian.balmer@gmail.com",NULL,NULL,SW_SHOWNORMAL); + } + else if (pnmhdr->idFrom == IDC_MOD_PAGE) { + ShellExecute(hwnd,L"open",L"https://xhmikosr.github.io/notepad2-mod/",NULL,NULL,SW_SHOWNORMAL); + } + } + break; + } + } + break; + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + EndDialog(hwnd,IDOK); + break; + } + return TRUE; + } + return FALSE; +} + + + +//============================================================================= +// +// RunDlgProc() +// +INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + MakeBitmapButton(hwnd,IDC_SEARCHEXE,g_hInstance,IDB_OPEN); + + SendDlgItemMessage(hwnd,IDC_COMMANDLINE,EM_LIMITTEXT,MAX_PATH - 1,0); + SetDlgItemText(hwnd,IDC_COMMANDLINE,(LPCWSTR)lParam); + SHAutoComplete(GetDlgItem(hwnd,IDC_COMMANDLINE),SHACF_FILESYSTEM); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + DeleteBitmapButton(hwnd,IDC_SEARCHEXE); + return FALSE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_SEARCHEXE: + { + WCHAR szArgs[MAX_PATH]; + WCHAR szArg2[MAX_PATH]; + WCHAR szFile[MAX_PATH * 2]; + WCHAR szFilter[256]; + OPENFILENAME ofn; + ZeroMemory(&ofn,sizeof(OPENFILENAME)); + + GetDlgItemText(hwnd,IDC_COMMANDLINE,szArgs,COUNTOF(szArgs)); + ExpandEnvironmentStringsEx(szArgs,COUNTOF(szArgs)); + ExtractFirstArgument(szArgs,szFile,szArg2); + + GetString(IDS_FILTER_EXE,szFilter,COUNTOF(szFilter)); + PrepareFilterStr(szFilter); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = szFilter; + ofn.lpstrFile = szFile; + ofn.nMaxFile = COUNTOF(szFile); + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT + | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS; + + if (GetOpenFileName(&ofn)) { + PathQuoteSpaces(szFile); + if (lstrlen(szArg2)) + { + lstrcat(szFile,L" "); + lstrcat(szFile,szArg2); + } + SetDlgItemText(hwnd,IDC_COMMANDLINE,szFile); + } + + PostMessage(hwnd,WM_NEXTDLGCTL,1,0); + } + break; + + + case IDC_COMMANDLINE: + { + BOOL bEnableOK = FALSE; + WCHAR args[MAX_PATH]; + + if (GetDlgItemText(hwnd,IDC_COMMANDLINE,args,MAX_PATH)) + if (ExtractFirstArgument(args,args,NULL)) + if (lstrlen(args)) + bEnableOK = TRUE; + + EnableWindow(GetDlgItem(hwnd,IDOK),bEnableOK); + } + break; + + + case IDOK: + { + WCHAR arg1[MAX_PATH]; + WCHAR arg2[MAX_PATH]; + SHELLEXECUTEINFO sei; + WCHAR wchDirectory[MAX_PATH] = L""; + + if (GetDlgItemText(hwnd,IDC_COMMANDLINE,arg1,MAX_PATH)) + { + BOOL bQuickExit = FALSE; + + ExpandEnvironmentStringsEx(arg1,COUNTOF(arg1)); + ExtractFirstArgument(arg1,arg1,arg2); + + if (lstrcmpi(arg1,L"notepad2") == 0 || + lstrcmpi(arg1,L"notepad2.exe") == 0) { + GetModuleFileName(NULL,arg1,COUNTOF(arg1)); + bQuickExit = TRUE; + } + + if (lstrlen(szCurFile)) { + lstrcpy(wchDirectory,szCurFile); + PathRemoveFileSpec(wchDirectory); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = 0; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = arg1; + sei.lpParameters = arg2; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + + if (bQuickExit) { + sei.fMask |= /*SEE_MASK_NOZONECHECKS*/0x00800000; + EndDialog(hwnd,IDOK); + ShellExecuteEx(&sei); + } + + else { + + if (ShellExecuteEx(&sei)) + EndDialog(hwnd,IDOK); + + else + PostMessage(hwnd,WM_NEXTDLGCTL, + (WPARAM)(GetDlgItem(hwnd,IDC_COMMANDLINE)),1); + } + } + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// RunDlg() +// +void RunDlg(HWND hwnd,LPCWSTR lpstrDefault) +{ + + ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_RUN), + hwnd,RunDlgProc,(LPARAM)lpstrDefault); + +} + + +//============================================================================= +// +// OpenWithDlgProc() +// +extern WCHAR tchOpenWithDir[MAX_PATH]; +extern int flagNoFadeHidden; + +extern int cxOpenWithDlg; +extern int cyOpenWithDlg; + +INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; + + ResizeDlg_Init(hwnd,cxOpenWithDlg,cyOpenWithDlg,IDC_RESIZEGRIP3); + + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); + + //SetExplorerTheme(GetDlgItem(hwnd,IDC_OPENWITHDIR)); + ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_OPENWITHDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); + ListView_InsertColumn(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,&lvc); + DirList_Init(GetDlgItem(hwnd,IDC_OPENWITHDIR),NULL); + DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); + DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); + ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); + + MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,g_hInstance,IDB_OPEN); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + DirList_Destroy(GetDlgItem(hwnd,IDC_OPENWITHDIR)); + DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR); + + ResizeDlg_Destroy(hwnd,&cxOpenWithDlg,&cyOpenWithDlg); + return FALSE; + + + case WM_SIZE: + { + int dx; + int dy; + HDWP hdwp; + + ResizeDlg_Size(hwnd,lParam,&dx,&dy); + + hdwp = BeginDeferWindowPos(6); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDIR,dx,dy,SWP_NOMOVE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETOPENWITHDIR,0,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_OPENWITHDESCR,0,dy,SWP_NOSIZE); + EndDeferWindowPos(hdwp); + + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVSCW_AUTOSIZE_USEHEADER); + } + return TRUE; + + + case WM_GETMINMAXINFO: + ResizeDlg_GetMinMaxInfo(hwnd,lParam); + return TRUE; + + + case WM_NOTIFY: + { + LPNMHDR pnmh = (LPNMHDR)lParam; + + if (pnmh->idFrom == IDC_OPENWITHDIR) + { + switch(pnmh->code) + { + case LVN_GETDISPINFO: + DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden); + break; + + case LVN_DELETEITEM: + DirList_DeleteItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam); + break; + + case LVN_ITEMCHANGED: { + NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam; + EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED)); + } + break; + + case NM_DBLCLK: + if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_OPENWITHDIR))) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + } + } + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_GETOPENWITHDIR: + { + if (GetDirectory(hwnd,IDS_OPENWITH,tchOpenWithDir,tchOpenWithDir,TRUE)) + { + DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); + DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); + ListView_EnsureVisible(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,FALSE); + ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_OPENWITHDIR)),1); + } + break; + + + case IDOK: { + LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER); + lpdli->mask = DLI_FILENAME | DLI_TYPE; + lpdli->ntype = DLE_NONE; + DirList_GetItem(GetDlgItem(hwnd,IDC_OPENWITHDIR),(-1),lpdli); + + if (lpdli->ntype != DLE_NONE) + EndDialog(hwnd,IDOK); + else + MessageBeep(0); + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// OpenWithDlg() +// +BOOL OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile) +{ + + DLITEM dliOpenWith; + dliOpenWith.mask = DLI_FILENAME; + + if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_OPENWITH), + hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith)) + { + SHELLEXECUTEINFO sei; + WCHAR szParam[MAX_PATH]; + WCHAR wchDirectory[MAX_PATH] = L""; + + if (lstrlen(szCurFile)) { + lstrcpy(wchDirectory,szCurFile); + PathRemoveFileSpec(wchDirectory); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = 0; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = dliOpenWith.szFileName; + sei.lpParameters = szParam; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + + // resolve links and get short path name + if (!(PathIsLnkFile(lpstrFile) && PathGetLnkPath(lpstrFile,szParam,COUNTOF(szParam)))) + lstrcpy(szParam,lpstrFile); + //GetShortPathName(szParam,szParam,sizeof(WCHAR)*COUNTOF(szParam)); + PathQuoteSpaces(szParam); + + ShellExecuteEx(&sei); + + return(TRUE); + } + + return(FALSE); + +} + + +//============================================================================= +// +// FavoritesDlgProc() +// +extern WCHAR tchFavoritesDir[MAX_PATH]; +//extern int flagNoFadeHidden; + +extern int cxFavoritesDlg; +extern int cyFavoritesDlg; + +INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static HWND hwndLV; + + switch(umsg) + { + + case WM_INITDIALOG: + { + LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; + + ResizeDlg_Init(hwnd,cxFavoritesDlg,cyFavoritesDlg,IDC_RESIZEGRIP3); + + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); + + //SetExplorerTheme(GetDlgItem(hwnd,IDC_FAVORITESDIR)); + ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FAVORITESDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); + ListView_InsertColumn(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,&lvc); + DirList_Init(GetDlgItem(hwnd,IDC_FAVORITESDIR),NULL); + DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); + DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); + ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); + + MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,g_hInstance,IDB_OPEN); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + DirList_Destroy(GetDlgItem(hwnd,IDC_FAVORITESDIR)); + DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR); + + ResizeDlg_Destroy(hwnd,&cxFavoritesDlg,&cyFavoritesDlg); + return FALSE; + + + case WM_SIZE: + { + int dx; + int dy; + HDWP hdwp; + + ResizeDlg_Size(hwnd,lParam,&dx,&dy); + + hdwp = BeginDeferWindowPos(6); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP3,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDIR,dx,dy,SWP_NOMOVE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_GETFAVORITESDIR,0,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_FAVORITESDESCR,0,dy,SWP_NOSIZE); + EndDeferWindowPos(hdwp); + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVSCW_AUTOSIZE_USEHEADER); + } + return TRUE; + + + case WM_GETMINMAXINFO: + ResizeDlg_GetMinMaxInfo(hwnd,lParam); + return TRUE; + + + case WM_NOTIFY: + { + LPNMHDR pnmh = (LPNMHDR)lParam; + + if (pnmh->idFrom == IDC_FAVORITESDIR) + { + switch(pnmh->code) + { + case LVN_GETDISPINFO: + DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,flagNoFadeHidden); + break; + + case LVN_DELETEITEM: + DirList_DeleteItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),lParam); + break; + + case LVN_ITEMCHANGED: { + NM_LISTVIEW *pnmlv = (NM_LISTVIEW*)lParam; + EnableWindow(GetDlgItem(hwnd,IDOK),(pnmlv->uNewState & LVIS_SELECTED)); + } + break; + + case NM_DBLCLK: + if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FAVORITESDIR))) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + } + } + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_GETFAVORITESDIR: + { + if (GetDirectory(hwnd,IDS_FAVORITES,tchFavoritesDir,tchFavoritesDir,TRUE)) + { + DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,FALSE,flagNoFadeHidden,DS_NAME,FALSE); + DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); + ListView_EnsureVisible(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,FALSE); + ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_FAVORITESDIR)),1); + } + break; + + + case IDOK: { + LPDLITEM lpdli = (LPDLITEM)GetWindowLongPtr(hwnd,DWLP_USER); + lpdli->mask = DLI_FILENAME | DLI_TYPE; + lpdli->ntype = DLE_NONE; + DirList_GetItem(GetDlgItem(hwnd,IDC_FAVORITESDIR),(-1),lpdli); + + if (lpdli->ntype != DLE_NONE) + EndDialog(hwnd,IDOK); + else + MessageBeep(0); + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// FavoritesDlg() +// +BOOL FavoritesDlg(HWND hwnd,LPWSTR lpstrFile) +{ + + DLITEM dliFavorite; + dliFavorite.mask = DLI_FILENAME; + + if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FAVORITES), + hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite)) + { + lstrcpyn(lpstrFile,dliFavorite.szFileName,MAX_PATH); + return(TRUE); + } + + return(FALSE); + +} + + +//============================================================================= +// +// AddToFavDlgProc() +// +// Controls: 100 Edit +// +INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + WCHAR *pszName; + + case WM_INITDIALOG: + pszName = (LPWSTR)lParam; + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)pszName); + + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,MAX_PATH-1,0); + SetDlgItemText(hwnd,100,pszName); + + CenterDlgInParent(hwnd); + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case 100: + EnableWindow(GetDlgItem(hwnd,IDOK), + GetWindowTextLength(GetDlgItem(hwnd,100))); + break; + + + case IDOK: + pszName = (LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER); + GetDlgItemText(hwnd,100,pszName, + MAX_PATH-1); + EndDialog(hwnd,IDOK); + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// AddToFavDlg() +// +BOOL AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget) +{ + + INT_PTR iResult; + + WCHAR pszName[MAX_PATH]; + lstrcpy(pszName,lpszName); + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_ADDTOFAV), + hwnd, + AddToFavDlgProc,(LPARAM)pszName); + + if (iResult == IDOK) + { + if (!PathCreateFavLnk(pszName,lpszTarget,tchFavoritesDir)) { + MsgBox(MBWARN,IDS_FAV_FAILURE); + return FALSE; + } + + else { + MsgBox(MBINFO,IDS_FAV_SUCCESS); + return TRUE; + } + } + + else + return FALSE; + +} + + +//============================================================================= +// +// FileMRUDlgProc() +// +// +extern LPMRULIST pFileMRU; +extern BOOL bSaveRecentFiles; +extern int cxFileMRUDlg; +extern int cyFileMRUDlg; +extern int flagNoFadeHidden; + +typedef struct tagIconThreadInfo +{ + HWND hwnd; // HWND of ListView Control + HANDLE hExitThread; // Flag is set when Icon Thread should terminate + HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated + +} ICONTHREADINFO, *LPICONTHREADINFO; + +DWORD WINAPI FileMRUIconThread(LPVOID lpParam) { + + HWND hwnd; + LPICONTHREADINFO lpit; + LV_ITEM lvi; + WCHAR tch[MAX_PATH]; + SHFILEINFO shfi; + DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED; + DWORD dwAttr = 0; + int iItem = 0; + int iMaxItem; + + lpit = (LPICONTHREADINFO)lpParam; + ResetEvent(lpit->hTerminatedThread); + + hwnd = lpit->hwnd; + iMaxItem = ListView_GetItemCount(hwnd); + + CoInitialize(NULL); + + ZeroMemory(&lvi,sizeof(LV_ITEM)); + + while (iItem < iMaxItem && WaitForSingleObject(lpit->hExitThread,0) != WAIT_OBJECT_0) { + + lvi.mask = LVIF_TEXT; + lvi.pszText = tch; + lvi.cchTextMax = COUNTOF(tch); + lvi.iItem = iItem; + if (ListView_GetItem(hwnd,&lvi)) { + + if (PathIsUNC(tch) || !PathFileExists(tch)) { + dwFlags |= SHGFI_USEFILEATTRIBUTES; + dwAttr = FILE_ATTRIBUTE_NORMAL; + shfi.dwAttributes = 0; + SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); + } + + else { + shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE; + SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); + } + + lvi.mask = LVIF_IMAGE; + lvi.iImage = shfi.iIcon; + lvi.stateMask = 0; + lvi.state = 0; + + if (shfi.dwAttributes & SFGAO_LINK) { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_OVERLAYMASK; + lvi.state |= INDEXTOOVERLAYMASK(2); + } + + if (shfi.dwAttributes & SFGAO_SHARE) { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_OVERLAYMASK; + lvi.state |= INDEXTOOVERLAYMASK(1); + } + + if (PathIsUNC(tch)) + dwAttr = FILE_ATTRIBUTE_NORMAL; + else + dwAttr = GetFileAttributes(tch); + + if (!flagNoFadeHidden && + dwAttr != INVALID_FILE_ATTRIBUTES && + dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_CUT; + lvi.state |= LVIS_CUT; + } + + lvi.iSubItem = 0; + ListView_SetItem(hwnd,&lvi); + } + iItem++; + } + + CoUninitialize(); + + SetEvent(lpit->hTerminatedThread); + ExitThread(0); + return(0); +} + +INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + SHFILEINFO shfi; + LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; + + LPICONTHREADINFO lpit = (LPVOID)GlobalAlloc(GPTR,sizeof(ICONTHREADINFO)); + SetProp(hwnd,L"it",(HANDLE)lpit); + lpit->hwnd = GetDlgItem(hwnd,IDC_FILEMRU); + lpit->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL); + lpit->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL); + + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); + + ResizeDlg_Init(hwnd,cxFileMRUDlg,cyFileMRUDlg,IDC_RESIZEGRIP); + + ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), + (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), + LVSIL_SMALL); + + ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), + (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), + LVSIL_NORMAL); + + //SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU)); + ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FILEMRU),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); + ListView_InsertColumn(GetDlgItem(hwnd,IDC_FILEMRU),0,&lvc); + + // Update view + SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0); + + if (bSaveRecentFiles) + CheckDlgButton(hwnd,IDC_SAVEMRU,BST_CHECKED); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + { + LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it"); + SetEvent(lpit->hExitThread); + while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) { + MSG msg; + if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + CloseHandle(lpit->hExitThread); + CloseHandle(lpit->hTerminatedThread); + RemoveProp(hwnd,L"it"); + GlobalFree(lpit); + + bSaveRecentFiles = (IsDlgButtonChecked(hwnd,IDC_SAVEMRU)) ? 1 : 0; + + ResizeDlg_Destroy(hwnd,&cxFileMRUDlg,&cyFileMRUDlg); + } + return FALSE; + + + case WM_SIZE: + { + int dx; + int dy; + HDWP hdwp; + + ResizeDlg_Size(hwnd,lParam,&dx,&dy); + + hdwp = BeginDeferWindowPos(5); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_FILEMRU,dx,dy,SWP_NOMOVE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_SAVEMRU,0,dy,SWP_NOSIZE); + EndDeferWindowPos(hdwp); + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER); + } + return TRUE; + + + case WM_GETMINMAXINFO: + ResizeDlg_GetMinMaxInfo(hwnd,lParam); + return TRUE; + + + case WM_NOTIFY: { + if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) { + + switch (((LPNMHDR)(lParam))->code) { + + case NM_DBLCLK: + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + + + case LVN_GETDISPINFO: { + /* + LV_DISPINFO *lpdi = (LPVOID)lParam; + + if (lpdi->item.mask & LVIF_IMAGE) { + + WCHAR tch[MAX_PATH]; + LV_ITEM lvi; + SHFILEINFO shfi; + DWORD dwFlags = SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED; + DWORD dwAttr = 0; + + ZeroMemory(&lvi,sizeof(LV_ITEM)); + + lvi.mask = LVIF_TEXT; + lvi.pszText = tch; + lvi.cchTextMax = COUNTOF(tch); + lvi.iItem = lpdi->item.iItem; + + ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); + + if (!PathFileExists(tch)) { + dwFlags |= SHGFI_USEFILEATTRIBUTES; + dwAttr = FILE_ATTRIBUTE_NORMAL; + shfi.dwAttributes = 0; + SHGetFileInfo(PathFindFileName(tch),dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); + } + + else { + shfi.dwAttributes = SFGAO_LINK | SFGAO_SHARE; + SHGetFileInfo(tch,dwAttr,&shfi,sizeof(SHFILEINFO),dwFlags); + } + + lpdi->item.iImage = shfi.iIcon; + lpdi->item.mask |= LVIF_DI_SETITEM; + + lpdi->item.stateMask = 0; + lpdi->item.state = 0; + + if (shfi.dwAttributes & SFGAO_LINK) { + lpdi->item.mask |= LVIF_STATE; + lpdi->item.stateMask |= LVIS_OVERLAYMASK; + lpdi->item.state |= INDEXTOOVERLAYMASK(2); + } + + if (shfi.dwAttributes & SFGAO_SHARE) { + lpdi->item.mask |= LVIF_STATE; + lpdi->item.stateMask |= LVIS_OVERLAYMASK; + lpdi->item.state |= INDEXTOOVERLAYMASK(1); + } + + dwAttr = GetFileAttributes(tch); + + if (!flagNoFadeHidden && + dwAttr != INVALID_FILE_ATTRIBUTES && + dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { + lpdi->item.mask |= LVIF_STATE; + lpdi->item.stateMask |= LVIS_CUT; + lpdi->item.state |= LVIS_CUT; + } + } + */ + } + break; + + + case LVN_ITEMCHANGED: + case LVN_DELETEITEM: + EnableWindow(GetDlgItem(hwnd,IDOK),ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))); + break; + } + } + } + + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case 0x00A0: + { + int i; + WCHAR tch[MAX_PATH]; + LV_ITEM lvi; + SHFILEINFO shfi; + + DWORD dwtid; + LPICONTHREADINFO lpit = (LPVOID)GetProp(hwnd,L"it"); + + SetEvent(lpit->hExitThread); + while (WaitForSingleObject(lpit->hTerminatedThread,0) != WAIT_OBJECT_0) { + MSG msg; + if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + ResetEvent(lpit->hExitThread); + SetEvent(lpit->hTerminatedThread); + + ListView_DeleteAllItems(GetDlgItem(hwnd,IDC_FILEMRU)); + + ZeroMemory(&lvi,sizeof(LV_ITEM)); + lvi.mask = LVIF_TEXT | LVIF_IMAGE; + + SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), + SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + lvi.iImage = shfi.iIcon; + + for (i = 0; i < MRU_Enum(pFileMRU,0,NULL,0); i++) { + MRU_Enum(pFileMRU,i,tch,COUNTOF(tch)); + PathAbsoluteFromApp(tch,NULL,0,TRUE); + // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); } + // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,FALSE); + lvi.iItem = i; + lvi.pszText = tch; + ListView_InsertItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); + } + + ListView_SetItemState(GetDlgItem(hwnd,IDC_FILEMRU),0,LVIS_FOCUSED,LVIS_FOCUSED); + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_FILEMRU),0,LVSCW_AUTOSIZE_USEHEADER); + + CreateThread(NULL,0,FileMRUIconThread,(LPVOID)lpit,0,&dwtid); + } + break; + + case IDC_FILEMRU: + break; + + + case IDOK: + { + WCHAR tch[MAX_PATH]; + //int iItem; + + //if ((iItem = SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETCURSEL,0,0)) != LB_ERR) + if (ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))) + { + //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_GETTEXT,(WPARAM)iItem,(LPARAM)tch); + LV_ITEM lvi; + ZeroMemory(&lvi,sizeof(LV_ITEM)); + + lvi.mask = LVIF_TEXT; + lvi.pszText = tch; + lvi.cchTextMax = COUNTOF(tch); + lvi.iItem = ListView_GetNextItem(GetDlgItem(hwnd,IDC_FILEMRU),-1,LVNI_ALL | LVNI_SELECTED); + + ListView_GetItem(GetDlgItem(hwnd,IDC_FILEMRU),&lvi); + + PathUnquoteSpaces(tch); + + if (!PathFileExists(tch)) { + + // Ask... + if (IDYES == MsgBox(MBYESNO,IDS_ERR_MRUDLG)) { + + MRU_Delete(pFileMRU,lvi.iItem); + MRU_DeleteFileFromStore(pFileMRU,tch); + + //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0); + //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem); + // must use IDM_VIEW_REFRESH, index might change... + SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0); + + //EnableWindow(GetDlgItem(hwnd,IDOK), + // (LB_ERR != SendDlgItemMessage(hwnd,IDC_GOTO,LB_GETCURSEL,0,0))); + + EnableWindow(GetDlgItem(hwnd,IDOK), + ListView_GetSelectedCount(GetDlgItem(hwnd,IDC_FILEMRU))); + } + } + + else { + lstrcpy((LPWSTR)GetWindowLongPtr(hwnd,DWLP_USER),tch); + EndDialog(hwnd,IDOK); + } + } + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// FileMRUDlg() +// +// +BOOL FileMRUDlg(HWND hwnd,LPWSTR lpstrFile) +{ + + if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_FILEMRU), + hwnd,FileMRUDlgProc,(LPARAM)lpstrFile)) + return TRUE; + else + return FALSE; + +} + + +//============================================================================= +// +// ChangeNotifyDlgProc() +// +// Controls: 100 Radio Button +// 101 Radio Button +// 102 Radio Button +// 103 Check Box +// +extern int iFileWatchingMode; +extern BOOL bResetFileWatching; + +INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + switch(umsg) + { + case WM_INITDIALOG: + CheckRadioButton(hwnd,100,102,100+iFileWatchingMode); + if (bResetFileWatching) + CheckDlgButton(hwnd,103,BST_CHECKED); + CenterDlgInParent(hwnd); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: + if (IsDlgButtonChecked(hwnd,100) == BST_CHECKED) + iFileWatchingMode = 0; + else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) + iFileWatchingMode = 1; + else + iFileWatchingMode = 2; + bResetFileWatching = (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) ? TRUE : FALSE; + EndDialog(hwnd,IDOK); + break; + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// ChangeNotifyDlg() +// +BOOL ChangeNotifyDlg(HWND hwnd) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_CHANGENOTIFY), + hwnd, + ChangeNotifyDlgProc, + 0); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// ColumnWrapDlgProc() +// +// Controls: 100 Edit +// +INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static int *piNumber; + + switch(umsg) + { + + case WM_INITDIALOG: + { + + piNumber = (int*)lParam; + + SetDlgItemInt(hwnd,100,*piNumber,FALSE); + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); + + CenterDlgInParent(hwnd); + + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: { + + BOOL fTranslated; + + int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE); + + if (fTranslated) + { + *piNumber = iNewNumber; + + EndDialog(hwnd,IDOK); + } + + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1); + + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// ColumnWrapDlg() +// +BOOL ColumnWrapDlg(HWND hwnd,UINT uidDlg,int *iNumber) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(uidDlg), + hwnd, + ColumnWrapDlgProc,(LPARAM)iNumber); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// WordWrapSettingsDlgProc() +// +// Controls: 100 Combo +// 101 Combo +// 102 Combo +// 103 Combo +// 200 Text +// 201 Text +// 202 Text +// 203 Text +// +extern int iWordWrapMode; +extern int iWordWrapIndent; +extern int iWordWrapSymbols; +extern BOOL bShowWordWrapSymbols; + +INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + + WCHAR tch[512]; + WCHAR *p1, *p2; + int i; + + for (i = 0; i < 4; i++) { + GetDlgItemText(hwnd,200+i,tch,COUNTOF(tch)); + lstrcat(tch,L"|"); + p1 = tch; + while (p2 = StrChr(p1,L'|')) { + *p2++ = L'\0'; + if (*p1) + SendDlgItemMessage(hwnd,100+i,CB_ADDSTRING,0,(LPARAM)p1); + p1 = p2; + } + + SendDlgItemMessage(hwnd,100+i,CB_SETEXTENDEDUI,TRUE,0); + } + + SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)iWordWrapIndent,0); + SendDlgItemMessage(hwnd,101,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? iWordWrapSymbols%10 : 0,0); + SendDlgItemMessage(hwnd,102,CB_SETCURSEL,(WPARAM)(bShowWordWrapSymbols) ? ((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10 : 0,0); + SendDlgItemMessage(hwnd,103,CB_SETCURSEL,(WPARAM)iWordWrapMode,0); + + CenterDlgInParent(hwnd); + + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: { + + int iSel, iSel2; + + iSel = (int)SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0); + iWordWrapIndent = iSel; + + bShowWordWrapSymbols = FALSE; + iSel = (int)SendDlgItemMessage(hwnd,101,CB_GETCURSEL,0,0); + iSel2 = (int)SendDlgItemMessage(hwnd,102,CB_GETCURSEL,0,0); + if (iSel > 0 || iSel2 > 0) { + bShowWordWrapSymbols = TRUE; + iWordWrapSymbols = iSel + iSel2*10; + } + + iSel = (int)SendDlgItemMessage(hwnd,103,CB_GETCURSEL,0,0); + iWordWrapMode = iSel; + + EndDialog(hwnd,IDOK); + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// WordWrapSettingsDlg() +// +BOOL WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(uidDlg), + hwnd, + WordWrapSettingsDlgProc,(LPARAM)iNumber); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// LongLineSettingsDlgProc() +// +// Controls: 100 Edit +// 101 Radio1 +// 102 Radio2 +// +extern int iLongLineMode; + +INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static int *piNumber; + + switch(umsg) + { + + case WM_INITDIALOG: + { + + piNumber = (int*)lParam; + + SetDlgItemInt(hwnd,100,*piNumber,FALSE); + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); + + if (iLongLineMode == EDGE_LINE) + CheckRadioButton(hwnd,101,102,101); + else + CheckRadioButton(hwnd,101,102,102); + + CenterDlgInParent(hwnd); + + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: { + + BOOL fTranslated; + + int iNewNumber = GetDlgItemInt(hwnd,100,&fTranslated,FALSE); + + if (fTranslated) + { + *piNumber = iNewNumber; + + iLongLineMode = (IsDlgButtonChecked(hwnd,101)) ? EDGE_LINE : EDGE_BACKGROUND; + + EndDialog(hwnd,IDOK); + } + + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,100)),1); + + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// LongLineSettingsDlg() +// +BOOL LongLineSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(uidDlg), + hwnd, + LongLineSettingsDlgProc,(LPARAM)iNumber); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// TabSettingsDlgProc() +// +// Controls: 100 Edit +// 101 Edit +// 102 Check +// 103 Check +// 104 Check +// +extern int iTabWidth; +extern int iIndentWidth; +extern BOOL bTabsAsSpaces; +extern BOOL bTabIndents; +extern BOOL bBackspaceUnindents; + +INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + + SetDlgItemInt(hwnd,100,iTabWidth,FALSE); + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); + + SetDlgItemInt(hwnd,101,iIndentWidth,FALSE); + SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,15,0); + + if (bTabsAsSpaces) + CheckDlgButton(hwnd,102,BST_CHECKED); + + if (bTabIndents) + CheckDlgButton(hwnd,103,BST_CHECKED); + + if (bBackspaceUnindents) + CheckDlgButton(hwnd,104,BST_CHECKED); + + CenterDlgInParent(hwnd); + + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: { + + BOOL fTranslated1,fTranslated2; + + int iNewTabWidth = GetDlgItemInt(hwnd,100,&fTranslated1,FALSE); + int iNewIndentWidth = GetDlgItemInt(hwnd,101,&fTranslated2,FALSE); + + if (fTranslated1 && fTranslated2) + { + iTabWidth = iNewTabWidth; + iIndentWidth = iNewIndentWidth; + + bTabsAsSpaces = (IsDlgButtonChecked(hwnd,102)) ? TRUE : FALSE; + + bTabIndents = (IsDlgButtonChecked(hwnd,103)) ? TRUE : FALSE; + + bBackspaceUnindents = (IsDlgButtonChecked(hwnd,104)) ? TRUE : FALSE; + + EndDialog(hwnd,IDOK); + } + + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(fTranslated1) ? 101 : 100)),1); + + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// TabSettingsDlg() +// +BOOL TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(uidDlg), + hwnd, + TabSettingsDlgProc,(LPARAM)iNumber); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// SelectDefEncodingDlgProc() +// +// +typedef struct encodedlg { + BOOL bRecodeOnly; + int idEncoding; + int cxDlg; + int cyDlg; +} ENCODEDLG, *PENCODEDLG; + +INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static PENCODEDLG pdd; + + switch(umsg) + { + case WM_INITDIALOG: + { + HBITMAP hbmp; + HIMAGELIST himl; + + pdd = (PENCODEDLG)lParam; + + hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); + DeleteObject(hbmp); + SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CBEM_SETIMAGELIST,0,(LPARAM)himl); + SendDlgItemMessage(hwnd,IDC_ENCODINGLIST,CB_SETEXTENDEDUI,TRUE,0); + + Encoding_AddToComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),pdd->idEncoding,0); + + if (bSkipUnicodeDetection) + CheckDlgButton(hwnd,IDC_NOUNICODEDETECTION,BST_CHECKED); + + if (bLoadASCIIasUTF8) + CheckDlgButton(hwnd,IDC_ASCIIASUTF8,BST_CHECKED); + + if (bLoadNFOasOEM) + CheckDlgButton(hwnd,IDC_NFOASOEM,BST_CHECKED); + + if (bNoEncodingTags) + CheckDlgButton(hwnd,IDC_ENCODINGFROMFILEVARS,BST_CHECKED); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + if (Encoding_GetFromComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),&pdd->idEncoding)) { + bSkipUnicodeDetection = (IsDlgButtonChecked(hwnd,IDC_NOUNICODEDETECTION) == BST_CHECKED) ? 1 : 0; + bLoadASCIIasUTF8 = (IsDlgButtonChecked(hwnd,IDC_ASCIIASUTF8) == BST_CHECKED) ? 1 : 0; + bLoadNFOasOEM = (IsDlgButtonChecked(hwnd,IDC_NFOASOEM) == BST_CHECKED) ? 1 : 0; + bNoEncodingTags = (IsDlgButtonChecked(hwnd,IDC_ENCODINGFROMFILEVARS) == BST_CHECKED) ? 1 : 0; + EndDialog(hwnd,IDOK); + } + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1); + } + break; + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// SelectDefEncodingDlg() +// +BOOL SelectDefEncodingDlg(HWND hwnd,int *pidREncoding) +{ + + INT_PTR iResult; + ENCODEDLG dd; + + dd.bRecodeOnly = FALSE; + dd.idEncoding = *pidREncoding; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_DEFENCODING), + hwnd, + SelectDefEncodingDlgProc, + (LPARAM)&dd); + + if (iResult == IDOK) { + *pidREncoding = dd.idEncoding; + return(TRUE); + } + else + return(FALSE); + +} + + +//============================================================================= +// +// SelectEncodingDlgProc() +// +// +INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static PENCODEDLG pdd; + static HWND hwndLV; + + switch(umsg) + { + + case WM_INITDIALOG: + { + LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; + HBITMAP hbmp; + HIMAGELIST himl; + + pdd = (PENCODEDLG)lParam; + + ResizeDlg_Init(hwnd,pdd->cxDlg,pdd->cyDlg,IDC_RESIZEGRIP4); + + hwndLV = GetDlgItem(hwnd,IDC_ENCODINGLIST); + + hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); + DeleteObject(hbmp); + ListView_SetImageList(GetDlgItem(hwnd,IDC_ENCODINGLIST),himl,LVSIL_SMALL); + + //SetExplorerTheme(hwndLV); + ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); + ListView_InsertColumn(hwndLV,0,&lvc); + + Encoding_AddToListView(hwndLV,pdd->idEncoding,pdd->bRecodeOnly); + + ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + ResizeDlg_Destroy(hwnd,&pdd->cxDlg,&pdd->cyDlg); + return FALSE; + + + case WM_SIZE: + { + int dx; + int dy; + HDWP hdwp; + + ResizeDlg_Size(hwnd,lParam,&dx,&dy); + + hdwp = BeginDeferWindowPos(4); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_RESIZEGRIP4,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDOK,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDCANCEL,dx,dy,SWP_NOSIZE); + hdwp = DeferCtlPos(hdwp,hwnd,IDC_ENCODINGLIST,dx,dy,SWP_NOMOVE); + EndDeferWindowPos(hdwp); + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_ENCODINGLIST),0,LVSCW_AUTOSIZE_USEHEADER); + } + return TRUE; + + + case WM_GETMINMAXINFO: + ResizeDlg_GetMinMaxInfo(hwnd,lParam); + return TRUE; + + + case WM_NOTIFY: { + if (((LPNMHDR)(lParam))->idFrom == IDC_ENCODINGLIST) { + + switch (((LPNMHDR)(lParam))->code) { + + case NM_DBLCLK: + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + + case LVN_ITEMCHANGED: + case LVN_DELETEITEM: { + int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); + EnableWindow(GetDlgItem(hwnd,IDOK),i != -1); + } + break; + } + } + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: + if (Encoding_GetFromListView(hwndLV,&pdd->idEncoding)) + EndDialog(hwnd,IDOK); + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_ENCODINGLIST)),1); + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// SelectEncodingDlg() +// +extern int cxEncodingDlg; +extern int cyEncodingDlg; + +BOOL SelectEncodingDlg(HWND hwnd,int *pidREncoding) +{ + + INT_PTR iResult; + ENCODEDLG dd; + + dd.bRecodeOnly = FALSE; + dd.idEncoding = *pidREncoding; + dd.cxDlg = cxEncodingDlg; + dd.cyDlg = cyEncodingDlg; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_ENCODING), + hwnd, + SelectEncodingDlgProc, + (LPARAM)&dd); + + cxEncodingDlg = dd.cxDlg; + cyEncodingDlg = dd.cyDlg; + + if (iResult == IDOK) { + *pidREncoding = dd.idEncoding; + return(TRUE); + } + else + return(FALSE); + +} + + +//============================================================================= +// +// RecodeDlg() +// +extern int cxRecodeDlg; +extern int cyRecodeDlg; + +BOOL RecodeDlg(HWND hwnd,int *pidREncoding) +{ + + INT_PTR iResult; + ENCODEDLG dd; + + dd.bRecodeOnly = TRUE; + dd.idEncoding = *pidREncoding; + dd.cxDlg = cxRecodeDlg; + dd.cyDlg = cyRecodeDlg; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_RECODE), + hwnd, + SelectEncodingDlgProc, + (LPARAM)&dd); + + cxRecodeDlg = dd.cxDlg; + cyRecodeDlg = dd.cyDlg; + + if (iResult == IDOK) { + *pidREncoding = dd.idEncoding; + return(TRUE); + } + else + return(FALSE); + +} + + +//============================================================================= +// +// SelectDefLineEndingDlgProc() +// +// Controls: 100 Combo +// IDC_CONSISTENTEOLS +// IDC_AUTOSTRIPBLANKS +// +INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static int *piOption; + + switch(umsg) + { + case WM_INITDIALOG: + { + int i; + WCHAR wch[128]; + + piOption = (int*)lParam; + + // Load options + for (i = 0; i < 3; i++) { + GetString(IDS_EOLMODENAME0+i,wch,COUNTOF(wch)); + SendDlgItemMessage(hwnd,100,CB_ADDSTRING,0,(LPARAM)wch); + } + + SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)*piOption,0); + SendDlgItemMessage(hwnd,100,CB_SETEXTENDEDUI,TRUE,0); + + if (bFixLineEndings) + CheckDlgButton(hwnd,IDC_CONSISTENTEOLS,BST_CHECKED); + + if (bAutoStripBlanks) + CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, BST_CHECKED); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + *piOption = (int)SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0); + bFixLineEndings = (IsDlgButtonChecked(hwnd,IDC_CONSISTENTEOLS) == BST_CHECKED) ? 1 : 0; + bAutoStripBlanks = (IsDlgButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS) == BST_CHECKED) ? 1 : 0; + EndDialog(hwnd,IDOK); + } + break; + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// SelectDefLineEndingDlg() +// +BOOL SelectDefLineEndingDlg(HWND hwnd,int *iOption) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(IDD_DEFEOLMODE), + hwnd, + SelectDefLineEndingDlgProc, + (LPARAM)iOption); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// InfoBoxDlgProc() +// +// +typedef struct _infobox { + LPWSTR lpstrMessage; + LPWSTR lpstrSetting; + BOOL bDisableCheckBox; +} INFOBOX, *LPINFOBOX; + +INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + LPINFOBOX lpib; + + switch(umsg) + { + case WM_INITDIALOG: + lpib = (LPINFOBOX)lParam; + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); + SendDlgItemMessage(hwnd,IDC_INFOBOXICON,STM_SETICON, + (WPARAM)LoadIcon(NULL,IDI_EXCLAMATION),0); + SetDlgItemText(hwnd,IDC_INFOBOXTEXT,lpib->lpstrMessage); + if (lpib->bDisableCheckBox) + EnableWindow(GetDlgItem(hwnd,IDC_INFOBOXCHECK),FALSE); + LocalFree(lpib->lpstrMessage); + CenterDlgInParent(hwnd); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + case IDYES: + case IDNO: + lpib = (LPINFOBOX)GetWindowLongPtr(hwnd,DWLP_USER); + if (IsDlgButtonChecked(hwnd,IDC_INFOBOXCHECK)) + IniSetInt(L"Suppressed Messages",lpib->lpstrSetting,1); + EndDialog(hwnd,LOWORD(wParam)); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// InfoBox() +// +// +extern WCHAR szIniFile[MAX_PATH]; + +INT_PTR InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...) +{ + + HWND hwnd; + int idDlg = IDD_INFOBOX; + INFOBOX ib; + WCHAR wchFormat[512]; + int iMode; + + iMode = IniGetInt(L"Suppressed Messages",lpstrSetting,0); + + if (lstrlen(lpstrSetting) > 0 && iMode == 1) + return (iType == MBYESNO) ? IDYES : IDOK; + + if (!GetString(uidMessage,wchFormat,COUNTOF(wchFormat))) + return(-1); + + ib.lpstrMessage = LocalAlloc(LPTR,1024 * sizeof(WCHAR)); + wvsprintf(ib.lpstrMessage,wchFormat,(LPVOID)((PUINT_PTR)&uidMessage + 1)); + ib.lpstrSetting = (LPWSTR)lpstrSetting; + ib.bDisableCheckBox = (lstrlen(szIniFile) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE; + + if (iType == MBYESNO) + idDlg = IDD_INFOBOX2; + else if (iType == MBOKCANCEL) + idDlg = IDD_INFOBOX3; + + if (!(hwnd = GetFocus())) + hwnd = hwndMain; + + MessageBeep(MB_ICONEXCLAMATION); + + return ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCE(idDlg), + hwnd, + InfoBoxDlgProc, + (LPARAM)&ib); + +} + + + +// End of Dialogs.c diff --git a/src/Dialogs.h b/src/Dialogs.h index 5451e78e..1900b799 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -1,50 +1,50 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Dialogs.h -* Definitions for Notepad2 dialog boxes -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - - -#define MBINFO 0 -#define MBWARN 1 -#define MBYESNO 2 -#define MBYESNOWARN 3 -#define MBYESNOCANCEL 4 -#define MBOKCANCEL 8 - -int MsgBox(int,UINT,...); -void DisplayCmdLineHelp(HWND hwnd); -BOOL GetDirectory(HWND,int,LPWSTR,LPCWSTR,BOOL); -INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM); -void RunDlg(HWND,LPCWSTR); -BOOL OpenWithDlg(HWND,LPCWSTR); -BOOL FavoritesDlg(HWND,LPWSTR); -BOOL AddToFavDlg(HWND,LPCWSTR,LPCWSTR); -BOOL FileMRUDlg(HWND,LPWSTR); -BOOL ChangeNotifyDlg(HWND); -BOOL ColumnWrapDlg(HWND,UINT,int *); -BOOL WordWrapSettingsDlg(HWND,UINT,int *); -BOOL LongLineSettingsDlg(HWND,UINT,int *); -BOOL TabSettingsDlg(HWND,UINT,int *); -BOOL SelectDefEncodingDlg(HWND,int *); -BOOL SelectEncodingDlg(HWND,int *); -BOOL RecodeDlg(HWND,int *); -BOOL SelectDefLineEndingDlg(HWND,int *); -INT_PTR InfoBox(int,LPCWSTR,int,...); - - -// End of Dialogs.h +/****************************************************************************** +* +* +* Notepad2 +* +* Dialogs.h +* Definitions for Notepad2 dialog boxes +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + + +#define MBINFO 0 +#define MBWARN 1 +#define MBYESNO 2 +#define MBYESNOWARN 3 +#define MBYESNOCANCEL 4 +#define MBOKCANCEL 8 + +int MsgBox(int,UINT,...); +void DisplayCmdLineHelp(HWND hwnd); +BOOL GetDirectory(HWND,int,LPWSTR,LPCWSTR,BOOL); +INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM); +void RunDlg(HWND,LPCWSTR); +BOOL OpenWithDlg(HWND,LPCWSTR); +BOOL FavoritesDlg(HWND,LPWSTR); +BOOL AddToFavDlg(HWND,LPCWSTR,LPCWSTR); +BOOL FileMRUDlg(HWND,LPWSTR); +BOOL ChangeNotifyDlg(HWND); +BOOL ColumnWrapDlg(HWND,UINT,int *); +BOOL WordWrapSettingsDlg(HWND,UINT,int *); +BOOL LongLineSettingsDlg(HWND,UINT,int *); +BOOL TabSettingsDlg(HWND,UINT,int *); +BOOL SelectDefEncodingDlg(HWND,int *); +BOOL SelectEncodingDlg(HWND,int *); +BOOL RecodeDlg(HWND,int *); +BOOL SelectDefLineEndingDlg(HWND,int *); +INT_PTR InfoBox(int,LPCWSTR,int,...); + + +// End of Dialogs.h diff --git a/src/Dlapi.c b/src/Dlapi.c index ed4951d8..fc0d4a3d 100644 --- a/src/Dlapi.c +++ b/src/Dlapi.c @@ -1,1586 +1,1586 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Dlapi.c -* Directory Listing APIs used in Notepad2 -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include "dlapi.h" - - - -//==== DirList ================================================================ - -//==== DLDATA Structure ======================================================= - -typedef struct tagDLDATA // dl -{ - - HWND hwnd; // HWND of ListView Control - UINT cbidl; // Size of pidl - LPITEMIDLIST pidl; // Directory Id - LPSHELLFOLDER lpsf; // IShellFolder Interface to pidl - WCHAR szPath[MAX_PATH]; // Pathname to Directory Id - int iDefIconFolder; // Default Folder Icon - int iDefIconFile; // Default File Icon - BOOL bNoFadeHidden; // Flag passed from GetDispInfo() - HANDLE hExitThread; // Flag is set when Icon Thread should terminate - HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated - -} DLDATA, *LPDLDATA; - - -//==== Property Name ========================================================== -static const WCHAR *pDirListProp = L"DirListData"; - - - -//============================================================================= -// -// DirList_Init() -// -// Initializes the DLDATA structure and sets up the listview control -// -BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader) -{ - - HIMAGELIST hil; - SHFILEINFO shfi; - LV_COLUMN lvc; - - // Allocate DirListData Property - LPDLDATA lpdl = (LPVOID)GlobalAlloc(GPTR,sizeof(DLDATA)); - SetProp(hwnd,pDirListProp,(HANDLE)lpdl); - - // Setup dl - lpdl->hwnd = hwnd; - lpdl->cbidl = 0; - lpdl->pidl = NULL; - lpdl->lpsf = NULL; - lstrcpy(lpdl->szPath,L""); - - // Add Imagelists - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - - ListView_SetImageList(hwnd,hil,LVSIL_SMALL); - - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_LARGEICON | SHGFI_SYSICONINDEX); - - ListView_SetImageList(hwnd,hil,LVSIL_NORMAL); - - // Initialize default icons - done in DirList_Fill() - //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), - // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - //lpdl->iDefIconFolder = shfi.iIcon; - - //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), - // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - //lpdl->iDefIconFile = shfi.iIcon; - - lpdl->iDefIconFolder = 0; - lpdl->iDefIconFile = 0; - - // Icon thread control - lpdl->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL); - lpdl->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL); - - lvc; - pszHeader; - - return TRUE; - -} - - -//============================================================================= -// -// DirList_Destroy() -// -// Free memory used by dl structure -// -BOOL DirList_Destroy(HWND hwnd) -{ - - LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); - - // Release multithreading objects - DirList_TerminateIconThread(hwnd); - CloseHandle(lpdl->hExitThread); - CloseHandle(lpdl->hTerminatedThread); - - if (lpdl->pidl) - CoTaskMemFree(lpdl->pidl); - - if (lpdl->lpsf) - lpdl->lpsf->lpVtbl->Release(lpdl->lpsf); - - // Free DirListData Property - RemoveProp(hwnd,pDirListProp); - GlobalFree(lpdl); - - return FALSE; - -} - - -//============================================================================= -// -// DirList_StartIconThread() -// -// Start thread to extract file icons in the background -// -BOOL DirList_StartIconThread(HWND hwnd) -{ - - DWORD dwtid; - LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); - - DirList_TerminateIconThread(hwnd); - - ResetEvent(lpdl->hExitThread); - //ResetEvent(lpdl->hTerminatedThread); - - CreateThread(NULL,0,DirList_IconThread,(LPVOID)lpdl,0,&dwtid); - - return TRUE; - -} - - -//============================================================================= -// -// DirList_TerminateIconThread() -// -// Terminate Icon Thread and reset multithreading control structures -// -BOOL DirList_TerminateIconThread(HWND hwnd) -{ - - LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); - - SetEvent(lpdl->hExitThread); - - //WaitForSingleObject(lpdl->hTerminatedThread,INFINITE); - while (WaitForSingleObject(lpdl->hTerminatedThread,0) != WAIT_OBJECT_0) - { - MSG msg; - if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - ResetEvent(lpdl->hExitThread); - SetEvent(lpdl->hTerminatedThread); - - return TRUE; - -} - - -//============================================================================= -// -// DirList_Fill() -// -// Snapshots a directory and displays the items in the listview control -// -int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec, - BOOL bExcludeFilter,BOOL bNoFadeHidden, - int iSortFlags,BOOL fSortRev) -{ - - WCHAR wszDir[MAX_PATH]; - - LPSHELLFOLDER lpsfDesktop = NULL; - LPSHELLFOLDER lpsf = NULL; - - LPITEMIDLIST pidl = NULL; - LPITEMIDLIST pidlEntry = NULL; - - LPENUMIDLIST lpe = NULL; - - LV_ITEM lvi; - LPLV_ITEMDATA lplvid; - - ULONG chParsed = 0; - ULONG dwAttributes = 0; - - DL_FILTER dlf; - SHFILEINFO shfi; - - LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); - - // Initialize default icons - SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), - SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - lpdl->iDefIconFolder = shfi.iIcon; - - SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), - SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - lpdl->iDefIconFile = shfi.iIcon; - - // First of all terminate running icon thread - DirList_TerminateIconThread(hwnd); - - // A Directory is strongly required - if (!lpszDir || !*lpszDir) - return(-1); - - lstrcpy(lpdl->szPath,lpszDir); - - // Init ListView - SendMessage(hwnd,WM_SETREDRAW,0,0); - ListView_DeleteAllItems(hwnd); - - // Init Filter - DirList_CreateFilter(&dlf,lpszFileSpec,bExcludeFilter); - - // Init lvi - lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - lvi.iItem = 0; - lvi.iSubItem = 0; - lvi.pszText = LPSTR_TEXTCALLBACK; - lvi.cchTextMax = MAX_PATH; - lvi.iImage = I_IMAGECALLBACK; - - // Convert Directory to a UNICODE string - /*MultiByteToWideChar(CP_ACP, - MB_PRECOMPOSED, - lpszDir, - -1, - wszDir, - MAX_PATH);*/ - lstrcpy(wszDir,lpszDir); - - - // Get Desktop Folder - if (NOERROR == SHGetDesktopFolder(&lpsfDesktop)) - { - - // Convert wszDir into a pidl - if (NOERROR == lpsfDesktop->lpVtbl->ParseDisplayName( - lpsfDesktop, - hwnd, - NULL, - wszDir, - &chParsed, - &pidl, - &dwAttributes)) - - { - - // Bind pidl to IShellFolder - if (NOERROR == lpsfDesktop->lpVtbl->BindToObject( - lpsfDesktop, - pidl, - NULL, - &IID_IShellFolder, - &lpsf)) - - { - - // Create an Enumeration object for lpsf - if (NOERROR == lpsf->lpVtbl->EnumObjects( - lpsf, - hwnd, - grfFlags, - &lpe)) - - { - - // Enumerate the contents of lpsf - while (NOERROR == lpe->lpVtbl->Next( - lpe, - 1, - &pidlEntry, - NULL)) - - { - - // Add found item to the List - // Check if it's part of the Filesystem - dwAttributes = SFGAO_FILESYSTEM | SFGAO_FOLDER; - - lpsf->lpVtbl->GetAttributesOf( - lpsf, - 1, - &pidlEntry, - &dwAttributes); - - if (dwAttributes & SFGAO_FILESYSTEM) - { - - // Check if item matches specified filter - if (DirList_MatchFilter(lpsf,pidlEntry,&dlf)) - { - - lplvid = CoTaskMemAlloc(sizeof(LV_ITEMDATA)); - - lplvid->pidl = pidlEntry; - lplvid->lpsf = lpsf; - - lpsf->lpVtbl->AddRef(lpsf); - - lvi.lParam = (LPARAM)lplvid; - - // Setup default Icon - Folder or File - lvi.iImage = (dwAttributes & SFGAO_FOLDER) ? - lpdl->iDefIconFolder : lpdl->iDefIconFile; - - ListView_InsertItem(hwnd,&lvi); - - lvi.iItem++; - - } - - } - - } // IEnumIDList::Next() - - lpe->lpVtbl->Release(lpe); - - } // IShellFolder::EnumObjects() - - } // IShellFolder::BindToObject() - - } // IShellFolder::ParseDisplayName() - - lpsfDesktop->lpVtbl->Release(lpsfDesktop); - - } // SHGetDesktopFolder() - - if (lpdl->pidl) - CoTaskMemFree(lpdl->pidl); - - if (lpdl->lpsf && lpdl->lpsf->lpVtbl) - lpdl->lpsf->lpVtbl->Release(lpdl->lpsf); - - // Set lpdl - lpdl->cbidl = IL_GetSize(pidl); - lpdl->pidl = pidl; - lpdl->lpsf = lpsf; - lpdl->bNoFadeHidden = bNoFadeHidden; - - // Set column width to fit window - ListView_SetColumnWidth(hwnd,0,LVSCW_AUTOSIZE_USEHEADER); - - // Sort before display is updated - DirList_Sort(hwnd,iSortFlags,fSortRev); - - // Redraw Listview - SendMessage(hwnd,WM_SETREDRAW,1,0); - - // Return number of items in the control - return (ListView_GetItemCount(hwnd)); - -} - - -//============================================================================= -// -// DirList_IconThread() -// -// Thread to extract file icons in the background -// -DWORD WINAPI DirList_IconThread(LPVOID lpParam) -{ - - HWND hwnd; - - LPDLDATA lpdl; - LV_ITEM lvi; - LPLV_ITEMDATA lplvid; - - IShellIcon* lpshi; - - int iItem = 0; - int iMaxItem; - - lpdl = (LPDLDATA)lpParam; - ResetEvent(lpdl->hTerminatedThread); - - // Exit immediately if DirList_Fill() hasn't been called - if (!lpdl->lpsf) { - SetEvent(lpdl->hTerminatedThread); - ExitThread(0); - return(0); - } - - hwnd = lpdl->hwnd; - iMaxItem = ListView_GetItemCount(hwnd); - - CoInitialize(NULL); - - // Get IShellIcon - lpdl->lpsf->lpVtbl->QueryInterface(lpdl->lpsf,&IID_IShellIcon,&lpshi); - - while (iItem < iMaxItem && WaitForSingleObject(lpdl->hExitThread,0) != WAIT_OBJECT_0) { - - lvi.iItem = iItem; - lvi.mask = LVIF_PARAM; - if (ListView_GetItem(hwnd,&lvi)) { - - SHFILEINFO shfi; - LPITEMIDLIST pidl; - DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE; - - lplvid = (LPLV_ITEMDATA)lvi.lParam; - - lvi.mask = LVIF_IMAGE; - - if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage)) - { - pidl = IL_Create(lpdl->pidl,lpdl->cbidl,lplvid->pidl,0); - SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - CoTaskMemFree(pidl); - lvi.iImage = shfi.iIcon; - } - - // It proved necessary to reset the state bits... - lvi.stateMask = 0; - lvi.state = 0; - - // Link and Share Overlay - lplvid->lpsf->lpVtbl->GetAttributesOf( - lplvid->lpsf, - 1,&lplvid->pidl, - &dwAttributes); - - if (dwAttributes & SFGAO_LINK) - { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_OVERLAYMASK; - lvi.state |= INDEXTOOVERLAYMASK(2); - } - - if (dwAttributes & SFGAO_SHARE) - { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_OVERLAYMASK; - lvi.state |= INDEXTOOVERLAYMASK(1); - } - - // Fade hidden/system files - if (!lpdl->bNoFadeHidden) - { - WIN32_FIND_DATA fd; - if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,lplvid->pidl, - SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA))) - { - if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || - (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) - { - lvi.mask |= LVIF_STATE; - lvi.stateMask |= LVIS_CUT; - lvi.state |= LVIS_CUT; - } - } - } - lvi.iSubItem = 0; - ListView_SetItem(hwnd,&lvi); - } - iItem++; - } - - if (lpshi) - lpshi->lpVtbl->Release(lpshi); - - CoUninitialize(); - - SetEvent(lpdl->hTerminatedThread); - ExitThread(0); - return(0); - -} - - -//============================================================================= -// -// DirList_GetDispInfo() -// -// Must be called in response to a WM_NOTIFY/LVN_GETDISPINFO message from -// the listview control -// -BOOL DirList_GetDispInfo(HWND hwnd,LPARAM lParam,BOOL bNoFadeHidden) -{ - - LV_DISPINFO *lpdi = (LPVOID)lParam; - - LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lpdi->item.lParam; - - // SubItem 0 is handled only - if (lpdi->item.iSubItem != 0) - return FALSE; - - // Text - if (lpdi->item.mask & LVIF_TEXT) - IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER, - lpdi->item.pszText,lpdi->item.cchTextMax); - - // Set values - lpdi->item.mask |= LVIF_DI_SETITEM; - - return TRUE; - -} - - -//============================================================================= -// -// DirList_DeleteItem() -// -// Must be called in response to a WM_NOTIFY/LVN_DELETEITEM message -// from the control -// -BOOL DirList_DeleteItem(HWND hwnd,LPARAM lParam) -{ - - LV_ITEM lvi; - - NM_LISTVIEW *lpnmlv = (LPVOID)lParam; - - lvi.iItem = lpnmlv->iItem; - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - - if (ListView_GetItem(hwnd,&lvi)) - { - - // Free mem - LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lvi.lParam; - CoTaskMemFree(lplvid->pidl); - lplvid->lpsf->lpVtbl->Release(lplvid->lpsf); - - CoTaskMemFree(lplvid); - - return TRUE; - - } - - else - return FALSE; - -} - - -//============================================================================= -// -// DirList_CompareProc() -// -// Compares two list items -// -int CALLBACK DirList_CompareProcFw(LPARAM lp1,LPARAM lp2,LPARAM lFlags) -{ - - HRESULT hr; - int result; - - LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1; - LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2; - - hr = (lplvid1->lpsf->lpVtbl->CompareIDs( - lplvid1->lpsf, - lFlags, - lplvid1->pidl, - lplvid2->pidl)); - - result = (short)(SCODE_CODE(GetScode(hr))); - - if (result != 0 || lFlags == 0) - return(result); - - hr = (lplvid1->lpsf->lpVtbl->CompareIDs( - lplvid1->lpsf, - 0, - lplvid1->pidl, - lplvid2->pidl)); - - result = (short)(SCODE_CODE(GetScode(hr))); - - return(result); - -} - -int CALLBACK DirList_CompareProcRw(LPARAM lp1,LPARAM lp2,LPARAM lFlags) -{ - - HRESULT hr; - int result; - - LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1; - LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2; - - hr = (lplvid1->lpsf->lpVtbl->CompareIDs( - lplvid1->lpsf, - lFlags, - lplvid1->pidl, - lplvid2->pidl)); - - result = -(short)(SCODE_CODE(GetScode(hr))); - - if (result != 0) - return(result); - - hr = (lplvid1->lpsf->lpVtbl->CompareIDs( - lplvid1->lpsf, - 0, - lplvid1->pidl, - lplvid2->pidl)); - - result = -(short)(SCODE_CODE(GetScode(hr))); - - return(result); - -} - - -//============================================================================= -// -// DirList_Sort() -// -// Sorts the listview control by the specified order -// -BOOL DirList_Sort(HWND hwnd,int lFlags,BOOL fRev) -{ - - if (fRev) - return ListView_SortItems(hwnd,DirList_CompareProcRw,lFlags); - - else - return ListView_SortItems(hwnd,DirList_CompareProcFw,lFlags); - -} - - -//============================================================================= -// -// DirList_GetItem() -// -// Copies the data of the specified item in the listview control to a buffer -// -int DirList_GetItem(HWND hwnd,int iItem,LPDLITEM lpdli) -{ - - LV_ITEM lvi; - LPLV_ITEMDATA lplvid; - - ULONG dwAttributes = SFGAO_FILESYSTEM; - - - if (iItem == -1) - { - - if (ListView_GetSelectedCount(hwnd)) - - iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); - - else - - return(-1); - - } - - lvi.mask = LVIF_PARAM; - lvi.iItem = iItem; - lvi.iSubItem = 0; - - if (!ListView_GetItem(hwnd,&lvi)) - { - - if (lpdli->mask & DLI_TYPE) - - lpdli->ntype = DLE_NONE; - - return(-1); - - } - - lplvid = (LPLV_ITEMDATA)lvi.lParam; - - // Filename - if (lpdli->mask & DLI_FILENAME) - - IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_FORPARSING, - lpdli->szFileName,MAX_PATH); - - // Displayname - if (lpdli->mask & DLI_DISPNAME) - - IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER, - lpdli->szDisplayName,MAX_PATH); - - // Type (File / Directory) - if (lpdli->mask & DLI_TYPE) - { - - WIN32_FIND_DATA fd; - - if (NOERROR == SHGetDataFromIDList(lplvid->lpsf, - lplvid->pidl, - SHGDFIL_FINDDATA, - &fd, - sizeof(WIN32_FIND_DATA))) - - lpdli->ntype = (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? - DLE_DIR : DLE_FILE; - - /*lplvid->lpsf->lpVtbl->GetAttributesOf( - lplvid->lpsf, - 1, - &lplvid->pidl, - &dwAttributes); - - lpdli->ntype = (dwAttributes & SFGAO_FOLDER) ? DLE_DIR : DLE_FILE;*/ - - } - - return iItem; - -} - - -//============================================================================= -// -// DirList_GetItemEx() -// -// Retrieves extended infomration on a dirlist item -// -int DirList_GetItemEx(HWND hwnd,int iItem,LPWIN32_FIND_DATA pfd) -{ - - LV_ITEM lvi; - LPLV_ITEMDATA lplvid; - - - if (iItem == -1) - { - - if (ListView_GetSelectedCount(hwnd)) - - iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); - - else - - return(-1); - - } - - lvi.mask = LVIF_PARAM; - lvi.iItem = iItem; - lvi.iSubItem = 0; - - if (!ListView_GetItem(hwnd,&lvi)) - return(-1); - - lplvid = (LPLV_ITEMDATA)lvi.lParam; - - if (NOERROR == SHGetDataFromIDList(lplvid->lpsf, - lplvid->pidl, - SHGDFIL_FINDDATA, - pfd, - sizeof(WIN32_FIND_DATA))) - return iItem; - - else - return(-1); - -} - - -//============================================================================= -// -// DirList_PropertyDlg() -// -// Shows standard Win95 Property Dlg for selected Item -// -BOOL DirList_PropertyDlg(HWND hwnd,int iItem) -{ - - LV_ITEM lvi; - LPLV_ITEMDATA lplvid; - LPCONTEXTMENU lpcm; - CMINVOKECOMMANDINFO cmi; - BOOL bSuccess = TRUE; - - static const char *lpVerb = "properties"; - - if (iItem == -1) - { - if (ListView_GetSelectedCount(hwnd)) - iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); - - else - return FALSE; - } - - lvi.mask = LVIF_PARAM; - lvi.iItem = iItem; - lvi.iSubItem = 0; - - if (!ListView_GetItem(hwnd,&lvi)) - return FALSE; - - lplvid = (LPLV_ITEMDATA)lvi.lParam; - - if (NOERROR == lplvid->lpsf->lpVtbl->GetUIObjectOf( - lplvid->lpsf, - GetParent(hwnd), // Owner - 1, // Number of objects - &lplvid->pidl, // pidl - &IID_IContextMenu, - NULL, - &lpcm)) - { - - cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); - cmi.fMask = 0; - cmi.hwnd = GetParent(hwnd); - cmi.lpVerb = lpVerb; - cmi.lpParameters = NULL; - cmi.lpDirectory = NULL; - cmi.nShow = SW_SHOWNORMAL; - cmi.dwHotKey = 0; - cmi.hIcon = NULL; - - if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi)) - bSuccess = FALSE; - - lpcm->lpVtbl->Release(lpcm); - - } - - else - bSuccess = FALSE; - - return(bSuccess); - -} - - - -//============================================================================= -// -// DirList_GetLongPathName() -// -// Get long pathname for currently displayed directory -// -BOOL DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath) -{ - WCHAR tch[MAX_PATH]; - LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); - if (SHGetPathFromIDList(lpdl->pidl,tch)) - { - lstrcpy(lpszLongPath,tch); - return(TRUE); - } - else - return(FALSE); -} - - - -//============================================================================= -// -// DirList_SelectItem() -// -// Select specified item in the list -// -BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath) -{ - - #define LVIS_FLAGS LVIS_SELECTED|LVIS_FOCUSED - - WCHAR szShortPath[MAX_PATH]; - SHFILEINFO shfi; - - LV_FINDINFO lvfi; - DLITEM dli; - - int i = -1; - - if (!lpszFullPath || !lstrlen(lpszFullPath)) - return(FALSE); - else - GetShortPathName(lpszFullPath,szShortPath,MAX_PATH); - - if (!lpszDisplayName || !lstrlen(lpszDisplayName)) - SHGetFileInfo(lpszFullPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); - else - lstrcpyn(shfi.szDisplayName,lpszDisplayName,MAX_PATH); - - lvfi.flags = LVFI_STRING; - lvfi.psz = shfi.szDisplayName; - - dli.mask = DLI_ALL; - - while ((i = ListView_FindItem(hwnd,i,&lvfi)) != -1) - { - - DirList_GetItem(hwnd,i,&dli); - GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH); - - if (!lstrcmpi(dli.szFileName,szShortPath)) - { - ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS); - ListView_EnsureVisible(hwnd,i,FALSE); - - return(TRUE); - } - - } - - return(FALSE); - -} - - - -//============================================================================= -// -// DirList_CreateFilter() -// -// Create a valid DL_FILTER structure -// -void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec, - BOOL bExcludeFilter) -{ - - WCHAR *p; - - ZeroMemory(pdlf,sizeof(DL_FILTER)); - lstrcpyn(pdlf->tFilterBuf,lpszFileSpec,(DL_FILTER_BUFSIZE-1)); - pdlf->bExcludeFilter = bExcludeFilter; - - if (!lstrcmp(lpszFileSpec,L"*.*") || !lstrlen(lpszFileSpec)) - return; - - pdlf->nCount = 1; - pdlf->pFilter[0] = &pdlf->tFilterBuf[0]; // Zeile zum Ausprobieren - - while (p = StrChr(pdlf->pFilter[pdlf->nCount-1],L';')) - { - *p = L'\0'; // Replace L';' by L'\0' - pdlf->pFilter[pdlf->nCount] = (p + 1); // Next position after L';' - pdlf->nCount++; // Increase number of filters - } - -} - - - -//============================================================================= -// -// DirList_MatchFilter() -// -// Check if a specified item matches a given filter -// -BOOL DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf) -{ - - int i; - WIN32_FIND_DATA fd; - BOOL bMatchSpec; - - // Immediately return true if lpszFileSpec is *.* or NULL - if (pdlf->nCount == 0 && !pdlf->bExcludeFilter) - return TRUE; - - SHGetDataFromIDList(lpsf,pidl,SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA)); - - // All the directories are added - if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - return(TRUE); - - // Check if exclude *.* after directories have been added - if (pdlf->nCount == 0 && pdlf->bExcludeFilter) - return FALSE; - - for (i = 0; i < pdlf->nCount; i++) - { - if (*pdlf->pFilter[i]) // Filters like L"\0" are ignored - { - bMatchSpec = PathMatchSpec(fd.cFileName,pdlf->pFilter[i]); - if (bMatchSpec) - { - if (!pdlf->bExcludeFilter) - return(TRUE); - else - return(FALSE); - } - } - } - - // No matching - return(pdlf->bExcludeFilter)?TRUE:FALSE; - -} - - - -//==== DriveBox =============================================================== - -//============================================================================= -// -// Internal Itemdata Structure -// -typedef struct tagDC_ITEMDATA -{ - - LPITEMIDLIST pidl; - LPSHELLFOLDER lpsf; - -} DC_ITEMDATA, *LPDC_ITEMDATA; - - -//============================================================================= -// -// DriveBox_Init() -// -// Initializes the drive box -// -BOOL DriveBox_Init(HWND hwnd) -{ - - HIMAGELIST hil; - SHFILEINFO shfi; - - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - SendMessage(hwnd,CBEM_SETIMAGELIST,0,(LPARAM)hil); - SendMessage(hwnd,CBEM_SETEXTENDEDSTYLE,CBES_EX_NOSIZELIMIT,CBES_EX_NOSIZELIMIT); - - return TRUE; - -} - - -//============================================================================= -// -// DriveBox_Fill -// - -int DriveBox_Fill(HWND hwnd) -{ - - LPSHELLFOLDER lpsfDesktop; - LPSHELLFOLDER lpsf; // Workspace == CSIDL_DRIVES - - LPITEMIDLIST pidl; - LPITEMIDLIST pidlEntry; - - LPENUMIDLIST lpe; - - COMBOBOXEXITEM cbei; - LPDC_ITEMDATA lpdcid; - - ULONG dwAttributes = 0; - - DWORD grfFlags = SHCONTF_FOLDERS; - - - // Init ComboBox - SendMessage(hwnd,WM_SETREDRAW,0,0); - SendMessage(hwnd,CB_RESETCONTENT,0,0); - - ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM)); - cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM; - cbei.pszText = LPSTR_TEXTCALLBACK; - cbei.cchTextMax = MAX_PATH; - cbei.iImage = I_IMAGECALLBACK; - cbei.iSelectedImage = I_IMAGECALLBACK; - - - // Get pidl to [My Computer] - if (NOERROR == SHGetSpecialFolderLocation(hwnd, - CSIDL_DRIVES, - &pidl)) - { - - // Get Desktop Folder - if (NOERROR == SHGetDesktopFolder(&lpsfDesktop)) - { - - // Bind pidl to IShellFolder - if (NOERROR == lpsfDesktop->lpVtbl->BindToObject( - lpsfDesktop, - pidl, - NULL, - &IID_IShellFolder, - &lpsf)) - - { - - // Create an Enumeration object for lpsf - if (NOERROR == lpsf->lpVtbl->EnumObjects( - lpsf, - hwnd, - grfFlags, - &lpe)) - - { - - // Enumerate the contents of [My Computer] - while (NOERROR == lpe->lpVtbl->Next( - lpe, - 1, - &pidlEntry, - NULL)) - - { - - // Add item to the List if it is part of the - // Filesystem - dwAttributes = SFGAO_FILESYSTEM; - - lpsf->lpVtbl->GetAttributesOf( - lpsf, - 1, - &pidlEntry, - &dwAttributes); - - if (dwAttributes & SFGAO_FILESYSTEM) - { - - // Windows XP: check if pidlEntry is a drive - SHDESCRIPTIONID di; - HRESULT hr; - hr = SHGetDataFromIDList(lpsf,pidlEntry,SHGDFIL_DESCRIPTIONID, - &di,sizeof(SHDESCRIPTIONID)); - if (hr != NOERROR || (di.dwDescriptionId >= SHDID_COMPUTER_DRIVE35 && - di.dwDescriptionId <= SHDID_COMPUTER_OTHER)) - { - - lpdcid = CoTaskMemAlloc(sizeof(DC_ITEMDATA)); - - //lpdcid->pidl = IL_Copy(pidlEntry); - lpdcid->pidl = pidlEntry; - lpdcid->lpsf = lpsf; - - lpsf->lpVtbl->AddRef(lpsf); - - // Insert sorted ... - { - COMBOBOXEXITEM cbei2; - LPDC_ITEMDATA lpdcid2; - HRESULT hr; - cbei2.mask = CBEIF_LPARAM; - cbei2.iItem = 0; - - while ((SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei2))) - { - lpdcid2 = (LPDC_ITEMDATA)cbei2.lParam; - hr = (lpdcid->lpsf->lpVtbl->CompareIDs( - lpdcid->lpsf, - 0, - lpdcid->pidl, - lpdcid2->pidl)); - - if ((short)(SCODE_CODE(GetScode(hr))) < 0) - break; - else - cbei2.iItem++; - } - - cbei.iItem = cbei2.iItem; - cbei.lParam = (LPARAM)lpdcid; - SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei); - - } - - } - - } - - } // IEnumIDList::Next() - - lpe->lpVtbl->Release(lpe); - - } // IShellFolder::EnumObjects() - - lpsf->lpVtbl->Release(lpsf); - - } // IShellFolder::BindToObject() - - CoTaskMemFree(pidl); - - } // SHGetSpecialFolderLocation() - - lpsfDesktop->lpVtbl->Release(lpsfDesktop); - - } // SHGetDesktopFolder() - - - SendMessage(hwnd,WM_SETREDRAW,1,0); - // Return number of items added to combo box - return ((int)SendMessage(hwnd,CB_GETCOUNT,0,0)); - -} - - -//============================================================================= -// -// DriveBox_GetSelDrive -// -BOOL DriveBox_GetSelDrive(HWND hwnd,LPWSTR lpszDrive,int nDrive,BOOL fNoSlash) -{ - - COMBOBOXEXITEM cbei; - LPDC_ITEMDATA lpdcid; - int i = (int)SendMessage(hwnd,CB_GETCURSEL,0,0); - - // CB_ERR means no Selection - if (i == CB_ERR) - return FALSE; - - // Get DC_ITEMDATA* of selected Item - cbei.mask = CBEIF_LPARAM; - cbei.iItem = i; - SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); - lpdcid = (LPDC_ITEMDATA)cbei.lParam; - - // Get File System Path for Drive - IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,lpszDrive,nDrive); - - // Remove Backslash if required (makes Drive relative!!!) - if (fNoSlash) - PathRemoveBackslash(lpszDrive); - - return TRUE; - -} - - -//============================================================================= -// -// DriveBox_SelectDrive -// -BOOL DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath) -{ - - COMBOBOXEXITEM cbei; - LPDC_ITEMDATA lpdcid; - WCHAR szRoot[64]; - - int i; - int cbItems = (int)SendMessage(hwnd,CB_GETCOUNT,0,0); - - // No Drives in Combo Box - if (!cbItems) - return FALSE; - - cbei.mask = CBEIF_LPARAM; - - for (i = 0; i < cbItems; i++) - { - // Get DC_ITEMDATA* of Item i - cbei.iItem = i; - SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); - lpdcid = (LPDC_ITEMDATA)cbei.lParam; - - // Get File System Path for Drive - IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szRoot,64); - - // Compare Root Directory with Path - if (PathIsSameRoot(lpszPath,szRoot)) - { - // Select matching Drive - SendMessage(hwnd,CB_SETCURSEL,i,0); - return TRUE; - } - } - - // Don't select anything - SendMessage(hwnd,CB_SETCURSEL,(WPARAM)-1,0); - return FALSE; - -} - - -//============================================================================= -// -// DriveBox_PropertyDlg() -// -// Shows standard Win95 Property Dlg for selected Drive -// -BOOL DriveBox_PropertyDlg(HWND hwnd) -{ - - COMBOBOXEXITEM cbei; - LPDC_ITEMDATA lpdcid; - int iItem; - LPCONTEXTMENU lpcm; - CMINVOKECOMMANDINFO cmi; - BOOL bSuccess = TRUE; - - static const char *lpVerb = "properties"; - - iItem = (int)SendMessage(hwnd,CB_GETCURSEL,0,0); - - if (iItem == CB_ERR) - return FALSE; - - cbei.mask = CBEIF_LPARAM; - cbei.iItem = iItem; - SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); - lpdcid = (LPDC_ITEMDATA)cbei.lParam; - - if (NOERROR == lpdcid->lpsf->lpVtbl->GetUIObjectOf( - lpdcid->lpsf, - GetParent(hwnd), // Owner - 1, // Number of objects - &lpdcid->pidl, // pidl - &IID_IContextMenu, - NULL, - &lpcm)) - { - - cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); - cmi.fMask = 0; - cmi.hwnd = GetParent(hwnd); - cmi.lpVerb = lpVerb; - cmi.lpParameters = NULL; - cmi.lpDirectory = NULL; - cmi.nShow = SW_SHOWNORMAL; - cmi.dwHotKey = 0; - cmi.hIcon = NULL; - - if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi)) - bSuccess = FALSE; - - lpcm->lpVtbl->Release(lpcm); - - } - - else - bSuccess = FALSE; - - return(bSuccess); - -} - - -//============================================================================= -// -// DriveBox_DeleteItem -// -LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam) -{ - - NMCOMBOBOXEX *lpnmcbe; - COMBOBOXEXITEM cbei; - LPDC_ITEMDATA lpdcid; - - lpnmcbe = (LPVOID)lParam; - cbei.iItem = lpnmcbe->ceItem.iItem; - - cbei.mask = CBEIF_LPARAM; - SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); - lpdcid = (LPDC_ITEMDATA)cbei.lParam; - - // Free pidl - CoTaskMemFree(lpdcid->pidl); - // Release lpsf - lpdcid->lpsf->lpVtbl->Release(lpdcid->lpsf); - - // Free lpdcid itself - CoTaskMemFree(lpdcid); - - return TRUE; - -} - - -//============================================================================= -// -// DriveBox_GetDispInfo -// -LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam) -{ - - NMCOMBOBOXEX *lpnmcbe; - LPDC_ITEMDATA lpdcid; - SHFILEINFO shfi; - WCHAR szTemp[256]; - - lpnmcbe = (LPVOID)lParam; - lpdcid = (LPDC_ITEMDATA)lpnmcbe->ceItem.lParam; - - if (!lpdcid) - return FALSE; - - // Get Display Name - if (lpnmcbe->ceItem.mask & CBEIF_TEXT) - IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_NORMAL,lpnmcbe->ceItem.pszText,lpnmcbe->ceItem.cchTextMax); - - // Get Icon Index - if (lpnmcbe->ceItem.mask & (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE)) - { - IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,256); - SHGetFileInfo(szTemp,0,&shfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - lpnmcbe->ceItem.iImage = shfi.iIcon; - lpnmcbe->ceItem.iSelectedImage = shfi.iIcon; - } - - // Set values - lpnmcbe->ceItem.mask |= CBEIF_DI_SETITEM; - - return TRUE; - -} - - - -//==== ItemID ================================================================= - -//============================================================================= -// -// IL_Create() -// -// Creates an ITEMIDLIST by concatenating pidl1 and pidl2 -// cb1 and cb2 indicate the sizes of the pidls, where cb1 -// can be zero and pidl1 can be NULL -// -// If cb2 is zero, the size of pidl2 is retrieved using -// IL_GetSize(pidl2) -// -LPITEMIDLIST IL_Create(LPCITEMIDLIST pidl1,UINT cb1, - LPCITEMIDLIST pidl2,UINT cb2) -{ - - LPITEMIDLIST pidl; - - if (!pidl2) - return NULL; - - if (!cb2) - cb2 = IL_GetSize(pidl2) + 2; // Space for terminating Bytes - - if (!cb1) - cb1 = IL_GetSize(pidl1); - - // Allocate Memory - pidl = CoTaskMemAlloc(cb1 + cb2); - - // Init new ITEMIDLIST - if (pidl1) - CopyMemory(pidl,pidl1,cb1); - - // pidl2 can't be NULL here - CopyMemory((LPBYTE)pidl + cb1,pidl2,cb2); - - return pidl; - -} - - -//============================================================================= -// -// IL_GetSize() -// -// Retrieves the number of bytes in a pidl -// Does not add space for zero terminators !! -// -UINT IL_GetSize(LPCITEMIDLIST pidl) -{ - - LPITEMIDLIST pidlTmp; - UINT cb = 0; - - if (!pidl) - return 0; - - for (pidlTmp = (LPITEMIDLIST)pidl; - pidlTmp->mkid.cb; - pidlTmp = _IL_Next(pidlTmp)) - - cb += pidlTmp->mkid.cb; - - - return cb; - -} - - -//============================================================================= -// -// IL_GetDisplayName() -// -// Gets the Display Name of a pidl. lpsf is the parent IShellFolder Interface -// dwFlags specify a SHGDN_xx value -// -BOOL IL_GetDisplayName(LPSHELLFOLDER lpsf, - LPCITEMIDLIST pidl, - DWORD dwFlags, - LPWSTR lpszDisplayName, - int nDisplayName) -{ - - STRRET str; - - if (NOERROR == lpsf->lpVtbl->GetDisplayNameOf(lpsf, - pidl, - dwFlags, - &str)) - { - - // Shlwapi.dll provides new function: - return StrRetToBuf(&str,pidl,lpszDisplayName,nDisplayName); - // ...but I suppose my version is faster ;-) - /*switch (str.uType) - { - - case STRRET_WSTR: - WideCharToMultiByte(CP_ACP, - 0, - str.pOleStr, - -1, - lpszDisplayName, - nDisplayName, - NULL, - NULL); - CoTaskMemFree(str.pOleStr); - break; - - case STRRET_OFFSET: - lstrcpyn(lpszDisplayName, - ((WCHAR *)(pidl)) + str.uOffset, - nDisplayName); - break; - - case STRRET_CSTR: - lstrcpyn(lpszDisplayName,str.cStr,nDisplayName); - break; - - } - - return TRUE;*/ - } - - return FALSE; -} - - - -/// End of Dlapi.c \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Dlapi.c +* Directory Listing APIs used in Notepad2 +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include "dlapi.h" + + + +//==== DirList ================================================================ + +//==== DLDATA Structure ======================================================= + +typedef struct tagDLDATA // dl +{ + + HWND hwnd; // HWND of ListView Control + UINT cbidl; // Size of pidl + LPITEMIDLIST pidl; // Directory Id + LPSHELLFOLDER lpsf; // IShellFolder Interface to pidl + WCHAR szPath[MAX_PATH]; // Pathname to Directory Id + int iDefIconFolder; // Default Folder Icon + int iDefIconFile; // Default File Icon + BOOL bNoFadeHidden; // Flag passed from GetDispInfo() + HANDLE hExitThread; // Flag is set when Icon Thread should terminate + HANDLE hTerminatedThread; // Flag is set when Icon Thread has terminated + +} DLDATA, *LPDLDATA; + + +//==== Property Name ========================================================== +static const WCHAR *pDirListProp = L"DirListData"; + + + +//============================================================================= +// +// DirList_Init() +// +// Initializes the DLDATA structure and sets up the listview control +// +BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader) +{ + + HIMAGELIST hil; + SHFILEINFO shfi; + LV_COLUMN lvc; + + // Allocate DirListData Property + LPDLDATA lpdl = (LPVOID)GlobalAlloc(GPTR,sizeof(DLDATA)); + SetProp(hwnd,pDirListProp,(HANDLE)lpdl); + + // Setup dl + lpdl->hwnd = hwnd; + lpdl->cbidl = 0; + lpdl->pidl = NULL; + lpdl->lpsf = NULL; + lstrcpy(lpdl->szPath,L""); + + // Add Imagelists + hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + + ListView_SetImageList(hwnd,hil,LVSIL_SMALL); + + hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), + SHGFI_LARGEICON | SHGFI_SYSICONINDEX); + + ListView_SetImageList(hwnd,hil,LVSIL_NORMAL); + + // Initialize default icons - done in DirList_Fill() + //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + //lpdl->iDefIconFolder = shfi.iIcon; + + //SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), + // SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + //lpdl->iDefIconFile = shfi.iIcon; + + lpdl->iDefIconFolder = 0; + lpdl->iDefIconFile = 0; + + // Icon thread control + lpdl->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL); + lpdl->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL); + + lvc; + pszHeader; + + return TRUE; + +} + + +//============================================================================= +// +// DirList_Destroy() +// +// Free memory used by dl structure +// +BOOL DirList_Destroy(HWND hwnd) +{ + + LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); + + // Release multithreading objects + DirList_TerminateIconThread(hwnd); + CloseHandle(lpdl->hExitThread); + CloseHandle(lpdl->hTerminatedThread); + + if (lpdl->pidl) + CoTaskMemFree(lpdl->pidl); + + if (lpdl->lpsf) + lpdl->lpsf->lpVtbl->Release(lpdl->lpsf); + + // Free DirListData Property + RemoveProp(hwnd,pDirListProp); + GlobalFree(lpdl); + + return FALSE; + +} + + +//============================================================================= +// +// DirList_StartIconThread() +// +// Start thread to extract file icons in the background +// +BOOL DirList_StartIconThread(HWND hwnd) +{ + + DWORD dwtid; + LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); + + DirList_TerminateIconThread(hwnd); + + ResetEvent(lpdl->hExitThread); + //ResetEvent(lpdl->hTerminatedThread); + + CreateThread(NULL,0,DirList_IconThread,(LPVOID)lpdl,0,&dwtid); + + return TRUE; + +} + + +//============================================================================= +// +// DirList_TerminateIconThread() +// +// Terminate Icon Thread and reset multithreading control structures +// +BOOL DirList_TerminateIconThread(HWND hwnd) +{ + + LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); + + SetEvent(lpdl->hExitThread); + + //WaitForSingleObject(lpdl->hTerminatedThread,INFINITE); + while (WaitForSingleObject(lpdl->hTerminatedThread,0) != WAIT_OBJECT_0) + { + MSG msg; + if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + ResetEvent(lpdl->hExitThread); + SetEvent(lpdl->hTerminatedThread); + + return TRUE; + +} + + +//============================================================================= +// +// DirList_Fill() +// +// Snapshots a directory and displays the items in the listview control +// +int DirList_Fill(HWND hwnd,LPCWSTR lpszDir,DWORD grfFlags,LPCWSTR lpszFileSpec, + BOOL bExcludeFilter,BOOL bNoFadeHidden, + int iSortFlags,BOOL fSortRev) +{ + + WCHAR wszDir[MAX_PATH]; + + LPSHELLFOLDER lpsfDesktop = NULL; + LPSHELLFOLDER lpsf = NULL; + + LPITEMIDLIST pidl = NULL; + LPITEMIDLIST pidlEntry = NULL; + + LPENUMIDLIST lpe = NULL; + + LV_ITEM lvi; + LPLV_ITEMDATA lplvid; + + ULONG chParsed = 0; + ULONG dwAttributes = 0; + + DL_FILTER dlf; + SHFILEINFO shfi; + + LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); + + // Initialize default icons + SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + lpdl->iDefIconFolder = shfi.iIcon; + + SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), + SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + lpdl->iDefIconFile = shfi.iIcon; + + // First of all terminate running icon thread + DirList_TerminateIconThread(hwnd); + + // A Directory is strongly required + if (!lpszDir || !*lpszDir) + return(-1); + + lstrcpy(lpdl->szPath,lpszDir); + + // Init ListView + SendMessage(hwnd,WM_SETREDRAW,0,0); + ListView_DeleteAllItems(hwnd); + + // Init Filter + DirList_CreateFilter(&dlf,lpszFileSpec,bExcludeFilter); + + // Init lvi + lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvi.iItem = 0; + lvi.iSubItem = 0; + lvi.pszText = LPSTR_TEXTCALLBACK; + lvi.cchTextMax = MAX_PATH; + lvi.iImage = I_IMAGECALLBACK; + + // Convert Directory to a UNICODE string + /*MultiByteToWideChar(CP_ACP, + MB_PRECOMPOSED, + lpszDir, + -1, + wszDir, + MAX_PATH);*/ + lstrcpy(wszDir,lpszDir); + + + // Get Desktop Folder + if (NOERROR == SHGetDesktopFolder(&lpsfDesktop)) + { + + // Convert wszDir into a pidl + if (NOERROR == lpsfDesktop->lpVtbl->ParseDisplayName( + lpsfDesktop, + hwnd, + NULL, + wszDir, + &chParsed, + &pidl, + &dwAttributes)) + + { + + // Bind pidl to IShellFolder + if (NOERROR == lpsfDesktop->lpVtbl->BindToObject( + lpsfDesktop, + pidl, + NULL, + &IID_IShellFolder, + &lpsf)) + + { + + // Create an Enumeration object for lpsf + if (NOERROR == lpsf->lpVtbl->EnumObjects( + lpsf, + hwnd, + grfFlags, + &lpe)) + + { + + // Enumerate the contents of lpsf + while (NOERROR == lpe->lpVtbl->Next( + lpe, + 1, + &pidlEntry, + NULL)) + + { + + // Add found item to the List + // Check if it's part of the Filesystem + dwAttributes = SFGAO_FILESYSTEM | SFGAO_FOLDER; + + lpsf->lpVtbl->GetAttributesOf( + lpsf, + 1, + &pidlEntry, + &dwAttributes); + + if (dwAttributes & SFGAO_FILESYSTEM) + { + + // Check if item matches specified filter + if (DirList_MatchFilter(lpsf,pidlEntry,&dlf)) + { + + lplvid = CoTaskMemAlloc(sizeof(LV_ITEMDATA)); + + lplvid->pidl = pidlEntry; + lplvid->lpsf = lpsf; + + lpsf->lpVtbl->AddRef(lpsf); + + lvi.lParam = (LPARAM)lplvid; + + // Setup default Icon - Folder or File + lvi.iImage = (dwAttributes & SFGAO_FOLDER) ? + lpdl->iDefIconFolder : lpdl->iDefIconFile; + + ListView_InsertItem(hwnd,&lvi); + + lvi.iItem++; + + } + + } + + } // IEnumIDList::Next() + + lpe->lpVtbl->Release(lpe); + + } // IShellFolder::EnumObjects() + + } // IShellFolder::BindToObject() + + } // IShellFolder::ParseDisplayName() + + lpsfDesktop->lpVtbl->Release(lpsfDesktop); + + } // SHGetDesktopFolder() + + if (lpdl->pidl) + CoTaskMemFree(lpdl->pidl); + + if (lpdl->lpsf && lpdl->lpsf->lpVtbl) + lpdl->lpsf->lpVtbl->Release(lpdl->lpsf); + + // Set lpdl + lpdl->cbidl = IL_GetSize(pidl); + lpdl->pidl = pidl; + lpdl->lpsf = lpsf; + lpdl->bNoFadeHidden = bNoFadeHidden; + + // Set column width to fit window + ListView_SetColumnWidth(hwnd,0,LVSCW_AUTOSIZE_USEHEADER); + + // Sort before display is updated + DirList_Sort(hwnd,iSortFlags,fSortRev); + + // Redraw Listview + SendMessage(hwnd,WM_SETREDRAW,1,0); + + // Return number of items in the control + return (ListView_GetItemCount(hwnd)); + +} + + +//============================================================================= +// +// DirList_IconThread() +// +// Thread to extract file icons in the background +// +DWORD WINAPI DirList_IconThread(LPVOID lpParam) +{ + + HWND hwnd; + + LPDLDATA lpdl; + LV_ITEM lvi; + LPLV_ITEMDATA lplvid; + + IShellIcon* lpshi; + + int iItem = 0; + int iMaxItem; + + lpdl = (LPDLDATA)lpParam; + ResetEvent(lpdl->hTerminatedThread); + + // Exit immediately if DirList_Fill() hasn't been called + if (!lpdl->lpsf) { + SetEvent(lpdl->hTerminatedThread); + ExitThread(0); + return(0); + } + + hwnd = lpdl->hwnd; + iMaxItem = ListView_GetItemCount(hwnd); + + CoInitialize(NULL); + + // Get IShellIcon + lpdl->lpsf->lpVtbl->QueryInterface(lpdl->lpsf,&IID_IShellIcon,&lpshi); + + while (iItem < iMaxItem && WaitForSingleObject(lpdl->hExitThread,0) != WAIT_OBJECT_0) { + + lvi.iItem = iItem; + lvi.mask = LVIF_PARAM; + if (ListView_GetItem(hwnd,&lvi)) { + + SHFILEINFO shfi; + LPITEMIDLIST pidl; + DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE; + + lplvid = (LPLV_ITEMDATA)lvi.lParam; + + lvi.mask = LVIF_IMAGE; + + if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage)) + { + pidl = IL_Create(lpdl->pidl,lpdl->cbidl,lplvid->pidl,0); + SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + CoTaskMemFree(pidl); + lvi.iImage = shfi.iIcon; + } + + // It proved necessary to reset the state bits... + lvi.stateMask = 0; + lvi.state = 0; + + // Link and Share Overlay + lplvid->lpsf->lpVtbl->GetAttributesOf( + lplvid->lpsf, + 1,&lplvid->pidl, + &dwAttributes); + + if (dwAttributes & SFGAO_LINK) + { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_OVERLAYMASK; + lvi.state |= INDEXTOOVERLAYMASK(2); + } + + if (dwAttributes & SFGAO_SHARE) + { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_OVERLAYMASK; + lvi.state |= INDEXTOOVERLAYMASK(1); + } + + // Fade hidden/system files + if (!lpdl->bNoFadeHidden) + { + WIN32_FIND_DATA fd; + if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,lplvid->pidl, + SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA))) + { + if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || + (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) + { + lvi.mask |= LVIF_STATE; + lvi.stateMask |= LVIS_CUT; + lvi.state |= LVIS_CUT; + } + } + } + lvi.iSubItem = 0; + ListView_SetItem(hwnd,&lvi); + } + iItem++; + } + + if (lpshi) + lpshi->lpVtbl->Release(lpshi); + + CoUninitialize(); + + SetEvent(lpdl->hTerminatedThread); + ExitThread(0); + return(0); + +} + + +//============================================================================= +// +// DirList_GetDispInfo() +// +// Must be called in response to a WM_NOTIFY/LVN_GETDISPINFO message from +// the listview control +// +BOOL DirList_GetDispInfo(HWND hwnd,LPARAM lParam,BOOL bNoFadeHidden) +{ + + LV_DISPINFO *lpdi = (LPVOID)lParam; + + LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lpdi->item.lParam; + + // SubItem 0 is handled only + if (lpdi->item.iSubItem != 0) + return FALSE; + + // Text + if (lpdi->item.mask & LVIF_TEXT) + IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER, + lpdi->item.pszText,lpdi->item.cchTextMax); + + // Set values + lpdi->item.mask |= LVIF_DI_SETITEM; + + return TRUE; + +} + + +//============================================================================= +// +// DirList_DeleteItem() +// +// Must be called in response to a WM_NOTIFY/LVN_DELETEITEM message +// from the control +// +BOOL DirList_DeleteItem(HWND hwnd,LPARAM lParam) +{ + + LV_ITEM lvi; + + NM_LISTVIEW *lpnmlv = (LPVOID)lParam; + + lvi.iItem = lpnmlv->iItem; + lvi.iSubItem = 0; + lvi.mask = LVIF_PARAM; + + if (ListView_GetItem(hwnd,&lvi)) + { + + // Free mem + LPLV_ITEMDATA lplvid = (LPLV_ITEMDATA)lvi.lParam; + CoTaskMemFree(lplvid->pidl); + lplvid->lpsf->lpVtbl->Release(lplvid->lpsf); + + CoTaskMemFree(lplvid); + + return TRUE; + + } + + else + return FALSE; + +} + + +//============================================================================= +// +// DirList_CompareProc() +// +// Compares two list items +// +int CALLBACK DirList_CompareProcFw(LPARAM lp1,LPARAM lp2,LPARAM lFlags) +{ + + HRESULT hr; + int result; + + LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1; + LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2; + + hr = (lplvid1->lpsf->lpVtbl->CompareIDs( + lplvid1->lpsf, + lFlags, + lplvid1->pidl, + lplvid2->pidl)); + + result = (short)(SCODE_CODE(GetScode(hr))); + + if (result != 0 || lFlags == 0) + return(result); + + hr = (lplvid1->lpsf->lpVtbl->CompareIDs( + lplvid1->lpsf, + 0, + lplvid1->pidl, + lplvid2->pidl)); + + result = (short)(SCODE_CODE(GetScode(hr))); + + return(result); + +} + +int CALLBACK DirList_CompareProcRw(LPARAM lp1,LPARAM lp2,LPARAM lFlags) +{ + + HRESULT hr; + int result; + + LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1; + LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2; + + hr = (lplvid1->lpsf->lpVtbl->CompareIDs( + lplvid1->lpsf, + lFlags, + lplvid1->pidl, + lplvid2->pidl)); + + result = -(short)(SCODE_CODE(GetScode(hr))); + + if (result != 0) + return(result); + + hr = (lplvid1->lpsf->lpVtbl->CompareIDs( + lplvid1->lpsf, + 0, + lplvid1->pidl, + lplvid2->pidl)); + + result = -(short)(SCODE_CODE(GetScode(hr))); + + return(result); + +} + + +//============================================================================= +// +// DirList_Sort() +// +// Sorts the listview control by the specified order +// +BOOL DirList_Sort(HWND hwnd,int lFlags,BOOL fRev) +{ + + if (fRev) + return ListView_SortItems(hwnd,DirList_CompareProcRw,lFlags); + + else + return ListView_SortItems(hwnd,DirList_CompareProcFw,lFlags); + +} + + +//============================================================================= +// +// DirList_GetItem() +// +// Copies the data of the specified item in the listview control to a buffer +// +int DirList_GetItem(HWND hwnd,int iItem,LPDLITEM lpdli) +{ + + LV_ITEM lvi; + LPLV_ITEMDATA lplvid; + + ULONG dwAttributes = SFGAO_FILESYSTEM; + + + if (iItem == -1) + { + + if (ListView_GetSelectedCount(hwnd)) + + iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); + + else + + return(-1); + + } + + lvi.mask = LVIF_PARAM; + lvi.iItem = iItem; + lvi.iSubItem = 0; + + if (!ListView_GetItem(hwnd,&lvi)) + { + + if (lpdli->mask & DLI_TYPE) + + lpdli->ntype = DLE_NONE; + + return(-1); + + } + + lplvid = (LPLV_ITEMDATA)lvi.lParam; + + // Filename + if (lpdli->mask & DLI_FILENAME) + + IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_FORPARSING, + lpdli->szFileName,MAX_PATH); + + // Displayname + if (lpdli->mask & DLI_DISPNAME) + + IL_GetDisplayName(lplvid->lpsf,lplvid->pidl,SHGDN_INFOLDER, + lpdli->szDisplayName,MAX_PATH); + + // Type (File / Directory) + if (lpdli->mask & DLI_TYPE) + { + + WIN32_FIND_DATA fd; + + if (NOERROR == SHGetDataFromIDList(lplvid->lpsf, + lplvid->pidl, + SHGDFIL_FINDDATA, + &fd, + sizeof(WIN32_FIND_DATA))) + + lpdli->ntype = (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? + DLE_DIR : DLE_FILE; + + /*lplvid->lpsf->lpVtbl->GetAttributesOf( + lplvid->lpsf, + 1, + &lplvid->pidl, + &dwAttributes); + + lpdli->ntype = (dwAttributes & SFGAO_FOLDER) ? DLE_DIR : DLE_FILE;*/ + + } + + return iItem; + +} + + +//============================================================================= +// +// DirList_GetItemEx() +// +// Retrieves extended infomration on a dirlist item +// +int DirList_GetItemEx(HWND hwnd,int iItem,LPWIN32_FIND_DATA pfd) +{ + + LV_ITEM lvi; + LPLV_ITEMDATA lplvid; + + + if (iItem == -1) + { + + if (ListView_GetSelectedCount(hwnd)) + + iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); + + else + + return(-1); + + } + + lvi.mask = LVIF_PARAM; + lvi.iItem = iItem; + lvi.iSubItem = 0; + + if (!ListView_GetItem(hwnd,&lvi)) + return(-1); + + lplvid = (LPLV_ITEMDATA)lvi.lParam; + + if (NOERROR == SHGetDataFromIDList(lplvid->lpsf, + lplvid->pidl, + SHGDFIL_FINDDATA, + pfd, + sizeof(WIN32_FIND_DATA))) + return iItem; + + else + return(-1); + +} + + +//============================================================================= +// +// DirList_PropertyDlg() +// +// Shows standard Win95 Property Dlg for selected Item +// +BOOL DirList_PropertyDlg(HWND hwnd,int iItem) +{ + + LV_ITEM lvi; + LPLV_ITEMDATA lplvid; + LPCONTEXTMENU lpcm; + CMINVOKECOMMANDINFO cmi; + BOOL bSuccess = TRUE; + + static const char *lpVerb = "properties"; + + if (iItem == -1) + { + if (ListView_GetSelectedCount(hwnd)) + iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); + + else + return FALSE; + } + + lvi.mask = LVIF_PARAM; + lvi.iItem = iItem; + lvi.iSubItem = 0; + + if (!ListView_GetItem(hwnd,&lvi)) + return FALSE; + + lplvid = (LPLV_ITEMDATA)lvi.lParam; + + if (NOERROR == lplvid->lpsf->lpVtbl->GetUIObjectOf( + lplvid->lpsf, + GetParent(hwnd), // Owner + 1, // Number of objects + &lplvid->pidl, // pidl + &IID_IContextMenu, + NULL, + &lpcm)) + { + + cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); + cmi.fMask = 0; + cmi.hwnd = GetParent(hwnd); + cmi.lpVerb = lpVerb; + cmi.lpParameters = NULL; + cmi.lpDirectory = NULL; + cmi.nShow = SW_SHOWNORMAL; + cmi.dwHotKey = 0; + cmi.hIcon = NULL; + + if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi)) + bSuccess = FALSE; + + lpcm->lpVtbl->Release(lpcm); + + } + + else + bSuccess = FALSE; + + return(bSuccess); + +} + + + +//============================================================================= +// +// DirList_GetLongPathName() +// +// Get long pathname for currently displayed directory +// +BOOL DirList_GetLongPathName(HWND hwnd,LPWSTR lpszLongPath) +{ + WCHAR tch[MAX_PATH]; + LPDLDATA lpdl = (LPVOID)GetProp(hwnd,pDirListProp); + if (SHGetPathFromIDList(lpdl->pidl,tch)) + { + lstrcpy(lpszLongPath,tch); + return(TRUE); + } + else + return(FALSE); +} + + + +//============================================================================= +// +// DirList_SelectItem() +// +// Select specified item in the list +// +BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath) +{ + + #define LVIS_FLAGS LVIS_SELECTED|LVIS_FOCUSED + + WCHAR szShortPath[MAX_PATH]; + SHFILEINFO shfi; + + LV_FINDINFO lvfi; + DLITEM dli; + + int i = -1; + + if (!lpszFullPath || !lstrlen(lpszFullPath)) + return(FALSE); + else + GetShortPathName(lpszFullPath,szShortPath,MAX_PATH); + + if (!lpszDisplayName || !lstrlen(lpszDisplayName)) + SHGetFileInfo(lpszFullPath,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + else + lstrcpyn(shfi.szDisplayName,lpszDisplayName,MAX_PATH); + + lvfi.flags = LVFI_STRING; + lvfi.psz = shfi.szDisplayName; + + dli.mask = DLI_ALL; + + while ((i = ListView_FindItem(hwnd,i,&lvfi)) != -1) + { + + DirList_GetItem(hwnd,i,&dli); + GetShortPathName(dli.szFileName,dli.szFileName,MAX_PATH); + + if (!lstrcmpi(dli.szFileName,szShortPath)) + { + ListView_SetItemState(hwnd,i,LVIS_FLAGS,LVIS_FLAGS); + ListView_EnsureVisible(hwnd,i,FALSE); + + return(TRUE); + } + + } + + return(FALSE); + +} + + + +//============================================================================= +// +// DirList_CreateFilter() +// +// Create a valid DL_FILTER structure +// +void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec, + BOOL bExcludeFilter) +{ + + WCHAR *p; + + ZeroMemory(pdlf,sizeof(DL_FILTER)); + lstrcpyn(pdlf->tFilterBuf,lpszFileSpec,(DL_FILTER_BUFSIZE-1)); + pdlf->bExcludeFilter = bExcludeFilter; + + if (!lstrcmp(lpszFileSpec,L"*.*") || !lstrlen(lpszFileSpec)) + return; + + pdlf->nCount = 1; + pdlf->pFilter[0] = &pdlf->tFilterBuf[0]; // Zeile zum Ausprobieren + + while (p = StrChr(pdlf->pFilter[pdlf->nCount-1],L';')) + { + *p = L'\0'; // Replace L';' by L'\0' + pdlf->pFilter[pdlf->nCount] = (p + 1); // Next position after L';' + pdlf->nCount++; // Increase number of filters + } + +} + + + +//============================================================================= +// +// DirList_MatchFilter() +// +// Check if a specified item matches a given filter +// +BOOL DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf) +{ + + int i; + WIN32_FIND_DATA fd; + BOOL bMatchSpec; + + // Immediately return true if lpszFileSpec is *.* or NULL + if (pdlf->nCount == 0 && !pdlf->bExcludeFilter) + return TRUE; + + SHGetDataFromIDList(lpsf,pidl,SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA)); + + // All the directories are added + if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + return(TRUE); + + // Check if exclude *.* after directories have been added + if (pdlf->nCount == 0 && pdlf->bExcludeFilter) + return FALSE; + + for (i = 0; i < pdlf->nCount; i++) + { + if (*pdlf->pFilter[i]) // Filters like L"\0" are ignored + { + bMatchSpec = PathMatchSpec(fd.cFileName,pdlf->pFilter[i]); + if (bMatchSpec) + { + if (!pdlf->bExcludeFilter) + return(TRUE); + else + return(FALSE); + } + } + } + + // No matching + return(pdlf->bExcludeFilter)?TRUE:FALSE; + +} + + + +//==== DriveBox =============================================================== + +//============================================================================= +// +// Internal Itemdata Structure +// +typedef struct tagDC_ITEMDATA +{ + + LPITEMIDLIST pidl; + LPSHELLFOLDER lpsf; + +} DC_ITEMDATA, *LPDC_ITEMDATA; + + +//============================================================================= +// +// DriveBox_Init() +// +// Initializes the drive box +// +BOOL DriveBox_Init(HWND hwnd) +{ + + HIMAGELIST hil; + SHFILEINFO shfi; + + hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + SendMessage(hwnd,CBEM_SETIMAGELIST,0,(LPARAM)hil); + SendMessage(hwnd,CBEM_SETEXTENDEDSTYLE,CBES_EX_NOSIZELIMIT,CBES_EX_NOSIZELIMIT); + + return TRUE; + +} + + +//============================================================================= +// +// DriveBox_Fill +// + +int DriveBox_Fill(HWND hwnd) +{ + + LPSHELLFOLDER lpsfDesktop; + LPSHELLFOLDER lpsf; // Workspace == CSIDL_DRIVES + + LPITEMIDLIST pidl; + LPITEMIDLIST pidlEntry; + + LPENUMIDLIST lpe; + + COMBOBOXEXITEM cbei; + LPDC_ITEMDATA lpdcid; + + ULONG dwAttributes = 0; + + DWORD grfFlags = SHCONTF_FOLDERS; + + + // Init ComboBox + SendMessage(hwnd,WM_SETREDRAW,0,0); + SendMessage(hwnd,CB_RESETCONTENT,0,0); + + ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM)); + cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM; + cbei.pszText = LPSTR_TEXTCALLBACK; + cbei.cchTextMax = MAX_PATH; + cbei.iImage = I_IMAGECALLBACK; + cbei.iSelectedImage = I_IMAGECALLBACK; + + + // Get pidl to [My Computer] + if (NOERROR == SHGetSpecialFolderLocation(hwnd, + CSIDL_DRIVES, + &pidl)) + { + + // Get Desktop Folder + if (NOERROR == SHGetDesktopFolder(&lpsfDesktop)) + { + + // Bind pidl to IShellFolder + if (NOERROR == lpsfDesktop->lpVtbl->BindToObject( + lpsfDesktop, + pidl, + NULL, + &IID_IShellFolder, + &lpsf)) + + { + + // Create an Enumeration object for lpsf + if (NOERROR == lpsf->lpVtbl->EnumObjects( + lpsf, + hwnd, + grfFlags, + &lpe)) + + { + + // Enumerate the contents of [My Computer] + while (NOERROR == lpe->lpVtbl->Next( + lpe, + 1, + &pidlEntry, + NULL)) + + { + + // Add item to the List if it is part of the + // Filesystem + dwAttributes = SFGAO_FILESYSTEM; + + lpsf->lpVtbl->GetAttributesOf( + lpsf, + 1, + &pidlEntry, + &dwAttributes); + + if (dwAttributes & SFGAO_FILESYSTEM) + { + + // Windows XP: check if pidlEntry is a drive + SHDESCRIPTIONID di; + HRESULT hr; + hr = SHGetDataFromIDList(lpsf,pidlEntry,SHGDFIL_DESCRIPTIONID, + &di,sizeof(SHDESCRIPTIONID)); + if (hr != NOERROR || (di.dwDescriptionId >= SHDID_COMPUTER_DRIVE35 && + di.dwDescriptionId <= SHDID_COMPUTER_OTHER)) + { + + lpdcid = CoTaskMemAlloc(sizeof(DC_ITEMDATA)); + + //lpdcid->pidl = IL_Copy(pidlEntry); + lpdcid->pidl = pidlEntry; + lpdcid->lpsf = lpsf; + + lpsf->lpVtbl->AddRef(lpsf); + + // Insert sorted ... + { + COMBOBOXEXITEM cbei2; + LPDC_ITEMDATA lpdcid2; + HRESULT hr; + cbei2.mask = CBEIF_LPARAM; + cbei2.iItem = 0; + + while ((SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei2))) + { + lpdcid2 = (LPDC_ITEMDATA)cbei2.lParam; + hr = (lpdcid->lpsf->lpVtbl->CompareIDs( + lpdcid->lpsf, + 0, + lpdcid->pidl, + lpdcid2->pidl)); + + if ((short)(SCODE_CODE(GetScode(hr))) < 0) + break; + else + cbei2.iItem++; + } + + cbei.iItem = cbei2.iItem; + cbei.lParam = (LPARAM)lpdcid; + SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei); + + } + + } + + } + + } // IEnumIDList::Next() + + lpe->lpVtbl->Release(lpe); + + } // IShellFolder::EnumObjects() + + lpsf->lpVtbl->Release(lpsf); + + } // IShellFolder::BindToObject() + + CoTaskMemFree(pidl); + + } // SHGetSpecialFolderLocation() + + lpsfDesktop->lpVtbl->Release(lpsfDesktop); + + } // SHGetDesktopFolder() + + + SendMessage(hwnd,WM_SETREDRAW,1,0); + // Return number of items added to combo box + return ((int)SendMessage(hwnd,CB_GETCOUNT,0,0)); + +} + + +//============================================================================= +// +// DriveBox_GetSelDrive +// +BOOL DriveBox_GetSelDrive(HWND hwnd,LPWSTR lpszDrive,int nDrive,BOOL fNoSlash) +{ + + COMBOBOXEXITEM cbei; + LPDC_ITEMDATA lpdcid; + int i = (int)SendMessage(hwnd,CB_GETCURSEL,0,0); + + // CB_ERR means no Selection + if (i == CB_ERR) + return FALSE; + + // Get DC_ITEMDATA* of selected Item + cbei.mask = CBEIF_LPARAM; + cbei.iItem = i; + SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); + lpdcid = (LPDC_ITEMDATA)cbei.lParam; + + // Get File System Path for Drive + IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,lpszDrive,nDrive); + + // Remove Backslash if required (makes Drive relative!!!) + if (fNoSlash) + PathRemoveBackslash(lpszDrive); + + return TRUE; + +} + + +//============================================================================= +// +// DriveBox_SelectDrive +// +BOOL DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath) +{ + + COMBOBOXEXITEM cbei; + LPDC_ITEMDATA lpdcid; + WCHAR szRoot[64]; + + int i; + int cbItems = (int)SendMessage(hwnd,CB_GETCOUNT,0,0); + + // No Drives in Combo Box + if (!cbItems) + return FALSE; + + cbei.mask = CBEIF_LPARAM; + + for (i = 0; i < cbItems; i++) + { + // Get DC_ITEMDATA* of Item i + cbei.iItem = i; + SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); + lpdcid = (LPDC_ITEMDATA)cbei.lParam; + + // Get File System Path for Drive + IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szRoot,64); + + // Compare Root Directory with Path + if (PathIsSameRoot(lpszPath,szRoot)) + { + // Select matching Drive + SendMessage(hwnd,CB_SETCURSEL,i,0); + return TRUE; + } + } + + // Don't select anything + SendMessage(hwnd,CB_SETCURSEL,(WPARAM)-1,0); + return FALSE; + +} + + +//============================================================================= +// +// DriveBox_PropertyDlg() +// +// Shows standard Win95 Property Dlg for selected Drive +// +BOOL DriveBox_PropertyDlg(HWND hwnd) +{ + + COMBOBOXEXITEM cbei; + LPDC_ITEMDATA lpdcid; + int iItem; + LPCONTEXTMENU lpcm; + CMINVOKECOMMANDINFO cmi; + BOOL bSuccess = TRUE; + + static const char *lpVerb = "properties"; + + iItem = (int)SendMessage(hwnd,CB_GETCURSEL,0,0); + + if (iItem == CB_ERR) + return FALSE; + + cbei.mask = CBEIF_LPARAM; + cbei.iItem = iItem; + SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); + lpdcid = (LPDC_ITEMDATA)cbei.lParam; + + if (NOERROR == lpdcid->lpsf->lpVtbl->GetUIObjectOf( + lpdcid->lpsf, + GetParent(hwnd), // Owner + 1, // Number of objects + &lpdcid->pidl, // pidl + &IID_IContextMenu, + NULL, + &lpcm)) + { + + cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); + cmi.fMask = 0; + cmi.hwnd = GetParent(hwnd); + cmi.lpVerb = lpVerb; + cmi.lpParameters = NULL; + cmi.lpDirectory = NULL; + cmi.nShow = SW_SHOWNORMAL; + cmi.dwHotKey = 0; + cmi.hIcon = NULL; + + if (NOERROR != lpcm->lpVtbl->InvokeCommand(lpcm,&cmi)) + bSuccess = FALSE; + + lpcm->lpVtbl->Release(lpcm); + + } + + else + bSuccess = FALSE; + + return(bSuccess); + +} + + +//============================================================================= +// +// DriveBox_DeleteItem +// +LRESULT DriveBox_DeleteItem(HWND hwnd,LPARAM lParam) +{ + + NMCOMBOBOXEX *lpnmcbe; + COMBOBOXEXITEM cbei; + LPDC_ITEMDATA lpdcid; + + lpnmcbe = (LPVOID)lParam; + cbei.iItem = lpnmcbe->ceItem.iItem; + + cbei.mask = CBEIF_LPARAM; + SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei); + lpdcid = (LPDC_ITEMDATA)cbei.lParam; + + // Free pidl + CoTaskMemFree(lpdcid->pidl); + // Release lpsf + lpdcid->lpsf->lpVtbl->Release(lpdcid->lpsf); + + // Free lpdcid itself + CoTaskMemFree(lpdcid); + + return TRUE; + +} + + +//============================================================================= +// +// DriveBox_GetDispInfo +// +LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam) +{ + + NMCOMBOBOXEX *lpnmcbe; + LPDC_ITEMDATA lpdcid; + SHFILEINFO shfi; + WCHAR szTemp[256]; + + lpnmcbe = (LPVOID)lParam; + lpdcid = (LPDC_ITEMDATA)lpnmcbe->ceItem.lParam; + + if (!lpdcid) + return FALSE; + + // Get Display Name + if (lpnmcbe->ceItem.mask & CBEIF_TEXT) + IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_NORMAL,lpnmcbe->ceItem.pszText,lpnmcbe->ceItem.cchTextMax); + + // Get Icon Index + if (lpnmcbe->ceItem.mask & (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE)) + { + IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,256); + SHGetFileInfo(szTemp,0,&shfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + lpnmcbe->ceItem.iImage = shfi.iIcon; + lpnmcbe->ceItem.iSelectedImage = shfi.iIcon; + } + + // Set values + lpnmcbe->ceItem.mask |= CBEIF_DI_SETITEM; + + return TRUE; + +} + + + +//==== ItemID ================================================================= + +//============================================================================= +// +// IL_Create() +// +// Creates an ITEMIDLIST by concatenating pidl1 and pidl2 +// cb1 and cb2 indicate the sizes of the pidls, where cb1 +// can be zero and pidl1 can be NULL +// +// If cb2 is zero, the size of pidl2 is retrieved using +// IL_GetSize(pidl2) +// +LPITEMIDLIST IL_Create(LPCITEMIDLIST pidl1,UINT cb1, + LPCITEMIDLIST pidl2,UINT cb2) +{ + + LPITEMIDLIST pidl; + + if (!pidl2) + return NULL; + + if (!cb2) + cb2 = IL_GetSize(pidl2) + 2; // Space for terminating Bytes + + if (!cb1) + cb1 = IL_GetSize(pidl1); + + // Allocate Memory + pidl = CoTaskMemAlloc(cb1 + cb2); + + // Init new ITEMIDLIST + if (pidl1) + CopyMemory(pidl,pidl1,cb1); + + // pidl2 can't be NULL here + CopyMemory((LPBYTE)pidl + cb1,pidl2,cb2); + + return pidl; + +} + + +//============================================================================= +// +// IL_GetSize() +// +// Retrieves the number of bytes in a pidl +// Does not add space for zero terminators !! +// +UINT IL_GetSize(LPCITEMIDLIST pidl) +{ + + LPITEMIDLIST pidlTmp; + UINT cb = 0; + + if (!pidl) + return 0; + + for (pidlTmp = (LPITEMIDLIST)pidl; + pidlTmp->mkid.cb; + pidlTmp = _IL_Next(pidlTmp)) + + cb += pidlTmp->mkid.cb; + + + return cb; + +} + + +//============================================================================= +// +// IL_GetDisplayName() +// +// Gets the Display Name of a pidl. lpsf is the parent IShellFolder Interface +// dwFlags specify a SHGDN_xx value +// +BOOL IL_GetDisplayName(LPSHELLFOLDER lpsf, + LPCITEMIDLIST pidl, + DWORD dwFlags, + LPWSTR lpszDisplayName, + int nDisplayName) +{ + + STRRET str; + + if (NOERROR == lpsf->lpVtbl->GetDisplayNameOf(lpsf, + pidl, + dwFlags, + &str)) + { + + // Shlwapi.dll provides new function: + return StrRetToBuf(&str,pidl,lpszDisplayName,nDisplayName); + // ...but I suppose my version is faster ;-) + /*switch (str.uType) + { + + case STRRET_WSTR: + WideCharToMultiByte(CP_ACP, + 0, + str.pOleStr, + -1, + lpszDisplayName, + nDisplayName, + NULL, + NULL); + CoTaskMemFree(str.pOleStr); + break; + + case STRRET_OFFSET: + lstrcpyn(lpszDisplayName, + ((WCHAR *)(pidl)) + str.uOffset, + nDisplayName); + break; + + case STRRET_CSTR: + lstrcpyn(lpszDisplayName,str.cStr,nDisplayName); + break; + + } + + return TRUE;*/ + } + + return FALSE; +} + + + +/// End of Dlapi.c \\\ diff --git a/src/Dlapi.h b/src/Dlapi.h index 66348669..4338c965 100644 --- a/src/Dlapi.h +++ b/src/Dlapi.h @@ -1,196 +1,196 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Dlapi.h -* Definitions for Directory Listing APIs -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - -#ifndef _DLAPI_H_ -#define _DLAPI_H_ - -#ifdef __cplusplus -extern "C" { // C-Declarations -#endif //__cplusplus - - - -//==== DirList ================================================================ - -//==== LV_ITEMDATA Structure ================================================== -typedef struct tagLV_ITEMDATA // lvid -{ - LPITEMIDLIST pidl; // Item Id - LPSHELLFOLDER lpsf; // Parent IShellFolder Interface - -} LV_ITEMDATA, *LPLV_ITEMDATA; - - -//==== DlInit() =============================================================== - -BOOL DirList_Init(HWND,LPCWSTR); - - -//==== DlDestroy() ============================================================ - -BOOL DirList_Destroy(HWND); - - -//==== DlStartIconThread() ==================================================== - -BOOL DirList_StartIconThread(HWND); - - -//==== DlTerminateIconThread() ================================================ - -BOOL DirList_TerminateIconThread(HWND); - - -//==== DlFill() =============================================================== - -#define DL_FOLDERS 32 -#define DL_NONFOLDERS 64 -#define DL_INCLHIDDEN 128 -#define DL_ALLOBJECTS (32|64|128) - -int DirList_Fill(HWND,LPCWSTR,DWORD,LPCWSTR,BOOL,BOOL,int,BOOL); - - -//==== DlIconThread() ========================================================= - -DWORD WINAPI DirList_IconThread(LPVOID); - - -//==== DlGetDispInfo() ======================================================== - -BOOL DirList_GetDispInfo(HWND,LPARAM,BOOL); - - -//==== DlDeleteItem() ========================================================= - -BOOL DirList_DeleteItem(HWND,LPARAM); - - -//==== DlSort() =============================================================== - -#define DS_NAME 0 -#define DS_SIZE 1 -#define DS_TYPE 2 -#define DS_LASTMOD 3 - -BOOL DirList_Sort(HWND,int,BOOL); - - -//==== DlGetItem() ============================================================ - -#define DLE_NONE 0 -#define DLE_DIR 1 -#define DLE_FILE 2 - -#define DLI_FILENAME 1 -#define DLI_DISPNAME 2 -#define DLI_TYPE 4 -#define DLI_ALL (1|2|4) - -typedef struct tagDLITEM // dli -{ - - UINT mask; - WCHAR szFileName[MAX_PATH]; - WCHAR szDisplayName[MAX_PATH]; - int ntype; - -} DLITEM, *LPDLITEM; - -int DirList_GetItem(HWND,int,LPDLITEM); - - -//==== DlGetItemEx() ========================================================== - -int DirList_GetItemEx(HWND,int,LPWIN32_FIND_DATA); - - -//==== DlPropertyDlg() ======================================================== - -BOOL DirList_PropertyDlg(HWND,int); - - -//==== DlGetLongPathName() ==================================================== - -BOOL DirList_GetLongPathName(HWND,LPWSTR); - -//==== DlSelectItem() ========================================================= - -BOOL DirList_SelectItem(HWND,LPCWSTR,LPCWSTR); - -//==== DlCreateFilter() and DlMatchFilter() =================================== - -#define DL_FILTER_BUFSIZE 128 - -typedef struct tagDL_FILTER { //dlf - int nCount; - WCHAR tFilterBuf[DL_FILTER_BUFSIZE]; - WCHAR *pFilter [DL_FILTER_BUFSIZE]; - BOOL bExcludeFilter; -} DL_FILTER, *PDL_FILTER; - -void DirList_CreateFilter(PDL_FILTER,LPCWSTR,BOOL); - -BOOL DirList_MatchFilter(LPSHELLFOLDER,LPCITEMIDLIST,PDL_FILTER); - - - -//==== DriveBox =============================================================== - -BOOL DriveBox_Init(HWND); -int DriveBox_Fill(HWND); -BOOL DriveBox_GetSelDrive(HWND,LPWSTR,int,BOOL); -BOOL DriveBox_SelectDrive(HWND,LPCWSTR); -BOOL DriveBox_PropertyDlg(HWND); - -LRESULT DriveBox_DeleteItem(HWND,LPARAM); -LRESULT DriveBox_GetDispInfo(HWND,LPARAM); - - - -//==== ItemID ================================================================= - -//==== IL_Next() ============================================================== -#define _IL_Next(pidl) ((LPITEMIDLIST)(((LPBYTE)(pidl)) + pidl->mkid.cb)) - -//==== IL_Create() ============================================================ -LPITEMIDLIST IL_Create(LPCITEMIDLIST,UINT, - LPCITEMIDLIST,UINT); - -//==== IL_GetSize() =========================================================== -UINT IL_GetSize(LPCITEMIDLIST); - -//==== IL_GetDisplayName() ==================================================== -BOOL IL_GetDisplayName(LPSHELLFOLDER, - LPCITEMIDLIST, - DWORD,LPWSTR,int); - - - - -#ifdef __cplusplus -} -#endif //__cplusplus - - -#endif // _DLAPI_H_ - - -/// End of Dlapi.h \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Dlapi.h +* Definitions for Directory Listing APIs +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + +#ifndef _DLAPI_H_ +#define _DLAPI_H_ + +#ifdef __cplusplus +extern "C" { // C-Declarations +#endif //__cplusplus + + + +//==== DirList ================================================================ + +//==== LV_ITEMDATA Structure ================================================== +typedef struct tagLV_ITEMDATA // lvid +{ + LPITEMIDLIST pidl; // Item Id + LPSHELLFOLDER lpsf; // Parent IShellFolder Interface + +} LV_ITEMDATA, *LPLV_ITEMDATA; + + +//==== DlInit() =============================================================== + +BOOL DirList_Init(HWND,LPCWSTR); + + +//==== DlDestroy() ============================================================ + +BOOL DirList_Destroy(HWND); + + +//==== DlStartIconThread() ==================================================== + +BOOL DirList_StartIconThread(HWND); + + +//==== DlTerminateIconThread() ================================================ + +BOOL DirList_TerminateIconThread(HWND); + + +//==== DlFill() =============================================================== + +#define DL_FOLDERS 32 +#define DL_NONFOLDERS 64 +#define DL_INCLHIDDEN 128 +#define DL_ALLOBJECTS (32|64|128) + +int DirList_Fill(HWND,LPCWSTR,DWORD,LPCWSTR,BOOL,BOOL,int,BOOL); + + +//==== DlIconThread() ========================================================= + +DWORD WINAPI DirList_IconThread(LPVOID); + + +//==== DlGetDispInfo() ======================================================== + +BOOL DirList_GetDispInfo(HWND,LPARAM,BOOL); + + +//==== DlDeleteItem() ========================================================= + +BOOL DirList_DeleteItem(HWND,LPARAM); + + +//==== DlSort() =============================================================== + +#define DS_NAME 0 +#define DS_SIZE 1 +#define DS_TYPE 2 +#define DS_LASTMOD 3 + +BOOL DirList_Sort(HWND,int,BOOL); + + +//==== DlGetItem() ============================================================ + +#define DLE_NONE 0 +#define DLE_DIR 1 +#define DLE_FILE 2 + +#define DLI_FILENAME 1 +#define DLI_DISPNAME 2 +#define DLI_TYPE 4 +#define DLI_ALL (1|2|4) + +typedef struct tagDLITEM // dli +{ + + UINT mask; + WCHAR szFileName[MAX_PATH]; + WCHAR szDisplayName[MAX_PATH]; + int ntype; + +} DLITEM, *LPDLITEM; + +int DirList_GetItem(HWND,int,LPDLITEM); + + +//==== DlGetItemEx() ========================================================== + +int DirList_GetItemEx(HWND,int,LPWIN32_FIND_DATA); + + +//==== DlPropertyDlg() ======================================================== + +BOOL DirList_PropertyDlg(HWND,int); + + +//==== DlGetLongPathName() ==================================================== + +BOOL DirList_GetLongPathName(HWND,LPWSTR); + +//==== DlSelectItem() ========================================================= + +BOOL DirList_SelectItem(HWND,LPCWSTR,LPCWSTR); + +//==== DlCreateFilter() and DlMatchFilter() =================================== + +#define DL_FILTER_BUFSIZE 128 + +typedef struct tagDL_FILTER { //dlf + int nCount; + WCHAR tFilterBuf[DL_FILTER_BUFSIZE]; + WCHAR *pFilter [DL_FILTER_BUFSIZE]; + BOOL bExcludeFilter; +} DL_FILTER, *PDL_FILTER; + +void DirList_CreateFilter(PDL_FILTER,LPCWSTR,BOOL); + +BOOL DirList_MatchFilter(LPSHELLFOLDER,LPCITEMIDLIST,PDL_FILTER); + + + +//==== DriveBox =============================================================== + +BOOL DriveBox_Init(HWND); +int DriveBox_Fill(HWND); +BOOL DriveBox_GetSelDrive(HWND,LPWSTR,int,BOOL); +BOOL DriveBox_SelectDrive(HWND,LPCWSTR); +BOOL DriveBox_PropertyDlg(HWND); + +LRESULT DriveBox_DeleteItem(HWND,LPARAM); +LRESULT DriveBox_GetDispInfo(HWND,LPARAM); + + + +//==== ItemID ================================================================= + +//==== IL_Next() ============================================================== +#define _IL_Next(pidl) ((LPITEMIDLIST)(((LPBYTE)(pidl)) + pidl->mkid.cb)) + +//==== IL_Create() ============================================================ +LPITEMIDLIST IL_Create(LPCITEMIDLIST,UINT, + LPCITEMIDLIST,UINT); + +//==== IL_GetSize() =========================================================== +UINT IL_GetSize(LPCITEMIDLIST); + +//==== IL_GetDisplayName() ==================================================== +BOOL IL_GetDisplayName(LPSHELLFOLDER, + LPCITEMIDLIST, + DWORD,LPWSTR,int); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + + +#endif // _DLAPI_H_ + + +/// End of Dlapi.h \\\ diff --git a/src/Edit.c b/src/Edit.c index 39a70d04..82a6a4e0 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1,7397 +1,7397 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Edit.c -* Text File Editing Helper Stuff -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include -#include -#include "scintilla.h" -#include "scilexer.h" -#include "notepad2.h" -#include "edit.h" -#include "styles.h" -#include "dialogs.h" -#include "helpers.h" -#include "resource.h" -#include "SciCall.h" - - -extern HWND hwndMain; -extern HWND hwndEdit; -extern HINSTANCE g_hInstance; -//extern LPMALLOC g_lpMalloc; -extern DWORD dwLastIOError; -extern HWND hDlgFindReplace; -extern UINT cpLastFind; -extern BOOL bReplaceInitialized; - -static EDITFINDREPLACE efrSave; -static BOOL bSwitchedFindReplace = FALSE; -static int xFindReplaceDlgSave; -static int yFindReplaceDlgSave; -extern int xFindReplaceDlg; -extern int yFindReplaceDlg; - -extern int iDefaultEncoding; -extern int iDefaultEOLMode; -extern int iLineEndings[3]; -extern BOOL bFixLineEndings; -extern BOOL bAutoStripBlanks; - - -// Default Codepage and Character Set -extern int iDefaultCodePage; -extern int iDefaultCharSet; -extern BOOL bSkipUnicodeDetection; -extern BOOL bLoadASCIIasUTF8; -extern BOOL bLoadNFOasOEM; -extern int iSrcEncoding; -extern int iWeakSrcEncoding; - -int g_DOSEncoding; - -// Supported Encodings -WCHAR wchANSI[8] = L""; -WCHAR wchOEM [8] = L""; - -NP2ENCODING mEncoding[] = { - { NCP_DEFAULT|NCP_RECODE, 0, "ansi,ansi,ascii,", 61000, L"" }, - { NCP_8BIT|NCP_RECODE, 0, "oem,oem,", 61001, L"" }, - { NCP_UNICODE|NCP_UNICODE_BOM, 0, "", 61002, L"" }, - { NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM, 0, "", 61003, L"" }, - { NCP_UNICODE|NCP_RECODE, 0, "utf-16,utf16,unicode,", 61004, L"" }, - { NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_RECODE, 0, "utf-16be,utf16be,unicodebe,", 61005, L"" }, - { NCP_UTF8|NCP_RECODE, 0, "utf-8,utf8,", 61006, L"" }, - { NCP_UTF8|NCP_UTF8_SIGN, 0, "utf-8,utf8,", 61007, L"" }, - { NCP_8BIT|NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" }, - { NCP_8BIT|NCP_RECODE, 720, "DOS-720,dos720,", 61009, L"" }, - { NCP_8BIT|NCP_RECODE, 28596, "iso-8859-6,iso88596,arabic,csisolatinarabic,ecma114,isoir127,", 61010, L"" }, - { NCP_8BIT|NCP_RECODE, 10004, "x-mac-arabic,xmacarabic,", 61011, L"" }, - { NCP_8BIT|NCP_RECODE, 1256, "windows-1256,windows1256,cp1256", 61012, L"" }, - { NCP_8BIT|NCP_RECODE, 775, "ibm775,ibm775,cp500,", 61013, L"" }, - { NCP_8BIT|NCP_RECODE, 28594, "iso-8859-4,iso88594,csisolatin4,isoir110,l4,latin4,", 61014, L"" }, - { NCP_8BIT|NCP_RECODE, 1257, "windows-1257,windows1257,", 61015, L"" }, - { NCP_8BIT|NCP_RECODE, 852, "ibm852,ibm852,cp852,", 61016, L"" }, - { NCP_8BIT|NCP_RECODE, 28592, "iso-8859-2,iso88592,csisolatin2,isoir101,latin2,l2,", 61017, L"" }, - { NCP_8BIT|NCP_RECODE, 10029, "x-mac-ce,xmacce,", 61018, L"" }, - { NCP_8BIT|NCP_RECODE, 1250, "windows-1250,windows1250,xcp1250,", 61019, L"" }, - { NCP_8BIT|NCP_RECODE, 936, "gb2312,gb2312,chinese,cngb,csgb2312,csgb231280,gb231280,gbk,", 61020, L"" }, - { NCP_8BIT|NCP_RECODE, 10008, "x-mac-chinesesimp,xmacchinesesimp,", 61021, L"" }, - { NCP_8BIT|NCP_RECODE, 950, "big5,big5,cnbig5,csbig5,xxbig5,", 61022, L"" }, - { NCP_8BIT|NCP_RECODE, 10002, "x-mac-chinesetrad,xmacchinesetrad,", 61023, L"" }, - { NCP_8BIT|NCP_RECODE, 10082, "x-mac-croatian,xmaccroatian,", 61024, L"" }, - { NCP_8BIT|NCP_RECODE, 866, "cp866,cp866,ibm866,", 61025, L"" }, - { NCP_8BIT|NCP_RECODE, 28595, "iso-8859-5,iso88595,csisolatin5,csisolatincyrillic,cyrillic,isoir144,", 61026, L"" }, - { NCP_8BIT|NCP_RECODE, 20866, "koi8-r,koi8r,cskoi8r,koi,koi8,", 61027, L"" }, - { NCP_8BIT|NCP_RECODE, 21866, "koi8-u,koi8u,koi8ru,", 61028, L"" }, - { NCP_8BIT|NCP_RECODE, 10007, "x-mac-cyrillic,xmaccyrillic,", 61029, L"" }, - { NCP_8BIT|NCP_RECODE, 1251, "windows-1251,windows1251,xcp1251,", 61030, L"" }, - { NCP_8BIT|NCP_RECODE, 28603, "iso-8859-13,iso885913,", 61031, L"" }, - { NCP_8BIT|NCP_RECODE, 863, "ibm863,ibm863,", 61032, L"" }, - { NCP_8BIT|NCP_RECODE, 737, "ibm737,ibm737,", 61033, L"" }, - { NCP_8BIT|NCP_RECODE, 28597, "iso-8859-7,iso88597,csisolatingreek,ecma118,elot928,greek,greek8,isoir126,", 61034, L"" }, - { NCP_8BIT|NCP_RECODE, 10006, "x-mac-greek,xmacgreek,", 61035, L"" }, - { NCP_8BIT|NCP_RECODE, 1253, "windows-1253,windows1253,", 61036, L"" }, - { NCP_8BIT|NCP_RECODE, 869, "ibm869,ibm869,", 61037, L"" }, - { NCP_8BIT|NCP_RECODE, 862, "DOS-862,dos862,", 61038, L"" }, - { NCP_8BIT|NCP_RECODE, 38598, "iso-8859-8-i,iso88598i,logical,", 61039, L"" }, - { NCP_8BIT|NCP_RECODE, 28598, "iso-8859-8,iso88598,csisolatinhebrew,hebrew,isoir138,visual,", 61040, L"" }, - { NCP_8BIT|NCP_RECODE, 10005, "x-mac-hebrew,xmachebrew,", 61041, L"" }, - { NCP_8BIT|NCP_RECODE, 1255, "windows-1255,windows1255,", 61042, L"" }, - { NCP_8BIT|NCP_RECODE, 861, "ibm861,ibm861,", 61043, L"" }, - { NCP_8BIT|NCP_RECODE, 10079, "x-mac-icelandic,xmacicelandic,", 61044, L"" }, - { NCP_8BIT|NCP_RECODE, 10001, "x-mac-japanese,xmacjapanese,", 61045, L"" }, - { NCP_8BIT|NCP_RECODE, 932, "shift_jis,shiftjis,shiftjs,csshiftjis,cswindows31j,mskanji,xmscp932,xsjis,", 61046, L"" }, - { NCP_8BIT|NCP_RECODE, 10003, "x-mac-korean,xmackorean,", 61047, L"" }, - { NCP_8BIT|NCP_RECODE, 949, "windows-949,windows949,ksc56011987,csksc5601,euckr,isoir149,korean,ksc56011989", 61048, L"" }, - { NCP_8BIT|NCP_RECODE, 28593, "iso-8859-3,iso88593,latin3,isoir109,l3,", 61049, L"" }, - { NCP_8BIT|NCP_RECODE, 28605, "iso-8859-15,iso885915,latin9,l9,", 61050, L"" }, - { NCP_8BIT|NCP_RECODE, 865, "ibm865,ibm865,", 61051, L"" }, - { NCP_8BIT|NCP_RECODE, 437, "ibm437,ibm437,437,cp437,cspc8,codepage437,", 61052, L"" }, - { NCP_8BIT|NCP_RECODE, 858, "ibm858,ibm858,ibm00858,", 61053, L"" }, - { NCP_8BIT|NCP_RECODE, 860, "ibm860,ibm860,", 61054, L"" }, - { NCP_8BIT|NCP_RECODE, 10010, "x-mac-romanian,xmacromanian,", 61055, L"" }, - { NCP_8BIT|NCP_RECODE, 10021, "x-mac-thai,xmacthai,", 61056, L"" }, - { NCP_8BIT|NCP_RECODE, 874, "windows-874,windows874,dos874,iso885911,tis620,", 61057, L"" }, - { NCP_8BIT|NCP_RECODE, 857, "ibm857,ibm857,", 61058, L"" }, - { NCP_8BIT|NCP_RECODE, 28599, "iso-8859-9,iso88599,latin5,isoir148,l5,", 61059, L"" }, - { NCP_8BIT|NCP_RECODE, 10081, "x-mac-turkish,xmacturkish,", 61060, L"" }, - { NCP_8BIT|NCP_RECODE, 1254, "windows-1254,windows1254,", 61061, L"" }, - { NCP_8BIT|NCP_RECODE, 10017, "x-mac-ukrainian,xmacukrainian,", 61062, L"" }, - { NCP_8BIT|NCP_RECODE, 1258, "windows-1258,windows-258,", 61063, L"" }, - { NCP_8BIT|NCP_RECODE, 850, "ibm850,ibm850,", 61064, L"" }, - { NCP_8BIT|NCP_RECODE, 28591, "iso-8859-1,iso88591,cp819,latin1,ibm819,isoir100,latin1,l1,", 61065, L"" }, - { NCP_8BIT|NCP_RECODE, 10000, "macintosh,macintosh,", 61066, L"" }, - { NCP_8BIT|NCP_RECODE, 1252, "windows-1252,windows1252,cp367,cp819,ibm367,us,xansi,", 61067, L"" }, - { NCP_8BIT|NCP_RECODE, 37, "ebcdic-cp-us,ebcdiccpus,ebcdiccpca,ebcdiccpwt,ebcdiccpnl,ibm037,cp037,", 61068, L"" }, - { NCP_8BIT|NCP_RECODE, 500, "x-ebcdic-international,xebcdicinternational,", 61069, L"" }, -/*{ NCP_8BIT|NCP_RECODE, 870, "CP870,cp870,ebcdiccproece,ebcdiccpyu,csibm870,ibm870,", 00000, L"" }, // IBM EBCDIC (Multilingual Latin-2) */ - { NCP_8BIT|NCP_RECODE, 875, "x-EBCDIC-GreekModern,xebcdicgreekmodern,", 61070, L"" }, - { NCP_8BIT|NCP_RECODE, 1026, "CP1026,cp1026,csibm1026,ibm1026,", 61071, L"" }, -/*{ NCP_8BIT|NCP_RECODE, 1047, "IBM01047,ibm01047,", 00000, L"" }, // IBM EBCDIC (Open System Latin-1) - { NCP_8BIT|NCP_RECODE, 1140, "x-ebcdic-cp-us-euro,xebcdiccpuseuro,", 00000, L"" }, // IBM EBCDIC (US-Canada-Euro) - { NCP_8BIT|NCP_RECODE, 1141, "x-ebcdic-germany-euro,xebcdicgermanyeuro,", 00000, L"" }, // IBM EBCDIC (Germany-Euro) - { NCP_8BIT|NCP_RECODE, 1142, "x-ebcdic-denmarknorway-euro,xebcdicdenmarknorwayeuro,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway-Euro) - { NCP_8BIT|NCP_RECODE, 1143, "x-ebcdic-finlandsweden-euro,xebcdicfinlandswedeneuro,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden-Euro) - { NCP_8BIT|NCP_RECODE, 1144, "x-ebcdic-italy-euro,xebcdicitalyeuro,", 00000, L"" }, // IBM EBCDIC (Italy-Euro) - { NCP_8BIT|NCP_RECODE, 1145, "x-ebcdic-spain-euro,xebcdicspaineuro,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America-Euro) - { NCP_8BIT|NCP_RECODE, 1146, "x-ebcdic-uk-euro,xebcdicukeuro,", 00000, L"" }, // IBM EBCDIC (UK-Euro) - { NCP_8BIT|NCP_RECODE, 1147, "x-ebcdic-france-euro,xebcdicfranceeuro,", 00000, L"" }, // IBM EBCDIC (France-Euro) - { NCP_8BIT|NCP_RECODE, 1148, "x-ebcdic-international-euro,xebcdicinternationaleuro,", 00000, L"" }, // IBM EBCDIC (International-Euro) - { NCP_8BIT|NCP_RECODE, 1149, "x-ebcdic-icelandic-euro,xebcdicicelandiceuro,", 00000, L"" }, // IBM EBCDIC (Icelandic-Euro) - { NCP_8BIT|NCP_RECODE, 20273, "x-EBCDIC-Germany,xebcdicgermany,", 00000, L"" }, // IBM EBCDIC (Germany) - { NCP_8BIT|NCP_RECODE, 20277, "x-EBCDIC-DenmarkNorway,xebcdicdenmarknorway,ebcdiccpdk,ebcdiccpno,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway) - { NCP_8BIT|NCP_RECODE, 20278, "x-EBCDIC-FinlandSweden,xebcdicfinlandsweden,ebcdicpfi,ebcdiccpse,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden) - { NCP_8BIT|NCP_RECODE, 20280, "x-EBCDIC-Italy,xebcdicitaly,", 00000, L"" }, // IBM EBCDIC (Italy) - { NCP_8BIT|NCP_RECODE, 20284, "x-EBCDIC-Spain,xebcdicspain,ebcdiccpes,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America) - { NCP_8BIT|NCP_RECODE, 20285, "x-EBCDIC-UK,xebcdicuk,ebcdiccpgb,", 00000, L"" }, // IBM EBCDIC (UK) - { NCP_8BIT|NCP_RECODE, 20290, "x-EBCDIC-JapaneseKatakana,xebcdicjapanesekatakana,", 00000, L"" }, // IBM EBCDIC (Japanese Katakana) - { NCP_8BIT|NCP_RECODE, 20297, "x-EBCDIC-France,xebcdicfrance,ebcdiccpfr,", 00000, L"" }, // IBM EBCDIC (France) - { NCP_8BIT|NCP_RECODE, 20420, "x-EBCDIC-Arabic,xebcdicarabic,ebcdiccpar1,", 00000, L"" }, // IBM EBCDIC (Arabic) - { NCP_8BIT|NCP_RECODE, 20423, "x-EBCDIC-Greek,xebcdicgreek,ebcdiccpgr,", 00000, L"" }, // IBM EBCDIC (Greek) - { NCP_8BIT|NCP_RECODE, 20424, "x-EBCDIC-Hebrew,xebcdichebrew,ebcdiccphe,", 00000, L"" }, // IBM EBCDIC (Hebrew) - { NCP_8BIT|NCP_RECODE, 20833, "x-EBCDIC-KoreanExtended,xebcdickoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean Extended) - { NCP_8BIT|NCP_RECODE, 20838, "x-EBCDIC-Thai,xebcdicthai,ibmthai,csibmthai,", 00000, L"" }, // IBM EBCDIC (Thai) - { NCP_8BIT|NCP_RECODE, 20871, "x-EBCDIC-Icelandic,xebcdicicelandic,ebcdiccpis,", 00000, L"" }, // IBM EBCDIC (Icelandic) - { NCP_8BIT|NCP_RECODE, 20880, "x-EBCDIC-CyrillicRussian,xebcdiccyrillicrussian,ebcdiccyrillic,", 00000, L"" }, // IBM EBCDIC (Cyrillic Russian) - { NCP_8BIT|NCP_RECODE, 20905, "x-EBCDIC-Turkish,xebcdicturkish,ebcdiccptr,", 00000, L"" }, // IBM EBCDIC (Turkish) - { NCP_8BIT|NCP_RECODE, 20924, "IBM00924,ibm00924,ebcdiclatin9euro,", 00000, L"" }, // IBM EBCDIC (Open System-Euro Latin-1) - { NCP_8BIT|NCP_RECODE, 21025, "x-EBCDIC-CyrillicSerbianBulgarian,xebcdiccyrillicserbianbulgarian,", 00000, L"" }, // IBM EBCDIC (Cyrillic Serbian-Bulgarian) - { NCP_8BIT|NCP_RECODE, 50930, "x-EBCDIC-JapaneseAndKana,xebcdicjapaneseandkana,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese Katakana) - { NCP_8BIT|NCP_RECODE, 50931, "x-EBCDIC-JapaneseAndUSCanada,xebcdicjapaneseanduscanada,", 00000, L"" }, // IBM EBCDIC (Japanese and US-Canada) - { NCP_8BIT|NCP_RECODE, 50933, "x-EBCDIC-KoreanAndKoreanExtended,xebcdickoreanandkoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean and Korean Extended) - { NCP_8BIT|NCP_RECODE, 50935, "x-EBCDIC-SimplifiedChinese,xebcdicsimplifiedchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Simplified) - { NCP_8BIT|NCP_RECODE, 50937, "x-EBCDIC-TraditionalChinese,xebcdictraditionalchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Traditional) - { NCP_8BIT|NCP_RECODE, 50939, "x-EBCDIC-JapaneseAndJapaneseLatin,xebcdicjapaneseandjapaneselatin,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese-Latin) - { NCP_8BIT|NCP_RECODE, 20105, "x-IA5,xia5,", 00000, L"" }, // Western European (IA5) - { NCP_8BIT|NCP_RECODE, 20106, "x-IA5-German,xia5german,", 00000, L"" }, // German (IA5) - { NCP_8BIT|NCP_RECODE, 20107, "x-IA5-Swedish,xia5swedish,", 00000, L"" }, // Swedish (IA5) - { NCP_8BIT|NCP_RECODE, 20108, "x-IA5-Norwegian,xia5norwegian,", 00000, L"" }, // Norwegian (IA5) - { NCP_8BIT|NCP_RECODE, 20936, "x-cp20936,xcp20936,", 00000, L"" }, // Chinese Simplified (GB2312) - { NCP_8BIT|NCP_RECODE, 52936, "hz-gb-2312,hzgb2312,hz,", 00000, L"" }, // Chinese Simplified (HZ-GB2312) */ - { NCP_8BIT|NCP_RECODE, 54936, "gb18030,gb18030,", 61072, L"" }, -/*{ NCP_8BIT|NCP_RECODE, 1361, "johab,johab,", 00000, L"" }, // Korean (Johab) - { NCP_8BIT|NCP_RECODE, 20932, "euc-jp,,", 00000, L"" }, // Japanese (JIS X 0208-1990 & 0212-1990) - { NCP_8BIT|NCP_RECODE, 50220, "iso-2022-jp,iso2022jp,", 00000, L"" }, // Japanese (JIS) - { NCP_8BIT|NCP_RECODE, 50221, "csISO2022JP,csiso2022jp,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana) - { NCP_8BIT|NCP_RECODE, 50222, "_iso-2022-jp$SIO,iso2022jpSIO,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana - SO/SI) - { NCP_8BIT|NCP_RECODE, 50225, "iso-2022-kr,iso2022kr,csiso2022kr,", 00000, L"" }, // Korean (ISO-2022-KR) - { NCP_8BIT|NCP_RECODE, 50227, "x-cp50227,xcp50227,", 00000, L"" }, // Chinese Simplified (ISO-2022) - { NCP_8BIT|NCP_RECODE, 50229, "iso-2022-cn,iso2022cn,", 00000, L"" }, // Chinese Traditional (ISO-2022) - { NCP_8BIT|NCP_RECODE, 20000, "x-Chinese-CNS,xchinesecns,", 00000, L"" }, // Chinese Traditional (CNS) - { NCP_8BIT|NCP_RECODE, 20002, "x-Chinese-Eten,xchineseeten,", 00000, L"" }, // Chinese Traditional (Eten) - { NCP_8BIT|NCP_RECODE, 51932, "euc-jp,eucjp,xeuc,xeucjp,", 00000, L"" }, // Japanese (EUC) - { NCP_8BIT|NCP_RECODE, 51936, "euc-cn,euccn,xeuccn,", 00000, L"" }, // Chinese Simplified (EUC) - { NCP_8BIT|NCP_RECODE, 51949, "euc-kr,euckr,cseuckr,", 00000, L"" }, // Korean (EUC) - { NCP_8BIT|NCP_RECODE, 57002, "x-iscii-de,xisciide,", 00000, L"" }, // ISCII Devanagari - { NCP_8BIT|NCP_RECODE, 57003, "x-iscii-be,xisciibe,", 00000, L"" }, // ISCII Bengali - { NCP_8BIT|NCP_RECODE, 57004, "x-iscii-ta,xisciita,", 00000, L"" }, // ISCII Tamil - { NCP_8BIT|NCP_RECODE, 57005, "x-iscii-te,xisciite,", 00000, L"" }, // ISCII Telugu - { NCP_8BIT|NCP_RECODE, 57006, "x-iscii-as,xisciias,", 00000, L"" }, // ISCII Assamese - { NCP_8BIT|NCP_RECODE, 57007, "x-iscii-or,xisciior,", 00000, L"" }, // ISCII Oriya - { NCP_8BIT|NCP_RECODE, 57008, "x-iscii-ka,xisciika,", 00000, L"" }, // ISCII Kannada - { NCP_8BIT|NCP_RECODE, 57009, "x-iscii-ma,xisciima,", 00000, L"" }, // ISCII Malayalam - { NCP_8BIT|NCP_RECODE, 57010, "x-iscii-gu,xisciigu,", 00000, L"" }, // ISCII Gujarathi - { NCP_8BIT|NCP_RECODE, 57011, "x-iscii-pa,xisciipa,", 00000, L"" }, // ISCII Panjabi */ -}; - - -extern LPMRULIST mruFind; -extern LPMRULIST mruReplace; - - -//============================================================================= -// -// EditCreate() -// -HWND EditCreate(HWND hwndParent) -{ - - HWND hwnd; - - hwnd = CreateWindowEx( - WS_EX_CLIENTEDGE, - L"Scintilla", - NULL, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, - 0,0,0,0, - hwndParent, - (HMENU)IDC_EDIT, - g_hInstance, - NULL); - - SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0); - SendMessage(hwnd,SCI_SETEOLMODE,SC_EOL_CRLF,0); - SendMessage(hwnd,SCI_SETPASTECONVERTENDINGS,1,0); - SendMessage(hwnd,SCI_SETMODEVENTMASK,/*SC_MODEVENTMASKALL*/SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT,0); - SendMessage(hwnd,SCI_USEPOPUP,FALSE,0); - SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0); - SendMessage(hwnd,SCI_SETSCROLLWIDTHTRACKING,TRUE,0); - SendMessage(hwnd,SCI_SETENDATLASTLINE,TRUE,0); - SendMessage(hwnd,SCI_SETCARETSTICKY,FALSE,0); - SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50); - SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0); - SendMessage(hwnd,SCI_SETMULTIPLESELECTION,FALSE,0); - SendMessage(hwnd,SCI_SETADDITIONALSELECTIONTYPING,FALSE,0); - SendMessage(hwnd,SCI_SETVIRTUALSPACEOPTIONS,SCVS_NONE,0); - SendMessage(hwnd,SCI_SETADDITIONALCARETSBLINK,FALSE,0); - SendMessage(hwnd,SCI_SETADDITIONALCARETSVISIBLE,FALSE,0); - - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + (SCMOD_CTRL << 16)),SCI_PARADOWN); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + (SCMOD_CTRL << 16)),SCI_PARAUP); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARADOWNEXTEND); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARAUPEXTEND); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (0 << 16)),SCI_VCHOMEWRAP); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (0 << 16)),SCI_LINEENDWRAP); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (SCMOD_SHIFT << 16)),SCI_VCHOMEWRAPEXTEND); - SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (SCMOD_SHIFT << 16)),SCI_LINEENDWRAPEXTEND); - - // Init default values for printing - EditPrintInit(); - - //SciInitThemes(hwnd); - - return(hwnd); - -} - - -//============================================================================= -// -// EditSetNewText() -// -extern BOOL bFreezeAppTitle; -extern FILEVARS fvCurFile; - -void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText) -{ - bFreezeAppTitle = TRUE; - - if (SendMessage(hwnd,SCI_GETREADONLY,0,0)) - SendMessage(hwnd,SCI_SETREADONLY,FALSE,0); - - SendMessage(hwnd,SCI_CANCEL,0,0); - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); - SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_CLEARALL,0,0); - SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); - SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0); - SendMessage(hwnd,SCI_SETXOFFSET,0,0); - - FileVars_Apply(hwnd,&fvCurFile); - - if (cbText > 0) - SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)lpstrText); - - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); - SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); - SendMessage(hwnd,SCI_GOTOPOS,0,0); - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - - bFreezeAppTitle = FALSE; -} - - -//============================================================================= -// -// EditConvertText() -// -BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint) -{ - struct Sci_TextRange tr = { { 0, -1 }, NULL }; - int length, cbText, cbwText; - char *pchText; - WCHAR *pwchText; - - if (cpSource == cpDest) - return(TRUE); - - length = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - if (length == 0) { - SendMessage(hwnd,SCI_CANCEL,0,0); - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); - SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_CLEARALL,0,0); - SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); - SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0); - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); - SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_GOTOPOS,0,0); - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - - if (bSetSavePoint) - SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); - } - - else { - pchText = GlobalAlloc(GPTR,length*5+2); - - tr.lpstrText = pchText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - pwchText = GlobalAlloc(GPTR,length*3+2); - cbwText = MultiByteToWideChar(cpSource,0,pchText,length,pwchText,length*3+2); - cbText = WideCharToMultiByte(cpDest,0,pwchText,cbwText,pchText,length*5+2,NULL,NULL); - - SendMessage(hwnd,SCI_CANCEL,0,0); - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); - SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_CLEARALL,0,0); - SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); - SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0); - SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)pchText); - SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); - SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); - SendMessage(hwnd,SCI_GOTOPOS,0,0); - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - - GlobalFree(pchText); - GlobalFree(pwchText); - } - return(TRUE); -} - - -//============================================================================= -// -// EditSetNewEncoding() -// -BOOL EditSetNewEncoding(HWND hwnd,int iCurrentEncoding,int iNewEncoding,BOOL bNoUI,BOOL bSetSavePoint) { - - if (iCurrentEncoding != iNewEncoding) { - - if ((iCurrentEncoding == CPI_DEFAULT && iNewEncoding == CPI_DEFAULT) || - (iCurrentEncoding != CPI_DEFAULT && iNewEncoding != CPI_DEFAULT)) - return(TRUE); - - if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) { - - BOOL bIsEmptyUndoHistory = - (SendMessage(hwnd,SCI_CANUNDO,0,0) == 0 && SendMessage(hwnd,SCI_CANREDO,0,0) == 0); - - if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) && - (bNoUI || bIsEmptyUndoHistory || InfoBox(MBYESNO,L"MsgConv2",IDS_ASK_ENCODING2) == IDYES)) { - - EditConvertText(hwnd, - (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, - (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, - bSetSavePoint); - - return(TRUE); - } - - else - return(FALSE); - } - - else if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) && - (bNoUI || InfoBox(MBYESNO,L"MsgConv1",IDS_ASK_ENCODING) == IDYES)) { - - BeginWaitCursor(); - - EditConvertText(hwnd, - (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, - (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, - FALSE); - - EndWaitCursor(); - - return(TRUE); - } - - else - return(FALSE); - } - - else - return(FALSE); -} - - -//============================================================================= -// -// EditGetClipboardText() -// -char* EditGetClipboardText(HWND hwnd) -{ - HANDLE hmem; - WCHAR *pwch; - char *pmch; - char *ptmp; - int wlen, mlen, mlen2; - UINT codepage; - int eolmode; - - if (!IsClipboardFormatAvailable(CF_UNICODETEXT) || !OpenClipboard(GetParent(hwnd))) - return(NULL); - - hmem = GetClipboardData(CF_UNICODETEXT); - pwch = GlobalLock(hmem); - - wlen = lstrlenW(pwch); - - codepage = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - eolmode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - - mlen = WideCharToMultiByte(codepage,0,pwch,wlen + 1,NULL,0,0,0) - 1; - pmch = LocalAlloc(LPTR,mlen + 1); - if (pmch) - WideCharToMultiByte(codepage,0,pwch,wlen + 1,pmch,mlen + 1,NULL,NULL); - - ptmp = LocalAlloc(LPTR,mlen * 2 + 1); - if (ptmp) { - char *s = pmch; - char *d = ptmp; - int i; - - for (i = 0; (i < mlen) && (*s != 0); i++) { - if (*s == '\n' || *s == '\r') { - if (eolmode == SC_EOL_CR) { - *d++ = '\r'; - } else if (eolmode == SC_EOL_LF) { - *d++ = '\n'; - } else { // eolmode == SC_EOL_CRLF - *d++ = '\r'; - *d++ = '\n'; - } - if ((*s == '\r') && (i+1 < mlen) && (*(s+1) == '\n')) { - i++; - s++; - } - s++; - } else { - *d++ = *s++; - } - } - *d++ = 0; - mlen2 = (int)(d - ptmp) - 1; - - LocalFree(pmch); - pmch = LocalAlloc(LPTR,mlen2 + 1); - lstrcpyA(pmch,ptmp); - LocalFree(ptmp); - } - - GlobalUnlock(hmem); - CloseClipboard(); - - return(pmch); -} - - -//============================================================================= -// -// EditCopyAppend() -// -BOOL EditCopyAppend(HWND hwnd) -{ - HANDLE hOld; - WCHAR *pszOld; - - HANDLE hNew; - WCHAR *pszNew; - - char *pszText; - int cchTextW; - WCHAR *pszTextW; - - WCHAR *pszSep = L"\r\n\r\n"; - - UINT uCodePage; - - int iCurPos; - int iAnchorPos; - - if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) { - SendMessage(hwnd,SCI_COPY,0,0); - return(TRUE); - } - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) { - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - MsgBox(MBWARN,IDS_SELRECT); - return(FALSE); - } - - else { - int iSelCount = - (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - pszText = LocalAlloc(LPTR,iSelCount + 1); - (int)SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - } - } - - else { - int cchText = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - pszText = LocalAlloc(LPTR,cchText + 1); - SendMessage(hwnd,SCI_GETTEXT,(int)LocalSize(pszText),(LPARAM)pszText); - } - - uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; - - cchTextW = MultiByteToWideChar(uCodePage,0,pszText,-1,NULL,0); - if (cchTextW > 0) { - pszTextW = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(pszSep) + cchTextW + 1)); - lstrcpy(pszTextW,pszSep); - MultiByteToWideChar(uCodePage,0,pszText,-1,StrEnd(pszTextW),(int)LocalSize(pszTextW)/sizeof(WCHAR)); - } - else { - pszTextW = L""; - } - - LocalFree(pszText); - - if (!OpenClipboard(GetParent(hwnd))) { - LocalFree(pszTextW); - return(FALSE); - } - - hOld = GetClipboardData(CF_UNICODETEXT); - pszOld = GlobalLock(hOld); - - hNew = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, - sizeof(WCHAR) * (lstrlen(pszOld) + lstrlen(pszTextW) + 1)); - pszNew = GlobalLock(hNew); - - lstrcpy(pszNew,pszOld); - lstrcat(pszNew,pszTextW); - - GlobalUnlock(hNew); - GlobalUnlock(hOld); - - EmptyClipboard(); - SetClipboardData(CF_UNICODETEXT,hNew); - CloseClipboard(); - - return(TRUE); -} - - -//============================================================================= -// -// EditDetectEOLMode() - moved here to handle Unicode files correctly -// -int EditDetectEOLMode(HWND hwnd,char* lpData,DWORD cbData) -{ - int iEOLMode = iLineEndings[iDefaultEOLMode]; - char *cp = (char*)lpData; - - if (!cp) - return (iEOLMode); - - while (*cp && (*cp != '\x0D' && *cp != '\x0A')) cp++; - - if (*cp == '\x0D' && *(cp+1) == '\x0A') - iEOLMode = SC_EOL_CRLF; - else if (*cp == '\x0D' && *(cp+1) != '\x0A') - iEOLMode = SC_EOL_CR; - else if (*cp == '\x0A') - iEOLMode = SC_EOL_LF; - - return (iEOLMode); -} - - - -//============================================================================= -// -// Encoding Helper Functions -// -void Encoding_InitDefaults() { - wsprintf(wchANSI,L" (%i)",GetACP()); - mEncoding[CPI_OEM].uCodePage = GetOEMCP(); - wsprintf(wchOEM,L" (%i)",mEncoding[CPI_OEM].uCodePage); - - g_DOSEncoding = CPI_OEM; - - // Try to set the DOS encoding to DOS-437 if the default OEMCP is not DOS-437 - if (mEncoding[g_DOSEncoding].uCodePage != 437) - { - int i; - for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); ++i) { - if (mEncoding[i].uCodePage == 437 && Encoding_IsValid(i)) { - g_DOSEncoding = i; - break; - } - } - } -} - - -int Encoding_MapIniSetting(BOOL bLoad,int iSetting) { - if (bLoad) { - switch (iSetting) { - case 0: return CPI_DEFAULT; - case 1: return CPI_UNICODEBOM; - case 2: return CPI_UNICODEBEBOM; - case 3: return CPI_UTF8; - case 4: return CPI_UTF8SIGN; - case 5: return CPI_OEM; - case 6: return CPI_UNICODE; - case 7: return CPI_UNICODEBE; - case 8: return CPI_UTF7; - default: { - int i; - for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); i++) { - if (mEncoding[i].uCodePage == (UINT)iSetting && Encoding_IsValid(i)) - return(i); - } - return CPI_DEFAULT; - } - } - } - else { - switch (iSetting) { - case CPI_DEFAULT: return 0; - case CPI_UNICODEBOM: return 1; - case CPI_UNICODEBEBOM: return 2; - case CPI_UTF8: return 3; - case CPI_UTF8SIGN: return 4; - case CPI_OEM: return 5; - case CPI_UNICODE: return 6; - case CPI_UNICODEBE: return 7; - case CPI_UTF7: return 8; - default: return(mEncoding[iSetting].uCodePage); - } - } -} - - -void Encoding_GetLabel(int iEncoding) { - if (mEncoding[iEncoding].wchLabel[0] == 0) { - WCHAR *pwsz; - WCHAR wch[256] = L""; - GetString(mEncoding[iEncoding].idsName,wch,COUNTOF(wch)); - if (pwsz = StrChr(wch,L';')) { - if (pwsz = StrChr(CharNext(pwsz),L';')) { - pwsz = CharNext(pwsz); - } - } - if (!pwsz) - pwsz = wch; - StrCpyN(mEncoding[iEncoding].wchLabel,pwsz,COUNTOF(mEncoding[iEncoding].wchLabel)); - } -} - - -int Encoding_MatchW(LPCWSTR pwszTest) { - char tchTest[256]; - WideCharToMultiByte(CP_ACP,0,pwszTest,-1,tchTest,COUNTOF(tchTest),NULL,NULL); - return(Encoding_MatchA(tchTest)); -} - - -int Encoding_MatchA(char *pchTest) { - int i; - char chTest[256]; - char *pchSrc = pchTest; - char *pchDst = chTest; - *pchDst++ = ','; - while (*pchSrc) { - if (IsCharAlphaNumericA(*pchSrc)) - *pchDst++ = *CharLowerA(pchSrc); - pchSrc++; - } - *pchDst++ = ','; - *pchDst = 0; - for (i = 0; i < COUNTOF(mEncoding); i++) { - if (StrStrIA(mEncoding[i].pszParseNames,chTest)) { - CPINFO cpi; - if ((mEncoding[i].uFlags & NCP_INTERNAL) || - IsValidCodePage(mEncoding[i].uCodePage) && - GetCPInfo(mEncoding[i].uCodePage,&cpi)) - return(i); - else - return(-1); - } - } - return(-1); -} - - -BOOL Encoding_IsValid(int iTestEncoding) { - CPINFO cpi; - if (iTestEncoding >= 0 && - iTestEncoding < COUNTOF(mEncoding)) { - if ((mEncoding[iTestEncoding].uFlags & NCP_INTERNAL) || - IsValidCodePage(mEncoding[iTestEncoding].uCodePage) && - GetCPInfo(mEncoding[iTestEncoding].uCodePage,&cpi)) { - return(TRUE); - } - } - return(FALSE); -} - - -typedef struct _ee { - int id; - WCHAR wch[256]; -} ENCODINGENTRY, *PENCODINGENTRY; - -int CmpEncoding(const void *s1, const void *s2) { - return StrCmp(((PENCODINGENTRY)s1)->wch,((PENCODINGENTRY)s2)->wch); -} - -void Encoding_AddToListView(HWND hwnd,int idSel,BOOL bRecodeOnly) -{ - int i; - int iSelItem = -1; - LVITEM lvi; - WCHAR wchBuf[256]; - - PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY)); - for (i = 0; i < COUNTOF(mEncoding); i++) { - pEE[i].id = i; - GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch)); - } - qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding); - - ZeroMemory(&lvi,sizeof(LVITEM)); - lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE; - lvi.pszText = wchBuf; - - for (i = 0; i < COUNTOF(mEncoding); i++) { - - int id = pEE[i].id; - if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) { - - CPINFO cpi; - WCHAR *pwsz; - - lvi.iItem = ListView_GetItemCount(hwnd); - - if (pwsz = StrChr(pEE[i].wch,L';')) { - StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf)); - if (pwsz = StrChr(wchBuf,L';')) - *pwsz = 0; - } - else - StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf)); - - if (id == CPI_DEFAULT) - StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf)); - else if (id == CPI_OEM) - StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf)); - - if ((mEncoding[id].uFlags & NCP_INTERNAL) || - (IsValidCodePage(mEncoding[id].uCodePage) && - GetCPInfo(mEncoding[id].uCodePage,&cpi))) - lvi.iImage = 0; - else - lvi.iImage = 1; - - lvi.lParam = (LPARAM)id; - ListView_InsertItem(hwnd,&lvi); - - if (idSel == id) - iSelItem = lvi.iItem; - } - } - - LocalFree(pEE); - - if (iSelItem != -1) { - ListView_SetItemState(hwnd,iSelItem,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED); - ListView_EnsureVisible(hwnd,iSelItem,FALSE); - } - else { - ListView_SetItemState(hwnd,0,LVIS_FOCUSED,LVIS_FOCUSED); - ListView_EnsureVisible(hwnd,0,FALSE); - } -} - - -BOOL Encoding_GetFromListView(HWND hwnd,int *pidEncoding) -{ - LVITEM lvi; - - lvi.iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - - if (ListView_GetItem(hwnd,&lvi)) { - if (Encoding_IsValid((int)lvi.lParam)) { - *pidEncoding = (int)lvi.lParam; - return (TRUE); - } - else - MsgBox(MBWARN,IDS_ERR_ENCODINGNA); - } - return(FALSE); -} - - -void Encoding_AddToComboboxEx(HWND hwnd,int idSel,BOOL bRecodeOnly) -{ - int i; - int iSelItem = -1; - COMBOBOXEXITEM cbei; - WCHAR wchBuf[256]; - - PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY)); - for (i = 0; i < COUNTOF(mEncoding); i++) { - pEE[i].id = i; - GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch)); - } - qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding); - - ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM)); - cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM; - cbei.pszText = wchBuf; - cbei.cchTextMax = COUNTOF(wchBuf); - cbei.iImage = 0; - cbei.iSelectedImage = 0; - - for (i = 0; i < COUNTOF(mEncoding); i++) { - - int id = pEE[i].id; - if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) { - - CPINFO cpi; - WCHAR *pwsz; - - cbei.iItem = SendMessage(hwnd,CB_GETCOUNT,0,0); - - if (pwsz = StrChr(pEE[i].wch,L';')) { - StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf)); - if (pwsz = StrChr(wchBuf,L';')) - *pwsz = 0; - } - else - StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf)); - - if (id == CPI_DEFAULT) - StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf)); - else if (id == CPI_OEM) - StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf)); - - if ((mEncoding[id].uFlags & NCP_INTERNAL) || - (IsValidCodePage(mEncoding[id].uCodePage) && - GetCPInfo(mEncoding[id].uCodePage,&cpi))) - cbei.iImage = 0; - else - cbei.iImage = 1; - - cbei.lParam = (LPARAM)id; - SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei); - - if (idSel == id) - iSelItem = (int)cbei.iItem; - } - } - - LocalFree(pEE); - - if (iSelItem != -1) - SendMessage(hwnd,CB_SETCURSEL,(WPARAM)iSelItem,0); -} - - -BOOL Encoding_GetFromComboboxEx(HWND hwnd,int *pidEncoding) -{ - COMBOBOXEXITEM cbei; - - cbei.iItem = SendMessage(hwnd,CB_GETCURSEL,0,0); - cbei.mask = CBEIF_LPARAM; - - if (SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei)) { - if (Encoding_IsValid((int)cbei.lParam)) { - *pidEncoding = (int)cbei.lParam; - return (TRUE); - } - else - MsgBox(MBWARN,IDS_ERR_ENCODINGNA); - } - return(FALSE); -} - - -BOOL IsUnicode(const char* pBuffer,int cb,LPBOOL lpbBOM,LPBOOL lpbReverse) -{ - int i = 0xFFFF; - - BOOL bIsTextUnicode; - - BOOL bHasBOM; - BOOL bHasRBOM; - - if (!pBuffer || cb < 2) - return FALSE; - - if (!bSkipUnicodeDetection) - bIsTextUnicode = IsTextUnicode(pBuffer,cb,&i); - else - bIsTextUnicode = FALSE; - - bHasBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFEFF); - bHasRBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFFFE); - - if (i == 0xFFFF) // i doesn't seem to have been modified ... - i = 0; - - if (bIsTextUnicode || bHasBOM || bHasRBOM || - ((i & (IS_TEXT_UNICODE_UNICODE_MASK | IS_TEXT_UNICODE_REVERSE_MASK)) && - !((i & IS_TEXT_UNICODE_UNICODE_MASK) && (i & IS_TEXT_UNICODE_REVERSE_MASK)) && - !(i & IS_TEXT_UNICODE_ODD_LENGTH) && - !(i & IS_TEXT_UNICODE_ILLEGAL_CHARS && !(i & IS_TEXT_UNICODE_REVERSE_SIGNATURE)) && - !((i & IS_TEXT_UNICODE_REVERSE_MASK) == IS_TEXT_UNICODE_REVERSE_STATISTICS))) { - - if (lpbBOM) - *lpbBOM = (bHasBOM || bHasRBOM || - (i & (IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE))) - ? TRUE : FALSE; - - if (lpbReverse) - *lpbReverse = (bHasRBOM || (i & IS_TEXT_UNICODE_REVERSE_MASK)) ? TRUE : FALSE; - - return TRUE; - } - - else - - return FALSE; -} - - -BOOL IsUTF8(const char* pTest,int nLength) -{ - static int byte_class_table[256] = { - /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ - /* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - /* A0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* B0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* C0 */ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* D0 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* E0 */ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, - /* F0 */ 9,10,10,10,11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 - /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ }; - - /* state table */ - typedef enum { - kSTART = 0,kA,kB,kC,kD,kE,kF,kG,kERROR,kNumOfStates } utf8_state; - - static utf8_state state_table[] = { - /* kSTART, kA, kB, kC, kD, kE, kF, kG, kERROR */ - /* 0x00-0x7F: 0 */ kSTART, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0x80-0x8F: 1 */ kERROR, kSTART, kA, kERROR, kA, kB, kERROR, kB, kERROR, - /* 0x90-0x9f: 2 */ kERROR, kSTART, kA, kERROR, kA, kB, kB, kERROR, kERROR, - /* 0xa0-0xbf: 3 */ kERROR, kSTART, kA, kA, kERROR, kB, kB, kERROR, kERROR, - /* 0xc0-0xc1, 0xf5-0xff: 4 */ kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xc2-0xdf: 5 */ kA, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xe0: 6 */ kC, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xe1-0xec, 0xee-0xef: 7 */ kB, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xed: 8 */ kD, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xf0: 9 */ kF, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xf1-0xf3: 10 */ kE, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, - /* 0xf4: 11 */ kG, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR }; - - #define BYTE_CLASS(b) (byte_class_table[(unsigned char)b]) - #define NEXT_STATE(b,cur) (state_table[(BYTE_CLASS(b) * kNumOfStates) + (cur)]) - - utf8_state current = kSTART; - int i; - - const char* pt = pTest; - int len = nLength; - - for(i = 0; i < len ; i++, pt++) { - - current = NEXT_STATE(*pt,current); - if (kERROR == current) - break; - } - - return (current == kSTART) ? TRUE : FALSE; - } - - -BOOL IsUTF7(const char* pTest,int nLength) -{ - int i; - const char *pt = pTest; - - for (i = 0; i < nLength; i++) { - if (*pt & 0x80 || !*pt) - return FALSE; - pt++; - } - - return TRUE; -} - - -#define IsUTF8Signature(p) \ - ((*(p+0) == '\xEF' && *(p+1) == '\xBB' && *(p+2) == '\xBF')) - - -#define UTF8StringStart(p) \ - (IsUTF8Signature(p)) ? (p+3) : (p) - - -/* byte length of UTF-8 sequence based on value of first byte. - for UTF-16 (21-bit space), max. code length is 4, so we only need to look - at 4 upper bits. - */ -static const INT utf8_lengths[16]= -{ - 1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */ - 0,0,0,0, /* 1000 to 1011 : not valid */ - 2,2, /* 1100, 1101 : 2 bytes */ - 3, /* 1110 : 3 bytes */ - 4 /* 1111 :4 bytes */ -}; - -/*++ -Function : - UTF8_mbslen_bytes [INTERNAL] - - Calculates the byte size of a NULL-terminated UTF-8 string. - -Parameters : - char *utf8_string : string to examine - -Return value : - size (in bytes) of a NULL-terminated UTF-8 string. - -1 if invalid NULL-terminated UTF-8 string ---*/ -static INT UTF8_mbslen_bytes(LPCSTR utf8_string) -{ - INT length=0; - INT code_size; - BYTE byte; - - while(*utf8_string) - { - byte=(BYTE)*utf8_string; - - if( (byte <= 0xF7) && (0 != (code_size = utf8_lengths[ byte >> 4 ]))) - { - length+=code_size; - utf8_string+=code_size; - } - else - { - /* we got an invalid byte value but need to count it, - it will be later ignored during the string conversion */ - //WARN("invalid first byte value 0x%02X in UTF-8 sequence!\n",byte); - length++; - utf8_string++; - } - } - length++; /* include NULL terminator */ - return length; -} - -/*++ -Function : - UTF8_mbslen [INTERNAL] - - Calculates the character size of a NULL-terminated UTF-8 string. - -Parameters : - char *utf8_string : string to examine - int byte_length : byte size of string - -Return value : - size (in characters) of a UTF-8 string. - -1 if invalid UTF-8 string ---*/ -static INT UTF8_mbslen(LPCSTR source, INT byte_length) -{ - INT wchar_length=0; - INT code_size; - BYTE byte; - - while(byte_length > 0) - { - byte=(BYTE)*source; - - /* UTF-16 can't encode 5-byte and 6-byte sequences, so maximum value - for first byte is 11110111. Use lookup table to determine sequence - length based on upper 4 bits of first byte */ - if ((byte <= 0xF7) && (0 != (code_size=utf8_lengths[ byte >> 4]))) - { - /* 1 sequence == 1 character */ - wchar_length++; - - if(code_size==4) - wchar_length++; - - source+=code_size; /* increment pointer */ - byte_length-=code_size; /* decrement counter*/ - } - else - { - /* - unlike UTF8_mbslen_bytes, we ignore the invalid characters. - we only report the number of valid characters we have encountered - to match the Windows behavior. - */ - //WARN("invalid byte 0x%02X in UTF-8 sequence, skipping it!\n", - // byte); - source++; - byte_length--; - } - } - return wchar_length; -} - - -//============================================================================= -// -// EditLoadFile() -// -BOOL EditLoadFile( - HWND hwnd, - LPCWSTR pszFile, - BOOL bSkipEncodingDetection, - int* iEncoding, - int* iEOLMode, - BOOL *pbUnicodeErr, - BOOL *pbFileTooBig) -{ - - HANDLE hFile; - - DWORD dwFileSize; - DWORD dwFileSizeLimit; - DWORD dwBufSize; - BOOL bReadSuccess; - - char* lpData; - DWORD cbData; - //char *cp; - int _iDefaultEncoding; - - BOOL bBOM; - BOOL bReverse = FALSE; - - BOOL bPreferOEM = FALSE; - - *pbUnicodeErr = FALSE; - *pbFileTooBig = FALSE; - - hFile = CreateFile(pszFile, - GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - dwLastIOError = GetLastError(); - - if (hFile == INVALID_HANDLE_VALUE) { - iSrcEncoding = -1; - iWeakSrcEncoding = -1; - return FALSE; - } - - // calculate buffer limit - dwFileSize = GetFileSize(hFile,NULL); - dwBufSize = dwFileSize + 10; - - // Check if a warning message should be displayed for large files - dwFileSizeLimit = IniGetInt(L"Settings2",L"FileLoadWarningMB",1); - if (dwFileSizeLimit != 0 && dwFileSizeLimit * 1024 * 1024 < dwFileSize) { - if (InfoBox(MBYESNO,L"MsgFileSizeWarning",IDS_WARNLOADBIGFILE) != IDYES) { - CloseHandle(hFile); - *pbFileTooBig = TRUE; - iSrcEncoding = -1; - iWeakSrcEncoding = -1; - return FALSE; - } - } - - lpData = GlobalAlloc(GPTR,dwBufSize); - bReadSuccess = ReadFile(hFile,lpData,(DWORD)GlobalSize(lpData)-2,&cbData,NULL); - dwLastIOError = GetLastError(); - CloseHandle(hFile); - - if (!bReadSuccess) { - GlobalFree(lpData); - iSrcEncoding = -1; - iWeakSrcEncoding = -1; - return FALSE; - } - - if (bLoadNFOasOEM) - { - PCWSTR pszExt = pszFile + lstrlen(pszFile) - 4; - if (pszExt >= pszFile && !(lstrcmpi(pszExt, L".nfo") && lstrcmpi(pszExt, L".diz"))) - bPreferOEM = TRUE; - } - - if (!Encoding_IsValid(iDefaultEncoding)) - iDefaultEncoding = CPI_DEFAULT; - - _iDefaultEncoding = (bPreferOEM) ? g_DOSEncoding : iDefaultEncoding; - if (iWeakSrcEncoding != -1 && Encoding_IsValid(iWeakSrcEncoding)) - _iDefaultEncoding = iWeakSrcEncoding; - - *iEncoding = CPI_DEFAULT; - - if (cbData == 0) { - FileVars_Init(NULL,0,&fvCurFile); - *iEOLMode = iLineEndings[iDefaultEOLMode]; - if (iSrcEncoding == -1) { - if (bLoadASCIIasUTF8 && !bPreferOEM) - *iEncoding = CPI_UTF8; - else - *iEncoding = _iDefaultEncoding; - } - else - *iEncoding = iSrcEncoding; - SendMessage(hwnd,SCI_SETCODEPAGE,(mEncoding[*iEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); - EditSetNewText(hwnd,"",0); - SendMessage(hwnd,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); - GlobalFree(lpData); - } - - else if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE) && - (iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || IsUnicode(lpData,cbData,&bBOM,&bReverse)) && - (iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || !IsUTF8Signature(lpData))) // check for UTF-8 signature - { - char* lpDataUTF8; - - if (iSrcEncoding == CPI_UNICODE) { - bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFEFF); - bReverse = FALSE; - } - else if (iSrcEncoding == CPI_UNICODEBE) - bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFFFE); - - if (iSrcEncoding == CPI_UNICODEBE || bReverse) { - _swab(lpData,lpData,cbData); - if (bBOM) - *iEncoding = CPI_UNICODEBEBOM; - else - *iEncoding = CPI_UNICODEBE; - } - else { - if (bBOM) - *iEncoding = CPI_UNICODEBOM; - else - *iEncoding = CPI_UNICODE; - } - - lpDataUTF8 = GlobalAlloc(GPTR,(cbData * 3) + 2); - cbData = WideCharToMultiByte(CP_UTF8,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData, - (bBOM) ? (cbData)/sizeof(WCHAR) : cbData/sizeof(WCHAR) + 1,lpDataUTF8,(int)GlobalSize(lpDataUTF8),NULL,NULL); - - if (cbData == 0) { - cbData = WideCharToMultiByte(CP_ACP,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData, - (-1),lpDataUTF8,(int)GlobalSize(lpDataUTF8),NULL,NULL); - *pbUnicodeErr = TRUE; - } - - GlobalFree(lpData); - SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); - EditSetNewText(hwnd,"",0); - FileVars_Init(lpDataUTF8,cbData-1,&fvCurFile); - EditSetNewText(hwnd,lpDataUTF8,cbData-1); - *iEOLMode = EditDetectEOLMode(hwnd,lpDataUTF8,cbData-1); - GlobalFree(lpDataUTF8); - } - - else { - FileVars_Init(lpData,cbData,&fvCurFile); - if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) && - ((IsUTF8Signature(lpData) || - FileVars_IsUTF8(&fvCurFile) || - (iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) || - // from menu "Reload As UTF-8" - (!bPreferOEM && bLoadASCIIasUTF8) || - (IsUTF8(lpData,cbData) && - (((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 != - UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) || - (!bPreferOEM && ( - mEncoding[_iDefaultEncoding].uFlags & NCP_UTF8 - )) ))))) && !(FileVars_IsNonUTF8(&fvCurFile) && - (iSrcEncoding != CPI_UTF8 && iSrcEncoding != CPI_UTF8SIGN))) - { - SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); - EditSetNewText(hwnd,"",0); - if (IsUTF8Signature(lpData)) { - EditSetNewText(hwnd,UTF8StringStart(lpData),cbData-3); - *iEncoding = CPI_UTF8SIGN; - *iEOLMode = EditDetectEOLMode(hwnd,UTF8StringStart(lpData),cbData-3); - } - else { - EditSetNewText(hwnd,lpData,cbData); - *iEncoding = CPI_UTF8; - *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); - } - GlobalFree(lpData); - } - - else { - - UINT uCodePage = CP_UTF8; - LPWSTR lpDataWide; - int cbDataWide; - - if (iSrcEncoding != -1) - *iEncoding = iSrcEncoding; - else { - *iEncoding = FileVars_GetEncoding(&fvCurFile); - if (*iEncoding == -1) { - if (fvCurFile.mask & FV_ENCODING) - *iEncoding = CPI_DEFAULT; - else { - if (iWeakSrcEncoding == -1) - *iEncoding = _iDefaultEncoding; - else if (mEncoding[iWeakSrcEncoding].uFlags & NCP_INTERNAL) - *iEncoding = iDefaultEncoding; - else - *iEncoding = _iDefaultEncoding; - } - } - } - - if ((mEncoding[*iEncoding].uFlags & NCP_8BIT && mEncoding[*iEncoding].uCodePage != CP_UTF7) || - (mEncoding[*iEncoding].uCodePage == CP_UTF7 && IsUTF7(lpData,cbData))) { - - uCodePage = mEncoding[*iEncoding].uCodePage; - - lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); - cbDataWide = MultiByteToWideChar(uCodePage,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); - - GlobalFree(lpData); - lpData = GlobalAlloc(GPTR,cbDataWide * 3 + 16); - - cbData = WideCharToMultiByte(CP_UTF8,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); - GlobalFree(lpDataWide); - - SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); - EditSetNewText(hwnd,"",0); - EditSetNewText(hwnd,lpData,cbData); - *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); - - GlobalFree(lpData); - } - - else { - - SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0); - EditSetNewText(hwnd,"",0); - EditSetNewText(hwnd,lpData,cbData); - *iEncoding = CPI_DEFAULT; - *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); - GlobalFree(lpData); - } - } - } - - iSrcEncoding = -1; - iWeakSrcEncoding = -1; - return TRUE; - -} - - -//============================================================================= -// -// EditSaveFile() -// -BOOL EditSaveFile( - HWND hwnd, - LPCWSTR pszFile, - int iEncoding, - BOOL *pbCancelDataLoss, - BOOL bSaveCopy) -{ - - HANDLE hFile; - BOOL bWriteSuccess; - - char* lpData; - DWORD cbData; - DWORD dwBytesWritten; - - *pbCancelDataLoss = FALSE; - - hFile = CreateFile(pszFile, - GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - dwLastIOError = GetLastError(); - - // failure could be due to missing attributes (2k/XP) - if (hFile == INVALID_HANDLE_VALUE) - { - DWORD dwAttributes = GetFileAttributes(pszFile); - if (dwAttributes != INVALID_FILE_ATTRIBUTES) - { - dwAttributes = dwAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); - hFile = CreateFile(pszFile, - GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | dwAttributes, - NULL); - dwLastIOError = GetLastError(); - } - } - - if (hFile == INVALID_HANDLE_VALUE) - return FALSE; - - // ensure consistent line endings - if (bFixLineEndings) { - SendMessage(hwnd,SCI_CONVERTEOLS,SendMessage(hwnd,SCI_GETEOLMODE,0,0),0); - EditFixPositions(hwnd); - } - - // strip trailing blanks - if (bAutoStripBlanks) - EditStripTrailingBlanks(hwnd,TRUE); - - // get text - cbData = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - lpData = GlobalAlloc(GPTR,cbData + 1); - SendMessage(hwnd,SCI_GETTEXT,GlobalSize(lpData),(LPARAM)lpData); - - if (cbData == 0) { - bWriteSuccess = SetEndOfFile(hFile); - dwLastIOError = GetLastError(); - } - - else { - - // FIXME: move checks in front of disk file access - /*if ((mEncoding[iEncoding].uFlags & NCP_UNICODE) == 0 && (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) == 0) { - BOOL bEncodingMismatch = TRUE; - FILEVARS fv; - FileVars_Init(lpData,cbData,&fv); - if (fv.mask & FV_ENCODING) { - int iAltEncoding; - if (FileVars_IsValidEncoding(&fv)) { - iAltEncoding = FileVars_GetEncoding(&fv); - if (iAltEncoding == iEncoding) - bEncodingMismatch = FALSE; - else if ((mEncoding[iAltEncoding].uFlags & NCP_UTF8) && (mEncoding[iEncoding].uFlags & NCP_UTF8)) - bEncodingMismatch = FALSE; - } - if (bEncodingMismatch) { - Encoding_GetLabel(iAltEncoding); - Encoding_GetLabel(iEncoding); - InfoBox(0,L"MsgEncodingMismatch",IDS_ENCODINGMISMATCH, - mEncoding[iAltEncoding].wchLabel, - mEncoding[iEncoding].wchLabel); - } - } - }*/ - - if (mEncoding[iEncoding].uFlags & NCP_UNICODE) - { - LPWSTR lpDataWide; - int cbDataWide; - - SetEndOfFile(hFile); - - lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); - cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); - - if (mEncoding[iEncoding].uFlags & NCP_UNICODE_BOM) { - if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) - WriteFile(hFile,(LPCVOID)"\xFE\xFF",2,&dwBytesWritten,NULL); - else - WriteFile(hFile,(LPCVOID)"\xFF\xFE",2,&dwBytesWritten,NULL); - } - - if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) - _swab((char*)lpDataWide,(char*)lpDataWide,cbDataWide * sizeof(WCHAR)); - - bWriteSuccess = WriteFile(hFile,lpDataWide,cbDataWide * sizeof(WCHAR),&dwBytesWritten,NULL); - dwLastIOError = GetLastError(); - - GlobalFree(lpDataWide); - GlobalFree(lpData); - } - - else if (mEncoding[iEncoding].uFlags & NCP_UTF8) - { - SetEndOfFile(hFile); - - if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) - WriteFile(hFile,(LPCVOID)"\xEF\xBB\xBF",3,&dwBytesWritten,NULL); - - bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); - dwLastIOError = GetLastError(); - - GlobalFree(lpData); - } - - else if (mEncoding[iEncoding].uFlags & NCP_8BIT) { - - BOOL bCancelDataLoss = FALSE; - UINT uCodePage = mEncoding[iEncoding].uCodePage; - - LPWSTR lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); - int cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); - - // Special cases: 42, 50220, 50221, 50222, 50225, 50227, 50229, 54936, 57002-11, 65000, 65001 - if (uCodePage == CP_UTF7 || uCodePage == 54936) { - GlobalFree(lpData); - lpData = GlobalAlloc(GPTR,GlobalSize(lpDataWide)*2); - } - else - ZeroMemory(lpData,GlobalSize(lpData)); - - if (uCodePage == CP_UTF7 || uCodePage == 54936) - cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); - else { - cbData = WideCharToMultiByte(uCodePage,WC_NO_BEST_FIT_CHARS,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,&bCancelDataLoss); - if (!bCancelDataLoss) { - cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); - bCancelDataLoss = FALSE; - } - } - GlobalFree(lpDataWide); - - if (!bCancelDataLoss || InfoBox(MBOKCANCEL,L"MsgConv3",IDS_ERR_UNICODE2) == IDOK) { - SetEndOfFile(hFile); - bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); - dwLastIOError = GetLastError(); - } - else { - bWriteSuccess = FALSE; - *pbCancelDataLoss = TRUE; - } - - GlobalFree(lpData); - } - - else { - SetEndOfFile(hFile); - bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); - dwLastIOError = GetLastError(); - GlobalFree(lpData); - } - } - - CloseHandle(hFile); - - if (bWriteSuccess) - { - if (!bSaveCopy) - SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); - - return TRUE; - } - - else - return FALSE; - -} - - -//============================================================================= -// -// EditInvertCase() -// -void EditInvertCase(HWND hwnd) -{ - int cchTextW; - int iCurPos; - int iAnchorPos; - UINT cpEdit; - int i; - BOOL bChanged = FALSE; - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); - LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - - if (pszText == NULL || pszTextW == NULL) { - GlobalFree(pszText); - GlobalFree(pszTextW); - return; - } - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - - for (i = 0; i < cchTextW; i++) { - if (IsCharUpperW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - else if (IsCharLowerW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - - if (bChanged) { - - WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_CLEAR,0,0); - SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - } - - GlobalFree(pszText); - GlobalFree(pszTextW); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditTitleCase() -// -void EditTitleCase(HWND hwnd) -{ - int cchTextW; - int iCurPos; - int iAnchorPos; - UINT cpEdit; - int i; - BOOL bNewWord = TRUE; - BOOL bWordEnd = TRUE; - BOOL bChanged = FALSE; - -#ifdef BOOKMARK_EDITION - BOOL bPrevWasSpace = FALSE; -#endif - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); - LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - - if (pszText == NULL || pszTextW == NULL) { - GlobalFree(pszText); - GlobalFree(pszTextW); - return; - } - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - - if (IsW7()) { - - LPWSTR pszMappedW = LocalAlloc(LPTR,LocalSize(pszTextW)); - - if (LCMapString( - LOCALE_SYSTEM_DEFAULT,LCMAP_LINGUISTIC_CASING|/*LCMAP_TITLECASE*/0x00000300, - pszTextW,cchTextW,pszMappedW,(int)LocalSize(pszMappedW)/sizeof(WCHAR))) { - - StrCpyN(pszTextW,pszMappedW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - bChanged = TRUE; - } - else - bChanged = FALSE; - - LocalFree(pszMappedW); - } - - else { - - -#ifdef BOOKMARK_EDITION - //Slightly enhanced function to make Title Case: Added some '-characters and bPrevWasSpace makes it better (for example "'Don't'" will now work) - bPrevWasSpace = TRUE; - for (i = 0; i < cchTextW; i++) - { - if (!IsCharAlphaNumericW(pszTextW[i]) && (!StrChr(L"'`΄’",pszTextW[i]) || bPrevWasSpace ) ) - { - bNewWord = TRUE; - } - else - { - if (bNewWord) - { - if (IsCharLowerW(pszTextW[i])) - { - pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - else - { - if (IsCharUpperW(pszTextW[i])) - { - pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - bNewWord = FALSE; - } - if( StrChr(L" \r\n\t[](){}",pszTextW[i]) ) bPrevWasSpace = TRUE; else bPrevWasSpace = FALSE; - } -#else - - for (i = 0; i < cchTextW; i++) { - BOOL bAlphaNumeric = IsCharAlphaNumericW(pszTextW[i]); - if (!bAlphaNumeric && (!StrChr(L"\x0027\x2019\x0060\x00B4",pszTextW[i]) || bWordEnd)) { - bNewWord = TRUE; - } - else { - if (bNewWord) { - if (IsCharLowerW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - else { - if (IsCharUpperW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - bNewWord = FALSE; - } - bWordEnd = !bAlphaNumeric; - } -#endif - } - - if (bChanged) { - - WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_CLEAR,0,0); - SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - } - - GlobalFree(pszText); - GlobalFree(pszTextW); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditSentenceCase() -// -void EditSentenceCase(HWND hwnd) -{ - int cchTextW; - int iCurPos; - int iAnchorPos; - UINT cpEdit; - int i; - BOOL bNewSentence = TRUE; - BOOL bChanged = FALSE; - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); - LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - - if (pszText == NULL || pszTextW == NULL) { - GlobalFree(pszText); - GlobalFree(pszTextW); - return; - } - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - - for (i = 0; i < cchTextW; i++) { - if (StrChr(L".;!?\r\n",pszTextW[i])) { - bNewSentence = TRUE; - } - else { - if (IsCharAlphaNumericW(pszTextW[i])) { - if (bNewSentence) { - if (IsCharLowerW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - bNewSentence = FALSE; - } - else { - if (IsCharUpperW(pszTextW[i])) { - pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); - bChanged = TRUE; - } - } - } - } - } - - if (bChanged) { - - WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_CLEAR,0,0); - SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - - GlobalFree(pszText); - GlobalFree(pszTextW); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditURLEncode() -// -void EditURLEncode(HWND hwnd) -{ - int cchTextW; - int iCurPos; - int iAnchorPos; - UINT cpEdit; - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - char* pszText; - LPWSTR pszTextW; - - DWORD cchEscaped; - char* pszEscaped; - DWORD cchEscapedW; - LPWSTR pszEscapedW; - - pszText = LocalAlloc(LPTR,(iSelCount)+2); - if (pszText == NULL) { - return; - } - - pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2); - if (pszTextW == NULL) { - LocalFree(pszText); - return; - } - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)LocalSize(pszTextW)/sizeof(WCHAR)); - - pszEscaped = LocalAlloc(LPTR,LocalSize(pszText) * 3); - if (pszEscaped == NULL) { - LocalFree(pszText); - LocalFree(pszTextW); - return; - } - - pszEscapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3); - if (pszEscapedW == NULL) { - LocalFree(pszText); - LocalFree(pszTextW); - LocalFree(pszEscaped); - return; - } - - cchEscapedW = (int)LocalSize(pszEscapedW) / sizeof(WCHAR); - UrlEscape(pszTextW,pszEscapedW,&cchEscapedW,URL_ESCAPE_SEGMENT_ONLY); - - cchEscaped = WideCharToMultiByte(cpEdit,0,pszEscapedW,cchEscapedW,pszEscaped,(int)LocalSize(pszEscaped),NULL,NULL); - - if (iCurPos < iAnchorPos) - iAnchorPos = iCurPos + cchEscaped; - else - iCurPos = iAnchorPos + cchEscaped; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_CLEAR,0,0); - SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchEscaped,(LPARAM)pszEscaped); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - LocalFree(pszText); - LocalFree(pszTextW); - LocalFree(pszEscaped); - LocalFree(pszEscapedW); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditURLDecode() -// -void EditURLDecode(HWND hwnd) -{ - int cchTextW; - int iCurPos; - int iAnchorPos; - UINT cpEdit; - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos != iAnchorPos) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - - char* pszText; - LPWSTR pszTextW; - - DWORD cchUnescaped; - char* pszUnescaped; - DWORD cchUnescapedW; - LPWSTR pszUnescapedW; - - pszText = LocalAlloc(LPTR,(iSelCount)+2); - if (pszText == NULL) { - return; - } - - pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2); - if (pszTextW == NULL) { - LocalFree(pszText); - return; - } - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)LocalSize(pszTextW)/sizeof(WCHAR)); - - pszUnescaped = LocalAlloc(LPTR,LocalSize(pszText) * 3); - if (pszUnescaped == NULL) { - LocalFree(pszText); - LocalFree(pszTextW); - return; - } - - pszUnescapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3); - if (pszUnescapedW == NULL) { - LocalFree(pszText); - LocalFree(pszTextW); - LocalFree(pszUnescaped); - return; - } - - cchUnescapedW = (int)LocalSize(pszUnescapedW) / sizeof(WCHAR); - UrlUnescape(pszTextW,pszUnescapedW,&cchUnescapedW,0); - - cchUnescaped = WideCharToMultiByte(cpEdit,0,pszUnescapedW,cchUnescapedW,pszUnescaped,(int)LocalSize(pszUnescaped),NULL,NULL); - - if (iCurPos < iAnchorPos) - iAnchorPos = iCurPos + cchUnescaped; - else - iCurPos = iAnchorPos + cchUnescaped; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_CLEAR,0,0); - SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchUnescaped,(LPARAM)pszUnescaped); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - LocalFree(pszText); - LocalFree(pszTextW); - LocalFree(pszUnescaped); - LocalFree(pszUnescapedW); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditEscapeCChars() -// -void EditEscapeCChars(HWND hwnd) { - - if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd }; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - lstrcpyA(efr.szFind,"\\"); - lstrcpyA(efr.szReplace,"\\\\"); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - lstrcpyA(efr.szFind,"\""); - lstrcpyA(efr.szReplace,"\\\""); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - lstrcpyA(efr.szFind,"\'"); - lstrcpyA(efr.szReplace,"\\\'"); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditUnescapeCChars() -// -void EditUnescapeCChars(HWND hwnd) { - - if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd }; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - lstrcpyA(efr.szFind,"\\\\"); - lstrcpyA(efr.szReplace,"\\"); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - lstrcpyA(efr.szFind,"\\\""); - lstrcpyA(efr.szReplace,"\""); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - lstrcpyA(efr.szFind,"\\\'"); - lstrcpyA(efr.szReplace,"\'"); - EditReplaceAllInSelection(hwnd,&efr,FALSE); - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } -} - - -//============================================================================= -// -// EditChar2Hex() -// -void EditChar2Hex(HWND hwnd) { - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0) == - SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0) && - iSelEnd == (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iSelStart,0)) { - - char ch[32]; - WCHAR wch[32]; - UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch); - - if (ch[0] == 0) - lstrcpyA(ch,"\\x00"); - - else { - MultiByteToWideChar(cp,0,ch,-1,wch,COUNTOF(wch)); - if (wch[0] <= 0xFF) - wsprintfA(ch,"\\x%02X",wch[0] & 0xFF); - else - wsprintfA(ch,"\\u%04X",wch[0]); - } - - SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)ch); - SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(ch)); - } - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditHex2Char() -// -void EditHex2Char(HWND hwnd) { - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - char ch[32]; - int i; - BOOL bTrySelExpand = FALSE; - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (iSelEnd - iSelStart) { - - if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(ch)) { - - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch); - - if (StrChrIA(ch,' ') || StrChrIA(ch,'\t') || StrChrIA(ch,'\r') || StrChrIA(ch,'\n') || StrChrIA(ch,'-')) - return; - - if (StrCmpNIA(ch,"\\x",2) == 0 || StrCmpNIA(ch,"\\u",2) == 0) { - ch[0] = '0'; - ch[1] = 'x'; - } - - else if (StrChrIA("xu",ch[0])) { - ch[0] = '0'; - bTrySelExpand = TRUE; - } - - if (sscanf(ch,"%x",&i) == 1) { - int cch; - if (i == 0) { - ch[0] = 0; - cch = 1; - } - else { - UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - WCHAR wch[4]; - wsprintf(wch,L"%lc",(WCHAR)i); - cch = WideCharToMultiByte(cp,0,wch,-1,ch,COUNTOF(ch),NULL,NULL) - 1; - if (bTrySelExpand && (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iSelStart-1,0) == '\\') { - iSelStart--; - } - } - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cch,(LPARAM)ch); - SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+cch); - } - } - } - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditModifyNumber() -// -void EditModifyNumber(HWND hwnd,BOOL bIncrease) { - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (iSelEnd - iSelStart) { - - char chFormat[32] = ""; - char chNumber[32]; - int iNumber; - int iWidth; - - if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(chNumber)) { - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)chNumber); - - if (StrChrIA(chNumber,'-')) - return; - - if (!StrChrIA(chNumber,'x') && sscanf(chNumber,"%d",&iNumber) == 1) { - iWidth = lstrlenA(chNumber); - if (iNumber >= 0) { - if (bIncrease && iNumber < INT_MAX) - iNumber++; - if (!bIncrease && iNumber > 0) - iNumber--; - wsprintfA(chFormat,"%%0%ii",iWidth); - wsprintfA(chNumber,chFormat,iNumber); - SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber); - SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber)); - } - } - else if (sscanf(chNumber,"%x",&iNumber) == 1) { - int i; - BOOL bUppercase = FALSE; - iWidth = lstrlenA(chNumber) - 2; - if (iNumber >= 0) { - if (bIncrease && iNumber < INT_MAX) - iNumber++; - if (!bIncrease && iNumber > 0) - iNumber--; - for (i = lstrlenA(chNumber) -1 ; i >= 0; i--) { - if (IsCharLowerA(chNumber[i])) - break; - else if (IsCharUpper(chNumber[i])) { - bUppercase = TRUE; - break; - } - } - if (bUppercase) - wsprintfA(chFormat,"%%#0%iX",iWidth); - else - wsprintfA(chFormat,"%%#0%ix",iWidth); - wsprintfA(chNumber,chFormat,iNumber); - SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber); - SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber)); - } - } - } - } - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditTabsToSpaces() -// -void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) -{ - char* pszText; - LPWSTR pszTextW; - int cchTextW; - int iTextW; - LPWSTR pszConvW; - int cchConvW; - int cchConvM; - int i,j; - int iLine; - int iCurPos; - int iAnchorPos; - int iSelStart; - int iSelEnd; - int iSelCount; - UINT cpEdit; - struct Sci_TextRange tr; - BOOL bIsLineStart = TRUE; - BOOL bModified = FALSE; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - MsgBox(MBWARN,IDS_SELRECT); - return; - } - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos) /*{ - iSelStart = 0; - iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); - }*/ - return; - - else { - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - } - - iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - - iSelCount = iSelEnd - iSelStart; - - pszText = GlobalAlloc(GPTR,(iSelCount)+2); - if (pszText == NULL) - return; - - pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - if (pszTextW == NULL) { - GlobalFree(pszText); - return; - } - - tr.chrg.cpMin = iSelStart; - tr.chrg.cpMax = iSelEnd; - tr.lpstrText = pszText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - GlobalFree(pszText); - - pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*nTabWidth+2); - if (pszConvW == NULL) { - GlobalFree(pszTextW); - return; - } - - cchConvW = 0; - - // Contributed by Homam - // Thank you very much! - i=0; - for (iTextW = 0; iTextW < cchTextW; iTextW++) - { - WCHAR w = pszTextW[iTextW]; - if (w == L'\t' && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { - for (j = 0; j < nTabWidth - i % nTabWidth; j++) - pszConvW[cchConvW++] = L' '; - i = 0; - bModified = TRUE; - } - else { - i++; - if (w == L'\n' || w == L'\r') { - i = 0; - bIsLineStart = TRUE; - } - else if (w != L' ') - bIsLineStart = FALSE; - pszConvW[cchConvW++] = w; - } - } - - GlobalFree(pszTextW); - - if (bModified) { - pszText = GlobalAlloc(GPTR,cchConvW * 3); - - cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); - GlobalFree(pszConvW); - - if (iAnchorPos > iCurPos) { - iCurPos = iSelStart; - iAnchorPos = iSelStart + cchConvM; - } - else { - iAnchorPos = iSelStart; - iCurPos = iSelStart + cchConvM; - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); - //SendMessage(hwnd,SCI_CLEAR,0,0); - //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - GlobalFree(pszText); - } - - else - GlobalFree(pszConvW); -} - - -//============================================================================= -// -// EditSpacesToTabs() -// -void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) -{ - char* pszText; - LPWSTR pszTextW; - int cchTextW; - int iTextW; - LPWSTR pszConvW; - int cchConvW; - int cchConvM; - int i,j,t; - int iLine; - int iCurPos; - int iAnchorPos; - int iSelStart; - int iSelEnd; - int iSelCount; - UINT cpEdit; - struct Sci_TextRange tr; - WCHAR space[256]; - BOOL bIsLineStart = TRUE; - BOOL bModified = FALSE; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - MsgBox(MBWARN,IDS_SELRECT); - return; - } - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos) /*{ - iSelStart = 0; - iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); - }*/ - return; - - else { - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - } - - iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - - iSelCount = iSelEnd - iSelStart; - - pszText = GlobalAlloc(GPTR,(iSelCount)+2); - if (pszText == NULL) - return; - - pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - if (pszTextW == NULL) { - GlobalFree(pszText); - return; - } - - tr.chrg.cpMin = iSelStart; - tr.chrg.cpMax = iSelEnd; - tr.lpstrText = pszText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - GlobalFree(pszText); - - pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)+2); - if (pszConvW == NULL) { - GlobalFree(pszTextW); - return; - } - - cchConvW = 0; - - // Contributed by Homam - // Thank you very much! - i = j = 0; - for (iTextW = 0; iTextW < cchTextW; iTextW++) - { - WCHAR w = pszTextW[iTextW]; - if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { - space[j++] = w; - if (j == nTabWidth - i % nTabWidth || w == L'\t') { - if (j > 1 || pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') - pszConvW[cchConvW++] = L'\t'; - else - pszConvW[cchConvW++] = w; - i = j = 0; - bModified = bModified || (w != pszConvW[cchConvW-1]); - } - } - else { - i += j + 1; - if (j > 0) { - //space[j] = '\0'; - for (t = 0; t < j; t++) - pszConvW[cchConvW++] = space[t]; - j = 0; - } - if (w == L'\n' || w == L'\r') { - i = 0; - bIsLineStart = TRUE; - } - else - bIsLineStart = FALSE; - pszConvW[cchConvW++] = w; - } - } - if (j > 0) { - for (t = 0; t < j; t++) - pszConvW[cchConvW++] = space[t]; - } - - GlobalFree(pszTextW); - - if (bModified || cchConvW != cchTextW) { - pszText = GlobalAlloc(GPTR,cchConvW * 3); - - cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); - GlobalFree(pszConvW); - - if (iAnchorPos > iCurPos) { - iCurPos = iSelStart; - iAnchorPos = iSelStart + cchConvM; - } - else { - iAnchorPos = iSelStart; - iCurPos = iSelStart + cchConvM; - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); - //SendMessage(hwnd,SCI_CLEAR,0,0); - //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - GlobalFree(pszText); - } - - else - GlobalFree(pszConvW); -} - - -//============================================================================= -// -// EditMoveUp() -// -void EditMoveUp(HWND hwnd) -{ - - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - int iCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); - - if (iCurLine == iAnchorLine) { - - int iLineCurPos = iCurPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0); - int iLineAnchorPos = iAnchorPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0); - if (iCurLine > 0) { - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_LINETRANSPOSE,0,0); - SendMessage(hwnd,SCI_SETSEL, - (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0)+iLineAnchorPos, - (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0)+iLineCurPos); - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - } - else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - int iLineSrc = min(iCurLine,iAnchorLine) -1; - if (iLineSrc >= 0) { - - DWORD cLine; - char *pLine; - int iLineSrcStart; - int iLineSrcEnd; - int iLineDest; - int iLineDestStart; - - cLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0); - pLine = LocalAlloc(LPTR,cLine+1); - SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine); - - iLineSrcStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0); - iLineSrcEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); - - iLineDest = max(iCurLine,iAnchorLine); - if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0)) { - if (iLineDest >= 1) - iLineDest--; - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - - iLineDestStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); - - SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine); - - LocalFree(pLine); - - if (iLineDest == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) { - - char chaEOL[] = "\r\n"; - int iEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - if (iEOLMode == SC_EOL_CR) - chaEOL[1] = 0; - else if (iEOLMode == SC_EOL_LF) { - chaEOL[0] = '\n'; - chaEOL[1] = 0; - } - - SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)chaEOL); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) - SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineDest,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) - SendMessage(hwnd,SCI_GETLENGTH,0,0),0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - - if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0); - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditMoveDown() -// -void EditMoveDown(HWND hwnd) -{ - - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - int iCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); - - if (iCurLine == iAnchorLine) { - - int iLineCurPos = iCurPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0); - int iLineAnchorPos = iAnchorPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0); - if (iCurLine < SendMessage(hwnd,SCI_GETLINECOUNT,0,0) - 1) { - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_GOTOLINE,(WPARAM)iCurLine+1,0); - SendMessage(hwnd,SCI_LINETRANSPOSE,0,0); - SendMessage(hwnd,SCI_SETSEL, - (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0)+iLineAnchorPos, - (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0)+iLineCurPos); - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - } - else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - int iLineSrc = max(iCurLine,iAnchorLine) +1; - if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0)) { - if (iLineSrc >= 1) - iLineSrc--; - } - - if (iLineSrc <= SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) { - - DWORD cLine; - char *pLine; - int iLineSrcStart; - int iLineSrcEnd; - int iLineDest; - int iLineDestStart; - - BOOL bLastLine = (iLineSrc == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1); - - if (bLastLine && - (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc,0) - - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0) == 0) && - (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc-1,0) - - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0) == 0)) - return; - - if (bLastLine) { - char chaEOL[] = "\r\n"; - int iEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - if (iEOLMode == SC_EOL_CR) - chaEOL[1] = 0; - else if (iEOLMode == SC_EOL_LF) { - chaEOL[0] = '\n'; - chaEOL[1] = 0; - } - SendMessage(hwnd,SCI_APPENDTEXT,(WPARAM)lstrlenA(chaEOL),(LPARAM)chaEOL); - } - - cLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0); - pLine = LocalAlloc(LPTR,cLine+3); - SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine); - - iLineSrcStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0); - iLineSrcEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); - - iLineDest = min(iCurLine,iAnchorLine); - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - - iLineDestStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); - - SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine); - - if (bLastLine) { - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) - SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM) - SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-2,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) - SendMessage(hwnd,SCI_GETLENGTH,0,0),0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - - LocalFree(pLine); - - if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0); - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditModifyLines() -// -void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend) -{ - char mszPrefix1[256*3] = ""; - char mszPrefix2[256*3] = ""; - BOOL bPrefixNum = FALSE; - int iPrefixNum = 0; - int iPrefixNumWidth = 1; - char *pszPrefixNumPad = ""; - char mszAppend1[256*3] = ""; - char mszAppend2[256*3] = ""; - BOOL bAppendNum = FALSE; - int iAppendNum = 0; - int iAppendNumWidth = 1; - char *pszAppendNumPad = ""; - int mbcp; - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - //if (iSelStart == iSelEnd) { - // iSelStart = 0; - // iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); - //} - - if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) - mbcp = CP_UTF8; - else - mbcp = CP_ACP; - - if (lstrlen(pwszPrefix)) - WideCharToMultiByte(mbcp,0,pwszPrefix,-1,mszPrefix1,COUNTOF(mszPrefix1),NULL,NULL); - if (lstrlen(pwszAppend)) - WideCharToMultiByte(mbcp,0,pwszAppend,-1,mszAppend1,COUNTOF(mszAppend1),NULL,NULL); - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - char *p; - int i; - - int iLine; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - //if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) - // iLineStart++; - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) - { - if (iLineEnd - iLineStart >= 1) - iLineEnd--; - } - - if (lstrlenA(mszPrefix1)) { - - p = mszPrefix1; - while (!bPrefixNum && (p = StrStrA(p,"$("))) { - - if (StrCmpNA(p,"$(I)",CSTRLEN("$(I)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(I)")); - bPrefixNum = TRUE; - iPrefixNum = 0; - for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = ""; - } - - else if (StrCmpNA(p,"$(0I)",CSTRLEN("$(0I)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(0I)")); - bPrefixNum = TRUE; - iPrefixNum = 0; - for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = "0"; - } - - else if (StrCmpNA(p,"$(N)",CSTRLEN("$(N)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(N)")); - bPrefixNum = TRUE; - iPrefixNum = 1; - for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = ""; - } - - else if (StrCmpNA(p,"$(0N)",CSTRLEN("$(0N)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(0N)")); - bPrefixNum = TRUE; - iPrefixNum = 1; - for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = "0"; - } - - else if (StrCmpNA(p,"$(L)",CSTRLEN("$(L)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(L)")); - bPrefixNum = TRUE; - iPrefixNum = iLineStart+1; - for (i = iLineEnd + 1; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = ""; - } - - else if (StrCmpNA(p,"$(0L)",CSTRLEN("$(0L)")) == 0) { - *p = 0; - StrCpyA(mszPrefix2,p+CSTRLEN("$(0L)")); - bPrefixNum = TRUE; - iPrefixNum = iLineStart+1; - for (i = iLineEnd + 1; i >= 10; i = i / 10) - iPrefixNumWidth++; - pszPrefixNumPad = "0"; - } - p += CSTRLEN("$("); - } - } - - if (lstrlenA(mszAppend1)) { - - p = mszAppend1; - while (!bAppendNum && (p = StrStrA(p,"$("))) { - - if (StrCmpNA(p,"$(I)",CSTRLEN("$(I)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(I)")); - bAppendNum = TRUE; - iAppendNum = 0; - for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = ""; - } - - else if (StrCmpNA(p,"$(0I)",CSTRLEN("$(0I)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(0I)")); - bAppendNum = TRUE; - iAppendNum = 0; - for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = "0"; - } - - else if (StrCmpNA(p,"$(N)",CSTRLEN("$(N)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(N)")); - bAppendNum = TRUE; - iAppendNum = 1; - for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = ""; - } - - else if (StrCmpNA(p,"$(0N)",CSTRLEN("$(0N)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(0N)")); - bAppendNum = TRUE; - iAppendNum = 1; - for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = "0"; - } - - else if (StrCmpNA(p,"$(L)",CSTRLEN("$(L)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(L)")); - bAppendNum = TRUE; - iAppendNum = iLineStart+1; - for (i = iLineEnd + 1; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = ""; - } - - else if (StrCmpNA(p,"$(0L)",CSTRLEN("$(0L)")) == 0) { - *p = 0; - StrCpyA(mszAppend2,p+CSTRLEN("$(0L)")); - bAppendNum = TRUE; - iAppendNum = iLineStart+1; - for (i = iLineEnd + 1; i >= 10; i = i / 10) - iAppendNumWidth++; - pszAppendNumPad = "0"; - } - p += CSTRLEN("$("); - } - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) - { - int iPos; - - if (lstrlen(pwszPrefix)) { - - char mszInsert[512*3]; - lstrcpyA(mszInsert,mszPrefix1); - - if (bPrefixNum) { - char tchFmt[64]; - char tchNum[64]; - wsprintfA(tchFmt,"%%%s%ii",pszPrefixNumPad,iPrefixNumWidth); - wsprintfA(tchNum,tchFmt,iPrefixNum); - lstrcatA(mszInsert,tchNum); - lstrcatA(mszInsert,mszPrefix2); - iPrefixNum++; - } - iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszInsert),(LPARAM)mszInsert); - } - - if (lstrlen(pwszAppend)) { - - char mszInsert[512*3]; - lstrcpyA(mszInsert,mszAppend1); - - if (bAppendNum) { - char tchFmt[64]; - char tchNum[64]; - wsprintfA(tchFmt,"%%%s%ii",pszAppendNumPad,iAppendNumWidth); - wsprintfA(tchNum,tchFmt,iAppendNum); - lstrcatA(mszInsert,tchNum); - lstrcatA(mszInsert,mszAppend2); - iAppendNum++; - } - iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszInsert),(LPARAM)mszInsert); - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - //// Fix selection - //if (iSelStart != iSelEnd && SendMessage(hwnd,SCI_GETTARGETEND,0,0) > SendMessage(hwnd,SCI_GETSELECTIONEND,0,0)) - //{ - // int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - // int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0); - // if (iCurPos > iAnchorPos) - // iCurPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0); - // else - // iAnchorPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0); - // SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - //} - - // extend selection to start of first line - // the above code is not required when last line has been excluded - if (iSelStart != iSelEnd) - { - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditAlignText() -// -void EditAlignText(HWND hwnd,int nMode) -{ - #define BUFSIZE_ALIGN 1024 - - int mbcp; - BOOL bModified = FALSE; - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) - mbcp = CP_UTF8; - else - mbcp = CP_ACP; - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iLine; - int iMinIndent = BUFSIZE_ALIGN; - int iMaxLength = 0; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) - { - if (iLineEnd - iLineStart >= 1) - iLineEnd--; - } - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - - int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - - if (iLineIndentPos != iLineEndPos) { - - int iIndentCol = (int)SendMessage(hwnd,SCI_GETLINEINDENTATION,(WPARAM)iLine,0); - int iEndCol; - char ch; - int iTail; - - iTail = iLineEndPos-1; - ch = (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iTail,0); - while (iTail >= iLineStart && (ch == ' ' || ch == '\t')) - { - iTail--; - ch = (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iTail,0); - iLineEndPos--; - } - iEndCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iLineEndPos,0); - - iMinIndent = min(iMinIndent,iIndentCol); - iMaxLength = max(iMaxLength,iEndCol); - } - } - - if (iMaxLength < BUFSIZE_ALIGN) { - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) - { - int iIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - int iEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - - if (iIndentPos == iEndPos && iEndPos > 0) { - - if (!bModified) { - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - bModified = TRUE; - } - - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iEndPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - - else { - - char tchLineBuf[BUFSIZE_ALIGN*3] = ""; - WCHAR wchLineBuf[BUFSIZE_ALIGN*3] = L""; - WCHAR *pWords[BUFSIZE_ALIGN*3/2]; - WCHAR *p = wchLineBuf; - - int iWords = 0; - int iWordsLength = 0; - int cchLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,(LPARAM)tchLineBuf); - - if (!bModified) { - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - bModified = TRUE; - } - - MultiByteToWideChar(mbcp,0,tchLineBuf,cchLine,wchLineBuf,COUNTOF(wchLineBuf)); - StrTrim(wchLineBuf,L"\r\n\t "); - - while (*p) { - if (*p != L' ' && *p != L'\t') { - pWords[iWords++] = p++; - iWordsLength++; - while (*p && *p != L' ' && *p != L'\t') { - p++; - iWordsLength++; - } - } - else - *p++ = 0; - } - - if (iWords > 0) { - - if (nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) { - - BOOL bNextLineIsBlank = FALSE; - if (nMode == ALIGN_JUSTIFY_EX) { - - if (SendMessage(hwnd,SCI_GETLINECOUNT,0,0) <= iLine+1) - bNextLineIsBlank = TRUE; - - else { - - int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine+1,0); - int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine+1,0); - - if (iLineIndentPos == iLineEndPos) - bNextLineIsBlank = TRUE; - } - } - - if ((nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) && - iWords > 1 && iWordsLength >= 2 && - ((nMode != ALIGN_JUSTIFY_EX || !bNextLineIsBlank || iLineStart == iLineEnd) || - (bNextLineIsBlank && iWordsLength > (iMaxLength - iMinIndent) * 0.75))) { - - int iGaps = iWords - 1; - int iSpacesPerGap = (iMaxLength - iMinIndent - iWordsLength) / iGaps; - int iExtraSpaces = (iMaxLength - iMinIndent - iWordsLength) % iGaps; - int i,j; - int iPos; - - WCHAR wchNewLineBuf[BUFSIZE_ALIGN*3]; - StrCpy(wchNewLineBuf,pWords[0]); - p = StrEnd(wchNewLineBuf); - - for (i = 1; i < iWords; i++) { - for (j = 0; j < iSpacesPerGap; j++) { - *p++ = L' '; - *p = 0; - } - if (i > iGaps - iExtraSpaces) { - *p++ = L' '; - *p = 0; - } - StrCat(p,pWords[i]); - p = StrEnd(p); - } - - WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); - - iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); - - SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); - } - else { - - int i; - int iPos; - - WCHAR wchNewLineBuf[BUFSIZE_ALIGN]; - StrCpy(wchNewLineBuf,pWords[0]); - p = StrEnd(wchNewLineBuf); - - for (i = 1; i < iWords; i++) { - *p++ = L' '; - *p = 0; - StrCat(wchNewLineBuf,pWords[i]); - p = StrEnd(p); - } - - WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); - - iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); - - SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); - } - } - else { - - int iExtraSpaces = iMaxLength - iMinIndent - iWordsLength - iWords + 1; - int iOddSpaces = iExtraSpaces % 2; - int i; - int iPos; - - WCHAR wchNewLineBuf[BUFSIZE_ALIGN*3] = L""; - p = wchNewLineBuf; - - if (nMode == ALIGN_RIGHT) { - for (i = 0; i < iExtraSpaces; i++) - *p++ = L' '; - *p = 0; - } - if (nMode == ALIGN_CENTER) { - for (i = 1; i < iExtraSpaces - iOddSpaces; i+=2) - *p++ = L' '; - *p = 0; - } - for (i = 0; i < iWords; i++) { - StrCat(p,pWords[i]); - if (i < iWords-1) - StrCat(p,L" "); - if (nMode == ALIGN_CENTER && iWords > 1 && iOddSpaces > 0 && i + 1 >= iWords / 2) { - StrCat(p,L" "); - iOddSpaces--; - } - p = StrEnd(p); - } - - WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); - - if (nMode == ALIGN_RIGHT || nMode == ALIGN_CENTER) { - SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); - iPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - } - else - iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); - - if (nMode == ALIGN_LEFT) - SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); - } - } - } - } - if (bModified) - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBINFO,IDS_BUFFERTOOSMALL); - - if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditEncloseSelection() -// -void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose) -{ - char mszOpen[256*3] = ""; - char mszClose[256*3] = ""; - int mbcp; - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) - mbcp = CP_UTF8; - else - mbcp = CP_ACP; - - if (lstrlen(pwszOpen)) - WideCharToMultiByte(mbcp,0,pwszOpen,-1,mszOpen,COUNTOF(mszOpen),NULL,NULL); - if (lstrlen(pwszClose)) - WideCharToMultiByte(mbcp,0,pwszClose,-1,mszClose,COUNTOF(mszClose),NULL,NULL); - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - if (lstrlenA(mszOpen)) { - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszOpen),(LPARAM)mszOpen); - } - - if (lstrlenA(mszClose)) { - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelEnd + lstrlenA(mszOpen),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd + lstrlenA(mszOpen),0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszClose),(LPARAM)mszClose); - } - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - // Fix selection - if (iSelStart == iSelEnd) - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iSelStart + lstrlenA(mszOpen),(WPARAM)iSelStart + lstrlenA(mszOpen)); - - else { - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - if (iCurPos < iAnchorPos) { - iCurPos = iSelStart + lstrlenA(mszOpen); - iAnchorPos = iSelEnd + lstrlenA(mszOpen); - } - else { - iAnchorPos = iSelStart + lstrlenA(mszOpen); - iCurPos = iSelEnd + lstrlenA(mszOpen); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditToggleLineComments() -// -void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart) -{ - char mszComment[256*3] = ""; - int cchComment; - int mbcp; - int iAction = 0; - - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - - if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) - mbcp = CP_UTF8; - else - mbcp = CP_ACP; - - if (lstrlen(pwszComment)) - WideCharToMultiByte(mbcp,0,pwszComment,-1,mszComment,COUNTOF(mszComment),NULL,NULL); - cchComment = lstrlenA(mszComment); - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0) && cchComment) - { - int iLine; - int iCommentCol = 0; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) - { - if (iLineEnd - iLineStart >= 1) - iLineEnd--; - } - - if (!bInsertAtStart) { - iCommentCol = 1024; - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - if (iLineIndentPos != iLineEndPos) { - int iIndentColumn = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iLineIndentPos,0); - iCommentCol = min(iCommentCol,iIndentColumn); - } - } - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) - { - int iCommentPos; - int iIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - char tchBuf[32]; - struct Sci_TextRange tr; - - if (iIndentPos == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0)) - continue; - - tr.chrg.cpMin = iIndentPos; - tr.chrg.cpMax = tr.chrg.cpMin + min(31,cchComment); - tr.lpstrText = tchBuf; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - if (StrCmpNIA(tchBuf,mszComment,cchComment) == 0) { - switch (iAction) { - case 0: - iAction = 2; - case 2: - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iIndentPos,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iIndentPos+cchComment,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - break; - case 1: - break; - } - } - else { - switch (iAction) { - case 0: - iAction = 1; - case 1: - iCommentPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iLine,(LPARAM)iCommentCol); - SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iCommentPos,(LPARAM)mszComment); - break; - case 2: - break; - } - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - if (iSelStart != iSelEnd) - { - int iAnchorPos; - if (iCurPos == iSelStart) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditPadWithSpaces() -// -void EditPadWithSpaces(HWND hwnd,BOOL bSkipEmpty,BOOL bNoUndoGroup) -{ - char *pmszPadStr; - int iMaxColumn = 0; - int iLine; - BOOL bIsRectangular = FALSE; - BOOL bReducedSelection = FALSE; - - int iSelStart; - int iSelEnd; - - int iLineStart; - int iLineEnd; - - int iRcCurLine; - int iRcAnchorLine; - int iRcCurCol; - int iRcAnchorCol; - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iLineStart == iLineEnd) { - iLineStart = 0; - iLineEnd = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1; - } - - else { - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) { - if (iLineEnd - iLineStart >= 1) { - iLineEnd--; - bReducedSelection = TRUE; - } - } - } - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - - int iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - iMaxColumn = max(iMaxColumn,(int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0)); - } - } - else { - - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - iRcCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - iRcAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); - - iRcCurCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0); - iRcAnchorCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0); - - bIsRectangular = TRUE; - - iLineStart = 0; - iLineEnd = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1; - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - - int iPos = (int)SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0); - if (iPos != INVALID_POSITION) - iMaxColumn = max(iMaxColumn,(int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0)); - } - } - - pmszPadStr = LocalAlloc(LPTR,(iMaxColumn +1 )* sizeof(char)); - if (pmszPadStr) { - - FillMemory(pmszPadStr,LocalSize(pmszPadStr),' '); - - if (!bNoUndoGroup) - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - - int iPos; - int iPadLen; - int iLineSelEndPos; - - iLineSelEndPos = (int)SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0); - if (bIsRectangular && INVALID_POSITION == iLineSelEndPos) - continue; - - iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - if (bIsRectangular && iPos > iLineSelEndPos) - continue; - if (bSkipEmpty && (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0) >= iPos) - continue; - - iPadLen = iMaxColumn - (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0); - - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)iPadLen,(LPARAM)pmszPadStr); - } - - if (pmszPadStr) - LocalFree(pmszPadStr); - - if (!bNoUndoGroup) - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - - if (!bIsRectangular && - SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0) != - SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0)) - { - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - if (!bReducedSelection) - iAnchorPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0); - else - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - else { - iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); - if (!bReducedSelection) - iCurPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0); - else - iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); - } - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - - else if (bIsRectangular) { - int iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcCurLine,(LPARAM)iRcCurCol); - int iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcAnchorLine,(LPARAM)iRcAnchorCol); - SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONCARET,(WPARAM)iCurPos,0); - SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONANCHOR,(WPARAM)iAnchorPos,0); - } -} - - -//============================================================================= -// -// EditStripFirstCharacter() -// -void EditStripFirstCharacter(HWND hwnd) -{ - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (iSelStart == iSelEnd) { - iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - } - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iLine; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) - iLineStart++; - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) - iLineEnd--; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) - { - int iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - if (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0)- iPos > 0) - { - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); - SendMessage(hwnd,SCI_SETTARGETEND, - (WPARAM)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iPos,0),0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditStripLastCharacter() -// -void EditStripLastCharacter(HWND hwnd) -{ - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (iSelStart == iSelEnd) { - iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - } - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iLine; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelStart >= SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineStart,0)) - iLineStart++; - - if (iSelEnd < SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0)) - iLineEnd--; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) - { - int iStartPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - int iEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - if (iEndPos - iStartPos > 0) - { - SendMessage(hwnd,SCI_SETTARGETSTART, - (WPARAM)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iEndPos,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iEndPos,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditStripTrailingBlanks() -// -void EditStripTrailingBlanks(HWND hwnd,BOOL bIgnoreSelection) -{ - // Check if there is any selection... simply use a regular expression replace! - if (!bIgnoreSelection && - (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) != 0)) - { - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - EDITFINDREPLACE efrTrim = { "[ \t]+$", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwnd }; - EditReplaceAllInSelection(hwnd,&efrTrim,FALSE); - } - else - MsgBox(MBWARN,IDS_SELRECT); - } - // Code from SciTE... - else - { - int line; - int maxLines; - int lineStart; - int lineEnd; - int i; - char ch; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - maxLines = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0); - for (line = 0; line < maxLines; line++) - { - lineStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,line,0); - lineEnd = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,line,0); - i = lineEnd-1; - ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0); - while ((i >= lineStart) && ((ch == ' ') || (ch == '\t'))) - { - i--; - ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0); - } - if (i < (lineEnd-1)) - { - SendMessage(hwnd,SCI_SETTARGETSTART,i + 1,0); - SendMessage(hwnd,SCI_SETTARGETEND,lineEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } -} - - -//============================================================================= -// -// EditCompressSpaces() -// -void EditCompressSpaces(HWND hwnd) -{ - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - int iLength = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - char* pszIn; - char* pszOut; - BOOL bIsLineStart, bIsLineEnd; - BOOL bModified = FALSE; - - if (iSelStart != iSelEnd) { - int cch = (int)SendMessage(hwnd,SCI_GETSELTEXT,0,0); - pszIn = LocalAlloc(LPTR,cch); - pszOut = LocalAlloc(LPTR,cch); - SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszIn); - bIsLineStart = - (iSelStart == SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)); - bIsLineEnd = - (iSelEnd == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0)); - } - else { - int cch = iLength + 1; - pszIn = LocalAlloc(GPTR,cch); - pszOut = LocalAlloc(GPTR,cch); - SendMessage(hwnd,SCI_GETTEXT,(WPARAM)cch,(LPARAM)pszIn); - bIsLineStart = TRUE; - bIsLineEnd = TRUE; - } - - if (pszIn && pszOut) { - char *ci, *co = pszOut; - for (ci = pszIn; *ci; ci++) { - if (*ci == ' ' || *ci == '\t') { - if (*ci == '\t') - bModified = TRUE; - while (*(ci+1) == ' ' || *(ci+1) == '\t') { - ci++; - bModified = TRUE; - } - if (!bIsLineStart && (*(ci+1) != '\n' && *(ci+1) != '\r')) - *co++ = ' '; - else - bModified = TRUE; - } - else { - if (*ci == '\n' || *ci == '\r') - bIsLineStart = TRUE; - else - bIsLineStart = FALSE; - *co++ = *ci; - } - } - if (bIsLineEnd && co > pszOut && *(co-1) == ' ') { - *--co = 0; - bModified = TRUE; - } - - if (bModified) { - if (iSelStart != iSelEnd) - SendMessage(hwnd,SCI_TARGETFROMSELECTION,0,0); - else { - SendMessage(hwnd,SCI_SETTARGETSTART,0,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLength,0); - } - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)-1,(LPARAM)pszOut); - if (iCurPos > iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - else if (iCurPos < iAnchorPos) { - iCurPos = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - } - if (pszIn) - LocalFree(pszIn); - if (pszOut) - LocalFree(pszOut); - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditRemoveBlankLines() -// -void EditRemoveBlankLines(HWND hwnd,BOOL bMerge) -{ - int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (iSelStart == iSelEnd) { - iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - } - - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - int iLine; - - int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) - iLineStart++; - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0) && - iLineEnd != SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-1) - iLineEnd--; - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - for (iLine = iLineStart; iLine <= iLineEnd; ) - { - int nBlanks = 0; - while (iLine + nBlanks <= iLineEnd && - SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine + nBlanks,0) == - SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine + nBlanks,0)) - nBlanks++; - - if (nBlanks == 0 || (nBlanks == 1 && bMerge)) - iLine += nBlanks + 1; - - else { - int iTargetStart; - int iTargetEnd; - - if (bMerge) - nBlanks--; - iTargetStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - iTargetEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine + nBlanks,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iTargetStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iTargetEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); - if (bMerge) - iLine++; - iLineEnd -= nBlanks; - } - } - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - else - MsgBox(MBWARN,IDS_SELRECT); -} - - -//============================================================================= -// -// EditWrapToColumn() -// -void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/) -{ - char* pszText; - LPWSTR pszTextW; - int cchTextW; - int iTextW; - LPWSTR pszConvW; - int cchConvW; - int cchConvM; - int iLineLength; - int iLine; - int iCurPos; - int iAnchorPos; - int iSelStart; - int iSelEnd; - int iSelCount; - UINT cpEdit; - struct Sci_TextRange tr; - int cEOLMode; - WCHAR wszEOL[] = L"\r\n"; - int cchEOL = 2; - BOOL bModified = FALSE; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - MsgBox(MBWARN,IDS_SELRECT); - return; - } - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos) /*{ - iSelStart = 0; - iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); - }*/ - return; - - else { - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - } - - iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - - iSelCount = iSelEnd - iSelStart; - - pszText = GlobalAlloc(GPTR,(iSelCount)+2); - if (pszText == NULL) - return; - - pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); - if (pszTextW == NULL) { - GlobalFree(pszText); - return; - } - - tr.chrg.cpMin = iSelStart; - tr.chrg.cpMax = iSelEnd; - tr.lpstrText = pszText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - - cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - GlobalFree(pszText); - - pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*3+2); - if (pszConvW == NULL) { - GlobalFree(pszTextW); - return; - } - - cEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - if (cEOLMode == SC_EOL_CR) - cchEOL = 1; - else if (cEOLMode == SC_EOL_LF) { - cchEOL = 1; wszEOL[0] = L'\n'; - } - - cchConvW = 0; - iLineLength = 0; - -#define ISDELIMITER(wc) StrChr(L",;.:-+%&¦|/*?!\"\'~΄#=",wc) -#define ISWHITE(wc) StrChr(L" \t",wc) -#define ISWORDEND(wc) (/*ISDELIMITER(wc) ||*/ StrChr(L" \t\r\n",wc)) - - for (iTextW = 0; iTextW < cchTextW; iTextW++) - { - WCHAR w; - w = pszTextW[iTextW]; - - //if (ISDELIMITER(w)) - //{ - // int iNextWordLen = 0; - // WCHAR w2 = pszTextW[iTextW + 1]; - - // if (iLineLength + iNextWordLen + 1 > nColumn) { - // pszConvW[cchConvW++] = wszEOL[0]; - // if (cchEOL > 1) - // pszConvW[cchConvW++] = wszEOL[1]; - // iLineLength = 0; - // bModified = TRUE; - // } - - // while (w2 != L'\0' && !ISWORDEND(w2)) { - // iNextWordLen++; - // w2 = pszTextW[iTextW + iNextWordLen + 1]; - // } - - // if (ISDELIMITER(w2) && iNextWordLen > 0) // delimiters go with the word - // iNextWordLen++; - - // pszConvW[cchConvW++] = w; - // iLineLength++; - - // if (iNextWordLen > 0) - // { - // if (iLineLength + iNextWordLen + 1 > nColumn) { - // pszConvW[cchConvW++] = wszEOL[0]; - // if (cchEOL > 1) - // pszConvW[cchConvW++] = wszEOL[1]; - // iLineLength = 0; - // bModified = TRUE; - // } - // } - //} - - if (ISWHITE(w)) - { - int iNextWordLen = 0; - WCHAR w2; - - while (pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') { - iTextW++; - bModified = TRUE; - } // Modified: left out some whitespaces - - w2 = pszTextW[iTextW + 1]; - - while (w2 != L'\0' && !ISWORDEND(w2)) { - iNextWordLen++; - w2 = pszTextW[iTextW + iNextWordLen + 1]; - } - - //if (ISDELIMITER(w2) /*&& iNextWordLen > 0*/) // delimiters go with the word - // iNextWordLen++; - - if (iNextWordLen > 0) - { - if (iLineLength + iNextWordLen + 1 > nColumn) { - pszConvW[cchConvW++] = wszEOL[0]; - if (cchEOL > 1) - pszConvW[cchConvW++] = wszEOL[1]; - iLineLength = 0; - bModified = TRUE; - } - else { - if (iLineLength > 0) { - pszConvW[cchConvW++] = L' '; - iLineLength++; - } - } - } - } - else - { - pszConvW[cchConvW++] = w; - if (w == L'\r' || w == L'\n') { - iLineLength = 0; - } - else { - iLineLength++; - } - } - } - - GlobalFree(pszTextW); - - if (bModified) { - pszText = GlobalAlloc(GPTR,cchConvW * 3); - - cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); - GlobalFree(pszConvW); - - if (iAnchorPos > iCurPos) { - iCurPos = iSelStart; - iAnchorPos = iSelStart + cchConvM; - } - else { - iAnchorPos = iSelStart; - iCurPos = iSelStart + cchConvM; - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); - //SendMessage(hwnd,SCI_CLEAR,0,0); - //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - GlobalFree(pszText); - } - - else - GlobalFree(pszConvW); -} - - -//============================================================================= -// -// EditJoinLinesEx() -// -void EditJoinLinesEx(HWND hwnd) -{ - char* pszText; - char* pszJoin; - int cchJoin = 0; - int i; - int iLine; - int iCurPos; - int iAnchorPos; - int iSelStart; - int iSelEnd; - int iSelCount; - struct Sci_TextRange tr; - int cEOLMode; - char szEOL[] = "\r\n"; - int cchEOL = 2; - BOOL bModified = FALSE; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - MsgBox(MBWARN,IDS_SELRECT); - return; - } - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos) - return; - - else { - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - } - - iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - - iSelCount = iSelEnd - iSelStart; - - pszText = LocalAlloc(LPTR,(iSelCount)+2); - if (pszText == NULL) - return; - - pszJoin = LocalAlloc(LPTR,LocalSize(pszText)); - if (pszJoin == NULL) { - LocalFree(pszText); - return; - } - - tr.chrg.cpMin = iSelStart; - tr.chrg.cpMax = iSelEnd; - tr.lpstrText = pszText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - cEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - if (cEOLMode == SC_EOL_CR) - cchEOL = 1; - else if (cEOLMode == SC_EOL_LF) { - cchEOL = 1; - szEOL[0] = '\n'; - } - - cchJoin = 0; - for (i = 0; i < iSelCount; i++) - { - if (pszText[i] == '\r' || pszText[i] == '\n') { - if (pszText[i] == '\r' && pszText[i+1] == '\n') - i++; - if (!StrChrA("\r\n",pszText[i+1]) && pszText[i+1] != 0) { - pszJoin[cchJoin++] = ' '; - bModified = TRUE; - } - else { - while (StrChrA("\r\n",pszText[i+1])) { - i++; - bModified = TRUE; - } - if (pszText[i+1] != 0) { - pszJoin[cchJoin++] = szEOL[0]; - if (cchEOL > 1) - pszJoin[cchJoin++] = szEOL[1]; - if (cchJoin > cchEOL) { - pszJoin[cchJoin++] = szEOL[0]; - if (cchEOL > 1) - pszJoin[cchJoin++] = szEOL[1]; - } - } - } - } - else { - pszJoin[cchJoin++] = pszText[i]; - } - } - - LocalFree(pszText); - - if (bModified) { - if (iAnchorPos > iCurPos) { - iCurPos = iSelStart; - iAnchorPos = iSelStart + cchJoin; - } - else { - iAnchorPos = iSelStart; - iCurPos = iSelStart + cchJoin; - } - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchJoin,(LPARAM)pszJoin); - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - - LocalFree(pszJoin); -} - - -//============================================================================= -// -// EditSortLines() -// -typedef struct _SORTLINE { - WCHAR *pwszLine; - WCHAR *pwszSortEntry; -} SORTLINE; - -static FARPROC pfnStrCmpLogicalW; -typedef int (__stdcall *FNSTRCMP)(LPCWSTR,LPCWSTR); - -int CmpStd(const void *s1, const void *s2) { - int cmp = StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - return (cmp) ? cmp : StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); -} - -int CmpStdRev(const void *s1, const void *s2) { - int cmp = -1 * StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - return (cmp) ? cmp : -1 * StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); -} - -int CmpLogical(const void *s1, const void *s2) { - int cmp = (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - if (cmp == 0) - cmp = (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); - if (cmp) - return cmp; - else { - cmp = StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - return (cmp) ? cmp : StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); - } -} - -int CmpLogicalRev(const void *s1, const void *s2) { - int cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - if (cmp == 0) - cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); - if (cmp) - return cmp; - else { - cmp = -1 * StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); - return (cmp) ? cmp : -1 * StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); - } -} - -void EditSortLines(HWND hwnd,int iSortFlags) -{ - int iCurPos; - int iAnchorPos; - int iSelStart; - int iSelEnd; - int iLineStart; - int iLineEnd; - int iLineCount; - - BOOL bIsRectangular = FALSE; - int iRcCurLine; - int iRcAnchorLine; - int iRcCurCol; - int iRcAnchorCol; - - int i, iLine; - int cchTotal = 0; - int ichlMax = 3; - - SORTLINE *pLines; - char *pmszResult; - char *pmszBuf; - - UINT uCodePage; - DWORD cEOLMode; - char mszEOL[] = "\r\n"; - - UINT iTabWidth; - UINT iSortColumn; - - BOOL bLastDup = FALSE; - FNSTRCMP pfnStrCmp; - - pfnStrCmpLogicalW = GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW"); - pfnStrCmp = (iSortFlags & SORT_NOCASE) ? StrCmpIW : StrCmpW; - - iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos) - return; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - - iRcCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - iRcAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); - - iRcCurCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0); - iRcAnchorCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0); - - bIsRectangular = TRUE; - - iLineStart = min(iRcCurLine,iRcAnchorLine); - iLineEnd = max(iRcCurLine,iRcAnchorLine); - - iSortColumn = min(iRcCurCol,iRcAnchorCol); - } - - else { - - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - - iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); - iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - - if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) - iLineEnd--; - - iSortColumn = (UINT)SendMessage(hwnd,SCI_GETCOLUMN, - (WPARAM)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0),0); - } - - iLineCount = iLineEnd - iLineStart +1; - if (iLineCount < 2) - return; - - uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; - - cEOLMode = (DWORD)SendMessage(hwnd,SCI_GETEOLMODE,0,0); - if (cEOLMode == SC_EOL_CR) { - mszEOL[1] = 0; - } - else if (cEOLMode == SC_EOL_LF) { - mszEOL[0] = '\n'; - mszEOL[1] = 0; - } - - iTabWidth = (UINT)SendMessage(hwnd,SCI_GETTABWIDTH,0,0); - - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - if (bIsRectangular) - EditPadWithSpaces(hwnd,!(iSortFlags & SORT_SHUFFLE),TRUE); - - pLines = LocalAlloc(LPTR,sizeof(SORTLINE) * iLineCount); - i = 0; - for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { - - char *pmsz; - int cchw; - int cchm = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,0); - - pmsz = LocalAlloc(LPTR,cchm+1); - SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,(LPARAM)pmsz); - StrTrimA(pmsz,"\r\n"); - cchTotal += cchm; - ichlMax = max(ichlMax,cchm); - - cchw = MultiByteToWideChar(uCodePage,0,pmsz,-1,NULL,0) -1; - if (cchw > 0) { - UINT col = 0, tabs = iTabWidth; - pLines[i].pwszLine = LocalAlloc(LPTR,sizeof(WCHAR) * (cchw +1)); - MultiByteToWideChar(uCodePage,0,pmsz,-1,pLines[i].pwszLine,(int)LocalSize(pLines[i].pwszLine)/sizeof(WCHAR)); - pLines[i].pwszSortEntry = pLines[i].pwszLine; - if (iSortFlags & SORT_COLUMN) { - while (*(pLines[i].pwszSortEntry)) { - if (*(pLines[i].pwszSortEntry) == L'\t') { - if (col + tabs <= iSortColumn) { - col += tabs; - tabs = iTabWidth; - pLines[i].pwszSortEntry = CharNext(pLines[i].pwszSortEntry); - } - else - break; - } - else if (col < iSortColumn) { - col++; - if (--tabs == 0) - tabs = iTabWidth; - pLines[i].pwszSortEntry = CharNext(pLines[i].pwszSortEntry); - } - else - break; - } - } - } - else { - pLines[i].pwszLine = StrDup(L""); - pLines[i].pwszSortEntry = pLines[i].pwszLine; - } - LocalFree(pmsz); - i++; - } - - if (iSortFlags & SORT_DESCENDING) { - if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW) - qsort(pLines,iLineCount,sizeof(SORTLINE),CmpLogicalRev); - else - qsort(pLines,iLineCount,sizeof(SORTLINE),CmpStdRev); - } - else if (iSortFlags & SORT_SHUFFLE) { - srand((UINT)GetTickCount()); - for (i = iLineCount-1; i > 0; i--) { - int j = rand() % i; - SORTLINE sLine; - sLine.pwszLine = pLines[i].pwszLine; - sLine.pwszSortEntry = pLines[i].pwszSortEntry; - pLines[i] = pLines[j]; - pLines[j].pwszLine = sLine.pwszLine; - pLines[j].pwszSortEntry = sLine.pwszSortEntry; - } - } - else { - if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW) - qsort(pLines,iLineCount,sizeof(SORTLINE),CmpLogical); - else - qsort(pLines,iLineCount,sizeof(SORTLINE),CmpStd); - } - - pmszResult = LocalAlloc(LPTR,cchTotal + 2*iLineCount +1); - pmszBuf = LocalAlloc(LPTR,ichlMax +1); - - for (i = 0; i < iLineCount; i++) { - BOOL bDropLine = FALSE; - if (pLines[i].pwszLine && ((iSortFlags & SORT_SHUFFLE) || lstrlen(pLines[i].pwszLine))) { - if (!(iSortFlags & SORT_SHUFFLE)) { - if (iSortFlags & SORT_MERGEDUP || iSortFlags & SORT_UNIQDUP || iSortFlags & SORT_UNIQUNIQ) { - if (i < iLineCount-1) { - if (pfnStrCmp(pLines[i].pwszLine,pLines[i+1].pwszLine) == 0) { - bLastDup = TRUE; - bDropLine = (iSortFlags & SORT_MERGEDUP || iSortFlags & SORT_UNIQDUP); - } - else { - bDropLine = (!bLastDup && (iSortFlags & SORT_UNIQUNIQ)) || (bLastDup && (iSortFlags & SORT_UNIQDUP)); - bLastDup = FALSE; - } - } - else { - bDropLine = (!bLastDup && (iSortFlags & SORT_UNIQUNIQ)) || (bLastDup && (iSortFlags & SORT_UNIQDUP)); - bLastDup = FALSE; - } - } - } - if (!bDropLine) { - WideCharToMultiByte(uCodePage,0,pLines[i].pwszLine,-1,pmszBuf,(int)LocalSize(pmszBuf),NULL,NULL); - StrCatBuffA(pmszResult,pmszBuf,(int)LocalSize(pmszResult)); - StrCatBuffA(pmszResult,mszEOL,(int)LocalSize(pmszResult)); - } - } - } - - LocalFree(pmszBuf); - - for (i = 0; i < iLineCount; i++) { - if (pLines[i].pwszLine) - LocalFree(pLines[i].pwszLine); - } - LocalFree(pLines); - - if (!bIsRectangular) { - if (iAnchorPos > iCurPos) { - iCurPos = iSelStart; - iAnchorPos = iSelStart + lstrlenA(pmszResult); - } - else { - iAnchorPos = iSelStart; - iCurPos = iSelStart + lstrlenA(pmszResult); - } - } - - SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0),0); - SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(pmszResult),(LPARAM)pmszResult); - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - LocalFree(pmszResult); - - if (!bIsRectangular) - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); - - else { - int iTargetStart = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); - int iTargetEnd = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - SendMessage(hwnd,SCI_CLEARSELECTIONS,0,0); - if (iTargetStart != iTargetEnd) { - iTargetEnd -= lstrlenA(mszEOL); - if (iRcAnchorLine > iRcCurLine) { - iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetStart,0),(LPARAM)iRcCurCol); - iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetEnd,0),(LPARAM)iRcAnchorCol); - } - else { - iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetEnd,0),(LPARAM)iRcCurCol); - iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetStart,0),(LPARAM)iRcAnchorCol); - } - if (iCurPos != iAnchorPos) { - SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONCARET,(WPARAM)iCurPos,0); - SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONANCHOR,(WPARAM)iAnchorPos,0); - } - else - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iTargetStart,(LPARAM)iTargetStart); - } - else - SendMessage(hwnd,SCI_SETSEL,(WPARAM)iTargetStart,(LPARAM)iTargetStart); - } -} - - -//============================================================================= -// -// EditJumpTo() -// -void EditJumpTo(HWND hwnd,int iNewLine,int iNewCol) -{ - int iMaxLine = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0); - - // Jumpt to end with line set to -1 - if (iNewLine == -1) { - SendMessage(hwnd,SCI_DOCUMENTEND,0,0); - return; - } - - // Line maximum is iMaxLine - iNewLine = min(iNewLine,iMaxLine); - - // Column minimum is 1 - iNewCol = max(iNewCol,1); - - if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0) - { - int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0); - int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0); - - while (iNewCol-1 > SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iNewPos,0)) - { - if (iNewPos >= iLineEndPos) - break; - - iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iNewPos,0); - } - - iNewPos = min(iNewPos,iLineEndPos); - EditSelectEx(hwnd,-1,iNewPos); // SCI_GOTOPOS(pos) is equivalent to SCI_SETSEL(-1, pos) - SendMessage(hwnd,SCI_CHOOSECARETX,0,0); - } -} - - -//============================================================================= -// -// EditSelectEx() -// -void EditSelectEx(HWND hwnd,int iAnchorPos,int iCurrentPos) -{ - int iNewLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0); - int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); - - // Ensure that the first and last lines of a selection are always unfolded - // This needs to be done *before* the SCI_SETSEL message - SciCall_EnsureVisible(iAnchorLine); - if (iAnchorLine != iNewLine) - SciCall_EnsureVisible(iNewLine); - - SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,50); - SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,5); - SendMessage(hwnd,SCI_SETSEL,iAnchorPos,iCurrentPos); - SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50); - SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0); -} - - -//============================================================================= -// -// EditFixPositions() -// -void EditFixPositions(HWND hwnd) -{ - int iMaxPos = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurrentPos > 0 && iCurrentPos < iMaxPos) { - int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM) - (int)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iCurrentPos,0),0); - if (iNewPos != iCurrentPos) { - SendMessage(hwnd,SCI_SETCURRENTPOS,(WPARAM)iNewPos,0); - iCurrentPos = iNewPos; - } - } - - if (iAnchorPos != iCurrentPos && iAnchorPos > 0 && iAnchorPos < iMaxPos) { - int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM) - (int)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iAnchorPos,0),0); - if (iNewPos != iAnchorPos) - SendMessage(hwnd,SCI_SETANCHOR,(WPARAM)iNewPos,0); - } -} - - -//============================================================================= -// -// EditEnsureSelectionVisible() -// -void EditEnsureSelectionVisible(HWND hwnd) -{ - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - SendMessage(hwnd,SCI_ENSUREVISIBLE, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0),0); - if (iAnchorPos != iCurrentPos) { - SendMessage(hwnd,SCI_ENSUREVISIBLE, - (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0),0); - } - EditSelectEx(hwnd,iAnchorPos,iCurrentPos); -} - - -//============================================================================= -// -// EditGetExcerpt() -// -void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) -{ - WCHAR tch[256] = L""; - WCHAR *p; - DWORD cch = 0; - UINT cpEdit; - struct Sci_TextRange tr; - char* pszText; - LPWSTR pszTextW; - - int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - if (iCurPos == iAnchorPos || SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - lstrcpy(lpszExcerpt,L""); - return; - } - - /*if (iCurPos != iAnchorPos && SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {*/ - - tr.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - tr.chrg.cpMax = min((int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch))); - /*} - else { - - int iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - tr.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch))); - }*/ - - tr.chrg.cpMax = min((int)SendMessage(hwnd,SCI_GETLENGTH,0,0),tr.chrg.cpMax); - - pszText = LocalAlloc(LPTR,(tr.chrg.cpMax - tr.chrg.cpMin)+2); - pszTextW = LocalAlloc(LPTR,((tr.chrg.cpMax - tr.chrg.cpMin)*2)+2); - - if (pszText && pszTextW) { - - tr.lpstrText = pszText; - SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - MultiByteToWideChar(cpEdit,0,pszText,tr.chrg.cpMax - tr.chrg.cpMin,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); - - for (p = pszTextW; *p && cch < COUNTOF(tch)-1; p++) { - if (*p == L'\r' || *p == L'\n' || *p == L'\t' || *p == L' ') { - tch[cch++] = L' '; - while (*(p+1) == L'\r' || *(p+1) == L'\n' || *(p+1) == L'\t' || *(p+1) == L' ') - p++; - } - else - tch[cch++] = *p; - } - tch[cch++] = L'\0'; - StrTrim(tch,L" "); - } - - if (cch == 1) - lstrcpy(tch,L" ... "); - - if (cch > cchExcerpt) { - tch[cchExcerpt-2] = L'.'; - tch[cchExcerpt-3] = L'.'; - tch[cchExcerpt-4] = L'.'; - } - StrCpyN(lpszExcerpt,tch,cchExcerpt); - - if (pszText) - LocalFree(pszText); - if (pszTextW) - LocalFree(pszTextW); -} - - -//============================================================================= -// -// EditFindReplaceDlgProcW() -// -INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - LPEDITFINDREPLACE lpefr; - int i; - WCHAR tch[512+32]; - BOOL bCloseDlg; - BOOL bIsFindDlg; - - static UINT uCPEdit; - - switch(umsg) - { - - case WM_INITDIALOG: - { - int cchSelection; - char *lpszSelection; - char *lpsz; - -#ifdef BOOKMARK_EDITION - static BOOL bFirstTime = TRUE; -#endif - - WCHAR tch[128]; - HMENU hmenu; - - SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - lpefr = (LPEDITFINDREPLACE)lParam; - - // Get the current code page for Unicode conversion - uCPEdit = (UINT)SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0); - - // Load MRUs - for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) { - MRU_Enum(mruFind,i,tch,COUNTOF(tch)); - SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch); - } - for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) { - MRU_Enum(mruReplace,i,tch,COUNTOF(tch)); - SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch); - } - - if (!bSwitchedFindReplace) { - cchSelection = (int)SendMessage(lpefr->hwnd,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(lpefr->hwnd,SCI_GETSELECTIONSTART,0,0); - - if (cchSelection <= 500) - { - cchSelection = (int)SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,0); - lpszSelection = GlobalAlloc(GPTR,cchSelection+2); - SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,(LPARAM)lpszSelection); - -#ifdef BOOKMARK_EDITION - // First time you bring up find/replace dialog, copy content from clipboard to find box (but only if nothing is selected in the editor) - if (lstrcmpA( lpszSelection , "" ) == 0 && bFirstTime ) - { - char *pClip = EditGetClipboardText(hwndEdit); - if( lstrlenA( pClip ) > 0 && lstrlenA( pClip ) <= 500 ) - { - GlobalFree(lpszSelection); - lpszSelection = GlobalAlloc(GPTR,lstrlenA( pClip )+2); - lstrcpynA( lpszSelection , pClip , 500 ); - } - LocalFree(pClip); - } - bFirstTime = FALSE; -#endif - - // Check lpszSelection and truncate bad chars - lpsz = StrChrA(lpszSelection,13); - if (lpsz) *lpsz = '\0'; - - lpsz = StrChrA(lpszSelection,10); - if (lpsz) *lpsz = '\0'; - - lpsz = StrChrA(lpszSelection,9); - if (lpsz) *lpsz = '\0'; - - SetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpszSelection); - GlobalFree(lpszSelection); - } - } - - SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_LIMITTEXT,500,0); - SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_SETEXTENDEDUI,TRUE,0); - - if (!GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT))) - SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); - - if (GetDlgItem(hwnd,IDC_REPLACETEXT)) - { - SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_LIMITTEXT,500,0); - SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_SETEXTENDEDUI,TRUE,0); - SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8); - } - - if (lpefr->fuFlags & SCFIND_MATCHCASE) - CheckDlgButton(hwnd,IDC_FINDCASE,BST_CHECKED); - - if (lpefr->fuFlags & SCFIND_WHOLEWORD) - CheckDlgButton(hwnd,IDC_FINDWORD,BST_CHECKED); - - if (lpefr->fuFlags & SCFIND_WORDSTART) - CheckDlgButton(hwnd,IDC_FINDSTART,BST_CHECKED); - - if (lpefr->fuFlags & SCFIND_REGEXP) - CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_CHECKED); - - if (lpefr->bTransformBS) - CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_CHECKED); - -#ifdef BOOKMARK_EDITION - if (lpefr->bWildcardSearch) - { - CheckDlgButton(hwnd,IDC_WILDCARDSEARCH,BST_CHECKED); - CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); - } -#endif - - if (lpefr->bNoFindWrap) - CheckDlgButton(hwnd,IDC_NOWRAP,BST_CHECKED); - - if (GetDlgItem(hwnd,IDC_REPLACE)) { - if (bSwitchedFindReplace) { - if (lpefr->bFindClose) - CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); - } - else { - if (lpefr->bReplaceClose) - CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); - } - } - else { - if (bSwitchedFindReplace) { - if (lpefr->bReplaceClose) - CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); - } - else { - if (lpefr->bFindClose) - CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); - } - } - - if (!bSwitchedFindReplace) { - if (xFindReplaceDlg == 0 || yFindReplaceDlg == 0) - CenterDlgInParent(hwnd); - else - SetDlgPos(hwnd,xFindReplaceDlg,yFindReplaceDlg); - } - - else { - SetDlgPos(hwnd,xFindReplaceDlgSave,yFindReplaceDlgSave); - bSwitchedFindReplace = FALSE; - CopyMemory(lpefr,&efrSave,sizeof(EDITFINDREPLACE)); - } - - hmenu = GetSystemMenu(hwnd,FALSE); - GetString(SC_SAVEPOS,tch,COUNTOF(tch)); - InsertMenu(hmenu,0,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_SAVEPOS,tch); - GetString(SC_RESETPOS,tch,COUNTOF(tch)); - InsertMenu(hmenu,1,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_RESETPOS,tch); - InsertMenu(hmenu,2,MF_BYPOSITION|MF_SEPARATOR,0,NULL); - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_FINDTEXT: - case IDC_REPLACETEXT: - { - BOOL bEnable = (GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT)) || - CB_ERR != SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_GETCURSEL,0,0)); - - EnableWindow(GetDlgItem(hwnd,IDOK),bEnable); - EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),bEnable); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),bEnable); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),bEnable); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),bEnable); - - if (HIWORD(wParam) == CBN_CLOSEUP) { - LONG lSelEnd; - SendDlgItemMessage(hwnd,LOWORD(wParam),CB_GETEDITSEL,0,(LPARAM)&lSelEnd); - SendDlgItemMessage(hwnd,LOWORD(wParam),CB_SETEDITSEL,0,MAKELPARAM(lSelEnd,lSelEnd)); - } - } - break; - - case IDC_FINDREGEXP: - if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED) - { - CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_UNCHECKED); -#ifdef BOOKMARK_EDITION - CheckDlgButton(hwnd,IDC_WILDCARDSEARCH,BST_UNCHECKED); // Can not use wildcard search together with regexp -#endif - } - break; - - case IDC_FINDTRANSFORMBS: - if (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED) - CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); - break; - -#ifdef BOOKMARK_EDITION - // handle wildcard search checkbox - case IDC_WILDCARDSEARCH: - CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); - //if (IsDlgButtonChecked(hwnd,IDC_FINDWILDCARDS) == BST_CHECKED) - // CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); - break; -#endif - - case IDOK: - case IDC_FINDPREV: - case IDC_REPLACE: - case IDC_REPLACEALL: - case IDC_REPLACEINSEL: - case IDACC_SELTONEXT: - case IDACC_SELTOPREV: - case IDMSG_SWITCHTOFIND: - case IDMSG_SWITCHTOREPLACE: - - lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd,DWLP_USER); - - bIsFindDlg = (GetDlgItem(hwnd,IDC_REPLACE) == NULL); - - if ((bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOREPLACE || - !bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOFIND)) { - GetDlgPos(hwnd,&xFindReplaceDlgSave,&yFindReplaceDlgSave); - bSwitchedFindReplace = TRUE; - CopyMemory(&efrSave,lpefr,sizeof(EDITFINDREPLACE)); - } - - // Get current code page for Unicode conversion - uCPEdit = (UINT)SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0); - cpLastFind = uCPEdit; - - if (!bSwitchedFindReplace && - !GetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpefr->szFind,COUNTOF(lpefr->szFind))) { - - EnableWindow(GetDlgItem(hwnd,IDOK),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),FALSE); - return TRUE; - } - - if (GetDlgItem(hwnd,IDC_REPLACETEXT)) - GetDlgItemTextA2W(uCPEdit,hwnd,IDC_REPLACETEXT,lpefr->szReplace,COUNTOF(lpefr->szReplace)); - -#ifdef BOOKMARK_EDITION - lpefr->bWildcardSearch = (IsDlgButtonChecked(hwnd,IDC_WILDCARDSEARCH) == BST_CHECKED) ? TRUE : FALSE; -#endif - - lpefr->fuFlags = 0; - - if (IsDlgButtonChecked(hwnd,IDC_FINDCASE) == BST_CHECKED) - lpefr->fuFlags |= SCFIND_MATCHCASE; - - if (IsDlgButtonChecked(hwnd,IDC_FINDWORD) == BST_CHECKED) - lpefr->fuFlags |= SCFIND_WHOLEWORD; - - if (IsDlgButtonChecked(hwnd,IDC_FINDSTART) == BST_CHECKED) - lpefr->fuFlags |= SCFIND_WORDSTART; - - if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED) - lpefr->fuFlags |= SCFIND_REGEXP | SCFIND_POSIX; - - lpefr->bTransformBS = - (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED) ? TRUE : FALSE; - - lpefr->bNoFindWrap = (IsDlgButtonChecked(hwnd,IDC_NOWRAP) == BST_CHECKED) ? TRUE : FALSE; - - if (bIsFindDlg) { - lpefr->bFindClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE; - } - else { - lpefr->bReplaceClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE; - } - - if (!bSwitchedFindReplace) { - // Save MRUs - if (lstrlenA(lpefr->szFind)) { - if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8))) { - GetDlgItemText(hwnd,IDC_FINDTEXT,tch,COUNTOF(tch)); - MRU_Add(mruFind,tch); - } - } - if (lstrlenA(lpefr->szReplace)) { - if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8))) { - GetDlgItemText(hwnd,IDC_REPLACETEXT,tch,COUNTOF(tch)); - MRU_Add(mruReplace,tch); - } - } - else - lstrcpyA(lpefr->szReplaceUTF8,""); - } - else { - GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8)); - if (!GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8))) - lstrcpyA(lpefr->szReplaceUTF8,""); - } - - if (bIsFindDlg) { - bCloseDlg = lpefr->bFindClose; - } - else { - if (LOWORD(wParam) == IDOK) - bCloseDlg = FALSE; - else - bCloseDlg = lpefr->bReplaceClose; - } - - // Reload MRUs - SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_RESETCONTENT,0,0); - SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_RESETCONTENT,0,0); - - for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) { - MRU_Enum(mruFind,i,tch,COUNTOF(tch)); - SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch); - } - for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) { - MRU_Enum(mruReplace,i,tch,COUNTOF(tch)); - SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch); - } - - SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); - SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8); - - if (!bSwitchedFindReplace) - SendMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetFocus()),1); - - if (bCloseDlg) { - //EndDialog(hwnd,LOWORD(wParam)); - DestroyWindow(hwnd); - hDlgFindReplace = NULL; - } - - switch (LOWORD(wParam)) - { - case IDOK: // find next - case IDACC_SELTONEXT: - if (!bIsFindDlg) - bReplaceInitialized = TRUE; - EditFindNext(lpefr->hwnd,lpefr,LOWORD(wParam)==IDACC_SELTONEXT||HIBYTE(GetKeyState(VK_SHIFT))); - break; - - case IDC_FINDPREV: // find previous - case IDACC_SELTOPREV: - if (!bIsFindDlg) - bReplaceInitialized = TRUE; - EditFindPrev(lpefr->hwnd,lpefr,LOWORD(wParam)==IDACC_SELTOPREV||HIBYTE(GetKeyState(VK_SHIFT))); - break; - - case IDC_REPLACE: - bReplaceInitialized = TRUE; - EditReplace(lpefr->hwnd,lpefr); - break; - - case IDC_REPLACEALL: - bReplaceInitialized = TRUE; - EditReplaceAll(lpefr->hwnd,lpefr,TRUE); - break; - - case IDC_REPLACEINSEL: - bReplaceInitialized = TRUE; - EditReplaceAllInSelection(lpefr->hwnd,lpefr,TRUE); - break; - } - -#ifdef BOOKMARK_EDITION - // Wildcard search will enable regexp, so I turn it off again otherwise it will be on in the gui - if( lpefr->bWildcardSearch && (lpefr->fuFlags & SCFIND_REGEXP) ) lpefr->fuFlags ^= SCFIND_REGEXP; -#endif - - break; - - - case IDCANCEL: - //EndDialog(hwnd,IDCANCEL); - DestroyWindow(hwnd); - break; - - case IDACC_FIND: - PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); - break; - - case IDACC_REPLACE: - PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); - break; - - case IDACC_SAVEPOS: - GetDlgPos(hwnd,&xFindReplaceDlg,&yFindReplaceDlg); - break; - - case IDACC_RESETPOS: - CenterDlgInParent(hwnd); - xFindReplaceDlg = yFindReplaceDlg = 0; - break; - - case IDACC_FINDNEXT: - PostMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - - case IDACC_FINDPREV: - PostMessage(hwnd,WM_COMMAND,MAKELONG(IDC_FINDPREV,1),0); - break; - - case IDACC_REPLACENEXT: - if (GetDlgItem(hwnd,IDC_REPLACE) != NULL) - PostMessage(hwnd,WM_COMMAND,MAKELONG(IDC_REPLACE,1),0); - break; - - case IDACC_SAVEFIND: - SendMessage(hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_SAVEFIND,1),0); - lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd,DWLP_USER); - SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); - CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); - CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_UNCHECKED); - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_FINDTEXT)),1); - break; - - } - - return TRUE; - - - case WM_SYSCOMMAND: - if (wParam == SC_SAVEPOS){ - PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_SAVEPOS,0),0); - return TRUE; - } - else if (wParam == SC_RESETPOS){ - PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_RESETPOS,0),0); - return TRUE; - } - else - return FALSE; - - - case WM_NOTIFY: - { - LPNMHDR pnmhdr = (LPNMHDR)lParam; - switch (pnmhdr->code) { - - case NM_CLICK: - case NM_RETURN: - if (pnmhdr->idFrom == IDC_TOGGLEFINDREPLACE) { - if (GetDlgItem(hwnd,IDC_REPLACE)) - PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); - else - PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); - } -#ifdef BOOKMARK_EDITION - // Display help messages in the find/replace windows - else if (pnmhdr->idFrom == IDC_BACKSLASHHELP) - { - MsgBox(MBINFO,IDS_BACKSLASHHELP); - } - else if (pnmhdr->idFrom == IDC_REGEXPHELP) - { - MsgBox(MBINFO,IDS_REGEXPHELP); - } - else if (pnmhdr->idFrom == IDC_WILDCARDHELP) - { - MsgBox(MBINFO,IDS_WILDCARDHELP); - } -#endif - break; - } - } - break; - - } - - return FALSE; - -} - - -//============================================================================= -// -// EditFindReplaceDlg() -// -HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bReplace) -{ - - HWND hDlg; - - lpefr->hwnd = hwnd; - - hDlg = CreateThemedDialogParam(g_hInstance, - (bReplace) ? MAKEINTRESOURCEW(IDD_REPLACE) : MAKEINTRESOURCEW(IDD_FIND), - GetParent(hwnd), - EditFindReplaceDlgProcW, - (LPARAM) lpefr); - - ShowWindow(hDlg,SW_SHOW); - - return hDlg; - -} - - -#ifdef BOOKMARK_EDITION - // Wildcard search uses the regexp engine to perform a simple search with * ? as wildcards instead of more advanced and user-unfriendly regexp syntax - void EscapeWildcards( char* szFind2 , LPCEDITFINDREPLACE lpefr ) - { - char szWildcardEscaped[512]; - int iSource = 0; - int iDest = 0; - - lpefr->fuFlags |= SCFIND_REGEXP; - - while( szFind2[iSource] ) - { - char c = szFind2[iSource]; - if( c == '*' ) - { - szWildcardEscaped[iDest++] = '.'; szWildcardEscaped[iDest] = '*'; - } - else if( c == '?' ) - { - szWildcardEscaped[iDest] = '.'; - } - else - { - if( c == '.' || c == '^' || c == '$' || c == '\\' || c == '[' || c == ']' || c == '+' ) szWildcardEscaped[iDest++] = '\\'; - szWildcardEscaped[iDest] = c; - } - iSource++; - iDest++; - } - szWildcardEscaped[iDest] = (char)NULL; - lstrcpynA(szFind2,szWildcardEscaped,COUNTOF(szWildcardEscaped)); - } -#endif - - -//============================================================================= -// -// EditFindNext() -// -BOOL EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) -{ - - struct Sci_TextToFind ttf; - int iPos; - int iSelPos, iSelAnchor; - char szFind2[512]; - BOOL bSuppressNotFound = FALSE; - - if (!lstrlenA(lpefr->szFind)) - return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE; - - lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); - if (lpefr->bTransformBS) - TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - - if (lstrlenA(szFind2) == 0) - { - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - -#ifdef BOOKMARK_EDITION - if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); -#endif - - iSelPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iSelAnchor = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - ttf.lpstrText = szFind2; - - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - - if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap && !fExtendSelection) { - if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { - ttf.chrg.cpMin = 0; - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - } - else - bSuppressNotFound = TRUE; - } - - if (iPos == -1) - { - // notfound - if (!bSuppressNotFound) - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - - if (!fExtendSelection) - EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); - else - EditSelectEx(hwnd,min(iSelAnchor,iSelPos),ttf.chrgText.cpMax); - - return TRUE; - -} - - -//============================================================================= -// -// EditFindPrev() -// -BOOL EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) -{ - - struct Sci_TextToFind ttf; - int iPos; - int iSelPos, iSelAnchor; - int iLength; - char szFind2[512]; - BOOL bSuppressNotFound = FALSE; - - if (!lstrlenA(lpefr->szFind)) - return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE; - - lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); - if (lpefr->bTransformBS) - TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - - if (lstrlenA(szFind2) == 0) - { - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - -#ifdef BOOKMARK_EDITION - if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); -#endif - - iSelPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - iSelAnchor = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = max(0,(int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)); - ttf.chrg.cpMax = 0; - ttf.lpstrText = szFind2; - - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - - iLength = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - if (iPos == -1 && ttf.chrg.cpMin < iLength && !lpefr->bNoFindWrap && !fExtendSelection) { - if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap2",IDS_FIND_WRAPRE)) { - ttf.chrg.cpMin = iLength; - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - } - else - bSuppressNotFound = TRUE; - } - - if (iPos == -1) - { - // notfound - if (!bSuppressNotFound) - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - - if (!fExtendSelection) - EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); - else - EditSelectEx(hwnd,max(iSelPos,iSelAnchor),ttf.chrgText.cpMin); - - return TRUE; - -} - - -//============================================================================= -// -// EditReplace() -// -BOOL EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr) -{ - - struct Sci_TextToFind ttf; - int iPos; - int iSelStart; - int iSelEnd; - int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; - char szFind2[512]; - char *pszReplace2; - BOOL bSuppressNotFound = FALSE; - - if (!lstrlenA(lpefr->szFind)) - return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; - - lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); - if (lpefr->bTransformBS) - TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - - if (lstrlenA(szFind2) == 0) - { - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - -#ifdef BOOKMARK_EDITION - if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); -#endif - - if (lstrcmpA(lpefr->szReplace,"^c") == 0) { - iReplaceMsg = SCI_REPLACETARGET; - pszReplace2 = EditGetClipboardText(hwnd); - } - else { - //lstrcpyA(szReplace2,lpefr->szReplace); - pszReplace2 = StrDupA(lpefr->szReplace); - if (lpefr->bTransformBS) - TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - } - - if (!pszReplace2) - pszReplace2 = StrDupA(""); - - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); // Start! - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - ttf.lpstrText = szFind2; - - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - - if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) { - if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { - ttf.chrg.cpMin = 0; - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - } - else - bSuppressNotFound = TRUE; - } - - if (iPos == -1) - { - // notfound - LocalFree(pszReplace2); - if (!bSuppressNotFound) - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - - if (iSelStart != ttf.chrgText.cpMin || iSelEnd != ttf.chrgText.cpMax) { - LocalFree(pszReplace2); - EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); - return FALSE; - } - - SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); - SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); - SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); - - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - - bSuppressNotFound = FALSE; - if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) { - if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { - ttf.chrg.cpMin = 0; - iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); - } - else - bSuppressNotFound = TRUE; - } - - if (iPos != -1) - EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); - - else { - EditSelectEx(hwnd, - (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0), - (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0)); - if (!bSuppressNotFound) - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - } - - LocalFree(pszReplace2); - return TRUE; - -} - -//============================================================================= -// -// CompleteWord() -// Auto-complete words (by Aleksandar Lekov) -// -struct WLIST { - char* word; - struct WLIST* next; -}; - -void CompleteWord(HWND hwnd, BOOL autoInsert) { - const char* NON_WORD = " \t\r\n@#$%^&*~-=+()[]{}\\/.,:;'\"!?<>`|"; - int iCurrentPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); - int iLine = (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iCurrentPos, 0); - int iCurrentLinePos = iCurrentPos - (int)SendMessage(hwnd, SCI_POSITIONFROMLINE, (WPARAM)iLine, 0); - int iStartWordPos = iCurrentLinePos; - char *pLine; - char *pRoot; - char *pWord; - int iNumWords = 0; - int iRootLen = 0; - int iDocLen; - int iPosFind; - struct Sci_TextRange tr = { { 0, -1 }, NULL }; - struct Sci_TextToFind ft = {{0, 0}, 0, {0, 0}}; - BOOL bWordAllNumbers = TRUE; - struct WLIST* lListHead = NULL; - int iWListSize = 0; - - pLine = LocalAlloc(LPTR, (int)SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, 0) + 1); - SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, (LPARAM)pLine); - - while (iStartWordPos > 0 && !StrChrIA(NON_WORD, pLine[iStartWordPos - 1])) { - iStartWordPos--; - if (pLine[iStartWordPos] < '0' || pLine[iStartWordPos] > '9') { - bWordAllNumbers = FALSE; - } - } - - if (iStartWordPos == iCurrentLinePos || bWordAllNumbers || iCurrentLinePos - iStartWordPos < 2) { - LocalFree(pLine); - return; - } - - pRoot = LocalAlloc(LPTR, iCurrentLinePos - iStartWordPos + 2); - lstrcpynA(pRoot, pLine + iStartWordPos, iCurrentLinePos - iStartWordPos + 1); - LocalFree(pLine); - iRootLen = lstrlenA(pRoot); - - iDocLen = (int)SendMessage(hwnd, SCI_GETLENGTH, 0, 0); - - ft.lpstrText = pRoot; - ft.chrg.cpMax = iDocLen; - - iPosFind = (int)SendMessage(hwnd, SCI_FINDTEXT, SCFIND_WORDSTART, (LPARAM)&ft); - - while (iPosFind >= 0 && iPosFind < iDocLen) { - int wordLength; - int wordEnd = iPosFind + iRootLen; - - if (iPosFind != iCurrentPos - iRootLen) { - while (wordEnd < iDocLen && !StrChrIA(NON_WORD, (char)SendMessage(hwnd, SCI_GETCHARAT, (WPARAM)wordEnd, 0))) - wordEnd++; - - wordLength = wordEnd - iPosFind; - if (wordLength > iRootLen) { - struct WLIST* p = lListHead; - struct WLIST* t = NULL; - int lastCmp = 0; - BOOL found = FALSE; - - pWord = LocalAlloc(LPTR, wordEnd - iPosFind + 2); - - tr.lpstrText = pWord; - tr.chrg.cpMin = iPosFind; - tr.chrg.cpMax = wordEnd; - SendMessage(hwnd, SCI_GETTEXTRANGE, 0, (LPARAM)&tr); - - while(p) { - int cmp = lstrcmpA(pWord, p->word); - if (!cmp) { - found = TRUE; - break; - } else if (cmp < 0) { - break; - } - t = p; - p = p->next; - } - if (!found) { - struct WLIST* el = (struct WLIST*)LocalAlloc(LPTR, sizeof(struct WLIST)); - el->word = LocalAlloc(LPTR, wordEnd - iPosFind + 2); - lstrcpyA(el->word, pWord); - el->next = p; - if (t) { - t->next = el; - } else { - lListHead = el; - } - - iNumWords++; - iWListSize += lstrlenA(pWord) + 1; - } - LocalFree(pWord); - } - } - ft.chrg.cpMin = wordEnd; - iPosFind = (int)SendMessage(hwnd, SCI_FINDTEXT, SCFIND_WORDSTART, (LPARAM)&ft); - } - - if (iNumWords > 0) { - char *pList; - struct WLIST* p = lListHead; - struct WLIST* t; - - pList = LocalAlloc(LPTR, iWListSize + 1); - while (p) { - lstrcatA(pList, " "); - lstrcatA(pList, p->word); - LocalFree(p->word); - t = p; - p = p->next; - LocalFree(t); - } - - SendMessage(hwnd, SCI_AUTOCSETIGNORECASE, 1, 0); - SendMessage(hwnd, SCI_AUTOCSETSEPARATOR, ' ', 0); - SendMessage(hwnd, SCI_AUTOCSETFILLUPS, 0, (LPARAM)"\t\n\r"); - SendMessage(hwnd, SCI_AUTOCSETCHOOSESINGLE, autoInsert, 0); - SendMessage(hwnd, SCI_AUTOCSHOW, iRootLen, (LPARAM)(pList + 1)); - LocalFree(pList); - } - - LocalFree(pRoot); -} - -//============================================================================= -// -// EditMarkAll() -// Mark all occurrences of the text currently selected (by Aleksandar Lekov) -// -void EditMarkAll(HWND hwnd, int iMarkOccurrences, BOOL bMarkOccurrencesMatchCase, BOOL bMarkOccurrencesMatchWords) -{ - struct Sci_TextToFind ttf; - int iPos; - char *pszText; - int iTextLen; - int iSelStart; - int iSelEnd; - int iSelCount; - int iMatchesCount; - - // feature is off - if (!iMarkOccurrences) - return; - - - iTextLen = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - // get current selection - iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - iSelCount = iSelEnd - iSelStart; - - // clear existing indicator - SendMessage(hwnd, SCI_SETINDICATORCURRENT, 1, 0); - SendMessage(hwnd, SCI_INDICATORCLEARRANGE, 0, iTextLen); - - // if nothing selected or multiple lines are selected exit - if (iSelCount == 0 || - (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iSelStart, 0) != - (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iSelEnd, 0)) - return; - - - // scintilla/src/Editor.h SelectionText.LengthWithTerminator() - iSelCount = (int)SendMessage(hwnd,SCI_GETSELTEXT,0,0) - 1; - pszText = LocalAlloc(LPTR,iSelCount + 1); - (int)SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); - - - // exit if selection is not a word and Match whole words only is enabled - if (bMarkOccurrencesMatchWords) - { - iSelStart = 0; - while (pszText[iSelStart]) - { - if (StrChrIA(" \t\r\n@#$%^&*~-=+()[]{}\\/:;'\"", pszText[iSelStart])) - { - LocalFree(pszText); - return; - } - iSelStart++; - } - } - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = 0; - ttf.chrg.cpMax = iTextLen; - ttf.lpstrText = pszText; - - // set style - SendMessage(hwnd, SCI_INDICSETALPHA, 1, 100); - SendMessage(hwnd, SCI_INDICSETFORE, 1, 0xff << ((iMarkOccurrences - 1) << 3)); - SendMessage(hwnd, SCI_INDICSETSTYLE, 1, INDIC_ROUNDBOX); - - iMatchesCount = 0; - while ((iPos = (int)SendMessage(hwnd, SCI_FINDTEXT, - (bMarkOccurrencesMatchCase ? SCFIND_MATCHCASE : 0) | (bMarkOccurrencesMatchWords ? SCFIND_WHOLEWORD : 0), - (LPARAM)&ttf)) != -1 - && ++iMatchesCount < 2000) - { - // mark this match - SendMessage(hwnd, SCI_INDICATORFILLRANGE, iPos, iSelCount); - ttf.chrg.cpMin = ttf.chrgText.cpMin + iSelCount; - if (ttf.chrg.cpMin == ttf.chrg.cpMax) - break; - } - - LocalFree(pszText); - return; -} - - -//============================================================================= -// -// EditReplaceAll() -// -BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) -{ - - struct Sci_TextToFind ttf; - int iPos; - int iCount = 0; - int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; - char szFind2[512]; - char *pszReplace2; - BOOL bRegexStartOfLine; - BOOL bRegexStartOrEndOfLine; - - if (!lstrlenA(lpefr->szFind)) - return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; - - // Show wait cursor... - BeginWaitCursor(); - - lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); - if (lpefr->bTransformBS) - TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - - if (lstrlenA(szFind2) == 0) - { - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - -#ifdef BOOKMARK_EDITION - if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); -#endif - - bRegexStartOfLine = - (szFind2[0] == '^'); - bRegexStartOrEndOfLine = - (lpefr->fuFlags & SCFIND_REGEXP && - (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$"))); - - if (lstrcmpA(lpefr->szReplace,"^c") == 0) { - iReplaceMsg = SCI_REPLACETARGET; - pszReplace2 = EditGetClipboardText(hwnd); - } - else { - //lstrcpyA(szReplace2,lpefr->szReplace); - pszReplace2 = StrDupA(lpefr->szReplace); - if (lpefr->bTransformBS) - TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - } - - if (!pszReplace2) - pszReplace2 = StrDupA(""); - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = 0; - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - ttf.lpstrText = szFind2; - - while ((iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1) - { - int iReplacedLen; - //char ch; - - if (iCount == 0 && bRegexStartOrEndOfLine) { - if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) { - iPos = 0; - ttf.chrgText.cpMin = 0; - ttf.chrgText.cpMax = 0; - } - } - - if (++iCount == 1) - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); - SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); - iReplacedLen = (int)SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); - - ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen; - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - if (ttf.chrg.cpMin == ttf.chrg.cpMax) - break; - - //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0); - - if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */ - ttf.chrgText.cpMin == ttf.chrgText.cpMax && - !(bRegexStartOrEndOfLine && iReplacedLen > 0)) - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0); - if (bRegexStartOfLine) { - int iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0); - int ilPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - if (ilPos == ttf.chrg.cpMin) - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0); - if (ttf.chrg.cpMin == ttf.chrg.cpMax) - break; - } - } - - if (iCount) - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - - // Remove wait cursor - EndWaitCursor(); - - if (bShowInfo) { - if (iCount > 0) - InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount); - else - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - } - - LocalFree(pszReplace2); - return TRUE; - -} - - -//============================================================================= -// -// EditReplaceAllInSelection() -// -BOOL EditReplaceAllInSelection(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) -{ - - struct Sci_TextToFind ttf; - int iPos; - int iCount = 0; - int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; - BOOL fCancel = FALSE; - char szFind2[512]; - char *pszReplace2; - BOOL bRegexStartOfLine; - BOOL bRegexStartOrEndOfLine; - - if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) - { - MsgBox(MBWARN,IDS_SELRECT); - return FALSE; - } - - if (!lstrlenA(lpefr->szFind)) - return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; - - // Show wait cursor... - BeginWaitCursor(); - - lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); - if (lpefr->bTransformBS) - TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - - if (lstrlenA(szFind2) == 0) - { - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - return FALSE; - } - -#ifdef BOOKMARK_EDITION - if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); -#endif - - bRegexStartOfLine = - (szFind2[0] == '^'); - bRegexStartOrEndOfLine = - (lpefr->fuFlags & SCFIND_REGEXP && - (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$"))); - - if (lstrcmpA(lpefr->szReplace,"^c") == 0) { - iReplaceMsg = SCI_REPLACETARGET; - pszReplace2 = EditGetClipboardText(hwnd); - } - else { - //lstrcpyA(szReplace2,lpefr->szReplace); - pszReplace2 = StrDupA(lpefr->szReplace); - if (lpefr->bTransformBS) - TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), - (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); - } - - if (!pszReplace2) - pszReplace2 = StrDupA(""); - - ZeroMemory(&ttf,sizeof(ttf)); - - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - ttf.lpstrText = szFind2; - - while ((iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1 && !fCancel) - { - if (ttf.chrgText.cpMin >= SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) && - ttf.chrgText.cpMax <= SendMessage(hwnd,SCI_GETSELECTIONEND,0,0)) - { - int iReplacedLen; - //char ch; - - if (ttf.chrg.cpMin == 0 && iCount == 0 && bRegexStartOrEndOfLine) { - if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) { - iPos = 0; - ttf.chrgText.cpMin = 0; - ttf.chrgText.cpMax = 0; - } - } - - if (++iCount == 1) - SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); - - SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); - SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); - iReplacedLen = (int)SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); - - ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen; - ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - - if (ttf.chrg.cpMin == ttf.chrg.cpMax) - fCancel = TRUE; - - //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0); - - if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */ - ttf.chrgText.cpMin == ttf.chrgText.cpMax && - !(bRegexStartOrEndOfLine && iReplacedLen > 0)) - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0); - if (bRegexStartOfLine) { - int iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0); - int ilPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - if (ilPos == ttf.chrg.cpMin) - ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0); - if (ttf.chrg.cpMin == ttf.chrg.cpMax) - break; - } - } - - else - // gone across selection, cancel - fCancel = TRUE; - } - - if (iCount) { - - if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) < - SendMessage(hwnd,SCI_GETTARGETEND,0,0)) { - - int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); - int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); - - if (iAnchorPos > iCurrentPos) - iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - else - iCurrentPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); - - EditSelectEx(hwnd,iAnchorPos,iCurrentPos); - } - - SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); - } - - // Remove wait cursor - EndWaitCursor(); - - if (bShowInfo) { - if (iCount > 0) - InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount); - else - InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); - } - - LocalFree(pszReplace2); - return TRUE; - -} - - -//============================================================================= -// -// EditLinenumDlgProc() -// -INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - switch(umsg) - { - - case WM_INITDIALOG: - { - - int iCurLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, - SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0),0)+1; - - SetDlgItemInt(hwnd,IDC_LINENUM,iCurLine,FALSE); - SendDlgItemMessage(hwnd,IDC_LINENUM,EM_LIMITTEXT,15,0); - - SendDlgItemMessage(hwnd,IDC_COLNUM,EM_LIMITTEXT,15,0); - - CenterDlgInParent(hwnd); - - } - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDOK: { - - BOOL fTranslated; - BOOL fTranslated2; - - int iNewCol; - - int iNewLine = (int)GetDlgItemInt(hwnd,IDC_LINENUM,&fTranslated,FALSE); - int iMaxLine = (int)SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0); - - if (SendDlgItemMessage(hwnd,IDC_COLNUM,WM_GETTEXTLENGTH,0,0) > 0) - iNewCol = GetDlgItemInt(hwnd,IDC_COLNUM,&fTranslated2,FALSE); - else { - iNewCol = 1; - fTranslated2 = TRUE; - } - - if (!fTranslated || !fTranslated2) - { - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!fTranslated) ? IDC_LINENUM : IDC_COLNUM)),1); - return TRUE; - } - - if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0) - { - //int iNewPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0); - //int iLineEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0); - - //while (iNewCol-1 > SendMessage(hwndEdit,SCI_GETCOLUMN,(WPARAM)iNewPos,0)) - //{ - // if (iNewPos >= iLineEndPos) - // break; - - // iNewPos = SendMessage(hwndEdit,SCI_POSITIONAFTER,(WPARAM)iNewPos,0); - //} - - //iNewPos = min(iNewPos,iLineEndPos); - //SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0); - //SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); - - EditJumpTo(hwndEdit,iNewLine,iNewCol); - - EndDialog(hwnd,IDOK); - } - - else - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!(iNewLine > 0 && iNewLine <= iMaxLine)) ? IDC_LINENUM : IDC_COLNUM)),1); - - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// EditLinenumDlg() -// -BOOL EditLinenumDlg(HWND hwnd) -{ - - if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_LINENUM), - GetParent(hwnd),EditLinenumDlgProc,(LPARAM)hwnd)) - return TRUE; - - else - return FALSE; - -} - - -//============================================================================= -// -// EditModifyLinesDlg() -// -// Controls: 100 Input -// 101 Input -// -typedef struct _modlinesdata { - LPWSTR pwsz1; - LPWSTR pwsz2; -} MODLINESDATA, *PMODLINESDATA; - - -INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static PMODLINESDATA pdata; - - static int id_hover; - static int id_capture; - - static HFONT hFontNormal; - static HFONT hFontHover; - - static HCURSOR hCursorNormal; - static HCURSOR hCursorHover; - - switch(umsg) - { - case WM_INITDIALOG: - { - LOGFONT lf; - - id_hover = 0; - id_capture = 0; - - if (NULL == (hFontNormal = (HFONT)SendDlgItemMessage(hwnd,200,WM_GETFONT,0,0))) - hFontNormal = GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFontNormal,sizeof(LOGFONT),&lf); - lf.lfUnderline = TRUE; - hFontHover = CreateFontIndirect(&lf); - - hCursorNormal = LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW)); - if (!(hCursorHover = LoadCursor(NULL,MAKEINTRESOURCE(IDC_HAND)))) - hCursorHover = LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_ARROW)); - - pdata = (PMODLINESDATA)lParam; - SetDlgItemTextW(hwnd,100,pdata->pwsz1); - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0); - SetDlgItemTextW(hwnd,101,pdata->pwsz2); - SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); - CenterDlgInParent(hwnd); - } - return TRUE; - - case WM_DESTROY: - DeleteObject(hFontHover); - return FALSE; - - case WM_NCACTIVATE: - if (!(BOOL)wParam) { - if (id_hover != 0) { - //int _id_hover = id_hover; - id_hover = 0; - id_capture = 0; - //InvalidateRect(GetDlgItem(hwnd,id_hover),NULL,FALSE); - } - } - return FALSE; - - case WM_CTLCOLORSTATIC: - { - DWORD dwId = GetWindowLong((HWND)lParam,GWL_ID); - HDC hdc = (HDC)wParam; - - if (dwId >= 200 && dwId <= 205) { - SetBkMode(hdc,TRANSPARENT); - if (GetSysColorBrush(COLOR_HOTLIGHT)) - SetTextColor(hdc,GetSysColor(COLOR_HOTLIGHT)); - else - SetTextColor(hdc,RGB(0,0,255)); - SelectObject(hdc,/*dwId == id_hover?*/hFontHover/*:hFontNormal*/); - return(LONG_PTR)GetSysColorBrush(COLOR_BTNFACE); - } - } - break; - - case WM_MOUSEMOVE: - { - POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - HWND hwndHover = ChildWindowFromPoint(hwnd,pt); - DWORD dwId = GetWindowLong(hwndHover,GWL_ID); - - if (GetActiveWindow() == hwnd) { - if (dwId >= 200 && dwId <= 205) { - if (id_capture == dwId || id_capture == 0) { - if (id_hover != id_capture || id_hover == 0) { - id_hover = dwId; - //InvalidateRect(GetDlgItem(hwnd,dwId),NULL,FALSE); - } - } - else if (id_hover != 0) { - //int _id_hover = id_hover; - id_hover = 0; - //InvalidateRect(GetDlgItem(hwnd,_id_hover),NULL,FALSE); - } - } - else if (id_hover != 0) { - //int _id_hover = id_hover; - id_hover = 0; - //InvalidateRect(GetDlgItem(hwnd,_id_hover),NULL,FALSE); - } - SetCursor(id_hover != 0?hCursorHover:hCursorNormal); - } - } - break; - - case WM_LBUTTONDOWN: - { - POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - HWND hwndHover = ChildWindowFromPoint(hwnd,pt); - DWORD dwId = GetWindowLong(hwndHover,GWL_ID); - - if (dwId >= 200 && dwId <= 205) { - GetCapture(); - id_hover = dwId; - id_capture = dwId; - //InvalidateRect(GetDlgItem(hwnd,dwId),NULL,FALSE); - } - SetCursor(id_hover != 0?hCursorHover:hCursorNormal); - } - break; - - case WM_LBUTTONUP: - { - POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - HWND hwndHover = ChildWindowFromPoint(hwnd,pt); - DWORD dwId = GetWindowLong(hwndHover,GWL_ID); - if (id_capture != 0) { - ReleaseCapture(); - if (id_hover == id_capture) { - int id_focus = GetWindowLong(GetFocus(),GWL_ID); - if (id_focus == 100 || id_focus == 101) { - WCHAR wch[8]; - GetDlgItemText(hwnd,id_capture,wch,COUNTOF(wch)); - SendDlgItemMessage(hwnd,id_focus,EM_SETSEL,(WPARAM)0,(LPARAM)-1); - SendDlgItemMessage(hwnd,id_focus,EM_REPLACESEL,(WPARAM)TRUE,(LPARAM)wch); - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetFocus()),1); - } - } - id_capture = 0; - } - SetCursor(id_hover != 0?hCursorHover:hCursorNormal); - } - break; - - case WM_CANCELMODE: - if (id_capture != 0) { - ReleaseCapture(); - id_hover = 0; - id_capture = 0; - SetCursor(hCursorNormal); - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); - GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); - EndDialog(hwnd,IDOK); - } - break; - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// EditModifyLinesDlg() -// -BOOL EditModifyLinesDlg(HWND hwnd,LPWSTR pwsz1,LPWSTR pwsz2) -{ - - INT_PTR iResult; - MODLINESDATA data = { pwsz1, pwsz2 }; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_MODIFYLINES), - hwnd, - EditModifyLinesDlgProc, - (LPARAM)&data); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// EditAlignDlgProc() -// -// Controls: 100 Radio Button -// 101 Radio Button -// 102 Radio Button -// 103 Radio Button -// 104 Radio Button -// -INT_PTR CALLBACK EditAlignDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static int *piAlignMode; - switch(umsg) - { - case WM_INITDIALOG: - { - piAlignMode = (int*)lParam; - CheckRadioButton(hwnd,100,104,*piAlignMode+100); - CenterDlgInParent(hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - *piAlignMode = 0; - if (IsDlgButtonChecked(hwnd,100) == BST_CHECKED) - *piAlignMode = ALIGN_LEFT; - else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) - *piAlignMode = ALIGN_RIGHT; - else if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED) - *piAlignMode = ALIGN_CENTER; - else if (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) - *piAlignMode = ALIGN_JUSTIFY; - else if (IsDlgButtonChecked(hwnd,104) == BST_CHECKED) - *piAlignMode = ALIGN_JUSTIFY_EX; - EndDialog(hwnd,IDOK); - } - break; - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// EditAlignDlg() -// -BOOL EditAlignDlg(HWND hwnd,int *piAlignMode) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_ALIGN), - hwnd, - EditAlignDlgProc, - (LPARAM)piAlignMode); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// EditEncloseSelectionDlgProc() -// -// Controls: 100 Input -// 101 Input -// -typedef struct _encloseselectiondata { - LPWSTR pwsz1; - LPWSTR pwsz2; -} ENCLOSESELDATA, *PENCLOSESELDATA; - - -INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static PENCLOSESELDATA pdata; - switch(umsg) - { - case WM_INITDIALOG: - { - pdata = (PENCLOSESELDATA)lParam; - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0); - SetDlgItemTextW(hwnd,100,pdata->pwsz1); - SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); - SetDlgItemTextW(hwnd,101,pdata->pwsz2); - CenterDlgInParent(hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); - GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); - EndDialog(hwnd,IDOK); - } - break; - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// EditEncloseSelectionDlg() -// -BOOL EditEncloseSelectionDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) -{ - - INT_PTR iResult; - ENCLOSESELDATA data = { pwszOpen, pwszClose }; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_ENCLOSESELECTION), - hwnd, - EditEncloseSelectionDlgProc, - (LPARAM)&data); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// EditInsertTagDlgProc() -// -// Controls: 100 Input -// 101 Input -// -typedef struct _tagsdata { - LPWSTR pwsz1; - LPWSTR pwsz2; -} TAGSDATA, *PTAGSDATA; - - -INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static PTAGSDATA pdata; - switch(umsg) - { - case WM_INITDIALOG: - { - pdata = (PTAGSDATA)lParam; - SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,254,0); - SetDlgItemTextW(hwnd,100,L""); - SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); - SetDlgItemTextW(hwnd,101,L""); - SetFocus(GetDlgItem(hwnd,100)); - PostMessage(GetDlgItem(hwnd,100),EM_SETSEL,1,4); - CenterDlgInParent(hwnd); - } - return FALSE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case 100: { - if (HIWORD(wParam) == EN_CHANGE) { - - WCHAR wchBuf[256]; - WCHAR wchIns[256] = L"= 3) { - - if (wchBuf[0] == L'<') { - - const WCHAR* pwCur = &wchBuf[1]; - - while ( - *pwCur && - *pwCur != L'<' && - *pwCur != L'>' && - *pwCur != L' ' && - *pwCur != L'\t' && - (StrChr(L":_-.",*pwCur) || IsCharAlphaNumericW(*pwCur))) - - wchIns[cchIns++] = *pwCur++; - - while ( - *pwCur && - *pwCur != L'>') - - pwCur++; - - if (*pwCur == L'>' && *(pwCur-1) != L'/') { - wchIns[cchIns++] = L'>'; - wchIns[cchIns] = L'\0'; - - if (cchIns > 3 && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"
") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"") && - lstrcmpi(wchIns,L"")) { - - SetDlgItemTextW(hwnd,101,wchIns); - bClear = FALSE; - } - } - } - } - if (bClear) - SetDlgItemTextW(hwnd,101,L""); - } - } - break; - case IDOK: { - GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); - GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); - EndDialog(hwnd,IDOK); - } - break; - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// EditInsertTagDlg() -// -BOOL EditInsertTagDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) -{ - - INT_PTR iResult; - TAGSDATA data = { pwszOpen, pwszClose }; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_INSERTTAG), - hwnd, - EditInsertTagDlgProc, - (LPARAM)&data); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// EditSortDlgProc() -// -// Controls: 100-102 Radio Button -// 103-108 Check Box -// -INT_PTR CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static int *piSortFlags; - static BOOL bEnableLogicalSort; - - switch(umsg) - { - case WM_INITDIALOG: - { - piSortFlags = (int*)lParam; - if (*piSortFlags & SORT_DESCENDING) - CheckRadioButton(hwnd,100,102,101); - else if (*piSortFlags & SORT_SHUFFLE) { - CheckRadioButton(hwnd,100,102,102); - EnableWindow(GetDlgItem(hwnd,103),FALSE); - EnableWindow(GetDlgItem(hwnd,104),FALSE); - EnableWindow(GetDlgItem(hwnd,105),FALSE); - EnableWindow(GetDlgItem(hwnd,106),FALSE); - EnableWindow(GetDlgItem(hwnd,107),FALSE); - } - else - CheckRadioButton(hwnd,100,102,100); - if (*piSortFlags & SORT_MERGEDUP) - CheckDlgButton(hwnd,103,BST_CHECKED); - if (*piSortFlags & SORT_UNIQDUP) { - CheckDlgButton(hwnd,104,BST_CHECKED); - EnableWindow(GetDlgItem(hwnd,103),FALSE); - } - if (*piSortFlags & SORT_UNIQUNIQ) - CheckDlgButton(hwnd,105,BST_CHECKED); - if (*piSortFlags & SORT_NOCASE) - CheckDlgButton(hwnd,106,BST_CHECKED); - if (GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW")) { - if (*piSortFlags & SORT_LOGICAL) - CheckDlgButton(hwnd,107,BST_CHECKED); - bEnableLogicalSort = TRUE; - } - else { - EnableWindow(GetDlgItem(hwnd,107),FALSE); - bEnableLogicalSort = FALSE; - } - if (SC_SEL_RECTANGLE != SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0)) { - *piSortFlags &= ~SORT_COLUMN; - EnableWindow(GetDlgItem(hwnd,108),FALSE); - } - else { - *piSortFlags |= SORT_COLUMN; - CheckDlgButton(hwnd,108,BST_CHECKED); - } - CenterDlgInParent(hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - *piSortFlags = 0; - if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) - *piSortFlags |= SORT_DESCENDING; - if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED) - *piSortFlags |= SORT_SHUFFLE; - if (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) - *piSortFlags |= SORT_MERGEDUP; - if (IsDlgButtonChecked(hwnd,104) == BST_CHECKED) - *piSortFlags |= SORT_UNIQDUP; - if (IsDlgButtonChecked(hwnd,105) == BST_CHECKED) - *piSortFlags |= SORT_UNIQUNIQ; - if (IsDlgButtonChecked(hwnd,106) == BST_CHECKED) - *piSortFlags |= SORT_NOCASE; - if (IsDlgButtonChecked(hwnd,107) == BST_CHECKED) - *piSortFlags |= SORT_LOGICAL; - if (IsDlgButtonChecked(hwnd,108) == BST_CHECKED) - *piSortFlags |= SORT_COLUMN; - EndDialog(hwnd,IDOK); - } - break; - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - case 100: - case 101: - EnableWindow(GetDlgItem(hwnd,103),IsDlgButtonChecked(hwnd,105) != BST_CHECKED); - EnableWindow(GetDlgItem(hwnd,104),TRUE); - EnableWindow(GetDlgItem(hwnd,105),TRUE); - EnableWindow(GetDlgItem(hwnd,106),TRUE); - EnableWindow(GetDlgItem(hwnd,107),bEnableLogicalSort); - break; - case 102: - EnableWindow(GetDlgItem(hwnd,103),FALSE); - EnableWindow(GetDlgItem(hwnd,104),FALSE); - EnableWindow(GetDlgItem(hwnd,105),FALSE); - EnableWindow(GetDlgItem(hwnd,106),FALSE); - EnableWindow(GetDlgItem(hwnd,107),FALSE); - break; - case 104: - EnableWindow(GetDlgItem(hwnd,103),IsDlgButtonChecked(hwnd,104) != BST_CHECKED); - break; - } - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// EditSortDlg() -// -BOOL EditSortDlg(HWND hwnd,int *piSortFlags) -{ - - INT_PTR iResult; - - iResult = ThemedDialogBoxParam( - g_hInstance, - MAKEINTRESOURCEW(IDD_SORT), - hwnd, - EditSortDlgProc, - (LPARAM)piSortFlags); - - return (iResult == IDOK) ? TRUE : FALSE; - -} - - -//============================================================================= -// -// FileVars_Init() -// -extern BOOL bNoEncodingTags; -extern int fNoFileVariables; - -BOOL FileVars_Init(char *lpData,DWORD cbData,LPFILEVARS lpfv) { - - int i; - char tch[512]; - BOOL bDisableFileVariables = FALSE; - - ZeroMemory(lpfv,sizeof(FILEVARS)); - if ((fNoFileVariables && bNoEncodingTags) || !lpData || !cbData) - return(TRUE); - - lstrcpynA(tch,lpData,min(cbData+1,COUNTOF(tch))); - - if (!fNoFileVariables) { - if (FileVars_ParseInt(tch,"enable-local-variables",&i) && (!i)) - bDisableFileVariables = TRUE; - - if (!bDisableFileVariables) { - - if (FileVars_ParseInt(tch,"tab-width",&i)) { - lpfv->iTabWidth = max(min(i,256),1); - lpfv->mask |= FV_TABWIDTH; - } - - if (FileVars_ParseInt(tch,"c-basic-indent",&i)) { - lpfv->iIndentWidth = max(min(i,256),0); - lpfv->mask |= FV_INDENTWIDTH; - } - - if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) { - lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE; - lpfv->mask |= FV_TABSASSPACES; - } - - if (FileVars_ParseInt(tch,"c-tab-always-indent",&i)) { - lpfv->bTabIndents = (i) ? TRUE : FALSE; - lpfv->mask |= FV_TABINDENTS; - } - - if (FileVars_ParseInt(tch,"truncate-lines",&i)) { - lpfv->fWordWrap = (i) ? FALSE : TRUE; - lpfv->mask |= FV_WORDWRAP; - } - - if (FileVars_ParseInt(tch,"fill-column",&i)) { - lpfv->iLongLinesLimit = max(min(i,4096),0); - lpfv->mask |= FV_LONGLINESLIMIT; - } - } - } - - if (!IsUTF8Signature(lpData) && !bNoEncodingTags && !bDisableFileVariables) { - - if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - } - - if (!fNoFileVariables && !bDisableFileVariables) { - if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode))) - lpfv->mask |= FV_MODE; - } - - if (lpfv->mask == 0 && cbData > COUNTOF(tch)) { - - lstrcpynA(tch,lpData+cbData-COUNTOF(tch)+1,COUNTOF(tch)); - - if (!fNoFileVariables) { - if (FileVars_ParseInt(tch,"enable-local-variables",&i) && (!i)) - bDisableFileVariables = TRUE; - - if (!bDisableFileVariables) { - - if (FileVars_ParseInt(tch,"tab-width",&i)) { - lpfv->iTabWidth = max(min(i,256),1); - lpfv->mask |= FV_TABWIDTH; - } - - if (FileVars_ParseInt(tch,"c-basic-indent",&i)) { - lpfv->iIndentWidth = max(min(i,256),0); - lpfv->mask |= FV_INDENTWIDTH; - } - - if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) { - lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE; - lpfv->mask |= FV_TABSASSPACES; - } - - if (FileVars_ParseInt(tch,"c-tab-always-indent",&i)) { - lpfv->bTabIndents = (i) ? TRUE : FALSE; - lpfv->mask |= FV_TABINDENTS; - } - - if (FileVars_ParseInt(tch,"truncate-lines",&i)) { - lpfv->fWordWrap = (i) ? FALSE : TRUE; - lpfv->mask |= FV_WORDWRAP; - } - - if (FileVars_ParseInt(tch,"fill-column",&i)) { - lpfv->iLongLinesLimit = max(min(i,4096),0); - lpfv->mask |= FV_LONGLINESLIMIT; - } - } - } - - if (!IsUTF8Signature(lpData) && !bNoEncodingTags && !bDisableFileVariables) { - - if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) - lpfv->mask |= FV_ENCODING; - } - - if (!fNoFileVariables && !bDisableFileVariables) { - if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode))) - lpfv->mask |= FV_MODE; - } - } - - if (lpfv->mask & FV_ENCODING) - lpfv->iEncoding = Encoding_MatchA(lpfv->tchEncoding); - - return(TRUE); -} - - -//============================================================================= -// -// FileVars_Apply() -// -extern int iTabWidth; -extern int iTabWidthG; -extern int iIndentWidth; -extern int iIndentWidthG; -extern BOOL bTabsAsSpaces; -extern BOOL bTabsAsSpacesG; -extern BOOL bTabIndents; -extern BOOL bTabIndentsG; -extern int fWordWrap; -extern int fWordWrapG; -extern int iWordWrapMode; -extern int iLongLinesLimit; -extern int iLongLinesLimitG; -extern int iWrapCol; - -BOOL FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) { - - if (lpfv->mask & FV_TABWIDTH) - iTabWidth = lpfv->iTabWidth; - else - iTabWidth = iTabWidthG; - SendMessage(hwnd,SCI_SETTABWIDTH,iTabWidth,0); - - if (lpfv->mask & FV_INDENTWIDTH) - iIndentWidth = lpfv->iIndentWidth; - else if (lpfv->mask & FV_TABWIDTH) - iIndentWidth = 0; - else - iIndentWidth = iIndentWidthG; - SendMessage(hwnd,SCI_SETINDENT,iIndentWidth,0); - - if (lpfv->mask & FV_TABSASSPACES) - bTabsAsSpaces = lpfv->bTabsAsSpaces; - else - bTabsAsSpaces = bTabsAsSpacesG; - SendMessage(hwnd,SCI_SETUSETABS,!bTabsAsSpaces,0); - - if (lpfv->mask & FV_TABINDENTS) - bTabIndents = lpfv->bTabIndents; - else - bTabIndents = bTabIndentsG; - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - - if (lpfv->mask & FV_WORDWRAP) - fWordWrap = lpfv->fWordWrap; - else - fWordWrap = fWordWrapG; - if (!fWordWrap) - SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); - else - SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); - - if (lpfv->mask & FV_LONGLINESLIMIT) - iLongLinesLimit = lpfv->iLongLinesLimit; - else - iLongLinesLimit = iLongLinesLimitG; - SendMessage(hwnd,SCI_SETEDGECOLUMN,iLongLinesLimit,0); - - iWrapCol = 0; - - return(TRUE); -} - - -//============================================================================= -// -// FileVars_ParseInt() -// -BOOL FileVars_ParseInt(char* pszData,char* pszName,int* piValue) { - - char tch[32]; - char *pvStart = pszData; - char chPrev; - char *pvEnd; - int itok; - - while (pvStart = StrStrIA(pvStart,pszName)) { - chPrev = (pvStart > pszData) ? *(pvStart-1) : 0; - if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') { - pvStart += lstrlenA(pszName); - while (*pvStart == ' ') - pvStart++; - if (*pvStart == ':' || *pvStart == '=') - break; - } - else - pvStart += lstrlenA(pszName); - } - - if (pvStart) { - - while (*pvStart && StrChrIA(":=\"' \t",*pvStart)) - pvStart++; - - lstrcpynA(tch,pvStart,COUNTOF(tch)); - - pvEnd = tch; - while (*pvEnd && IsCharAlphaNumericA(*pvEnd)) - pvEnd++; - *pvEnd = 0; - StrTrimA(tch," \t:=\"'"); - - itok = sscanf(tch,"%i",piValue); - if (itok == 1) - return(TRUE); - - if (tch[0] == 't') { - *piValue = 1; - return(TRUE); - } - - if (tch[0] == 'n' || tch[0] == 'f') { - *piValue = 0; - return(TRUE); - } - } - return(FALSE); -} - - -//============================================================================= -// -// FileVars_ParseStr() -// -BOOL FileVars_ParseStr(char* pszData,char* pszName,char* pszValue,int cchValue) { - - char tch[32]; - char *pvStart = pszData; - char chPrev; - char *pvEnd; - BOOL bQuoted = FALSE; - - while (pvStart = StrStrIA(pvStart,pszName)) { - chPrev = (pvStart > pszData) ? *(pvStart-1) : 0; - if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') { - pvStart += lstrlenA(pszName); - while (*pvStart == ' ') - pvStart++; - if (*pvStart == ':' || *pvStart == '=') - break; - } - else - pvStart += lstrlenA(pszName); - } - - if (pvStart) { - - while (*pvStart && StrChrIA(":=\"' \t",*pvStart)) { - if (*pvStart == '\'' || *pvStart == '"') - bQuoted = TRUE; - pvStart++; - } - lstrcpynA(tch,pvStart,COUNTOF(tch)); - - pvEnd = tch; - while (*pvEnd && (IsCharAlphaNumericA(*pvEnd) || StrChrIA("+-/_",*pvEnd) || (bQuoted && *pvEnd == ' '))) - pvEnd++; - *pvEnd = 0; - StrTrimA(tch," \t:=\"'"); - - lstrcpynA(pszValue,tch,cchValue); - return(TRUE); - } - return(FALSE); -} - - -//============================================================================= -// -// FileVars_IsUTF8() -// -BOOL FileVars_IsUTF8(LPFILEVARS lpfv) { - if (lpfv->mask & FV_ENCODING) { - if (lstrcmpiA(lpfv->tchEncoding,"utf-8") == 0 || - lstrcmpiA(lpfv->tchEncoding,"utf8") == 0) - return(TRUE); - } - return(FALSE); -} - - -//============================================================================= -// -// FileVars_IsNonUTF8() -// -BOOL FileVars_IsNonUTF8(LPFILEVARS lpfv) { - if (lpfv->mask & FV_ENCODING) { - if (lstrlenA(lpfv->tchEncoding) && - lstrcmpiA(lpfv->tchEncoding,"utf-8") != 0 && - lstrcmpiA(lpfv->tchEncoding,"utf8") != 0) - return(TRUE); - } - return(FALSE); -} - - -//============================================================================= -// -// FileVars_IsValidEncoding() -// -BOOL FileVars_IsValidEncoding(LPFILEVARS lpfv) { - CPINFO cpi; - if (lpfv->mask & FV_ENCODING && - lpfv->iEncoding >= 0 && - lpfv->iEncoding < COUNTOF(mEncoding)) { - if ((mEncoding[lpfv->iEncoding].uFlags & NCP_INTERNAL) || - IsValidCodePage(mEncoding[lpfv->iEncoding].uCodePage) && - GetCPInfo(mEncoding[lpfv->iEncoding].uCodePage,&cpi)) { - return(TRUE); - } - } - return(FALSE); -} - - -//============================================================================= -// -// FileVars_GetEncoding() -// -int FileVars_GetEncoding(LPFILEVARS lpfv) { - if (lpfv->mask & FV_ENCODING) - return(lpfv->iEncoding); - else - return(-1); -} - - -//============================================================================= -// -// SciInitThemes() -// -//WNDPROC pfnSciWndProc = NULL; -// -//FARPROC pfnOpenThemeData = NULL; -//FARPROC pfnCloseThemeData = NULL; -//FARPROC pfnDrawThemeBackground = NULL; -//FARPROC pfnGetThemeBackgroundContentRect = NULL; -//FARPROC pfnIsThemeActive = NULL; -//FARPROC pfnDrawThemeParentBackground = NULL; -//FARPROC pfnIsThemeBackgroundPartiallyTransparent = NULL; -// -//BOOL bThemesPresent = FALSE; -//extern BOOL bIsAppThemed; -//extern HMODULE hModUxTheme; -// -//void SciInitThemes(HWND hwnd) -//{ -// if (hModUxTheme) { -// -// pfnOpenThemeData = GetProcAddress(hModUxTheme,"OpenThemeData"); -// pfnCloseThemeData = GetProcAddress(hModUxTheme,"CloseThemeData"); -// pfnDrawThemeBackground = GetProcAddress(hModUxTheme,"DrawThemeBackground"); -// pfnGetThemeBackgroundContentRect = GetProcAddress(hModUxTheme,"GetThemeBackgroundContentRect"); -// pfnIsThemeActive = GetProcAddress(hModUxTheme,"IsThemeActive"); -// pfnDrawThemeParentBackground = GetProcAddress(hModUxTheme,"DrawThemeParentBackground"); -// pfnIsThemeBackgroundPartiallyTransparent = GetProcAddress(hModUxTheme,"IsThemeBackgroundPartiallyTransparent"); -// -// pfnSciWndProc = (WNDPROC)SetWindowLongPtrW(hwnd,GWLP_WNDPROC,(LONG_PTR)&SciThemedWndProc); -// bThemesPresent = TRUE; -// } -//} -// -// -////============================================================================= -//// -//// SciThemedWndProc() -//// -//LRESULT CALLBACK SciThemedWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -//{ -// static RECT rcContent; -// -// if (umsg == WM_NCCALCSIZE) { -// if (wParam) { -// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCCALCSIZE,wParam,lParam); -// NCCALCSIZE_PARAMS *csp = (NCCALCSIZE_PARAMS*)lParam; -// -// if (bThemesPresent && bIsAppThemed) { -// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit"); -// if(hTheme) { -// BOOL bSuccess = FALSE; -// RECT rcClient; -// -// if(pfnGetThemeBackgroundContentRect( -// hTheme,NULL,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1,&csp->rgrc[0],&rcClient) == S_OK) { -// InflateRect(&rcClient,-1,-1); -// -// rcContent.left = rcClient.left-csp->rgrc[0].left; -// rcContent.top = rcClient.top-csp->rgrc[0].top; -// rcContent.right = csp->rgrc[0].right-rcClient.right; -// rcContent.bottom = csp->rgrc[0].bottom-rcClient.bottom; -// -// CopyRect(&csp->rgrc[0],&rcClient); -// bSuccess = TRUE; -// } -// pfnCloseThemeData(hTheme); -// -// if (bSuccess) -// return WVR_REDRAW; -// } -// } -// return lresult; -// } -// } -// -// else if (umsg == WM_NCPAINT) { -// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCPAINT,wParam,lParam); -// if(bThemesPresent && bIsAppThemed) { -// -// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit"); -// if(hTheme) { -// RECT rcBorder; -// RECT rcClient; -// int nState; -// -// HDC hdc = GetWindowDC(hwnd); -// -// GetWindowRect(hwnd,&rcBorder); -// OffsetRect(&rcBorder,-rcBorder.left,-rcBorder.top); -// -// CopyRect(&rcClient,&rcBorder); -// rcClient.left += rcContent.left; -// rcClient.top += rcContent.top; -// rcClient.right -= rcContent.right; -// rcClient.bottom -= rcContent.bottom; -// -// ExcludeClipRect(hdc,rcClient.left,rcClient.top,rcClient.right,rcClient.bottom); -// -// if(pfnIsThemeBackgroundPartiallyTransparent(hTheme,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1)) -// pfnDrawThemeParentBackground(hwnd,hdc,&rcBorder); -// -// /* -// ETS_NORMAL = 1 -// ETS_HOT = 2 -// ETS_SELECTED = 3 -// ETS_DISABLED = 4 -// ETS_FOCUSED = 5 -// ETS_READONLY = 6 -// ETS_ASSIST = 7 -// */ -// -// if(!IsWindowEnabled(hwnd)) -// nState = /*ETS_DISABLED*/4; -// else if (GetFocus() == hwnd) -// nState = /*ETS_FOCUSED*/5; -// else if(SendMessage(hwnd,SCI_GETREADONLY,0,0)) -// nState = /*ETS_READONLY*/6; -// else -// nState = /*ETS_NORMAL*/1; -// -// pfnDrawThemeBackground(hTheme,hdc,/*EP_EDITTEXT*/1,nState,&rcBorder,NULL); -// pfnCloseThemeData(hTheme); -// -// ReleaseDC(hwnd,hdc); -// return 0; -// } -// } -// return lresult; -// } -// -// return CallWindowProcW(pfnSciWndProc,hwnd,umsg,wParam,lParam); -//} - - - -/// End of Edit.c \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Edit.c +* Text File Editing Helper Stuff +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include +#include +#include "scintilla.h" +#include "scilexer.h" +#include "notepad2.h" +#include "edit.h" +#include "styles.h" +#include "dialogs.h" +#include "helpers.h" +#include "resource.h" +#include "SciCall.h" + + +extern HWND hwndMain; +extern HWND hwndEdit; +extern HINSTANCE g_hInstance; +//extern LPMALLOC g_lpMalloc; +extern DWORD dwLastIOError; +extern HWND hDlgFindReplace; +extern UINT cpLastFind; +extern BOOL bReplaceInitialized; + +static EDITFINDREPLACE efrSave; +static BOOL bSwitchedFindReplace = FALSE; +static int xFindReplaceDlgSave; +static int yFindReplaceDlgSave; +extern int xFindReplaceDlg; +extern int yFindReplaceDlg; + +extern int iDefaultEncoding; +extern int iDefaultEOLMode; +extern int iLineEndings[3]; +extern BOOL bFixLineEndings; +extern BOOL bAutoStripBlanks; + + +// Default Codepage and Character Set +extern int iDefaultCodePage; +extern int iDefaultCharSet; +extern BOOL bSkipUnicodeDetection; +extern BOOL bLoadASCIIasUTF8; +extern BOOL bLoadNFOasOEM; +extern int iSrcEncoding; +extern int iWeakSrcEncoding; + +int g_DOSEncoding; + +// Supported Encodings +WCHAR wchANSI[8] = L""; +WCHAR wchOEM [8] = L""; + +NP2ENCODING mEncoding[] = { + { NCP_DEFAULT|NCP_RECODE, 0, "ansi,ansi,ascii,", 61000, L"" }, + { NCP_8BIT|NCP_RECODE, 0, "oem,oem,", 61001, L"" }, + { NCP_UNICODE|NCP_UNICODE_BOM, 0, "", 61002, L"" }, + { NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM, 0, "", 61003, L"" }, + { NCP_UNICODE|NCP_RECODE, 0, "utf-16,utf16,unicode,", 61004, L"" }, + { NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_RECODE, 0, "utf-16be,utf16be,unicodebe,", 61005, L"" }, + { NCP_UTF8|NCP_RECODE, 0, "utf-8,utf8,", 61006, L"" }, + { NCP_UTF8|NCP_UTF8_SIGN, 0, "utf-8,utf8,", 61007, L"" }, + { NCP_8BIT|NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" }, + { NCP_8BIT|NCP_RECODE, 720, "DOS-720,dos720,", 61009, L"" }, + { NCP_8BIT|NCP_RECODE, 28596, "iso-8859-6,iso88596,arabic,csisolatinarabic,ecma114,isoir127,", 61010, L"" }, + { NCP_8BIT|NCP_RECODE, 10004, "x-mac-arabic,xmacarabic,", 61011, L"" }, + { NCP_8BIT|NCP_RECODE, 1256, "windows-1256,windows1256,cp1256", 61012, L"" }, + { NCP_8BIT|NCP_RECODE, 775, "ibm775,ibm775,cp500,", 61013, L"" }, + { NCP_8BIT|NCP_RECODE, 28594, "iso-8859-4,iso88594,csisolatin4,isoir110,l4,latin4,", 61014, L"" }, + { NCP_8BIT|NCP_RECODE, 1257, "windows-1257,windows1257,", 61015, L"" }, + { NCP_8BIT|NCP_RECODE, 852, "ibm852,ibm852,cp852,", 61016, L"" }, + { NCP_8BIT|NCP_RECODE, 28592, "iso-8859-2,iso88592,csisolatin2,isoir101,latin2,l2,", 61017, L"" }, + { NCP_8BIT|NCP_RECODE, 10029, "x-mac-ce,xmacce,", 61018, L"" }, + { NCP_8BIT|NCP_RECODE, 1250, "windows-1250,windows1250,xcp1250,", 61019, L"" }, + { NCP_8BIT|NCP_RECODE, 936, "gb2312,gb2312,chinese,cngb,csgb2312,csgb231280,gb231280,gbk,", 61020, L"" }, + { NCP_8BIT|NCP_RECODE, 10008, "x-mac-chinesesimp,xmacchinesesimp,", 61021, L"" }, + { NCP_8BIT|NCP_RECODE, 950, "big5,big5,cnbig5,csbig5,xxbig5,", 61022, L"" }, + { NCP_8BIT|NCP_RECODE, 10002, "x-mac-chinesetrad,xmacchinesetrad,", 61023, L"" }, + { NCP_8BIT|NCP_RECODE, 10082, "x-mac-croatian,xmaccroatian,", 61024, L"" }, + { NCP_8BIT|NCP_RECODE, 866, "cp866,cp866,ibm866,", 61025, L"" }, + { NCP_8BIT|NCP_RECODE, 28595, "iso-8859-5,iso88595,csisolatin5,csisolatincyrillic,cyrillic,isoir144,", 61026, L"" }, + { NCP_8BIT|NCP_RECODE, 20866, "koi8-r,koi8r,cskoi8r,koi,koi8,", 61027, L"" }, + { NCP_8BIT|NCP_RECODE, 21866, "koi8-u,koi8u,koi8ru,", 61028, L"" }, + { NCP_8BIT|NCP_RECODE, 10007, "x-mac-cyrillic,xmaccyrillic,", 61029, L"" }, + { NCP_8BIT|NCP_RECODE, 1251, "windows-1251,windows1251,xcp1251,", 61030, L"" }, + { NCP_8BIT|NCP_RECODE, 28603, "iso-8859-13,iso885913,", 61031, L"" }, + { NCP_8BIT|NCP_RECODE, 863, "ibm863,ibm863,", 61032, L"" }, + { NCP_8BIT|NCP_RECODE, 737, "ibm737,ibm737,", 61033, L"" }, + { NCP_8BIT|NCP_RECODE, 28597, "iso-8859-7,iso88597,csisolatingreek,ecma118,elot928,greek,greek8,isoir126,", 61034, L"" }, + { NCP_8BIT|NCP_RECODE, 10006, "x-mac-greek,xmacgreek,", 61035, L"" }, + { NCP_8BIT|NCP_RECODE, 1253, "windows-1253,windows1253,", 61036, L"" }, + { NCP_8BIT|NCP_RECODE, 869, "ibm869,ibm869,", 61037, L"" }, + { NCP_8BIT|NCP_RECODE, 862, "DOS-862,dos862,", 61038, L"" }, + { NCP_8BIT|NCP_RECODE, 38598, "iso-8859-8-i,iso88598i,logical,", 61039, L"" }, + { NCP_8BIT|NCP_RECODE, 28598, "iso-8859-8,iso88598,csisolatinhebrew,hebrew,isoir138,visual,", 61040, L"" }, + { NCP_8BIT|NCP_RECODE, 10005, "x-mac-hebrew,xmachebrew,", 61041, L"" }, + { NCP_8BIT|NCP_RECODE, 1255, "windows-1255,windows1255,", 61042, L"" }, + { NCP_8BIT|NCP_RECODE, 861, "ibm861,ibm861,", 61043, L"" }, + { NCP_8BIT|NCP_RECODE, 10079, "x-mac-icelandic,xmacicelandic,", 61044, L"" }, + { NCP_8BIT|NCP_RECODE, 10001, "x-mac-japanese,xmacjapanese,", 61045, L"" }, + { NCP_8BIT|NCP_RECODE, 932, "shift_jis,shiftjis,shiftjs,csshiftjis,cswindows31j,mskanji,xmscp932,xsjis,", 61046, L"" }, + { NCP_8BIT|NCP_RECODE, 10003, "x-mac-korean,xmackorean,", 61047, L"" }, + { NCP_8BIT|NCP_RECODE, 949, "windows-949,windows949,ksc56011987,csksc5601,euckr,isoir149,korean,ksc56011989", 61048, L"" }, + { NCP_8BIT|NCP_RECODE, 28593, "iso-8859-3,iso88593,latin3,isoir109,l3,", 61049, L"" }, + { NCP_8BIT|NCP_RECODE, 28605, "iso-8859-15,iso885915,latin9,l9,", 61050, L"" }, + { NCP_8BIT|NCP_RECODE, 865, "ibm865,ibm865,", 61051, L"" }, + { NCP_8BIT|NCP_RECODE, 437, "ibm437,ibm437,437,cp437,cspc8,codepage437,", 61052, L"" }, + { NCP_8BIT|NCP_RECODE, 858, "ibm858,ibm858,ibm00858,", 61053, L"" }, + { NCP_8BIT|NCP_RECODE, 860, "ibm860,ibm860,", 61054, L"" }, + { NCP_8BIT|NCP_RECODE, 10010, "x-mac-romanian,xmacromanian,", 61055, L"" }, + { NCP_8BIT|NCP_RECODE, 10021, "x-mac-thai,xmacthai,", 61056, L"" }, + { NCP_8BIT|NCP_RECODE, 874, "windows-874,windows874,dos874,iso885911,tis620,", 61057, L"" }, + { NCP_8BIT|NCP_RECODE, 857, "ibm857,ibm857,", 61058, L"" }, + { NCP_8BIT|NCP_RECODE, 28599, "iso-8859-9,iso88599,latin5,isoir148,l5,", 61059, L"" }, + { NCP_8BIT|NCP_RECODE, 10081, "x-mac-turkish,xmacturkish,", 61060, L"" }, + { NCP_8BIT|NCP_RECODE, 1254, "windows-1254,windows1254,", 61061, L"" }, + { NCP_8BIT|NCP_RECODE, 10017, "x-mac-ukrainian,xmacukrainian,", 61062, L"" }, + { NCP_8BIT|NCP_RECODE, 1258, "windows-1258,windows-258,", 61063, L"" }, + { NCP_8BIT|NCP_RECODE, 850, "ibm850,ibm850,", 61064, L"" }, + { NCP_8BIT|NCP_RECODE, 28591, "iso-8859-1,iso88591,cp819,latin1,ibm819,isoir100,latin1,l1,", 61065, L"" }, + { NCP_8BIT|NCP_RECODE, 10000, "macintosh,macintosh,", 61066, L"" }, + { NCP_8BIT|NCP_RECODE, 1252, "windows-1252,windows1252,cp367,cp819,ibm367,us,xansi,", 61067, L"" }, + { NCP_8BIT|NCP_RECODE, 37, "ebcdic-cp-us,ebcdiccpus,ebcdiccpca,ebcdiccpwt,ebcdiccpnl,ibm037,cp037,", 61068, L"" }, + { NCP_8BIT|NCP_RECODE, 500, "x-ebcdic-international,xebcdicinternational,", 61069, L"" }, +/*{ NCP_8BIT|NCP_RECODE, 870, "CP870,cp870,ebcdiccproece,ebcdiccpyu,csibm870,ibm870,", 00000, L"" }, // IBM EBCDIC (Multilingual Latin-2) */ + { NCP_8BIT|NCP_RECODE, 875, "x-EBCDIC-GreekModern,xebcdicgreekmodern,", 61070, L"" }, + { NCP_8BIT|NCP_RECODE, 1026, "CP1026,cp1026,csibm1026,ibm1026,", 61071, L"" }, +/*{ NCP_8BIT|NCP_RECODE, 1047, "IBM01047,ibm01047,", 00000, L"" }, // IBM EBCDIC (Open System Latin-1) + { NCP_8BIT|NCP_RECODE, 1140, "x-ebcdic-cp-us-euro,xebcdiccpuseuro,", 00000, L"" }, // IBM EBCDIC (US-Canada-Euro) + { NCP_8BIT|NCP_RECODE, 1141, "x-ebcdic-germany-euro,xebcdicgermanyeuro,", 00000, L"" }, // IBM EBCDIC (Germany-Euro) + { NCP_8BIT|NCP_RECODE, 1142, "x-ebcdic-denmarknorway-euro,xebcdicdenmarknorwayeuro,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway-Euro) + { NCP_8BIT|NCP_RECODE, 1143, "x-ebcdic-finlandsweden-euro,xebcdicfinlandswedeneuro,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden-Euro) + { NCP_8BIT|NCP_RECODE, 1144, "x-ebcdic-italy-euro,xebcdicitalyeuro,", 00000, L"" }, // IBM EBCDIC (Italy-Euro) + { NCP_8BIT|NCP_RECODE, 1145, "x-ebcdic-spain-euro,xebcdicspaineuro,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America-Euro) + { NCP_8BIT|NCP_RECODE, 1146, "x-ebcdic-uk-euro,xebcdicukeuro,", 00000, L"" }, // IBM EBCDIC (UK-Euro) + { NCP_8BIT|NCP_RECODE, 1147, "x-ebcdic-france-euro,xebcdicfranceeuro,", 00000, L"" }, // IBM EBCDIC (France-Euro) + { NCP_8BIT|NCP_RECODE, 1148, "x-ebcdic-international-euro,xebcdicinternationaleuro,", 00000, L"" }, // IBM EBCDIC (International-Euro) + { NCP_8BIT|NCP_RECODE, 1149, "x-ebcdic-icelandic-euro,xebcdicicelandiceuro,", 00000, L"" }, // IBM EBCDIC (Icelandic-Euro) + { NCP_8BIT|NCP_RECODE, 20273, "x-EBCDIC-Germany,xebcdicgermany,", 00000, L"" }, // IBM EBCDIC (Germany) + { NCP_8BIT|NCP_RECODE, 20277, "x-EBCDIC-DenmarkNorway,xebcdicdenmarknorway,ebcdiccpdk,ebcdiccpno,", 00000, L"" }, // IBM EBCDIC (Denmark-Norway) + { NCP_8BIT|NCP_RECODE, 20278, "x-EBCDIC-FinlandSweden,xebcdicfinlandsweden,ebcdicpfi,ebcdiccpse,", 00000, L"" }, // IBM EBCDIC (Finland-Sweden) + { NCP_8BIT|NCP_RECODE, 20280, "x-EBCDIC-Italy,xebcdicitaly,", 00000, L"" }, // IBM EBCDIC (Italy) + { NCP_8BIT|NCP_RECODE, 20284, "x-EBCDIC-Spain,xebcdicspain,ebcdiccpes,", 00000, L"" }, // IBM EBCDIC (Spain-Latin America) + { NCP_8BIT|NCP_RECODE, 20285, "x-EBCDIC-UK,xebcdicuk,ebcdiccpgb,", 00000, L"" }, // IBM EBCDIC (UK) + { NCP_8BIT|NCP_RECODE, 20290, "x-EBCDIC-JapaneseKatakana,xebcdicjapanesekatakana,", 00000, L"" }, // IBM EBCDIC (Japanese Katakana) + { NCP_8BIT|NCP_RECODE, 20297, "x-EBCDIC-France,xebcdicfrance,ebcdiccpfr,", 00000, L"" }, // IBM EBCDIC (France) + { NCP_8BIT|NCP_RECODE, 20420, "x-EBCDIC-Arabic,xebcdicarabic,ebcdiccpar1,", 00000, L"" }, // IBM EBCDIC (Arabic) + { NCP_8BIT|NCP_RECODE, 20423, "x-EBCDIC-Greek,xebcdicgreek,ebcdiccpgr,", 00000, L"" }, // IBM EBCDIC (Greek) + { NCP_8BIT|NCP_RECODE, 20424, "x-EBCDIC-Hebrew,xebcdichebrew,ebcdiccphe,", 00000, L"" }, // IBM EBCDIC (Hebrew) + { NCP_8BIT|NCP_RECODE, 20833, "x-EBCDIC-KoreanExtended,xebcdickoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean Extended) + { NCP_8BIT|NCP_RECODE, 20838, "x-EBCDIC-Thai,xebcdicthai,ibmthai,csibmthai,", 00000, L"" }, // IBM EBCDIC (Thai) + { NCP_8BIT|NCP_RECODE, 20871, "x-EBCDIC-Icelandic,xebcdicicelandic,ebcdiccpis,", 00000, L"" }, // IBM EBCDIC (Icelandic) + { NCP_8BIT|NCP_RECODE, 20880, "x-EBCDIC-CyrillicRussian,xebcdiccyrillicrussian,ebcdiccyrillic,", 00000, L"" }, // IBM EBCDIC (Cyrillic Russian) + { NCP_8BIT|NCP_RECODE, 20905, "x-EBCDIC-Turkish,xebcdicturkish,ebcdiccptr,", 00000, L"" }, // IBM EBCDIC (Turkish) + { NCP_8BIT|NCP_RECODE, 20924, "IBM00924,ibm00924,ebcdiclatin9euro,", 00000, L"" }, // IBM EBCDIC (Open System-Euro Latin-1) + { NCP_8BIT|NCP_RECODE, 21025, "x-EBCDIC-CyrillicSerbianBulgarian,xebcdiccyrillicserbianbulgarian,", 00000, L"" }, // IBM EBCDIC (Cyrillic Serbian-Bulgarian) + { NCP_8BIT|NCP_RECODE, 50930, "x-EBCDIC-JapaneseAndKana,xebcdicjapaneseandkana,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese Katakana) + { NCP_8BIT|NCP_RECODE, 50931, "x-EBCDIC-JapaneseAndUSCanada,xebcdicjapaneseanduscanada,", 00000, L"" }, // IBM EBCDIC (Japanese and US-Canada) + { NCP_8BIT|NCP_RECODE, 50933, "x-EBCDIC-KoreanAndKoreanExtended,xebcdickoreanandkoreanextended,", 00000, L"" }, // IBM EBCDIC (Korean and Korean Extended) + { NCP_8BIT|NCP_RECODE, 50935, "x-EBCDIC-SimplifiedChinese,xebcdicsimplifiedchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Simplified) + { NCP_8BIT|NCP_RECODE, 50937, "x-EBCDIC-TraditionalChinese,xebcdictraditionalchinese,", 00000, L"" }, // IBM EBCDIC (Chinese Traditional) + { NCP_8BIT|NCP_RECODE, 50939, "x-EBCDIC-JapaneseAndJapaneseLatin,xebcdicjapaneseandjapaneselatin,", 00000, L"" }, // IBM EBCDIC (Japanese and Japanese-Latin) + { NCP_8BIT|NCP_RECODE, 20105, "x-IA5,xia5,", 00000, L"" }, // Western European (IA5) + { NCP_8BIT|NCP_RECODE, 20106, "x-IA5-German,xia5german,", 00000, L"" }, // German (IA5) + { NCP_8BIT|NCP_RECODE, 20107, "x-IA5-Swedish,xia5swedish,", 00000, L"" }, // Swedish (IA5) + { NCP_8BIT|NCP_RECODE, 20108, "x-IA5-Norwegian,xia5norwegian,", 00000, L"" }, // Norwegian (IA5) + { NCP_8BIT|NCP_RECODE, 20936, "x-cp20936,xcp20936,", 00000, L"" }, // Chinese Simplified (GB2312) + { NCP_8BIT|NCP_RECODE, 52936, "hz-gb-2312,hzgb2312,hz,", 00000, L"" }, // Chinese Simplified (HZ-GB2312) */ + { NCP_8BIT|NCP_RECODE, 54936, "gb18030,gb18030,", 61072, L"" }, +/*{ NCP_8BIT|NCP_RECODE, 1361, "johab,johab,", 00000, L"" }, // Korean (Johab) + { NCP_8BIT|NCP_RECODE, 20932, "euc-jp,,", 00000, L"" }, // Japanese (JIS X 0208-1990 & 0212-1990) + { NCP_8BIT|NCP_RECODE, 50220, "iso-2022-jp,iso2022jp,", 00000, L"" }, // Japanese (JIS) + { NCP_8BIT|NCP_RECODE, 50221, "csISO2022JP,csiso2022jp,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana) + { NCP_8BIT|NCP_RECODE, 50222, "_iso-2022-jp$SIO,iso2022jpSIO,", 00000, L"" }, // Japanese (JIS-Allow 1 byte Kana - SO/SI) + { NCP_8BIT|NCP_RECODE, 50225, "iso-2022-kr,iso2022kr,csiso2022kr,", 00000, L"" }, // Korean (ISO-2022-KR) + { NCP_8BIT|NCP_RECODE, 50227, "x-cp50227,xcp50227,", 00000, L"" }, // Chinese Simplified (ISO-2022) + { NCP_8BIT|NCP_RECODE, 50229, "iso-2022-cn,iso2022cn,", 00000, L"" }, // Chinese Traditional (ISO-2022) + { NCP_8BIT|NCP_RECODE, 20000, "x-Chinese-CNS,xchinesecns,", 00000, L"" }, // Chinese Traditional (CNS) + { NCP_8BIT|NCP_RECODE, 20002, "x-Chinese-Eten,xchineseeten,", 00000, L"" }, // Chinese Traditional (Eten) + { NCP_8BIT|NCP_RECODE, 51932, "euc-jp,eucjp,xeuc,xeucjp,", 00000, L"" }, // Japanese (EUC) + { NCP_8BIT|NCP_RECODE, 51936, "euc-cn,euccn,xeuccn,", 00000, L"" }, // Chinese Simplified (EUC) + { NCP_8BIT|NCP_RECODE, 51949, "euc-kr,euckr,cseuckr,", 00000, L"" }, // Korean (EUC) + { NCP_8BIT|NCP_RECODE, 57002, "x-iscii-de,xisciide,", 00000, L"" }, // ISCII Devanagari + { NCP_8BIT|NCP_RECODE, 57003, "x-iscii-be,xisciibe,", 00000, L"" }, // ISCII Bengali + { NCP_8BIT|NCP_RECODE, 57004, "x-iscii-ta,xisciita,", 00000, L"" }, // ISCII Tamil + { NCP_8BIT|NCP_RECODE, 57005, "x-iscii-te,xisciite,", 00000, L"" }, // ISCII Telugu + { NCP_8BIT|NCP_RECODE, 57006, "x-iscii-as,xisciias,", 00000, L"" }, // ISCII Assamese + { NCP_8BIT|NCP_RECODE, 57007, "x-iscii-or,xisciior,", 00000, L"" }, // ISCII Oriya + { NCP_8BIT|NCP_RECODE, 57008, "x-iscii-ka,xisciika,", 00000, L"" }, // ISCII Kannada + { NCP_8BIT|NCP_RECODE, 57009, "x-iscii-ma,xisciima,", 00000, L"" }, // ISCII Malayalam + { NCP_8BIT|NCP_RECODE, 57010, "x-iscii-gu,xisciigu,", 00000, L"" }, // ISCII Gujarathi + { NCP_8BIT|NCP_RECODE, 57011, "x-iscii-pa,xisciipa,", 00000, L"" }, // ISCII Panjabi */ +}; + + +extern LPMRULIST mruFind; +extern LPMRULIST mruReplace; + + +//============================================================================= +// +// EditCreate() +// +HWND EditCreate(HWND hwndParent) +{ + + HWND hwnd; + + hwnd = CreateWindowEx( + WS_EX_CLIENTEDGE, + L"Scintilla", + NULL, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, + 0,0,0,0, + hwndParent, + (HMENU)IDC_EDIT, + g_hInstance, + NULL); + + SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0); + SendMessage(hwnd,SCI_SETEOLMODE,SC_EOL_CRLF,0); + SendMessage(hwnd,SCI_SETPASTECONVERTENDINGS,1,0); + SendMessage(hwnd,SCI_SETMODEVENTMASK,/*SC_MODEVENTMASKALL*/SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT,0); + SendMessage(hwnd,SCI_USEPOPUP,FALSE,0); + SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0); + SendMessage(hwnd,SCI_SETSCROLLWIDTHTRACKING,TRUE,0); + SendMessage(hwnd,SCI_SETENDATLASTLINE,TRUE,0); + SendMessage(hwnd,SCI_SETCARETSTICKY,FALSE,0); + SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50); + SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0); + SendMessage(hwnd,SCI_SETMULTIPLESELECTION,FALSE,0); + SendMessage(hwnd,SCI_SETADDITIONALSELECTIONTYPING,FALSE,0); + SendMessage(hwnd,SCI_SETVIRTUALSPACEOPTIONS,SCVS_NONE,0); + SendMessage(hwnd,SCI_SETADDITIONALCARETSBLINK,FALSE,0); + SendMessage(hwnd,SCI_SETADDITIONALCARETSVISIBLE,FALSE,0); + + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + (SCMOD_CTRL << 16)),SCI_PARADOWN); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + (SCMOD_CTRL << 16)),SCI_PARAUP); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_NEXT + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARADOWNEXTEND); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_PRIOR + ((SCMOD_CTRL | SCMOD_SHIFT) << 16)),SCI_PARAUPEXTEND); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (0 << 16)),SCI_VCHOMEWRAP); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (0 << 16)),SCI_LINEENDWRAP); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (SCMOD_SHIFT << 16)),SCI_VCHOMEWRAPEXTEND); + SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (SCMOD_SHIFT << 16)),SCI_LINEENDWRAPEXTEND); + + // Init default values for printing + EditPrintInit(); + + //SciInitThemes(hwnd); + + return(hwnd); + +} + + +//============================================================================= +// +// EditSetNewText() +// +extern BOOL bFreezeAppTitle; +extern FILEVARS fvCurFile; + +void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText) +{ + bFreezeAppTitle = TRUE; + + if (SendMessage(hwnd,SCI_GETREADONLY,0,0)) + SendMessage(hwnd,SCI_SETREADONLY,FALSE,0); + + SendMessage(hwnd,SCI_CANCEL,0,0); + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); + SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_CLEARALL,0,0); + SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); + SendMessage(hwnd,SCI_SETSCROLLWIDTH,2048,0); + SendMessage(hwnd,SCI_SETXOFFSET,0,0); + + FileVars_Apply(hwnd,&fvCurFile); + + if (cbText > 0) + SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)lpstrText); + + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); + SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); + SendMessage(hwnd,SCI_GOTOPOS,0,0); + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + + bFreezeAppTitle = FALSE; +} + + +//============================================================================= +// +// EditConvertText() +// +BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint) +{ + struct Sci_TextRange tr = { { 0, -1 }, NULL }; + int length, cbText, cbwText; + char *pchText; + WCHAR *pwchText; + + if (cpSource == cpDest) + return(TRUE); + + length = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + if (length == 0) { + SendMessage(hwnd,SCI_CANCEL,0,0); + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); + SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_CLEARALL,0,0); + SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); + SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0); + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); + SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_GOTOPOS,0,0); + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + + if (bSetSavePoint) + SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); + } + + else { + pchText = GlobalAlloc(GPTR,length*5+2); + + tr.lpstrText = pchText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + pwchText = GlobalAlloc(GPTR,length*3+2); + cbwText = MultiByteToWideChar(cpSource,0,pchText,length,pwchText,length*3+2); + cbText = WideCharToMultiByte(cpDest,0,pwchText,cbwText,pchText,length*5+2,NULL,NULL); + + SendMessage(hwnd,SCI_CANCEL,0,0); + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0); + SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_CLEARALL,0,0); + SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0); + SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0); + SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)pchText); + SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0); + SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0); + SendMessage(hwnd,SCI_GOTOPOS,0,0); + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + + GlobalFree(pchText); + GlobalFree(pwchText); + } + return(TRUE); +} + + +//============================================================================= +// +// EditSetNewEncoding() +// +BOOL EditSetNewEncoding(HWND hwnd,int iCurrentEncoding,int iNewEncoding,BOOL bNoUI,BOOL bSetSavePoint) { + + if (iCurrentEncoding != iNewEncoding) { + + if ((iCurrentEncoding == CPI_DEFAULT && iNewEncoding == CPI_DEFAULT) || + (iCurrentEncoding != CPI_DEFAULT && iNewEncoding != CPI_DEFAULT)) + return(TRUE); + + if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) { + + BOOL bIsEmptyUndoHistory = + (SendMessage(hwnd,SCI_CANUNDO,0,0) == 0 && SendMessage(hwnd,SCI_CANREDO,0,0) == 0); + + if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) && + (bNoUI || bIsEmptyUndoHistory || InfoBox(MBYESNO,L"MsgConv2",IDS_ASK_ENCODING2) == IDYES)) { + + EditConvertText(hwnd, + (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, + (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, + bSetSavePoint); + + return(TRUE); + } + + else + return(FALSE); + } + + else if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) && + (bNoUI || InfoBox(MBYESNO,L"MsgConv1",IDS_ASK_ENCODING) == IDYES)) { + + BeginWaitCursor(); + + EditConvertText(hwnd, + (mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, + (mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8, + FALSE); + + EndWaitCursor(); + + return(TRUE); + } + + else + return(FALSE); + } + + else + return(FALSE); +} + + +//============================================================================= +// +// EditGetClipboardText() +// +char* EditGetClipboardText(HWND hwnd) +{ + HANDLE hmem; + WCHAR *pwch; + char *pmch; + char *ptmp; + int wlen, mlen, mlen2; + UINT codepage; + int eolmode; + + if (!IsClipboardFormatAvailable(CF_UNICODETEXT) || !OpenClipboard(GetParent(hwnd))) + return(NULL); + + hmem = GetClipboardData(CF_UNICODETEXT); + pwch = GlobalLock(hmem); + + wlen = lstrlenW(pwch); + + codepage = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + eolmode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + + mlen = WideCharToMultiByte(codepage,0,pwch,wlen + 1,NULL,0,0,0) - 1; + pmch = LocalAlloc(LPTR,mlen + 1); + if (pmch) + WideCharToMultiByte(codepage,0,pwch,wlen + 1,pmch,mlen + 1,NULL,NULL); + + ptmp = LocalAlloc(LPTR,mlen * 2 + 1); + if (ptmp) { + char *s = pmch; + char *d = ptmp; + int i; + + for (i = 0; (i < mlen) && (*s != 0); i++) { + if (*s == '\n' || *s == '\r') { + if (eolmode == SC_EOL_CR) { + *d++ = '\r'; + } else if (eolmode == SC_EOL_LF) { + *d++ = '\n'; + } else { // eolmode == SC_EOL_CRLF + *d++ = '\r'; + *d++ = '\n'; + } + if ((*s == '\r') && (i+1 < mlen) && (*(s+1) == '\n')) { + i++; + s++; + } + s++; + } else { + *d++ = *s++; + } + } + *d++ = 0; + mlen2 = (int)(d - ptmp) - 1; + + LocalFree(pmch); + pmch = LocalAlloc(LPTR,mlen2 + 1); + lstrcpyA(pmch,ptmp); + LocalFree(ptmp); + } + + GlobalUnlock(hmem); + CloseClipboard(); + + return(pmch); +} + + +//============================================================================= +// +// EditCopyAppend() +// +BOOL EditCopyAppend(HWND hwnd) +{ + HANDLE hOld; + WCHAR *pszOld; + + HANDLE hNew; + WCHAR *pszNew; + + char *pszText; + int cchTextW; + WCHAR *pszTextW; + + WCHAR *pszSep = L"\r\n\r\n"; + + UINT uCodePage; + + int iCurPos; + int iAnchorPos; + + if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) { + SendMessage(hwnd,SCI_COPY,0,0); + return(TRUE); + } + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) { + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + MsgBox(MBWARN,IDS_SELRECT); + return(FALSE); + } + + else { + int iSelCount = + (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + pszText = LocalAlloc(LPTR,iSelCount + 1); + (int)SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + } + } + + else { + int cchText = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + pszText = LocalAlloc(LPTR,cchText + 1); + SendMessage(hwnd,SCI_GETTEXT,(int)LocalSize(pszText),(LPARAM)pszText); + } + + uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; + + cchTextW = MultiByteToWideChar(uCodePage,0,pszText,-1,NULL,0); + if (cchTextW > 0) { + pszTextW = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(pszSep) + cchTextW + 1)); + lstrcpy(pszTextW,pszSep); + MultiByteToWideChar(uCodePage,0,pszText,-1,StrEnd(pszTextW),(int)LocalSize(pszTextW)/sizeof(WCHAR)); + } + else { + pszTextW = L""; + } + + LocalFree(pszText); + + if (!OpenClipboard(GetParent(hwnd))) { + LocalFree(pszTextW); + return(FALSE); + } + + hOld = GetClipboardData(CF_UNICODETEXT); + pszOld = GlobalLock(hOld); + + hNew = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, + sizeof(WCHAR) * (lstrlen(pszOld) + lstrlen(pszTextW) + 1)); + pszNew = GlobalLock(hNew); + + lstrcpy(pszNew,pszOld); + lstrcat(pszNew,pszTextW); + + GlobalUnlock(hNew); + GlobalUnlock(hOld); + + EmptyClipboard(); + SetClipboardData(CF_UNICODETEXT,hNew); + CloseClipboard(); + + return(TRUE); +} + + +//============================================================================= +// +// EditDetectEOLMode() - moved here to handle Unicode files correctly +// +int EditDetectEOLMode(HWND hwnd,char* lpData,DWORD cbData) +{ + int iEOLMode = iLineEndings[iDefaultEOLMode]; + char *cp = (char*)lpData; + + if (!cp) + return (iEOLMode); + + while (*cp && (*cp != '\x0D' && *cp != '\x0A')) cp++; + + if (*cp == '\x0D' && *(cp+1) == '\x0A') + iEOLMode = SC_EOL_CRLF; + else if (*cp == '\x0D' && *(cp+1) != '\x0A') + iEOLMode = SC_EOL_CR; + else if (*cp == '\x0A') + iEOLMode = SC_EOL_LF; + + return (iEOLMode); +} + + + +//============================================================================= +// +// Encoding Helper Functions +// +void Encoding_InitDefaults() { + wsprintf(wchANSI,L" (%i)",GetACP()); + mEncoding[CPI_OEM].uCodePage = GetOEMCP(); + wsprintf(wchOEM,L" (%i)",mEncoding[CPI_OEM].uCodePage); + + g_DOSEncoding = CPI_OEM; + + // Try to set the DOS encoding to DOS-437 if the default OEMCP is not DOS-437 + if (mEncoding[g_DOSEncoding].uCodePage != 437) + { + int i; + for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); ++i) { + if (mEncoding[i].uCodePage == 437 && Encoding_IsValid(i)) { + g_DOSEncoding = i; + break; + } + } + } +} + + +int Encoding_MapIniSetting(BOOL bLoad,int iSetting) { + if (bLoad) { + switch (iSetting) { + case 0: return CPI_DEFAULT; + case 1: return CPI_UNICODEBOM; + case 2: return CPI_UNICODEBEBOM; + case 3: return CPI_UTF8; + case 4: return CPI_UTF8SIGN; + case 5: return CPI_OEM; + case 6: return CPI_UNICODE; + case 7: return CPI_UNICODEBE; + case 8: return CPI_UTF7; + default: { + int i; + for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); i++) { + if (mEncoding[i].uCodePage == (UINT)iSetting && Encoding_IsValid(i)) + return(i); + } + return CPI_DEFAULT; + } + } + } + else { + switch (iSetting) { + case CPI_DEFAULT: return 0; + case CPI_UNICODEBOM: return 1; + case CPI_UNICODEBEBOM: return 2; + case CPI_UTF8: return 3; + case CPI_UTF8SIGN: return 4; + case CPI_OEM: return 5; + case CPI_UNICODE: return 6; + case CPI_UNICODEBE: return 7; + case CPI_UTF7: return 8; + default: return(mEncoding[iSetting].uCodePage); + } + } +} + + +void Encoding_GetLabel(int iEncoding) { + if (mEncoding[iEncoding].wchLabel[0] == 0) { + WCHAR *pwsz; + WCHAR wch[256] = L""; + GetString(mEncoding[iEncoding].idsName,wch,COUNTOF(wch)); + if (pwsz = StrChr(wch,L';')) { + if (pwsz = StrChr(CharNext(pwsz),L';')) { + pwsz = CharNext(pwsz); + } + } + if (!pwsz) + pwsz = wch; + StrCpyN(mEncoding[iEncoding].wchLabel,pwsz,COUNTOF(mEncoding[iEncoding].wchLabel)); + } +} + + +int Encoding_MatchW(LPCWSTR pwszTest) { + char tchTest[256]; + WideCharToMultiByte(CP_ACP,0,pwszTest,-1,tchTest,COUNTOF(tchTest),NULL,NULL); + return(Encoding_MatchA(tchTest)); +} + + +int Encoding_MatchA(char *pchTest) { + int i; + char chTest[256]; + char *pchSrc = pchTest; + char *pchDst = chTest; + *pchDst++ = ','; + while (*pchSrc) { + if (IsCharAlphaNumericA(*pchSrc)) + *pchDst++ = *CharLowerA(pchSrc); + pchSrc++; + } + *pchDst++ = ','; + *pchDst = 0; + for (i = 0; i < COUNTOF(mEncoding); i++) { + if (StrStrIA(mEncoding[i].pszParseNames,chTest)) { + CPINFO cpi; + if ((mEncoding[i].uFlags & NCP_INTERNAL) || + IsValidCodePage(mEncoding[i].uCodePage) && + GetCPInfo(mEncoding[i].uCodePage,&cpi)) + return(i); + else + return(-1); + } + } + return(-1); +} + + +BOOL Encoding_IsValid(int iTestEncoding) { + CPINFO cpi; + if (iTestEncoding >= 0 && + iTestEncoding < COUNTOF(mEncoding)) { + if ((mEncoding[iTestEncoding].uFlags & NCP_INTERNAL) || + IsValidCodePage(mEncoding[iTestEncoding].uCodePage) && + GetCPInfo(mEncoding[iTestEncoding].uCodePage,&cpi)) { + return(TRUE); + } + } + return(FALSE); +} + + +typedef struct _ee { + int id; + WCHAR wch[256]; +} ENCODINGENTRY, *PENCODINGENTRY; + +int CmpEncoding(const void *s1, const void *s2) { + return StrCmp(((PENCODINGENTRY)s1)->wch,((PENCODINGENTRY)s2)->wch); +} + +void Encoding_AddToListView(HWND hwnd,int idSel,BOOL bRecodeOnly) +{ + int i; + int iSelItem = -1; + LVITEM lvi; + WCHAR wchBuf[256]; + + PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY)); + for (i = 0; i < COUNTOF(mEncoding); i++) { + pEE[i].id = i; + GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch)); + } + qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding); + + ZeroMemory(&lvi,sizeof(LVITEM)); + lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE; + lvi.pszText = wchBuf; + + for (i = 0; i < COUNTOF(mEncoding); i++) { + + int id = pEE[i].id; + if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) { + + CPINFO cpi; + WCHAR *pwsz; + + lvi.iItem = ListView_GetItemCount(hwnd); + + if (pwsz = StrChr(pEE[i].wch,L';')) { + StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf)); + if (pwsz = StrChr(wchBuf,L';')) + *pwsz = 0; + } + else + StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf)); + + if (id == CPI_DEFAULT) + StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf)); + else if (id == CPI_OEM) + StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf)); + + if ((mEncoding[id].uFlags & NCP_INTERNAL) || + (IsValidCodePage(mEncoding[id].uCodePage) && + GetCPInfo(mEncoding[id].uCodePage,&cpi))) + lvi.iImage = 0; + else + lvi.iImage = 1; + + lvi.lParam = (LPARAM)id; + ListView_InsertItem(hwnd,&lvi); + + if (idSel == id) + iSelItem = lvi.iItem; + } + } + + LocalFree(pEE); + + if (iSelItem != -1) { + ListView_SetItemState(hwnd,iSelItem,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED); + ListView_EnsureVisible(hwnd,iSelItem,FALSE); + } + else { + ListView_SetItemState(hwnd,0,LVIS_FOCUSED,LVIS_FOCUSED); + ListView_EnsureVisible(hwnd,0,FALSE); + } +} + + +BOOL Encoding_GetFromListView(HWND hwnd,int *pidEncoding) +{ + LVITEM lvi; + + lvi.iItem = ListView_GetNextItem(hwnd,-1,LVNI_ALL | LVNI_SELECTED); + lvi.iSubItem = 0; + lvi.mask = LVIF_PARAM; + + if (ListView_GetItem(hwnd,&lvi)) { + if (Encoding_IsValid((int)lvi.lParam)) { + *pidEncoding = (int)lvi.lParam; + return (TRUE); + } + else + MsgBox(MBWARN,IDS_ERR_ENCODINGNA); + } + return(FALSE); +} + + +void Encoding_AddToComboboxEx(HWND hwnd,int idSel,BOOL bRecodeOnly) +{ + int i; + int iSelItem = -1; + COMBOBOXEXITEM cbei; + WCHAR wchBuf[256]; + + PENCODINGENTRY pEE = LocalAlloc(LPTR,COUNTOF(mEncoding) * sizeof(ENCODINGENTRY)); + for (i = 0; i < COUNTOF(mEncoding); i++) { + pEE[i].id = i; + GetString(mEncoding[i].idsName,pEE[i].wch,COUNTOF(pEE[i].wch)); + } + qsort(pEE,COUNTOF(mEncoding),sizeof(ENCODINGENTRY),CmpEncoding); + + ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM)); + cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM; + cbei.pszText = wchBuf; + cbei.cchTextMax = COUNTOF(wchBuf); + cbei.iImage = 0; + cbei.iSelectedImage = 0; + + for (i = 0; i < COUNTOF(mEncoding); i++) { + + int id = pEE[i].id; + if (!bRecodeOnly || (mEncoding[id].uFlags & NCP_RECODE)) { + + CPINFO cpi; + WCHAR *pwsz; + + cbei.iItem = SendMessage(hwnd,CB_GETCOUNT,0,0); + + if (pwsz = StrChr(pEE[i].wch,L';')) { + StrCpyN(wchBuf,CharNext(pwsz),COUNTOF(wchBuf)); + if (pwsz = StrChr(wchBuf,L';')) + *pwsz = 0; + } + else + StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf)); + + if (id == CPI_DEFAULT) + StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf)); + else if (id == CPI_OEM) + StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf)); + + if ((mEncoding[id].uFlags & NCP_INTERNAL) || + (IsValidCodePage(mEncoding[id].uCodePage) && + GetCPInfo(mEncoding[id].uCodePage,&cpi))) + cbei.iImage = 0; + else + cbei.iImage = 1; + + cbei.lParam = (LPARAM)id; + SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei); + + if (idSel == id) + iSelItem = (int)cbei.iItem; + } + } + + LocalFree(pEE); + + if (iSelItem != -1) + SendMessage(hwnd,CB_SETCURSEL,(WPARAM)iSelItem,0); +} + + +BOOL Encoding_GetFromComboboxEx(HWND hwnd,int *pidEncoding) +{ + COMBOBOXEXITEM cbei; + + cbei.iItem = SendMessage(hwnd,CB_GETCURSEL,0,0); + cbei.mask = CBEIF_LPARAM; + + if (SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei)) { + if (Encoding_IsValid((int)cbei.lParam)) { + *pidEncoding = (int)cbei.lParam; + return (TRUE); + } + else + MsgBox(MBWARN,IDS_ERR_ENCODINGNA); + } + return(FALSE); +} + + +BOOL IsUnicode(const char* pBuffer,int cb,LPBOOL lpbBOM,LPBOOL lpbReverse) +{ + int i = 0xFFFF; + + BOOL bIsTextUnicode; + + BOOL bHasBOM; + BOOL bHasRBOM; + + if (!pBuffer || cb < 2) + return FALSE; + + if (!bSkipUnicodeDetection) + bIsTextUnicode = IsTextUnicode(pBuffer,cb,&i); + else + bIsTextUnicode = FALSE; + + bHasBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFEFF); + bHasRBOM = (*((UNALIGNED PWCHAR)pBuffer) == 0xFFFE); + + if (i == 0xFFFF) // i doesn't seem to have been modified ... + i = 0; + + if (bIsTextUnicode || bHasBOM || bHasRBOM || + ((i & (IS_TEXT_UNICODE_UNICODE_MASK | IS_TEXT_UNICODE_REVERSE_MASK)) && + !((i & IS_TEXT_UNICODE_UNICODE_MASK) && (i & IS_TEXT_UNICODE_REVERSE_MASK)) && + !(i & IS_TEXT_UNICODE_ODD_LENGTH) && + !(i & IS_TEXT_UNICODE_ILLEGAL_CHARS && !(i & IS_TEXT_UNICODE_REVERSE_SIGNATURE)) && + !((i & IS_TEXT_UNICODE_REVERSE_MASK) == IS_TEXT_UNICODE_REVERSE_STATISTICS))) { + + if (lpbBOM) + *lpbBOM = (bHasBOM || bHasRBOM || + (i & (IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE))) + ? TRUE : FALSE; + + if (lpbReverse) + *lpbReverse = (bHasRBOM || (i & IS_TEXT_UNICODE_REVERSE_MASK)) ? TRUE : FALSE; + + return TRUE; + } + + else + + return FALSE; +} + + +BOOL IsUTF8(const char* pTest,int nLength) +{ + static int byte_class_table[256] = { + /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ + /* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + /* A0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + /* B0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + /* C0 */ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* D0 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* E0 */ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, + /* F0 */ 9,10,10,10,11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 + /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ }; + + /* state table */ + typedef enum { + kSTART = 0,kA,kB,kC,kD,kE,kF,kG,kERROR,kNumOfStates } utf8_state; + + static utf8_state state_table[] = { + /* kSTART, kA, kB, kC, kD, kE, kF, kG, kERROR */ + /* 0x00-0x7F: 0 */ kSTART, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0x80-0x8F: 1 */ kERROR, kSTART, kA, kERROR, kA, kB, kERROR, kB, kERROR, + /* 0x90-0x9f: 2 */ kERROR, kSTART, kA, kERROR, kA, kB, kB, kERROR, kERROR, + /* 0xa0-0xbf: 3 */ kERROR, kSTART, kA, kA, kERROR, kB, kB, kERROR, kERROR, + /* 0xc0-0xc1, 0xf5-0xff: 4 */ kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xc2-0xdf: 5 */ kA, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xe0: 6 */ kC, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xe1-0xec, 0xee-0xef: 7 */ kB, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xed: 8 */ kD, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xf0: 9 */ kF, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xf1-0xf3: 10 */ kE, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, + /* 0xf4: 11 */ kG, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR }; + + #define BYTE_CLASS(b) (byte_class_table[(unsigned char)b]) + #define NEXT_STATE(b,cur) (state_table[(BYTE_CLASS(b) * kNumOfStates) + (cur)]) + + utf8_state current = kSTART; + int i; + + const char* pt = pTest; + int len = nLength; + + for(i = 0; i < len ; i++, pt++) { + + current = NEXT_STATE(*pt,current); + if (kERROR == current) + break; + } + + return (current == kSTART) ? TRUE : FALSE; + } + + +BOOL IsUTF7(const char* pTest,int nLength) +{ + int i; + const char *pt = pTest; + + for (i = 0; i < nLength; i++) { + if (*pt & 0x80 || !*pt) + return FALSE; + pt++; + } + + return TRUE; +} + + +#define IsUTF8Signature(p) \ + ((*(p+0) == '\xEF' && *(p+1) == '\xBB' && *(p+2) == '\xBF')) + + +#define UTF8StringStart(p) \ + (IsUTF8Signature(p)) ? (p+3) : (p) + + +/* byte length of UTF-8 sequence based on value of first byte. + for UTF-16 (21-bit space), max. code length is 4, so we only need to look + at 4 upper bits. + */ +static const INT utf8_lengths[16]= +{ + 1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */ + 0,0,0,0, /* 1000 to 1011 : not valid */ + 2,2, /* 1100, 1101 : 2 bytes */ + 3, /* 1110 : 3 bytes */ + 4 /* 1111 :4 bytes */ +}; + +/*++ +Function : + UTF8_mbslen_bytes [INTERNAL] + + Calculates the byte size of a NULL-terminated UTF-8 string. + +Parameters : + char *utf8_string : string to examine + +Return value : + size (in bytes) of a NULL-terminated UTF-8 string. + -1 if invalid NULL-terminated UTF-8 string +--*/ +static INT UTF8_mbslen_bytes(LPCSTR utf8_string) +{ + INT length=0; + INT code_size; + BYTE byte; + + while(*utf8_string) + { + byte=(BYTE)*utf8_string; + + if( (byte <= 0xF7) && (0 != (code_size = utf8_lengths[ byte >> 4 ]))) + { + length+=code_size; + utf8_string+=code_size; + } + else + { + /* we got an invalid byte value but need to count it, + it will be later ignored during the string conversion */ + //WARN("invalid first byte value 0x%02X in UTF-8 sequence!\n",byte); + length++; + utf8_string++; + } + } + length++; /* include NULL terminator */ + return length; +} + +/*++ +Function : + UTF8_mbslen [INTERNAL] + + Calculates the character size of a NULL-terminated UTF-8 string. + +Parameters : + char *utf8_string : string to examine + int byte_length : byte size of string + +Return value : + size (in characters) of a UTF-8 string. + -1 if invalid UTF-8 string +--*/ +static INT UTF8_mbslen(LPCSTR source, INT byte_length) +{ + INT wchar_length=0; + INT code_size; + BYTE byte; + + while(byte_length > 0) + { + byte=(BYTE)*source; + + /* UTF-16 can't encode 5-byte and 6-byte sequences, so maximum value + for first byte is 11110111. Use lookup table to determine sequence + length based on upper 4 bits of first byte */ + if ((byte <= 0xF7) && (0 != (code_size=utf8_lengths[ byte >> 4]))) + { + /* 1 sequence == 1 character */ + wchar_length++; + + if(code_size==4) + wchar_length++; + + source+=code_size; /* increment pointer */ + byte_length-=code_size; /* decrement counter*/ + } + else + { + /* + unlike UTF8_mbslen_bytes, we ignore the invalid characters. + we only report the number of valid characters we have encountered + to match the Windows behavior. + */ + //WARN("invalid byte 0x%02X in UTF-8 sequence, skipping it!\n", + // byte); + source++; + byte_length--; + } + } + return wchar_length; +} + + +//============================================================================= +// +// EditLoadFile() +// +BOOL EditLoadFile( + HWND hwnd, + LPCWSTR pszFile, + BOOL bSkipEncodingDetection, + int* iEncoding, + int* iEOLMode, + BOOL *pbUnicodeErr, + BOOL *pbFileTooBig) +{ + + HANDLE hFile; + + DWORD dwFileSize; + DWORD dwFileSizeLimit; + DWORD dwBufSize; + BOOL bReadSuccess; + + char* lpData; + DWORD cbData; + //char *cp; + int _iDefaultEncoding; + + BOOL bBOM; + BOOL bReverse = FALSE; + + BOOL bPreferOEM = FALSE; + + *pbUnicodeErr = FALSE; + *pbFileTooBig = FALSE; + + hFile = CreateFile(pszFile, + GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + dwLastIOError = GetLastError(); + + if (hFile == INVALID_HANDLE_VALUE) { + iSrcEncoding = -1; + iWeakSrcEncoding = -1; + return FALSE; + } + + // calculate buffer limit + dwFileSize = GetFileSize(hFile,NULL); + dwBufSize = dwFileSize + 10; + + // Check if a warning message should be displayed for large files + dwFileSizeLimit = IniGetInt(L"Settings2",L"FileLoadWarningMB",1); + if (dwFileSizeLimit != 0 && dwFileSizeLimit * 1024 * 1024 < dwFileSize) { + if (InfoBox(MBYESNO,L"MsgFileSizeWarning",IDS_WARNLOADBIGFILE) != IDYES) { + CloseHandle(hFile); + *pbFileTooBig = TRUE; + iSrcEncoding = -1; + iWeakSrcEncoding = -1; + return FALSE; + } + } + + lpData = GlobalAlloc(GPTR,dwBufSize); + bReadSuccess = ReadFile(hFile,lpData,(DWORD)GlobalSize(lpData)-2,&cbData,NULL); + dwLastIOError = GetLastError(); + CloseHandle(hFile); + + if (!bReadSuccess) { + GlobalFree(lpData); + iSrcEncoding = -1; + iWeakSrcEncoding = -1; + return FALSE; + } + + if (bLoadNFOasOEM) + { + PCWSTR pszExt = pszFile + lstrlen(pszFile) - 4; + if (pszExt >= pszFile && !(lstrcmpi(pszExt, L".nfo") && lstrcmpi(pszExt, L".diz"))) + bPreferOEM = TRUE; + } + + if (!Encoding_IsValid(iDefaultEncoding)) + iDefaultEncoding = CPI_DEFAULT; + + _iDefaultEncoding = (bPreferOEM) ? g_DOSEncoding : iDefaultEncoding; + if (iWeakSrcEncoding != -1 && Encoding_IsValid(iWeakSrcEncoding)) + _iDefaultEncoding = iWeakSrcEncoding; + + *iEncoding = CPI_DEFAULT; + + if (cbData == 0) { + FileVars_Init(NULL,0,&fvCurFile); + *iEOLMode = iLineEndings[iDefaultEOLMode]; + if (iSrcEncoding == -1) { + if (bLoadASCIIasUTF8 && !bPreferOEM) + *iEncoding = CPI_UTF8; + else + *iEncoding = _iDefaultEncoding; + } + else + *iEncoding = iSrcEncoding; + SendMessage(hwnd,SCI_SETCODEPAGE,(mEncoding[*iEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); + EditSetNewText(hwnd,"",0); + SendMessage(hwnd,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); + GlobalFree(lpData); + } + + else if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE) && + (iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || IsUnicode(lpData,cbData,&bBOM,&bReverse)) && + (iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || !IsUTF8Signature(lpData))) // check for UTF-8 signature + { + char* lpDataUTF8; + + if (iSrcEncoding == CPI_UNICODE) { + bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFEFF); + bReverse = FALSE; + } + else if (iSrcEncoding == CPI_UNICODEBE) + bBOM = (*((UNALIGNED PWCHAR)lpData) == 0xFFFE); + + if (iSrcEncoding == CPI_UNICODEBE || bReverse) { + _swab(lpData,lpData,cbData); + if (bBOM) + *iEncoding = CPI_UNICODEBEBOM; + else + *iEncoding = CPI_UNICODEBE; + } + else { + if (bBOM) + *iEncoding = CPI_UNICODEBOM; + else + *iEncoding = CPI_UNICODE; + } + + lpDataUTF8 = GlobalAlloc(GPTR,(cbData * 3) + 2); + cbData = WideCharToMultiByte(CP_UTF8,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData, + (bBOM) ? (cbData)/sizeof(WCHAR) : cbData/sizeof(WCHAR) + 1,lpDataUTF8,(int)GlobalSize(lpDataUTF8),NULL,NULL); + + if (cbData == 0) { + cbData = WideCharToMultiByte(CP_ACP,0,(bBOM) ? (LPWSTR)lpData + 1 : (LPWSTR)lpData, + (-1),lpDataUTF8,(int)GlobalSize(lpDataUTF8),NULL,NULL); + *pbUnicodeErr = TRUE; + } + + GlobalFree(lpData); + SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); + EditSetNewText(hwnd,"",0); + FileVars_Init(lpDataUTF8,cbData-1,&fvCurFile); + EditSetNewText(hwnd,lpDataUTF8,cbData-1); + *iEOLMode = EditDetectEOLMode(hwnd,lpDataUTF8,cbData-1); + GlobalFree(lpDataUTF8); + } + + else { + FileVars_Init(lpData,cbData,&fvCurFile); + if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) && + ((IsUTF8Signature(lpData) || + FileVars_IsUTF8(&fvCurFile) || + (iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) || + // from menu "Reload As UTF-8" + (!bPreferOEM && bLoadASCIIasUTF8) || + (IsUTF8(lpData,cbData) && + (((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 != + UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) || + (!bPreferOEM && ( + mEncoding[_iDefaultEncoding].uFlags & NCP_UTF8 + )) ))))) && !(FileVars_IsNonUTF8(&fvCurFile) && + (iSrcEncoding != CPI_UTF8 && iSrcEncoding != CPI_UTF8SIGN))) + { + SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); + EditSetNewText(hwnd,"",0); + if (IsUTF8Signature(lpData)) { + EditSetNewText(hwnd,UTF8StringStart(lpData),cbData-3); + *iEncoding = CPI_UTF8SIGN; + *iEOLMode = EditDetectEOLMode(hwnd,UTF8StringStart(lpData),cbData-3); + } + else { + EditSetNewText(hwnd,lpData,cbData); + *iEncoding = CPI_UTF8; + *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); + } + GlobalFree(lpData); + } + + else { + + UINT uCodePage = CP_UTF8; + LPWSTR lpDataWide; + int cbDataWide; + + if (iSrcEncoding != -1) + *iEncoding = iSrcEncoding; + else { + *iEncoding = FileVars_GetEncoding(&fvCurFile); + if (*iEncoding == -1) { + if (fvCurFile.mask & FV_ENCODING) + *iEncoding = CPI_DEFAULT; + else { + if (iWeakSrcEncoding == -1) + *iEncoding = _iDefaultEncoding; + else if (mEncoding[iWeakSrcEncoding].uFlags & NCP_INTERNAL) + *iEncoding = iDefaultEncoding; + else + *iEncoding = _iDefaultEncoding; + } + } + } + + if ((mEncoding[*iEncoding].uFlags & NCP_8BIT && mEncoding[*iEncoding].uCodePage != CP_UTF7) || + (mEncoding[*iEncoding].uCodePage == CP_UTF7 && IsUTF7(lpData,cbData))) { + + uCodePage = mEncoding[*iEncoding].uCodePage; + + lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); + cbDataWide = MultiByteToWideChar(uCodePage,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); + + GlobalFree(lpData); + lpData = GlobalAlloc(GPTR,cbDataWide * 3 + 16); + + cbData = WideCharToMultiByte(CP_UTF8,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); + GlobalFree(lpDataWide); + + SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0); + EditSetNewText(hwnd,"",0); + EditSetNewText(hwnd,lpData,cbData); + *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); + + GlobalFree(lpData); + } + + else { + + SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0); + EditSetNewText(hwnd,"",0); + EditSetNewText(hwnd,lpData,cbData); + *iEncoding = CPI_DEFAULT; + *iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData); + GlobalFree(lpData); + } + } + } + + iSrcEncoding = -1; + iWeakSrcEncoding = -1; + return TRUE; + +} + + +//============================================================================= +// +// EditSaveFile() +// +BOOL EditSaveFile( + HWND hwnd, + LPCWSTR pszFile, + int iEncoding, + BOOL *pbCancelDataLoss, + BOOL bSaveCopy) +{ + + HANDLE hFile; + BOOL bWriteSuccess; + + char* lpData; + DWORD cbData; + DWORD dwBytesWritten; + + *pbCancelDataLoss = FALSE; + + hFile = CreateFile(pszFile, + GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + dwLastIOError = GetLastError(); + + // failure could be due to missing attributes (2k/XP) + if (hFile == INVALID_HANDLE_VALUE) + { + DWORD dwAttributes = GetFileAttributes(pszFile); + if (dwAttributes != INVALID_FILE_ATTRIBUTES) + { + dwAttributes = dwAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); + hFile = CreateFile(pszFile, + GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL | dwAttributes, + NULL); + dwLastIOError = GetLastError(); + } + } + + if (hFile == INVALID_HANDLE_VALUE) + return FALSE; + + // ensure consistent line endings + if (bFixLineEndings) { + SendMessage(hwnd,SCI_CONVERTEOLS,SendMessage(hwnd,SCI_GETEOLMODE,0,0),0); + EditFixPositions(hwnd); + } + + // strip trailing blanks + if (bAutoStripBlanks) + EditStripTrailingBlanks(hwnd,TRUE); + + // get text + cbData = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + lpData = GlobalAlloc(GPTR,cbData + 1); + SendMessage(hwnd,SCI_GETTEXT,GlobalSize(lpData),(LPARAM)lpData); + + if (cbData == 0) { + bWriteSuccess = SetEndOfFile(hFile); + dwLastIOError = GetLastError(); + } + + else { + + // FIXME: move checks in front of disk file access + /*if ((mEncoding[iEncoding].uFlags & NCP_UNICODE) == 0 && (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) == 0) { + BOOL bEncodingMismatch = TRUE; + FILEVARS fv; + FileVars_Init(lpData,cbData,&fv); + if (fv.mask & FV_ENCODING) { + int iAltEncoding; + if (FileVars_IsValidEncoding(&fv)) { + iAltEncoding = FileVars_GetEncoding(&fv); + if (iAltEncoding == iEncoding) + bEncodingMismatch = FALSE; + else if ((mEncoding[iAltEncoding].uFlags & NCP_UTF8) && (mEncoding[iEncoding].uFlags & NCP_UTF8)) + bEncodingMismatch = FALSE; + } + if (bEncodingMismatch) { + Encoding_GetLabel(iAltEncoding); + Encoding_GetLabel(iEncoding); + InfoBox(0,L"MsgEncodingMismatch",IDS_ENCODINGMISMATCH, + mEncoding[iAltEncoding].wchLabel, + mEncoding[iEncoding].wchLabel); + } + } + }*/ + + if (mEncoding[iEncoding].uFlags & NCP_UNICODE) + { + LPWSTR lpDataWide; + int cbDataWide; + + SetEndOfFile(hFile); + + lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); + cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); + + if (mEncoding[iEncoding].uFlags & NCP_UNICODE_BOM) { + if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) + WriteFile(hFile,(LPCVOID)"\xFE\xFF",2,&dwBytesWritten,NULL); + else + WriteFile(hFile,(LPCVOID)"\xFF\xFE",2,&dwBytesWritten,NULL); + } + + if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) + _swab((char*)lpDataWide,(char*)lpDataWide,cbDataWide * sizeof(WCHAR)); + + bWriteSuccess = WriteFile(hFile,lpDataWide,cbDataWide * sizeof(WCHAR),&dwBytesWritten,NULL); + dwLastIOError = GetLastError(); + + GlobalFree(lpDataWide); + GlobalFree(lpData); + } + + else if (mEncoding[iEncoding].uFlags & NCP_UTF8) + { + SetEndOfFile(hFile); + + if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) + WriteFile(hFile,(LPCVOID)"\xEF\xBB\xBF",3,&dwBytesWritten,NULL); + + bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); + dwLastIOError = GetLastError(); + + GlobalFree(lpData); + } + + else if (mEncoding[iEncoding].uFlags & NCP_8BIT) { + + BOOL bCancelDataLoss = FALSE; + UINT uCodePage = mEncoding[iEncoding].uCodePage; + + LPWSTR lpDataWide = GlobalAlloc(GPTR,cbData * 2 + 16); + int cbDataWide = MultiByteToWideChar(CP_UTF8,0,lpData,cbData,lpDataWide,(int)GlobalSize(lpDataWide)/sizeof(WCHAR)); + + // Special cases: 42, 50220, 50221, 50222, 50225, 50227, 50229, 54936, 57002-11, 65000, 65001 + if (uCodePage == CP_UTF7 || uCodePage == 54936) { + GlobalFree(lpData); + lpData = GlobalAlloc(GPTR,GlobalSize(lpDataWide)*2); + } + else + ZeroMemory(lpData,GlobalSize(lpData)); + + if (uCodePage == CP_UTF7 || uCodePage == 54936) + cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); + else { + cbData = WideCharToMultiByte(uCodePage,WC_NO_BEST_FIT_CHARS,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,&bCancelDataLoss); + if (!bCancelDataLoss) { + cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL); + bCancelDataLoss = FALSE; + } + } + GlobalFree(lpDataWide); + + if (!bCancelDataLoss || InfoBox(MBOKCANCEL,L"MsgConv3",IDS_ERR_UNICODE2) == IDOK) { + SetEndOfFile(hFile); + bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); + dwLastIOError = GetLastError(); + } + else { + bWriteSuccess = FALSE; + *pbCancelDataLoss = TRUE; + } + + GlobalFree(lpData); + } + + else { + SetEndOfFile(hFile); + bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); + dwLastIOError = GetLastError(); + GlobalFree(lpData); + } + } + + CloseHandle(hFile); + + if (bWriteSuccess) + { + if (!bSaveCopy) + SendMessage(hwnd,SCI_SETSAVEPOINT,0,0); + + return TRUE; + } + + else + return FALSE; + +} + + +//============================================================================= +// +// EditInvertCase() +// +void EditInvertCase(HWND hwnd) +{ + int cchTextW; + int iCurPos; + int iAnchorPos; + UINT cpEdit; + int i; + BOOL bChanged = FALSE; + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); + LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + + if (pszText == NULL || pszTextW == NULL) { + GlobalFree(pszText); + GlobalFree(pszTextW); + return; + } + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + + for (i = 0; i < cchTextW; i++) { + if (IsCharUpperW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + else if (IsCharLowerW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + + if (bChanged) { + + WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_CLEAR,0,0); + SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + } + + GlobalFree(pszText); + GlobalFree(pszTextW); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditTitleCase() +// +void EditTitleCase(HWND hwnd) +{ + int cchTextW; + int iCurPos; + int iAnchorPos; + UINT cpEdit; + int i; + BOOL bNewWord = TRUE; + BOOL bWordEnd = TRUE; + BOOL bChanged = FALSE; + +#ifdef BOOKMARK_EDITION + BOOL bPrevWasSpace = FALSE; +#endif + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); + LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + + if (pszText == NULL || pszTextW == NULL) { + GlobalFree(pszText); + GlobalFree(pszTextW); + return; + } + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + + if (IsW7()) { + + LPWSTR pszMappedW = LocalAlloc(LPTR,LocalSize(pszTextW)); + + if (LCMapString( + LOCALE_SYSTEM_DEFAULT,LCMAP_LINGUISTIC_CASING|/*LCMAP_TITLECASE*/0x00000300, + pszTextW,cchTextW,pszMappedW,(int)LocalSize(pszMappedW)/sizeof(WCHAR))) { + + StrCpyN(pszTextW,pszMappedW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + bChanged = TRUE; + } + else + bChanged = FALSE; + + LocalFree(pszMappedW); + } + + else { + + +#ifdef BOOKMARK_EDITION + //Slightly enhanced function to make Title Case: Added some '-characters and bPrevWasSpace makes it better (for example "'Don't'" will now work) + bPrevWasSpace = TRUE; + for (i = 0; i < cchTextW; i++) + { + if (!IsCharAlphaNumericW(pszTextW[i]) && (!StrChr(L"'`΄’",pszTextW[i]) || bPrevWasSpace ) ) + { + bNewWord = TRUE; + } + else + { + if (bNewWord) + { + if (IsCharLowerW(pszTextW[i])) + { + pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + else + { + if (IsCharUpperW(pszTextW[i])) + { + pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + bNewWord = FALSE; + } + if( StrChr(L" \r\n\t[](){}",pszTextW[i]) ) bPrevWasSpace = TRUE; else bPrevWasSpace = FALSE; + } +#else + + for (i = 0; i < cchTextW; i++) { + BOOL bAlphaNumeric = IsCharAlphaNumericW(pszTextW[i]); + if (!bAlphaNumeric && (!StrChr(L"\x0027\x2019\x0060\x00B4",pszTextW[i]) || bWordEnd)) { + bNewWord = TRUE; + } + else { + if (bNewWord) { + if (IsCharLowerW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + else { + if (IsCharUpperW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + bNewWord = FALSE; + } + bWordEnd = !bAlphaNumeric; + } +#endif + } + + if (bChanged) { + + WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_CLEAR,0,0); + SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + } + + GlobalFree(pszText); + GlobalFree(pszTextW); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditSentenceCase() +// +void EditSentenceCase(HWND hwnd) +{ + int cchTextW; + int iCurPos; + int iAnchorPos; + UINT cpEdit; + int i; + BOOL bNewSentence = TRUE; + BOOL bChanged = FALSE; + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + char* pszText = GlobalAlloc(GPTR,(iSelCount)+2); + LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + + if (pszText == NULL || pszTextW == NULL) { + GlobalFree(pszText); + GlobalFree(pszTextW); + return; + } + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + + for (i = 0; i < cchTextW; i++) { + if (StrChr(L".;!?\r\n",pszTextW[i])) { + bNewSentence = TRUE; + } + else { + if (IsCharAlphaNumericW(pszTextW[i])) { + if (bNewSentence) { + if (IsCharLowerW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharUpperW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + bNewSentence = FALSE; + } + else { + if (IsCharUpperW(pszTextW[i])) { + pszTextW[i] = LOWORD(CharLowerW((LPWSTR)(LONG_PTR)MAKELONG(pszTextW[i],0))); + bChanged = TRUE; + } + } + } + } + } + + if (bChanged) { + + WideCharToMultiByte(cpEdit,0,pszTextW,cchTextW,pszText,(int)GlobalSize(pszText),NULL,NULL); + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_CLEAR,0,0); + SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)iSelCount,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + + GlobalFree(pszText); + GlobalFree(pszTextW); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditURLEncode() +// +void EditURLEncode(HWND hwnd) +{ + int cchTextW; + int iCurPos; + int iAnchorPos; + UINT cpEdit; + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + char* pszText; + LPWSTR pszTextW; + + DWORD cchEscaped; + char* pszEscaped; + DWORD cchEscapedW; + LPWSTR pszEscapedW; + + pszText = LocalAlloc(LPTR,(iSelCount)+2); + if (pszText == NULL) { + return; + } + + pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2); + if (pszTextW == NULL) { + LocalFree(pszText); + return; + } + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)LocalSize(pszTextW)/sizeof(WCHAR)); + + pszEscaped = LocalAlloc(LPTR,LocalSize(pszText) * 3); + if (pszEscaped == NULL) { + LocalFree(pszText); + LocalFree(pszTextW); + return; + } + + pszEscapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3); + if (pszEscapedW == NULL) { + LocalFree(pszText); + LocalFree(pszTextW); + LocalFree(pszEscaped); + return; + } + + cchEscapedW = (int)LocalSize(pszEscapedW) / sizeof(WCHAR); + UrlEscape(pszTextW,pszEscapedW,&cchEscapedW,URL_ESCAPE_SEGMENT_ONLY); + + cchEscaped = WideCharToMultiByte(cpEdit,0,pszEscapedW,cchEscapedW,pszEscaped,(int)LocalSize(pszEscaped),NULL,NULL); + + if (iCurPos < iAnchorPos) + iAnchorPos = iCurPos + cchEscaped; + else + iCurPos = iAnchorPos + cchEscaped; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_CLEAR,0,0); + SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchEscaped,(LPARAM)pszEscaped); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + LocalFree(pszText); + LocalFree(pszTextW); + LocalFree(pszEscaped); + LocalFree(pszEscapedW); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditURLDecode() +// +void EditURLDecode(HWND hwnd) +{ + int cchTextW; + int iCurPos; + int iAnchorPos; + UINT cpEdit; + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos != iAnchorPos) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelCount = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + + char* pszText; + LPWSTR pszTextW; + + DWORD cchUnescaped; + char* pszUnescaped; + DWORD cchUnescapedW; + LPWSTR pszUnescapedW; + + pszText = LocalAlloc(LPTR,(iSelCount)+2); + if (pszText == NULL) { + return; + } + + pszTextW = LocalAlloc(LPTR,(iSelCount*2)+2); + if (pszTextW == NULL) { + LocalFree(pszText); + return; + } + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)LocalSize(pszTextW)/sizeof(WCHAR)); + + pszUnescaped = LocalAlloc(LPTR,LocalSize(pszText) * 3); + if (pszUnescaped == NULL) { + LocalFree(pszText); + LocalFree(pszTextW); + return; + } + + pszUnescapedW = LocalAlloc(LPTR,LocalSize(pszTextW) * 3); + if (pszUnescapedW == NULL) { + LocalFree(pszText); + LocalFree(pszTextW); + LocalFree(pszUnescaped); + return; + } + + cchUnescapedW = (int)LocalSize(pszUnescapedW) / sizeof(WCHAR); + UrlUnescape(pszTextW,pszUnescapedW,&cchUnescapedW,0); + + cchUnescaped = WideCharToMultiByte(cpEdit,0,pszUnescapedW,cchUnescapedW,pszUnescaped,(int)LocalSize(pszUnescaped),NULL,NULL); + + if (iCurPos < iAnchorPos) + iAnchorPos = iCurPos + cchUnescaped; + else + iCurPos = iAnchorPos + cchUnescaped; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_CLEAR,0,0); + SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchUnescaped,(LPARAM)pszUnescaped); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + LocalFree(pszText); + LocalFree(pszTextW); + LocalFree(pszUnescaped); + LocalFree(pszUnescapedW); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditEscapeCChars() +// +void EditEscapeCChars(HWND hwnd) { + + if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd }; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + lstrcpyA(efr.szFind,"\\"); + lstrcpyA(efr.szReplace,"\\\\"); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + lstrcpyA(efr.szFind,"\""); + lstrcpyA(efr.szReplace,"\\\""); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + lstrcpyA(efr.szFind,"\'"); + lstrcpyA(efr.szReplace,"\\\'"); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditUnescapeCChars() +// +void EditUnescapeCChars(HWND hwnd) { + + if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + EDITFINDREPLACE efr = { "", "", "", "", 0, 0, 0, 0, 0, 0, hwnd }; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + lstrcpyA(efr.szFind,"\\\\"); + lstrcpyA(efr.szReplace,"\\"); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + lstrcpyA(efr.szFind,"\\\""); + lstrcpyA(efr.szReplace,"\""); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + lstrcpyA(efr.szFind,"\\\'"); + lstrcpyA(efr.szReplace,"\'"); + EditReplaceAllInSelection(hwnd,&efr,FALSE); + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } +} + + +//============================================================================= +// +// EditChar2Hex() +// +void EditChar2Hex(HWND hwnd) { + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0) == + SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0) && + iSelEnd == (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iSelStart,0)) { + + char ch[32]; + WCHAR wch[32]; + UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch); + + if (ch[0] == 0) + lstrcpyA(ch,"\\x00"); + + else { + MultiByteToWideChar(cp,0,ch,-1,wch,COUNTOF(wch)); + if (wch[0] <= 0xFF) + wsprintfA(ch,"\\x%02X",wch[0] & 0xFF); + else + wsprintfA(ch,"\\u%04X",wch[0]); + } + + SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)ch); + SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(ch)); + } + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditHex2Char() +// +void EditHex2Char(HWND hwnd) { + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + char ch[32]; + int i; + BOOL bTrySelExpand = FALSE; + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (iSelEnd - iSelStart) { + + if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(ch)) { + + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch); + + if (StrChrIA(ch,' ') || StrChrIA(ch,'\t') || StrChrIA(ch,'\r') || StrChrIA(ch,'\n') || StrChrIA(ch,'-')) + return; + + if (StrCmpNIA(ch,"\\x",2) == 0 || StrCmpNIA(ch,"\\u",2) == 0) { + ch[0] = '0'; + ch[1] = 'x'; + } + + else if (StrChrIA("xu",ch[0])) { + ch[0] = '0'; + bTrySelExpand = TRUE; + } + + if (sscanf(ch,"%x",&i) == 1) { + int cch; + if (i == 0) { + ch[0] = 0; + cch = 1; + } + else { + UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + WCHAR wch[4]; + wsprintf(wch,L"%lc",(WCHAR)i); + cch = WideCharToMultiByte(cp,0,wch,-1,ch,COUNTOF(ch),NULL,NULL) - 1; + if (bTrySelExpand && (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iSelStart-1,0) == '\\') { + iSelStart--; + } + } + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cch,(LPARAM)ch); + SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+cch); + } + } + } + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditModifyNumber() +// +void EditModifyNumber(HWND hwnd,BOOL bIncrease) { + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (iSelEnd - iSelStart) { + + char chFormat[32] = ""; + char chNumber[32]; + int iNumber; + int iWidth; + + if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(chNumber)) { + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)chNumber); + + if (StrChrIA(chNumber,'-')) + return; + + if (!StrChrIA(chNumber,'x') && sscanf(chNumber,"%d",&iNumber) == 1) { + iWidth = lstrlenA(chNumber); + if (iNumber >= 0) { + if (bIncrease && iNumber < INT_MAX) + iNumber++; + if (!bIncrease && iNumber > 0) + iNumber--; + wsprintfA(chFormat,"%%0%ii",iWidth); + wsprintfA(chNumber,chFormat,iNumber); + SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber); + SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber)); + } + } + else if (sscanf(chNumber,"%x",&iNumber) == 1) { + int i; + BOOL bUppercase = FALSE; + iWidth = lstrlenA(chNumber) - 2; + if (iNumber >= 0) { + if (bIncrease && iNumber < INT_MAX) + iNumber++; + if (!bIncrease && iNumber > 0) + iNumber--; + for (i = lstrlenA(chNumber) -1 ; i >= 0; i--) { + if (IsCharLowerA(chNumber[i])) + break; + else if (IsCharUpper(chNumber[i])) { + bUppercase = TRUE; + break; + } + } + if (bUppercase) + wsprintfA(chFormat,"%%#0%iX",iWidth); + else + wsprintfA(chFormat,"%%#0%ix",iWidth); + wsprintfA(chNumber,chFormat,iNumber); + SendMessage(hwnd,SCI_REPLACESEL,0,(LPARAM)chNumber); + SendMessage(hwnd,SCI_SETSEL,iSelStart,iSelStart+lstrlenA(chNumber)); + } + } + } + } + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditTabsToSpaces() +// +void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) +{ + char* pszText; + LPWSTR pszTextW; + int cchTextW; + int iTextW; + LPWSTR pszConvW; + int cchConvW; + int cchConvM; + int i,j; + int iLine; + int iCurPos; + int iAnchorPos; + int iSelStart; + int iSelEnd; + int iSelCount; + UINT cpEdit; + struct Sci_TextRange tr; + BOOL bIsLineStart = TRUE; + BOOL bModified = FALSE; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + MsgBox(MBWARN,IDS_SELRECT); + return; + } + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos) /*{ + iSelStart = 0; + iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); + }*/ + return; + + else { + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + } + + iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + + iSelCount = iSelEnd - iSelStart; + + pszText = GlobalAlloc(GPTR,(iSelCount)+2); + if (pszText == NULL) + return; + + pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + if (pszTextW == NULL) { + GlobalFree(pszText); + return; + } + + tr.chrg.cpMin = iSelStart; + tr.chrg.cpMax = iSelEnd; + tr.lpstrText = pszText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + GlobalFree(pszText); + + pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*nTabWidth+2); + if (pszConvW == NULL) { + GlobalFree(pszTextW); + return; + } + + cchConvW = 0; + + // Contributed by Homam + // Thank you very much! + i=0; + for (iTextW = 0; iTextW < cchTextW; iTextW++) + { + WCHAR w = pszTextW[iTextW]; + if (w == L'\t' && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { + for (j = 0; j < nTabWidth - i % nTabWidth; j++) + pszConvW[cchConvW++] = L' '; + i = 0; + bModified = TRUE; + } + else { + i++; + if (w == L'\n' || w == L'\r') { + i = 0; + bIsLineStart = TRUE; + } + else if (w != L' ') + bIsLineStart = FALSE; + pszConvW[cchConvW++] = w; + } + } + + GlobalFree(pszTextW); + + if (bModified) { + pszText = GlobalAlloc(GPTR,cchConvW * 3); + + cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); + GlobalFree(pszConvW); + + if (iAnchorPos > iCurPos) { + iCurPos = iSelStart; + iAnchorPos = iSelStart + cchConvM; + } + else { + iAnchorPos = iSelStart; + iCurPos = iSelStart + cchConvM; + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); + //SendMessage(hwnd,SCI_CLEAR,0,0); + //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + GlobalFree(pszText); + } + + else + GlobalFree(pszConvW); +} + + +//============================================================================= +// +// EditSpacesToTabs() +// +void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) +{ + char* pszText; + LPWSTR pszTextW; + int cchTextW; + int iTextW; + LPWSTR pszConvW; + int cchConvW; + int cchConvM; + int i,j,t; + int iLine; + int iCurPos; + int iAnchorPos; + int iSelStart; + int iSelEnd; + int iSelCount; + UINT cpEdit; + struct Sci_TextRange tr; + WCHAR space[256]; + BOOL bIsLineStart = TRUE; + BOOL bModified = FALSE; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + MsgBox(MBWARN,IDS_SELRECT); + return; + } + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos) /*{ + iSelStart = 0; + iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); + }*/ + return; + + else { + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + } + + iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + + iSelCount = iSelEnd - iSelStart; + + pszText = GlobalAlloc(GPTR,(iSelCount)+2); + if (pszText == NULL) + return; + + pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + if (pszTextW == NULL) { + GlobalFree(pszText); + return; + } + + tr.chrg.cpMin = iSelStart; + tr.chrg.cpMax = iSelEnd; + tr.lpstrText = pszText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + GlobalFree(pszText); + + pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)+2); + if (pszConvW == NULL) { + GlobalFree(pszTextW); + return; + } + + cchConvW = 0; + + // Contributed by Homam + // Thank you very much! + i = j = 0; + for (iTextW = 0; iTextW < cchTextW; iTextW++) + { + WCHAR w = pszTextW[iTextW]; + if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { + space[j++] = w; + if (j == nTabWidth - i % nTabWidth || w == L'\t') { + if (j > 1 || pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') + pszConvW[cchConvW++] = L'\t'; + else + pszConvW[cchConvW++] = w; + i = j = 0; + bModified = bModified || (w != pszConvW[cchConvW-1]); + } + } + else { + i += j + 1; + if (j > 0) { + //space[j] = '\0'; + for (t = 0; t < j; t++) + pszConvW[cchConvW++] = space[t]; + j = 0; + } + if (w == L'\n' || w == L'\r') { + i = 0; + bIsLineStart = TRUE; + } + else + bIsLineStart = FALSE; + pszConvW[cchConvW++] = w; + } + } + if (j > 0) { + for (t = 0; t < j; t++) + pszConvW[cchConvW++] = space[t]; + } + + GlobalFree(pszTextW); + + if (bModified || cchConvW != cchTextW) { + pszText = GlobalAlloc(GPTR,cchConvW * 3); + + cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); + GlobalFree(pszConvW); + + if (iAnchorPos > iCurPos) { + iCurPos = iSelStart; + iAnchorPos = iSelStart + cchConvM; + } + else { + iAnchorPos = iSelStart; + iCurPos = iSelStart + cchConvM; + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); + //SendMessage(hwnd,SCI_CLEAR,0,0); + //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + GlobalFree(pszText); + } + + else + GlobalFree(pszConvW); +} + + +//============================================================================= +// +// EditMoveUp() +// +void EditMoveUp(HWND hwnd) +{ + + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + int iCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); + + if (iCurLine == iAnchorLine) { + + int iLineCurPos = iCurPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0); + int iLineAnchorPos = iAnchorPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0); + if (iCurLine > 0) { + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_LINETRANSPOSE,0,0); + SendMessage(hwnd,SCI_SETSEL, + (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0)+iLineAnchorPos, + (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0)+iLineCurPos); + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + } + else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + int iLineSrc = min(iCurLine,iAnchorLine) -1; + if (iLineSrc >= 0) { + + DWORD cLine; + char *pLine; + int iLineSrcStart; + int iLineSrcEnd; + int iLineDest; + int iLineDestStart; + + cLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0); + pLine = LocalAlloc(LPTR,cLine+1); + SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine); + + iLineSrcStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0); + iLineSrcEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); + + iLineDest = max(iCurLine,iAnchorLine); + if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0)) { + if (iLineDest >= 1) + iLineDest--; + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + + iLineDestStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); + + SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine); + + LocalFree(pLine); + + if (iLineDest == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) { + + char chaEOL[] = "\r\n"; + int iEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + if (iEOLMode == SC_EOL_CR) + chaEOL[1] = 0; + else if (iEOLMode == SC_EOL_LF) { + chaEOL[0] = '\n'; + chaEOL[1] = 0; + } + + SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)chaEOL); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) + SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineDest,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) + SendMessage(hwnd,SCI_GETLENGTH,0,0),0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + + if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine-1,0); + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditMoveDown() +// +void EditMoveDown(HWND hwnd) +{ + + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + int iCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); + + if (iCurLine == iAnchorLine) { + + int iLineCurPos = iCurPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine,0); + int iLineAnchorPos = iAnchorPos - (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine,0); + if (iCurLine < SendMessage(hwnd,SCI_GETLINECOUNT,0,0) - 1) { + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_GOTOLINE,(WPARAM)iCurLine+1,0); + SendMessage(hwnd,SCI_LINETRANSPOSE,0,0); + SendMessage(hwnd,SCI_SETSEL, + (WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0)+iLineAnchorPos, + (LPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0)+iLineCurPos); + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + } + else if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + int iLineSrc = max(iCurLine,iAnchorLine) +1; + if (max(iCurPos,iAnchorPos) <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0)) { + if (iLineSrc >= 1) + iLineSrc--; + } + + if (iLineSrc <= SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1) { + + DWORD cLine; + char *pLine; + int iLineSrcStart; + int iLineSrcEnd; + int iLineDest; + int iLineDestStart; + + BOOL bLastLine = (iLineSrc == SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1); + + if (bLastLine && + (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc,0) - + SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0) == 0) && + (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineSrc-1,0) - + SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc-1,0) == 0)) + return; + + if (bLastLine) { + char chaEOL[] = "\r\n"; + int iEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + if (iEOLMode == SC_EOL_CR) + chaEOL[1] = 0; + else if (iEOLMode == SC_EOL_LF) { + chaEOL[0] = '\n'; + chaEOL[1] = 0; + } + SendMessage(hwnd,SCI_APPENDTEXT,(WPARAM)lstrlenA(chaEOL),(LPARAM)chaEOL); + } + + cLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,0); + pLine = LocalAlloc(LPTR,cLine+3); + SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLineSrc,(LPARAM)pLine); + + iLineSrcStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc,0); + iLineSrcEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); + + iLineDest = min(iCurLine,iAnchorLine); + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iLineSrcStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLineSrcEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + + iLineDestStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineDest,0); + + SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)pLine); + + if (bLastLine) { + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) + SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM) + SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-2,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) + SendMessage(hwnd,SCI_GETLENGTH,0,0),0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + + LocalFree(pLine); + + if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iCurLine+1,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iAnchorLine+1,0); + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineSrc+1,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditModifyLines() +// +void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend) +{ + char mszPrefix1[256*3] = ""; + char mszPrefix2[256*3] = ""; + BOOL bPrefixNum = FALSE; + int iPrefixNum = 0; + int iPrefixNumWidth = 1; + char *pszPrefixNumPad = ""; + char mszAppend1[256*3] = ""; + char mszAppend2[256*3] = ""; + BOOL bAppendNum = FALSE; + int iAppendNum = 0; + int iAppendNumWidth = 1; + char *pszAppendNumPad = ""; + int mbcp; + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + //if (iSelStart == iSelEnd) { + // iSelStart = 0; + // iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); + //} + + if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) + mbcp = CP_UTF8; + else + mbcp = CP_ACP; + + if (lstrlen(pwszPrefix)) + WideCharToMultiByte(mbcp,0,pwszPrefix,-1,mszPrefix1,COUNTOF(mszPrefix1),NULL,NULL); + if (lstrlen(pwszAppend)) + WideCharToMultiByte(mbcp,0,pwszAppend,-1,mszAppend1,COUNTOF(mszAppend1),NULL,NULL); + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + char *p; + int i; + + int iLine; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + //if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) + // iLineStart++; + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) + { + if (iLineEnd - iLineStart >= 1) + iLineEnd--; + } + + if (lstrlenA(mszPrefix1)) { + + p = mszPrefix1; + while (!bPrefixNum && (p = StrStrA(p,"$("))) { + + if (StrCmpNA(p,"$(I)",CSTRLEN("$(I)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(I)")); + bPrefixNum = TRUE; + iPrefixNum = 0; + for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = ""; + } + + else if (StrCmpNA(p,"$(0I)",CSTRLEN("$(0I)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(0I)")); + bPrefixNum = TRUE; + iPrefixNum = 0; + for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = "0"; + } + + else if (StrCmpNA(p,"$(N)",CSTRLEN("$(N)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(N)")); + bPrefixNum = TRUE; + iPrefixNum = 1; + for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = ""; + } + + else if (StrCmpNA(p,"$(0N)",CSTRLEN("$(0N)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(0N)")); + bPrefixNum = TRUE; + iPrefixNum = 1; + for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = "0"; + } + + else if (StrCmpNA(p,"$(L)",CSTRLEN("$(L)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(L)")); + bPrefixNum = TRUE; + iPrefixNum = iLineStart+1; + for (i = iLineEnd + 1; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = ""; + } + + else if (StrCmpNA(p,"$(0L)",CSTRLEN("$(0L)")) == 0) { + *p = 0; + StrCpyA(mszPrefix2,p+CSTRLEN("$(0L)")); + bPrefixNum = TRUE; + iPrefixNum = iLineStart+1; + for (i = iLineEnd + 1; i >= 10; i = i / 10) + iPrefixNumWidth++; + pszPrefixNumPad = "0"; + } + p += CSTRLEN("$("); + } + } + + if (lstrlenA(mszAppend1)) { + + p = mszAppend1; + while (!bAppendNum && (p = StrStrA(p,"$("))) { + + if (StrCmpNA(p,"$(I)",CSTRLEN("$(I)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(I)")); + bAppendNum = TRUE; + iAppendNum = 0; + for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = ""; + } + + else if (StrCmpNA(p,"$(0I)",CSTRLEN("$(0I)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(0I)")); + bAppendNum = TRUE; + iAppendNum = 0; + for (i = iLineEnd - iLineStart; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = "0"; + } + + else if (StrCmpNA(p,"$(N)",CSTRLEN("$(N)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(N)")); + bAppendNum = TRUE; + iAppendNum = 1; + for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = ""; + } + + else if (StrCmpNA(p,"$(0N)",CSTRLEN("$(0N)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(0N)")); + bAppendNum = TRUE; + iAppendNum = 1; + for (i = iLineEnd - iLineStart + 1; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = "0"; + } + + else if (StrCmpNA(p,"$(L)",CSTRLEN("$(L)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(L)")); + bAppendNum = TRUE; + iAppendNum = iLineStart+1; + for (i = iLineEnd + 1; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = ""; + } + + else if (StrCmpNA(p,"$(0L)",CSTRLEN("$(0L)")) == 0) { + *p = 0; + StrCpyA(mszAppend2,p+CSTRLEN("$(0L)")); + bAppendNum = TRUE; + iAppendNum = iLineStart+1; + for (i = iLineEnd + 1; i >= 10; i = i / 10) + iAppendNumWidth++; + pszAppendNumPad = "0"; + } + p += CSTRLEN("$("); + } + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) + { + int iPos; + + if (lstrlen(pwszPrefix)) { + + char mszInsert[512*3]; + lstrcpyA(mszInsert,mszPrefix1); + + if (bPrefixNum) { + char tchFmt[64]; + char tchNum[64]; + wsprintfA(tchFmt,"%%%s%ii",pszPrefixNumPad,iPrefixNumWidth); + wsprintfA(tchNum,tchFmt,iPrefixNum); + lstrcatA(mszInsert,tchNum); + lstrcatA(mszInsert,mszPrefix2); + iPrefixNum++; + } + iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszInsert),(LPARAM)mszInsert); + } + + if (lstrlen(pwszAppend)) { + + char mszInsert[512*3]; + lstrcpyA(mszInsert,mszAppend1); + + if (bAppendNum) { + char tchFmt[64]; + char tchNum[64]; + wsprintfA(tchFmt,"%%%s%ii",pszAppendNumPad,iAppendNumWidth); + wsprintfA(tchNum,tchFmt,iAppendNum); + lstrcatA(mszInsert,tchNum); + lstrcatA(mszInsert,mszAppend2); + iAppendNum++; + } + iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszInsert),(LPARAM)mszInsert); + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + //// Fix selection + //if (iSelStart != iSelEnd && SendMessage(hwnd,SCI_GETTARGETEND,0,0) > SendMessage(hwnd,SCI_GETSELECTIONEND,0,0)) + //{ + // int iCurPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + // int iAnchorPos = SendMessage(hwnd,SCI_GETANCHOR,0,0); + // if (iCurPos > iAnchorPos) + // iCurPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0); + // else + // iAnchorPos = SendMessage(hwnd,SCI_GETTARGETEND,0,0); + // SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + //} + + // extend selection to start of first line + // the above code is not required when last line has been excluded + if (iSelStart != iSelEnd) + { + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditAlignText() +// +void EditAlignText(HWND hwnd,int nMode) +{ + #define BUFSIZE_ALIGN 1024 + + int mbcp; + BOOL bModified = FALSE; + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) + mbcp = CP_UTF8; + else + mbcp = CP_ACP; + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iLine; + int iMinIndent = BUFSIZE_ALIGN; + int iMaxLength = 0; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) + { + if (iLineEnd - iLineStart >= 1) + iLineEnd--; + } + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + + int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + + if (iLineIndentPos != iLineEndPos) { + + int iIndentCol = (int)SendMessage(hwnd,SCI_GETLINEINDENTATION,(WPARAM)iLine,0); + int iEndCol; + char ch; + int iTail; + + iTail = iLineEndPos-1; + ch = (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iTail,0); + while (iTail >= iLineStart && (ch == ' ' || ch == '\t')) + { + iTail--; + ch = (char)SendMessage(hwnd,SCI_GETCHARAT,(WPARAM)iTail,0); + iLineEndPos--; + } + iEndCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iLineEndPos,0); + + iMinIndent = min(iMinIndent,iIndentCol); + iMaxLength = max(iMaxLength,iEndCol); + } + } + + if (iMaxLength < BUFSIZE_ALIGN) { + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) + { + int iIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + int iEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + + if (iIndentPos == iEndPos && iEndPos > 0) { + + if (!bModified) { + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + bModified = TRUE; + } + + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iEndPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + + else { + + char tchLineBuf[BUFSIZE_ALIGN*3] = ""; + WCHAR wchLineBuf[BUFSIZE_ALIGN*3] = L""; + WCHAR *pWords[BUFSIZE_ALIGN*3/2]; + WCHAR *p = wchLineBuf; + + int iWords = 0; + int iWordsLength = 0; + int cchLine = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,(LPARAM)tchLineBuf); + + if (!bModified) { + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + bModified = TRUE; + } + + MultiByteToWideChar(mbcp,0,tchLineBuf,cchLine,wchLineBuf,COUNTOF(wchLineBuf)); + StrTrim(wchLineBuf,L"\r\n\t "); + + while (*p) { + if (*p != L' ' && *p != L'\t') { + pWords[iWords++] = p++; + iWordsLength++; + while (*p && *p != L' ' && *p != L'\t') { + p++; + iWordsLength++; + } + } + else + *p++ = 0; + } + + if (iWords > 0) { + + if (nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) { + + BOOL bNextLineIsBlank = FALSE; + if (nMode == ALIGN_JUSTIFY_EX) { + + if (SendMessage(hwnd,SCI_GETLINECOUNT,0,0) <= iLine+1) + bNextLineIsBlank = TRUE; + + else { + + int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine+1,0); + int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine+1,0); + + if (iLineIndentPos == iLineEndPos) + bNextLineIsBlank = TRUE; + } + } + + if ((nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) && + iWords > 1 && iWordsLength >= 2 && + ((nMode != ALIGN_JUSTIFY_EX || !bNextLineIsBlank || iLineStart == iLineEnd) || + (bNextLineIsBlank && iWordsLength > (iMaxLength - iMinIndent) * 0.75))) { + + int iGaps = iWords - 1; + int iSpacesPerGap = (iMaxLength - iMinIndent - iWordsLength) / iGaps; + int iExtraSpaces = (iMaxLength - iMinIndent - iWordsLength) % iGaps; + int i,j; + int iPos; + + WCHAR wchNewLineBuf[BUFSIZE_ALIGN*3]; + StrCpy(wchNewLineBuf,pWords[0]); + p = StrEnd(wchNewLineBuf); + + for (i = 1; i < iWords; i++) { + for (j = 0; j < iSpacesPerGap; j++) { + *p++ = L' '; + *p = 0; + } + if (i > iGaps - iExtraSpaces) { + *p++ = L' '; + *p = 0; + } + StrCat(p,pWords[i]); + p = StrEnd(p); + } + + WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); + + iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); + + SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); + } + else { + + int i; + int iPos; + + WCHAR wchNewLineBuf[BUFSIZE_ALIGN]; + StrCpy(wchNewLineBuf,pWords[0]); + p = StrEnd(wchNewLineBuf); + + for (i = 1; i < iWords; i++) { + *p++ = L' '; + *p = 0; + StrCat(wchNewLineBuf,pWords[i]); + p = StrEnd(p); + } + + WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); + + iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); + + SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); + } + } + else { + + int iExtraSpaces = iMaxLength - iMinIndent - iWordsLength - iWords + 1; + int iOddSpaces = iExtraSpaces % 2; + int i; + int iPos; + + WCHAR wchNewLineBuf[BUFSIZE_ALIGN*3] = L""; + p = wchNewLineBuf; + + if (nMode == ALIGN_RIGHT) { + for (i = 0; i < iExtraSpaces; i++) + *p++ = L' '; + *p = 0; + } + if (nMode == ALIGN_CENTER) { + for (i = 1; i < iExtraSpaces - iOddSpaces; i+=2) + *p++ = L' '; + *p = 0; + } + for (i = 0; i < iWords; i++) { + StrCat(p,pWords[i]); + if (i < iWords-1) + StrCat(p,L" "); + if (nMode == ALIGN_CENTER && iWords > 1 && iOddSpaces > 0 && i + 1 >= iWords / 2) { + StrCat(p,L" "); + iOddSpaces--; + } + p = StrEnd(p); + } + + WideCharToMultiByte(mbcp,0,wchNewLineBuf,-1,tchLineBuf,COUNTOF(tchLineBuf),NULL,NULL); + + if (nMode == ALIGN_RIGHT || nMode == ALIGN_CENTER) { + SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); + iPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + } + else + iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(tchLineBuf),(LPARAM)tchLineBuf); + + if (nMode == ALIGN_LEFT) + SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent); + } + } + } + } + if (bModified) + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBINFO,IDS_BUFFERTOOSMALL); + + if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditEncloseSelection() +// +void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose) +{ + char mszOpen[256*3] = ""; + char mszClose[256*3] = ""; + int mbcp; + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) + mbcp = CP_UTF8; + else + mbcp = CP_ACP; + + if (lstrlen(pwszOpen)) + WideCharToMultiByte(mbcp,0,pwszOpen,-1,mszOpen,COUNTOF(mszOpen),NULL,NULL); + if (lstrlen(pwszClose)) + WideCharToMultiByte(mbcp,0,pwszClose,-1,mszClose,COUNTOF(mszClose),NULL,NULL); + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + if (lstrlenA(mszOpen)) { + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszOpen),(LPARAM)mszOpen); + } + + if (lstrlenA(mszClose)) { + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelEnd + lstrlenA(mszOpen),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd + lstrlenA(mszOpen),0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(mszClose),(LPARAM)mszClose); + } + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + // Fix selection + if (iSelStart == iSelEnd) + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iSelStart + lstrlenA(mszOpen),(WPARAM)iSelStart + lstrlenA(mszOpen)); + + else { + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + if (iCurPos < iAnchorPos) { + iCurPos = iSelStart + lstrlenA(mszOpen); + iAnchorPos = iSelEnd + lstrlenA(mszOpen); + } + else { + iAnchorPos = iSelStart + lstrlenA(mszOpen); + iCurPos = iSelEnd + lstrlenA(mszOpen); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditToggleLineComments() +// +void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart) +{ + char mszComment[256*3] = ""; + int cchComment; + int mbcp; + int iAction = 0; + + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + + if (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) + mbcp = CP_UTF8; + else + mbcp = CP_ACP; + + if (lstrlen(pwszComment)) + WideCharToMultiByte(mbcp,0,pwszComment,-1,mszComment,COUNTOF(mszComment),NULL,NULL); + cchComment = lstrlenA(mszComment); + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0) && cchComment) + { + int iLine; + int iCommentCol = 0; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) + { + if (iLineEnd - iLineStart >= 1) + iLineEnd--; + } + + if (!bInsertAtStart) { + iCommentCol = 1024; + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + int iLineIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + if (iLineIndentPos != iLineEndPos) { + int iIndentColumn = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iLineIndentPos,0); + iCommentCol = min(iCommentCol,iIndentColumn); + } + } + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) + { + int iCommentPos; + int iIndentPos = (int)SendMessage(hwnd,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + char tchBuf[32]; + struct Sci_TextRange tr; + + if (iIndentPos == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0)) + continue; + + tr.chrg.cpMin = iIndentPos; + tr.chrg.cpMax = tr.chrg.cpMin + min(31,cchComment); + tr.lpstrText = tchBuf; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + if (StrCmpNIA(tchBuf,mszComment,cchComment) == 0) { + switch (iAction) { + case 0: + iAction = 2; + case 2: + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iIndentPos,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iIndentPos+cchComment,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + break; + case 1: + break; + } + } + else { + switch (iAction) { + case 0: + iAction = 1; + case 1: + iCommentPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iLine,(LPARAM)iCommentCol); + SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iCommentPos,(LPARAM)mszComment); + break; + case 2: + break; + } + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + if (iSelStart != iSelEnd) + { + int iAnchorPos; + if (iCurPos == iSelStart) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditPadWithSpaces() +// +void EditPadWithSpaces(HWND hwnd,BOOL bSkipEmpty,BOOL bNoUndoGroup) +{ + char *pmszPadStr; + int iMaxColumn = 0; + int iLine; + BOOL bIsRectangular = FALSE; + BOOL bReducedSelection = FALSE; + + int iSelStart; + int iSelEnd; + + int iLineStart; + int iLineEnd; + + int iRcCurLine; + int iRcAnchorLine; + int iRcCurCol; + int iRcAnchorCol; + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iLineStart == iLineEnd) { + iLineStart = 0; + iLineEnd = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1; + } + + else { + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) { + if (iLineEnd - iLineStart >= 1) { + iLineEnd--; + bReducedSelection = TRUE; + } + } + } + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + + int iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + iMaxColumn = max(iMaxColumn,(int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0)); + } + } + else { + + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + iRcCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + iRcAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); + + iRcCurCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0); + iRcAnchorCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0); + + bIsRectangular = TRUE; + + iLineStart = 0; + iLineEnd = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0) -1; + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + + int iPos = (int)SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0); + if (iPos != INVALID_POSITION) + iMaxColumn = max(iMaxColumn,(int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0)); + } + } + + pmszPadStr = LocalAlloc(LPTR,(iMaxColumn +1 )* sizeof(char)); + if (pmszPadStr) { + + FillMemory(pmszPadStr,LocalSize(pmszPadStr),' '); + + if (!bNoUndoGroup) + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + + int iPos; + int iPadLen; + int iLineSelEndPos; + + iLineSelEndPos = (int)SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0); + if (bIsRectangular && INVALID_POSITION == iLineSelEndPos) + continue; + + iPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + if (bIsRectangular && iPos > iLineSelEndPos) + continue; + if (bSkipEmpty && (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0) >= iPos) + continue; + + iPadLen = iMaxColumn - (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iPos,0); + + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)iPadLen,(LPARAM)pmszPadStr); + } + + if (pmszPadStr) + LocalFree(pmszPadStr); + + if (!bNoUndoGroup) + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + + if (!bIsRectangular && + SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0) != + SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0)) + { + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + if (!bReducedSelection) + iAnchorPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0); + else + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + else { + iAnchorPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0); + if (!bReducedSelection) + iCurPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0); + else + iCurPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0); + } + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + + else if (bIsRectangular) { + int iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcCurLine,(LPARAM)iRcCurCol); + int iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN,(WPARAM)iRcAnchorLine,(LPARAM)iRcAnchorCol); + SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONCARET,(WPARAM)iCurPos,0); + SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONANCHOR,(WPARAM)iAnchorPos,0); + } +} + + +//============================================================================= +// +// EditStripFirstCharacter() +// +void EditStripFirstCharacter(HWND hwnd) +{ + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (iSelStart == iSelEnd) { + iSelStart = 0; + iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + } + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iLine; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) + iLineStart++; + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) + iLineEnd--; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) + { + int iPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + if (SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0)- iPos > 0) + { + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iPos,0); + SendMessage(hwnd,SCI_SETTARGETEND, + (WPARAM)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iPos,0),0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditStripLastCharacter() +// +void EditStripLastCharacter(HWND hwnd) +{ + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (iSelStart == iSelEnd) { + iSelStart = 0; + iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + } + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iLine; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelStart >= SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineStart,0)) + iLineStart++; + + if (iSelEnd < SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0)) + iLineEnd--; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) + { + int iStartPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + int iEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + if (iEndPos - iStartPos > 0) + { + SendMessage(hwnd,SCI_SETTARGETSTART, + (WPARAM)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iEndPos,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iEndPos,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditStripTrailingBlanks() +// +void EditStripTrailingBlanks(HWND hwnd,BOOL bIgnoreSelection) +{ + // Check if there is any selection... simply use a regular expression replace! + if (!bIgnoreSelection && + (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) - SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) != 0)) + { + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + EDITFINDREPLACE efrTrim = { "[ \t]+$", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwnd }; + EditReplaceAllInSelection(hwnd,&efrTrim,FALSE); + } + else + MsgBox(MBWARN,IDS_SELRECT); + } + // Code from SciTE... + else + { + int line; + int maxLines; + int lineStart; + int lineEnd; + int i; + char ch; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + maxLines = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0); + for (line = 0; line < maxLines; line++) + { + lineStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,line,0); + lineEnd = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,line,0); + i = lineEnd-1; + ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0); + while ((i >= lineStart) && ((ch == ' ') || (ch == '\t'))) + { + i--; + ch = (char)SendMessage(hwnd,SCI_GETCHARAT,i,0); + } + if (i < (lineEnd-1)) + { + SendMessage(hwnd,SCI_SETTARGETSTART,i + 1,0); + SendMessage(hwnd,SCI_SETTARGETEND,lineEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } +} + + +//============================================================================= +// +// EditCompressSpaces() +// +void EditCompressSpaces(HWND hwnd) +{ + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + int iLength = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + char* pszIn; + char* pszOut; + BOOL bIsLineStart, bIsLineEnd; + BOOL bModified = FALSE; + + if (iSelStart != iSelEnd) { + int cch = (int)SendMessage(hwnd,SCI_GETSELTEXT,0,0); + pszIn = LocalAlloc(LPTR,cch); + pszOut = LocalAlloc(LPTR,cch); + SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszIn); + bIsLineStart = + (iSelStart == SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)); + bIsLineEnd = + (iSelEnd == SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineEnd,0)); + } + else { + int cch = iLength + 1; + pszIn = LocalAlloc(GPTR,cch); + pszOut = LocalAlloc(GPTR,cch); + SendMessage(hwnd,SCI_GETTEXT,(WPARAM)cch,(LPARAM)pszIn); + bIsLineStart = TRUE; + bIsLineEnd = TRUE; + } + + if (pszIn && pszOut) { + char *ci, *co = pszOut; + for (ci = pszIn; *ci; ci++) { + if (*ci == ' ' || *ci == '\t') { + if (*ci == '\t') + bModified = TRUE; + while (*(ci+1) == ' ' || *(ci+1) == '\t') { + ci++; + bModified = TRUE; + } + if (!bIsLineStart && (*(ci+1) != '\n' && *(ci+1) != '\r')) + *co++ = ' '; + else + bModified = TRUE; + } + else { + if (*ci == '\n' || *ci == '\r') + bIsLineStart = TRUE; + else + bIsLineStart = FALSE; + *co++ = *ci; + } + } + if (bIsLineEnd && co > pszOut && *(co-1) == ' ') { + *--co = 0; + bModified = TRUE; + } + + if (bModified) { + if (iSelStart != iSelEnd) + SendMessage(hwnd,SCI_TARGETFROMSELECTION,0,0); + else { + SendMessage(hwnd,SCI_SETTARGETSTART,0,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iLength,0); + } + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)-1,(LPARAM)pszOut); + if (iCurPos > iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + else if (iCurPos < iAnchorPos) { + iCurPos = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + } + if (pszIn) + LocalFree(pszIn); + if (pszOut) + LocalFree(pszOut); + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditRemoveBlankLines() +// +void EditRemoveBlankLines(HWND hwnd,BOOL bMerge) +{ + int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (iSelStart == iSelEnd) { + iSelStart = 0; + iSelEnd = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + } + + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + int iLine; + + int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelStart > SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0)) + iLineStart++; + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0) && + iLineEnd != SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-1) + iLineEnd--; + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + for (iLine = iLineStart; iLine <= iLineEnd; ) + { + int nBlanks = 0; + while (iLine + nBlanks <= iLineEnd && + SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine + nBlanks,0) == + SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine + nBlanks,0)) + nBlanks++; + + if (nBlanks == 0 || (nBlanks == 1 && bMerge)) + iLine += nBlanks + 1; + + else { + int iTargetStart; + int iTargetEnd; + + if (bMerge) + nBlanks--; + iTargetStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + iTargetEnd = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine + nBlanks,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iTargetStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iTargetEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); + if (bMerge) + iLine++; + iLineEnd -= nBlanks; + } + } + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + else + MsgBox(MBWARN,IDS_SELRECT); +} + + +//============================================================================= +// +// EditWrapToColumn() +// +void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/) +{ + char* pszText; + LPWSTR pszTextW; + int cchTextW; + int iTextW; + LPWSTR pszConvW; + int cchConvW; + int cchConvM; + int iLineLength; + int iLine; + int iCurPos; + int iAnchorPos; + int iSelStart; + int iSelEnd; + int iSelCount; + UINT cpEdit; + struct Sci_TextRange tr; + int cEOLMode; + WCHAR wszEOL[] = L"\r\n"; + int cchEOL = 2; + BOOL bModified = FALSE; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + MsgBox(MBWARN,IDS_SELRECT); + return; + } + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos) /*{ + iSelStart = 0; + iSelEnd = SendMessage(hwnd,SCI_GETLENGTH,0,0); + }*/ + return; + + else { + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + } + + iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + + iSelCount = iSelEnd - iSelStart; + + pszText = GlobalAlloc(GPTR,(iSelCount)+2); + if (pszText == NULL) + return; + + pszTextW = GlobalAlloc(GPTR,(iSelCount*2)+2); + if (pszTextW == NULL) { + GlobalFree(pszText); + return; + } + + tr.chrg.cpMin = iSelStart; + tr.chrg.cpMax = iSelEnd; + tr.lpstrText = pszText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + + cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + GlobalFree(pszText); + + pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*3+2); + if (pszConvW == NULL) { + GlobalFree(pszTextW); + return; + } + + cEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + if (cEOLMode == SC_EOL_CR) + cchEOL = 1; + else if (cEOLMode == SC_EOL_LF) { + cchEOL = 1; wszEOL[0] = L'\n'; + } + + cchConvW = 0; + iLineLength = 0; + +#define ISDELIMITER(wc) StrChr(L",;.:-+%&¦|/*?!\"\'~΄#=",wc) +#define ISWHITE(wc) StrChr(L" \t",wc) +#define ISWORDEND(wc) (/*ISDELIMITER(wc) ||*/ StrChr(L" \t\r\n",wc)) + + for (iTextW = 0; iTextW < cchTextW; iTextW++) + { + WCHAR w; + w = pszTextW[iTextW]; + + //if (ISDELIMITER(w)) + //{ + // int iNextWordLen = 0; + // WCHAR w2 = pszTextW[iTextW + 1]; + + // if (iLineLength + iNextWordLen + 1 > nColumn) { + // pszConvW[cchConvW++] = wszEOL[0]; + // if (cchEOL > 1) + // pszConvW[cchConvW++] = wszEOL[1]; + // iLineLength = 0; + // bModified = TRUE; + // } + + // while (w2 != L'\0' && !ISWORDEND(w2)) { + // iNextWordLen++; + // w2 = pszTextW[iTextW + iNextWordLen + 1]; + // } + + // if (ISDELIMITER(w2) && iNextWordLen > 0) // delimiters go with the word + // iNextWordLen++; + + // pszConvW[cchConvW++] = w; + // iLineLength++; + + // if (iNextWordLen > 0) + // { + // if (iLineLength + iNextWordLen + 1 > nColumn) { + // pszConvW[cchConvW++] = wszEOL[0]; + // if (cchEOL > 1) + // pszConvW[cchConvW++] = wszEOL[1]; + // iLineLength = 0; + // bModified = TRUE; + // } + // } + //} + + if (ISWHITE(w)) + { + int iNextWordLen = 0; + WCHAR w2; + + while (pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') { + iTextW++; + bModified = TRUE; + } // Modified: left out some whitespaces + + w2 = pszTextW[iTextW + 1]; + + while (w2 != L'\0' && !ISWORDEND(w2)) { + iNextWordLen++; + w2 = pszTextW[iTextW + iNextWordLen + 1]; + } + + //if (ISDELIMITER(w2) /*&& iNextWordLen > 0*/) // delimiters go with the word + // iNextWordLen++; + + if (iNextWordLen > 0) + { + if (iLineLength + iNextWordLen + 1 > nColumn) { + pszConvW[cchConvW++] = wszEOL[0]; + if (cchEOL > 1) + pszConvW[cchConvW++] = wszEOL[1]; + iLineLength = 0; + bModified = TRUE; + } + else { + if (iLineLength > 0) { + pszConvW[cchConvW++] = L' '; + iLineLength++; + } + } + } + } + else + { + pszConvW[cchConvW++] = w; + if (w == L'\r' || w == L'\n') { + iLineLength = 0; + } + else { + iLineLength++; + } + } + } + + GlobalFree(pszTextW); + + if (bModified) { + pszText = GlobalAlloc(GPTR,cchConvW * 3); + + cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL); + GlobalFree(pszConvW); + + if (iAnchorPos > iCurPos) { + iCurPos = iSelStart; + iAnchorPos = iSelStart + cchConvM; + } + else { + iAnchorPos = iSelStart; + iCurPos = iSelStart + cchConvM; + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchConvM,(LPARAM)pszText); + //SendMessage(hwnd,SCI_CLEAR,0,0); + //SendMessage(hwnd,SCI_ADDTEXT,(WPARAM)cchConvW,(LPARAM)pszText); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + GlobalFree(pszText); + } + + else + GlobalFree(pszConvW); +} + + +//============================================================================= +// +// EditJoinLinesEx() +// +void EditJoinLinesEx(HWND hwnd) +{ + char* pszText; + char* pszJoin; + int cchJoin = 0; + int i; + int iLine; + int iCurPos; + int iAnchorPos; + int iSelStart; + int iSelEnd; + int iSelCount; + struct Sci_TextRange tr; + int cEOLMode; + char szEOL[] = "\r\n"; + int cchEOL = 2; + BOOL bModified = FALSE; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + MsgBox(MBWARN,IDS_SELRECT); + return; + } + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos) + return; + + else { + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + } + + iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + + iSelCount = iSelEnd - iSelStart; + + pszText = LocalAlloc(LPTR,(iSelCount)+2); + if (pszText == NULL) + return; + + pszJoin = LocalAlloc(LPTR,LocalSize(pszText)); + if (pszJoin == NULL) { + LocalFree(pszText); + return; + } + + tr.chrg.cpMin = iSelStart; + tr.chrg.cpMax = iSelEnd; + tr.lpstrText = pszText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + cEOLMode = (int)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + if (cEOLMode == SC_EOL_CR) + cchEOL = 1; + else if (cEOLMode == SC_EOL_LF) { + cchEOL = 1; + szEOL[0] = '\n'; + } + + cchJoin = 0; + for (i = 0; i < iSelCount; i++) + { + if (pszText[i] == '\r' || pszText[i] == '\n') { + if (pszText[i] == '\r' && pszText[i+1] == '\n') + i++; + if (!StrChrA("\r\n",pszText[i+1]) && pszText[i+1] != 0) { + pszJoin[cchJoin++] = ' '; + bModified = TRUE; + } + else { + while (StrChrA("\r\n",pszText[i+1])) { + i++; + bModified = TRUE; + } + if (pszText[i+1] != 0) { + pszJoin[cchJoin++] = szEOL[0]; + if (cchEOL > 1) + pszJoin[cchJoin++] = szEOL[1]; + if (cchJoin > cchEOL) { + pszJoin[cchJoin++] = szEOL[0]; + if (cchEOL > 1) + pszJoin[cchJoin++] = szEOL[1]; + } + } + } + } + else { + pszJoin[cchJoin++] = pszText[i]; + } + } + + LocalFree(pszText); + + if (bModified) { + if (iAnchorPos > iCurPos) { + iCurPos = iSelStart; + iAnchorPos = iSelStart + cchJoin; + } + else { + iAnchorPos = iSelStart; + iCurPos = iSelStart + cchJoin; + } + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)iSelStart,0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)iSelEnd,0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)cchJoin,(LPARAM)pszJoin); + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + + LocalFree(pszJoin); +} + + +//============================================================================= +// +// EditSortLines() +// +typedef struct _SORTLINE { + WCHAR *pwszLine; + WCHAR *pwszSortEntry; +} SORTLINE; + +static FARPROC pfnStrCmpLogicalW; +typedef int (__stdcall *FNSTRCMP)(LPCWSTR,LPCWSTR); + +int CmpStd(const void *s1, const void *s2) { + int cmp = StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + return (cmp) ? cmp : StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); +} + +int CmpStdRev(const void *s1, const void *s2) { + int cmp = -1 * StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + return (cmp) ? cmp : -1 * StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); +} + +int CmpLogical(const void *s1, const void *s2) { + int cmp = (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + if (cmp == 0) + cmp = (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); + if (cmp) + return cmp; + else { + cmp = StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + return (cmp) ? cmp : StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); + } +} + +int CmpLogicalRev(const void *s1, const void *s2) { + int cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + if (cmp == 0) + cmp = -1 * (int)pfnStrCmpLogicalW(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); + if (cmp) + return cmp; + else { + cmp = -1 * StrCmp(((SORTLINE*)s1)->pwszSortEntry,((SORTLINE*)s2)->pwszSortEntry); + return (cmp) ? cmp : -1 * StrCmp(((SORTLINE*)s1)->pwszLine,((SORTLINE*)s2)->pwszLine); + } +} + +void EditSortLines(HWND hwnd,int iSortFlags) +{ + int iCurPos; + int iAnchorPos; + int iSelStart; + int iSelEnd; + int iLineStart; + int iLineEnd; + int iLineCount; + + BOOL bIsRectangular = FALSE; + int iRcCurLine; + int iRcAnchorLine; + int iRcCurCol; + int iRcAnchorCol; + + int i, iLine; + int cchTotal = 0; + int ichlMax = 3; + + SORTLINE *pLines; + char *pmszResult; + char *pmszBuf; + + UINT uCodePage; + DWORD cEOLMode; + char mszEOL[] = "\r\n"; + + UINT iTabWidth; + UINT iSortColumn; + + BOOL bLastDup = FALSE; + FNSTRCMP pfnStrCmp; + + pfnStrCmpLogicalW = GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW"); + pfnStrCmp = (iSortFlags & SORT_NOCASE) ? StrCmpIW : StrCmpW; + + iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos) + return; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + + iRcCurLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + iRcAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); + + iRcCurCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0); + iRcAnchorCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0); + + bIsRectangular = TRUE; + + iLineStart = min(iRcCurLine,iRcAnchorLine); + iLineEnd = max(iRcCurLine,iRcAnchorLine); + + iSortColumn = min(iRcCurCol,iRcAnchorCol); + } + + else { + + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iSelStart = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + + iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); + iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); + + if (iSelEnd <= SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd,0)) + iLineEnd--; + + iSortColumn = (UINT)SendMessage(hwnd,SCI_GETCOLUMN, + (WPARAM)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0),0); + } + + iLineCount = iLineEnd - iLineStart +1; + if (iLineCount < 2) + return; + + uCodePage = (SendMessage(hwnd,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; + + cEOLMode = (DWORD)SendMessage(hwnd,SCI_GETEOLMODE,0,0); + if (cEOLMode == SC_EOL_CR) { + mszEOL[1] = 0; + } + else if (cEOLMode == SC_EOL_LF) { + mszEOL[0] = '\n'; + mszEOL[1] = 0; + } + + iTabWidth = (UINT)SendMessage(hwnd,SCI_GETTABWIDTH,0,0); + + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + if (bIsRectangular) + EditPadWithSpaces(hwnd,!(iSortFlags & SORT_SHUFFLE),TRUE); + + pLines = LocalAlloc(LPTR,sizeof(SORTLINE) * iLineCount); + i = 0; + for (iLine = iLineStart; iLine <= iLineEnd; iLine++) { + + char *pmsz; + int cchw; + int cchm = (int)SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,0); + + pmsz = LocalAlloc(LPTR,cchm+1); + SendMessage(hwnd,SCI_GETLINE,(WPARAM)iLine,(LPARAM)pmsz); + StrTrimA(pmsz,"\r\n"); + cchTotal += cchm; + ichlMax = max(ichlMax,cchm); + + cchw = MultiByteToWideChar(uCodePage,0,pmsz,-1,NULL,0) -1; + if (cchw > 0) { + UINT col = 0, tabs = iTabWidth; + pLines[i].pwszLine = LocalAlloc(LPTR,sizeof(WCHAR) * (cchw +1)); + MultiByteToWideChar(uCodePage,0,pmsz,-1,pLines[i].pwszLine,(int)LocalSize(pLines[i].pwszLine)/sizeof(WCHAR)); + pLines[i].pwszSortEntry = pLines[i].pwszLine; + if (iSortFlags & SORT_COLUMN) { + while (*(pLines[i].pwszSortEntry)) { + if (*(pLines[i].pwszSortEntry) == L'\t') { + if (col + tabs <= iSortColumn) { + col += tabs; + tabs = iTabWidth; + pLines[i].pwszSortEntry = CharNext(pLines[i].pwszSortEntry); + } + else + break; + } + else if (col < iSortColumn) { + col++; + if (--tabs == 0) + tabs = iTabWidth; + pLines[i].pwszSortEntry = CharNext(pLines[i].pwszSortEntry); + } + else + break; + } + } + } + else { + pLines[i].pwszLine = StrDup(L""); + pLines[i].pwszSortEntry = pLines[i].pwszLine; + } + LocalFree(pmsz); + i++; + } + + if (iSortFlags & SORT_DESCENDING) { + if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW) + qsort(pLines,iLineCount,sizeof(SORTLINE),CmpLogicalRev); + else + qsort(pLines,iLineCount,sizeof(SORTLINE),CmpStdRev); + } + else if (iSortFlags & SORT_SHUFFLE) { + srand((UINT)GetTickCount()); + for (i = iLineCount-1; i > 0; i--) { + int j = rand() % i; + SORTLINE sLine; + sLine.pwszLine = pLines[i].pwszLine; + sLine.pwszSortEntry = pLines[i].pwszSortEntry; + pLines[i] = pLines[j]; + pLines[j].pwszLine = sLine.pwszLine; + pLines[j].pwszSortEntry = sLine.pwszSortEntry; + } + } + else { + if (iSortFlags & SORT_LOGICAL && pfnStrCmpLogicalW) + qsort(pLines,iLineCount,sizeof(SORTLINE),CmpLogical); + else + qsort(pLines,iLineCount,sizeof(SORTLINE),CmpStd); + } + + pmszResult = LocalAlloc(LPTR,cchTotal + 2*iLineCount +1); + pmszBuf = LocalAlloc(LPTR,ichlMax +1); + + for (i = 0; i < iLineCount; i++) { + BOOL bDropLine = FALSE; + if (pLines[i].pwszLine && ((iSortFlags & SORT_SHUFFLE) || lstrlen(pLines[i].pwszLine))) { + if (!(iSortFlags & SORT_SHUFFLE)) { + if (iSortFlags & SORT_MERGEDUP || iSortFlags & SORT_UNIQDUP || iSortFlags & SORT_UNIQUNIQ) { + if (i < iLineCount-1) { + if (pfnStrCmp(pLines[i].pwszLine,pLines[i+1].pwszLine) == 0) { + bLastDup = TRUE; + bDropLine = (iSortFlags & SORT_MERGEDUP || iSortFlags & SORT_UNIQDUP); + } + else { + bDropLine = (!bLastDup && (iSortFlags & SORT_UNIQUNIQ)) || (bLastDup && (iSortFlags & SORT_UNIQDUP)); + bLastDup = FALSE; + } + } + else { + bDropLine = (!bLastDup && (iSortFlags & SORT_UNIQUNIQ)) || (bLastDup && (iSortFlags & SORT_UNIQDUP)); + bLastDup = FALSE; + } + } + } + if (!bDropLine) { + WideCharToMultiByte(uCodePage,0,pLines[i].pwszLine,-1,pmszBuf,(int)LocalSize(pmszBuf),NULL,NULL); + StrCatBuffA(pmszResult,pmszBuf,(int)LocalSize(pmszResult)); + StrCatBuffA(pmszResult,mszEOL,(int)LocalSize(pmszResult)); + } + } + } + + LocalFree(pmszBuf); + + for (i = 0; i < iLineCount; i++) { + if (pLines[i].pwszLine) + LocalFree(pLines[i].pwszLine); + } + LocalFree(pLines); + + if (!bIsRectangular) { + if (iAnchorPos > iCurPos) { + iCurPos = iSelStart; + iAnchorPos = iSelStart + lstrlenA(pmszResult); + } + else { + iAnchorPos = iSelStart; + iCurPos = iSelStart + lstrlenA(pmszResult); + } + } + + SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineStart,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLineEnd+1,0),0); + SendMessage(hwnd,SCI_REPLACETARGET,(WPARAM)lstrlenA(pmszResult),(LPARAM)pmszResult); + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + LocalFree(pmszResult); + + if (!bIsRectangular) + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iAnchorPos,(LPARAM)iCurPos); + + else { + int iTargetStart = (int)SendMessage(hwnd,SCI_GETTARGETSTART,0,0); + int iTargetEnd = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + SendMessage(hwnd,SCI_CLEARSELECTIONS,0,0); + if (iTargetStart != iTargetEnd) { + iTargetEnd -= lstrlenA(mszEOL); + if (iRcAnchorLine > iRcCurLine) { + iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetStart,0),(LPARAM)iRcCurCol); + iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetEnd,0),(LPARAM)iRcAnchorCol); + } + else { + iCurPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetEnd,0),(LPARAM)iRcCurCol); + iAnchorPos = (int)SendMessage(hwnd,SCI_FINDCOLUMN, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iTargetStart,0),(LPARAM)iRcAnchorCol); + } + if (iCurPos != iAnchorPos) { + SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONCARET,(WPARAM)iCurPos,0); + SendMessage(hwnd,SCI_SETRECTANGULARSELECTIONANCHOR,(WPARAM)iAnchorPos,0); + } + else + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iTargetStart,(LPARAM)iTargetStart); + } + else + SendMessage(hwnd,SCI_SETSEL,(WPARAM)iTargetStart,(LPARAM)iTargetStart); + } +} + + +//============================================================================= +// +// EditJumpTo() +// +void EditJumpTo(HWND hwnd,int iNewLine,int iNewCol) +{ + int iMaxLine = (int)SendMessage(hwnd,SCI_GETLINECOUNT,0,0); + + // Jumpt to end with line set to -1 + if (iNewLine == -1) { + SendMessage(hwnd,SCI_DOCUMENTEND,0,0); + return; + } + + // Line maximum is iMaxLine + iNewLine = min(iNewLine,iMaxLine); + + // Column minimum is 1 + iNewCol = max(iNewCol,1); + + if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0) + { + int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0); + int iLineEndPos = (int)SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0); + + while (iNewCol-1 > SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iNewPos,0)) + { + if (iNewPos >= iLineEndPos) + break; + + iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM)iNewPos,0); + } + + iNewPos = min(iNewPos,iLineEndPos); + EditSelectEx(hwnd,-1,iNewPos); // SCI_GOTOPOS(pos) is equivalent to SCI_SETSEL(-1, pos) + SendMessage(hwnd,SCI_CHOOSECARETX,0,0); + } +} + + +//============================================================================= +// +// EditSelectEx() +// +void EditSelectEx(HWND hwnd,int iAnchorPos,int iCurrentPos) +{ + int iNewLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0); + int iAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); + + // Ensure that the first and last lines of a selection are always unfolded + // This needs to be done *before* the SCI_SETSEL message + SciCall_EnsureVisible(iAnchorLine); + if (iAnchorLine != iNewLine) + SciCall_EnsureVisible(iNewLine); + + SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,50); + SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_SLOP|CARET_STRICT|CARET_EVEN,5); + SendMessage(hwnd,SCI_SETSEL,iAnchorPos,iCurrentPos); + SendMessage(hwnd,SCI_SETXCARETPOLICY,CARET_SLOP|CARET_EVEN,50); + SendMessage(hwnd,SCI_SETYCARETPOLICY,CARET_EVEN,0); +} + + +//============================================================================= +// +// EditFixPositions() +// +void EditFixPositions(HWND hwnd) +{ + int iMaxPos = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurrentPos > 0 && iCurrentPos < iMaxPos) { + int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM) + (int)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iCurrentPos,0),0); + if (iNewPos != iCurrentPos) { + SendMessage(hwnd,SCI_SETCURRENTPOS,(WPARAM)iNewPos,0); + iCurrentPos = iNewPos; + } + } + + if (iAnchorPos != iCurrentPos && iAnchorPos > 0 && iAnchorPos < iMaxPos) { + int iNewPos = (int)SendMessage(hwnd,SCI_POSITIONAFTER,(WPARAM) + (int)SendMessage(hwnd,SCI_POSITIONBEFORE,(WPARAM)iAnchorPos,0),0); + if (iNewPos != iAnchorPos) + SendMessage(hwnd,SCI_SETANCHOR,(WPARAM)iNewPos,0); + } +} + + +//============================================================================= +// +// EditEnsureSelectionVisible() +// +void EditEnsureSelectionVisible(HWND hwnd) +{ + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + SendMessage(hwnd,SCI_ENSUREVISIBLE, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0),0); + if (iAnchorPos != iCurrentPos) { + SendMessage(hwnd,SCI_ENSUREVISIBLE, + (WPARAM)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurrentPos,0),0); + } + EditSelectEx(hwnd,iAnchorPos,iCurrentPos); +} + + +//============================================================================= +// +// EditGetExcerpt() +// +void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) +{ + WCHAR tch[256] = L""; + WCHAR *p; + DWORD cch = 0; + UINT cpEdit; + struct Sci_TextRange tr; + char* pszText; + LPWSTR pszTextW; + + int iCurPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + if (iCurPos == iAnchorPos || SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + lstrcpy(lpszExcerpt,L""); + return; + } + + /*if (iCurPos != iAnchorPos && SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) {*/ + + tr.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + tr.chrg.cpMax = min((int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch))); + /*} + else { + + int iLine = SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + tr.chrg.cpMin = SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch))); + }*/ + + tr.chrg.cpMax = min((int)SendMessage(hwnd,SCI_GETLENGTH,0,0),tr.chrg.cpMax); + + pszText = LocalAlloc(LPTR,(tr.chrg.cpMax - tr.chrg.cpMin)+2); + pszTextW = LocalAlloc(LPTR,((tr.chrg.cpMax - tr.chrg.cpMin)*2)+2); + + if (pszText && pszTextW) { + + tr.lpstrText = pszText; + SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + cpEdit = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + MultiByteToWideChar(cpEdit,0,pszText,tr.chrg.cpMax - tr.chrg.cpMin,pszTextW,(int)GlobalSize(pszTextW)/sizeof(WCHAR)); + + for (p = pszTextW; *p && cch < COUNTOF(tch)-1; p++) { + if (*p == L'\r' || *p == L'\n' || *p == L'\t' || *p == L' ') { + tch[cch++] = L' '; + while (*(p+1) == L'\r' || *(p+1) == L'\n' || *(p+1) == L'\t' || *(p+1) == L' ') + p++; + } + else + tch[cch++] = *p; + } + tch[cch++] = L'\0'; + StrTrim(tch,L" "); + } + + if (cch == 1) + lstrcpy(tch,L" ... "); + + if (cch > cchExcerpt) { + tch[cchExcerpt-2] = L'.'; + tch[cchExcerpt-3] = L'.'; + tch[cchExcerpt-4] = L'.'; + } + StrCpyN(lpszExcerpt,tch,cchExcerpt); + + if (pszText) + LocalFree(pszText); + if (pszTextW) + LocalFree(pszTextW); +} + + +//============================================================================= +// +// EditFindReplaceDlgProcW() +// +INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + LPEDITFINDREPLACE lpefr; + int i; + WCHAR tch[512+32]; + BOOL bCloseDlg; + BOOL bIsFindDlg; + + static UINT uCPEdit; + + switch(umsg) + { + + case WM_INITDIALOG: + { + int cchSelection; + char *lpszSelection; + char *lpsz; + +#ifdef BOOKMARK_EDITION + static BOOL bFirstTime = TRUE; +#endif + + WCHAR tch[128]; + HMENU hmenu; + + SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); + lpefr = (LPEDITFINDREPLACE)lParam; + + // Get the current code page for Unicode conversion + uCPEdit = (UINT)SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0); + + // Load MRUs + for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) { + MRU_Enum(mruFind,i,tch,COUNTOF(tch)); + SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch); + } + for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) { + MRU_Enum(mruReplace,i,tch,COUNTOF(tch)); + SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch); + } + + if (!bSwitchedFindReplace) { + cchSelection = (int)SendMessage(lpefr->hwnd,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(lpefr->hwnd,SCI_GETSELECTIONSTART,0,0); + + if (cchSelection <= 500) + { + cchSelection = (int)SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,0); + lpszSelection = GlobalAlloc(GPTR,cchSelection+2); + SendMessage(lpefr->hwnd,SCI_GETSELTEXT,0,(LPARAM)lpszSelection); + +#ifdef BOOKMARK_EDITION + // First time you bring up find/replace dialog, copy content from clipboard to find box (but only if nothing is selected in the editor) + if (lstrcmpA( lpszSelection , "" ) == 0 && bFirstTime ) + { + char *pClip = EditGetClipboardText(hwndEdit); + if( lstrlenA( pClip ) > 0 && lstrlenA( pClip ) <= 500 ) + { + GlobalFree(lpszSelection); + lpszSelection = GlobalAlloc(GPTR,lstrlenA( pClip )+2); + lstrcpynA( lpszSelection , pClip , 500 ); + } + LocalFree(pClip); + } + bFirstTime = FALSE; +#endif + + // Check lpszSelection and truncate bad chars + lpsz = StrChrA(lpszSelection,13); + if (lpsz) *lpsz = '\0'; + + lpsz = StrChrA(lpszSelection,10); + if (lpsz) *lpsz = '\0'; + + lpsz = StrChrA(lpszSelection,9); + if (lpsz) *lpsz = '\0'; + + SetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpszSelection); + GlobalFree(lpszSelection); + } + } + + SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_LIMITTEXT,500,0); + SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_SETEXTENDEDUI,TRUE,0); + + if (!GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT))) + SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); + + if (GetDlgItem(hwnd,IDC_REPLACETEXT)) + { + SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_LIMITTEXT,500,0); + SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_SETEXTENDEDUI,TRUE,0); + SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8); + } + + if (lpefr->fuFlags & SCFIND_MATCHCASE) + CheckDlgButton(hwnd,IDC_FINDCASE,BST_CHECKED); + + if (lpefr->fuFlags & SCFIND_WHOLEWORD) + CheckDlgButton(hwnd,IDC_FINDWORD,BST_CHECKED); + + if (lpefr->fuFlags & SCFIND_WORDSTART) + CheckDlgButton(hwnd,IDC_FINDSTART,BST_CHECKED); + + if (lpefr->fuFlags & SCFIND_REGEXP) + CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_CHECKED); + + if (lpefr->bTransformBS) + CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_CHECKED); + +#ifdef BOOKMARK_EDITION + if (lpefr->bWildcardSearch) + { + CheckDlgButton(hwnd,IDC_WILDCARDSEARCH,BST_CHECKED); + CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); + } +#endif + + if (lpefr->bNoFindWrap) + CheckDlgButton(hwnd,IDC_NOWRAP,BST_CHECKED); + + if (GetDlgItem(hwnd,IDC_REPLACE)) { + if (bSwitchedFindReplace) { + if (lpefr->bFindClose) + CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); + } + else { + if (lpefr->bReplaceClose) + CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); + } + } + else { + if (bSwitchedFindReplace) { + if (lpefr->bReplaceClose) + CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); + } + else { + if (lpefr->bFindClose) + CheckDlgButton(hwnd,IDC_FINDCLOSE,BST_CHECKED); + } + } + + if (!bSwitchedFindReplace) { + if (xFindReplaceDlg == 0 || yFindReplaceDlg == 0) + CenterDlgInParent(hwnd); + else + SetDlgPos(hwnd,xFindReplaceDlg,yFindReplaceDlg); + } + + else { + SetDlgPos(hwnd,xFindReplaceDlgSave,yFindReplaceDlgSave); + bSwitchedFindReplace = FALSE; + CopyMemory(lpefr,&efrSave,sizeof(EDITFINDREPLACE)); + } + + hmenu = GetSystemMenu(hwnd,FALSE); + GetString(SC_SAVEPOS,tch,COUNTOF(tch)); + InsertMenu(hmenu,0,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_SAVEPOS,tch); + GetString(SC_RESETPOS,tch,COUNTOF(tch)); + InsertMenu(hmenu,1,MF_BYPOSITION|MF_STRING|MF_ENABLED,SC_RESETPOS,tch); + InsertMenu(hmenu,2,MF_BYPOSITION|MF_SEPARATOR,0,NULL); + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_FINDTEXT: + case IDC_REPLACETEXT: + { + BOOL bEnable = (GetWindowTextLengthW(GetDlgItem(hwnd,IDC_FINDTEXT)) || + CB_ERR != SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_GETCURSEL,0,0)); + + EnableWindow(GetDlgItem(hwnd,IDOK),bEnable); + EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),bEnable); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),bEnable); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),bEnable); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),bEnable); + + if (HIWORD(wParam) == CBN_CLOSEUP) { + LONG lSelEnd; + SendDlgItemMessage(hwnd,LOWORD(wParam),CB_GETEDITSEL,0,(LPARAM)&lSelEnd); + SendDlgItemMessage(hwnd,LOWORD(wParam),CB_SETEDITSEL,0,MAKELPARAM(lSelEnd,lSelEnd)); + } + } + break; + + case IDC_FINDREGEXP: + if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED) + { + CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_UNCHECKED); +#ifdef BOOKMARK_EDITION + CheckDlgButton(hwnd,IDC_WILDCARDSEARCH,BST_UNCHECKED); // Can not use wildcard search together with regexp +#endif + } + break; + + case IDC_FINDTRANSFORMBS: + if (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED) + CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); + break; + +#ifdef BOOKMARK_EDITION + // handle wildcard search checkbox + case IDC_WILDCARDSEARCH: + CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); + //if (IsDlgButtonChecked(hwnd,IDC_FINDWILDCARDS) == BST_CHECKED) + // CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); + break; +#endif + + case IDOK: + case IDC_FINDPREV: + case IDC_REPLACE: + case IDC_REPLACEALL: + case IDC_REPLACEINSEL: + case IDACC_SELTONEXT: + case IDACC_SELTOPREV: + case IDMSG_SWITCHTOFIND: + case IDMSG_SWITCHTOREPLACE: + + lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd,DWLP_USER); + + bIsFindDlg = (GetDlgItem(hwnd,IDC_REPLACE) == NULL); + + if ((bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOREPLACE || + !bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOFIND)) { + GetDlgPos(hwnd,&xFindReplaceDlgSave,&yFindReplaceDlgSave); + bSwitchedFindReplace = TRUE; + CopyMemory(&efrSave,lpefr,sizeof(EDITFINDREPLACE)); + } + + // Get current code page for Unicode conversion + uCPEdit = (UINT)SendMessage(lpefr->hwnd,SCI_GETCODEPAGE,0,0); + cpLastFind = uCPEdit; + + if (!bSwitchedFindReplace && + !GetDlgItemTextA2W(uCPEdit,hwnd,IDC_FINDTEXT,lpefr->szFind,COUNTOF(lpefr->szFind))) { + + EnableWindow(GetDlgItem(hwnd,IDOK),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_FINDPREV),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACE),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACEALL),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_REPLACEINSEL),FALSE); + return TRUE; + } + + if (GetDlgItem(hwnd,IDC_REPLACETEXT)) + GetDlgItemTextA2W(uCPEdit,hwnd,IDC_REPLACETEXT,lpefr->szReplace,COUNTOF(lpefr->szReplace)); + +#ifdef BOOKMARK_EDITION + lpefr->bWildcardSearch = (IsDlgButtonChecked(hwnd,IDC_WILDCARDSEARCH) == BST_CHECKED) ? TRUE : FALSE; +#endif + + lpefr->fuFlags = 0; + + if (IsDlgButtonChecked(hwnd,IDC_FINDCASE) == BST_CHECKED) + lpefr->fuFlags |= SCFIND_MATCHCASE; + + if (IsDlgButtonChecked(hwnd,IDC_FINDWORD) == BST_CHECKED) + lpefr->fuFlags |= SCFIND_WHOLEWORD; + + if (IsDlgButtonChecked(hwnd,IDC_FINDSTART) == BST_CHECKED) + lpefr->fuFlags |= SCFIND_WORDSTART; + + if (IsDlgButtonChecked(hwnd,IDC_FINDREGEXP) == BST_CHECKED) + lpefr->fuFlags |= SCFIND_REGEXP | SCFIND_POSIX; + + lpefr->bTransformBS = + (IsDlgButtonChecked(hwnd,IDC_FINDTRANSFORMBS) == BST_CHECKED) ? TRUE : FALSE; + + lpefr->bNoFindWrap = (IsDlgButtonChecked(hwnd,IDC_NOWRAP) == BST_CHECKED) ? TRUE : FALSE; + + if (bIsFindDlg) { + lpefr->bFindClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE; + } + else { + lpefr->bReplaceClose = (IsDlgButtonChecked(hwnd,IDC_FINDCLOSE) == BST_CHECKED) ? TRUE : FALSE; + } + + if (!bSwitchedFindReplace) { + // Save MRUs + if (lstrlenA(lpefr->szFind)) { + if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8))) { + GetDlgItemText(hwnd,IDC_FINDTEXT,tch,COUNTOF(tch)); + MRU_Add(mruFind,tch); + } + } + if (lstrlenA(lpefr->szReplace)) { + if (GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8))) { + GetDlgItemText(hwnd,IDC_REPLACETEXT,tch,COUNTOF(tch)); + MRU_Add(mruReplace,tch); + } + } + else + lstrcpyA(lpefr->szReplaceUTF8,""); + } + else { + GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8,COUNTOF(lpefr->szFindUTF8)); + if (!GetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8,COUNTOF(lpefr->szReplaceUTF8))) + lstrcpyA(lpefr->szReplaceUTF8,""); + } + + if (bIsFindDlg) { + bCloseDlg = lpefr->bFindClose; + } + else { + if (LOWORD(wParam) == IDOK) + bCloseDlg = FALSE; + else + bCloseDlg = lpefr->bReplaceClose; + } + + // Reload MRUs + SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_RESETCONTENT,0,0); + SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_RESETCONTENT,0,0); + + for (i = 0; i < MRU_Enum(mruFind,0,NULL,0); i++) { + MRU_Enum(mruFind,i,tch,COUNTOF(tch)); + SendDlgItemMessage(hwnd,IDC_FINDTEXT,CB_ADDSTRING,0,(LPARAM)tch); + } + for (i = 0; i < MRU_Enum(mruReplace,0,NULL,0); i++) { + MRU_Enum(mruReplace,i,tch,COUNTOF(tch)); + SendDlgItemMessage(hwnd,IDC_REPLACETEXT,CB_ADDSTRING,0,(LPARAM)tch); + } + + SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); + SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_REPLACETEXT,lpefr->szReplaceUTF8); + + if (!bSwitchedFindReplace) + SendMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetFocus()),1); + + if (bCloseDlg) { + //EndDialog(hwnd,LOWORD(wParam)); + DestroyWindow(hwnd); + hDlgFindReplace = NULL; + } + + switch (LOWORD(wParam)) + { + case IDOK: // find next + case IDACC_SELTONEXT: + if (!bIsFindDlg) + bReplaceInitialized = TRUE; + EditFindNext(lpefr->hwnd,lpefr,LOWORD(wParam)==IDACC_SELTONEXT||HIBYTE(GetKeyState(VK_SHIFT))); + break; + + case IDC_FINDPREV: // find previous + case IDACC_SELTOPREV: + if (!bIsFindDlg) + bReplaceInitialized = TRUE; + EditFindPrev(lpefr->hwnd,lpefr,LOWORD(wParam)==IDACC_SELTOPREV||HIBYTE(GetKeyState(VK_SHIFT))); + break; + + case IDC_REPLACE: + bReplaceInitialized = TRUE; + EditReplace(lpefr->hwnd,lpefr); + break; + + case IDC_REPLACEALL: + bReplaceInitialized = TRUE; + EditReplaceAll(lpefr->hwnd,lpefr,TRUE); + break; + + case IDC_REPLACEINSEL: + bReplaceInitialized = TRUE; + EditReplaceAllInSelection(lpefr->hwnd,lpefr,TRUE); + break; + } + +#ifdef BOOKMARK_EDITION + // Wildcard search will enable regexp, so I turn it off again otherwise it will be on in the gui + if( lpefr->bWildcardSearch && (lpefr->fuFlags & SCFIND_REGEXP) ) lpefr->fuFlags ^= SCFIND_REGEXP; +#endif + + break; + + + case IDCANCEL: + //EndDialog(hwnd,IDCANCEL); + DestroyWindow(hwnd); + break; + + case IDACC_FIND: + PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); + break; + + case IDACC_REPLACE: + PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); + break; + + case IDACC_SAVEPOS: + GetDlgPos(hwnd,&xFindReplaceDlg,&yFindReplaceDlg); + break; + + case IDACC_RESETPOS: + CenterDlgInParent(hwnd); + xFindReplaceDlg = yFindReplaceDlg = 0; + break; + + case IDACC_FINDNEXT: + PostMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + + case IDACC_FINDPREV: + PostMessage(hwnd,WM_COMMAND,MAKELONG(IDC_FINDPREV,1),0); + break; + + case IDACC_REPLACENEXT: + if (GetDlgItem(hwnd,IDC_REPLACE) != NULL) + PostMessage(hwnd,WM_COMMAND,MAKELONG(IDC_REPLACE,1),0); + break; + + case IDACC_SAVEFIND: + SendMessage(hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_SAVEFIND,1),0); + lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd,DWLP_USER); + SetDlgItemTextA2W(CP_UTF8,hwnd,IDC_FINDTEXT,lpefr->szFindUTF8); + CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); + CheckDlgButton(hwnd,IDC_FINDTRANSFORMBS,BST_UNCHECKED); + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_FINDTEXT)),1); + break; + + } + + return TRUE; + + + case WM_SYSCOMMAND: + if (wParam == SC_SAVEPOS){ + PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_SAVEPOS,0),0); + return TRUE; + } + else if (wParam == SC_RESETPOS){ + PostMessage(hwnd,WM_COMMAND,MAKELONG(IDACC_RESETPOS,0),0); + return TRUE; + } + else + return FALSE; + + + case WM_NOTIFY: + { + LPNMHDR pnmhdr = (LPNMHDR)lParam; + switch (pnmhdr->code) { + + case NM_CLICK: + case NM_RETURN: + if (pnmhdr->idFrom == IDC_TOGGLEFINDREPLACE) { + if (GetDlgItem(hwnd,IDC_REPLACE)) + PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); + else + PostMessage(GetParent(hwnd),WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); + } +#ifdef BOOKMARK_EDITION + // Display help messages in the find/replace windows + else if (pnmhdr->idFrom == IDC_BACKSLASHHELP) + { + MsgBox(MBINFO,IDS_BACKSLASHHELP); + } + else if (pnmhdr->idFrom == IDC_REGEXPHELP) + { + MsgBox(MBINFO,IDS_REGEXPHELP); + } + else if (pnmhdr->idFrom == IDC_WILDCARDHELP) + { + MsgBox(MBINFO,IDS_WILDCARDHELP); + } +#endif + break; + } + } + break; + + } + + return FALSE; + +} + + +//============================================================================= +// +// EditFindReplaceDlg() +// +HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bReplace) +{ + + HWND hDlg; + + lpefr->hwnd = hwnd; + + hDlg = CreateThemedDialogParam(g_hInstance, + (bReplace) ? MAKEINTRESOURCEW(IDD_REPLACE) : MAKEINTRESOURCEW(IDD_FIND), + GetParent(hwnd), + EditFindReplaceDlgProcW, + (LPARAM) lpefr); + + ShowWindow(hDlg,SW_SHOW); + + return hDlg; + +} + + +#ifdef BOOKMARK_EDITION + // Wildcard search uses the regexp engine to perform a simple search with * ? as wildcards instead of more advanced and user-unfriendly regexp syntax + void EscapeWildcards( char* szFind2 , LPCEDITFINDREPLACE lpefr ) + { + char szWildcardEscaped[512]; + int iSource = 0; + int iDest = 0; + + lpefr->fuFlags |= SCFIND_REGEXP; + + while( szFind2[iSource] ) + { + char c = szFind2[iSource]; + if( c == '*' ) + { + szWildcardEscaped[iDest++] = '.'; szWildcardEscaped[iDest] = '*'; + } + else if( c == '?' ) + { + szWildcardEscaped[iDest] = '.'; + } + else + { + if( c == '.' || c == '^' || c == '$' || c == '\\' || c == '[' || c == ']' || c == '+' ) szWildcardEscaped[iDest++] = '\\'; + szWildcardEscaped[iDest] = c; + } + iSource++; + iDest++; + } + szWildcardEscaped[iDest] = (char)NULL; + lstrcpynA(szFind2,szWildcardEscaped,COUNTOF(szWildcardEscaped)); + } +#endif + + +//============================================================================= +// +// EditFindNext() +// +BOOL EditFindNext(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) +{ + + struct Sci_TextToFind ttf; + int iPos; + int iSelPos, iSelAnchor; + char szFind2[512]; + BOOL bSuppressNotFound = FALSE; + + if (!lstrlenA(lpefr->szFind)) + return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE; + + lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); + if (lpefr->bTransformBS) + TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + + if (lstrlenA(szFind2) == 0) + { + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + +#ifdef BOOKMARK_EDITION + if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); +#endif + + iSelPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iSelAnchor = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + ttf.lpstrText = szFind2; + + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + + if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap && !fExtendSelection) { + if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { + ttf.chrg.cpMin = 0; + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + } + else + bSuppressNotFound = TRUE; + } + + if (iPos == -1) + { + // notfound + if (!bSuppressNotFound) + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + + if (!fExtendSelection) + EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); + else + EditSelectEx(hwnd,min(iSelAnchor,iSelPos),ttf.chrgText.cpMax); + + return TRUE; + +} + + +//============================================================================= +// +// EditFindPrev() +// +BOOL EditFindPrev(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL fExtendSelection) +{ + + struct Sci_TextToFind ttf; + int iPos; + int iSelPos, iSelAnchor; + int iLength; + char szFind2[512]; + BOOL bSuppressNotFound = FALSE; + + if (!lstrlenA(lpefr->szFind)) + return /*EditFindReplaceDlg(hwnd,lpefr,FALSE)*/FALSE; + + lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); + if (lpefr->bTransformBS) + TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + + if (lstrlenA(szFind2) == 0) + { + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + +#ifdef BOOKMARK_EDITION + if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); +#endif + + iSelPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + iSelAnchor = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = max(0,(int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0)); + ttf.chrg.cpMax = 0; + ttf.lpstrText = szFind2; + + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + + iLength = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + if (iPos == -1 && ttf.chrg.cpMin < iLength && !lpefr->bNoFindWrap && !fExtendSelection) { + if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap2",IDS_FIND_WRAPRE)) { + ttf.chrg.cpMin = iLength; + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + } + else + bSuppressNotFound = TRUE; + } + + if (iPos == -1) + { + // notfound + if (!bSuppressNotFound) + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + + if (!fExtendSelection) + EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); + else + EditSelectEx(hwnd,max(iSelPos,iSelAnchor),ttf.chrgText.cpMin); + + return TRUE; + +} + + +//============================================================================= +// +// EditReplace() +// +BOOL EditReplace(HWND hwnd,LPCEDITFINDREPLACE lpefr) +{ + + struct Sci_TextToFind ttf; + int iPos; + int iSelStart; + int iSelEnd; + int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; + char szFind2[512]; + char *pszReplace2; + BOOL bSuppressNotFound = FALSE; + + if (!lstrlenA(lpefr->szFind)) + return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; + + lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); + if (lpefr->bTransformBS) + TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + + if (lstrlenA(szFind2) == 0) + { + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + +#ifdef BOOKMARK_EDITION + if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); +#endif + + if (lstrcmpA(lpefr->szReplace,"^c") == 0) { + iReplaceMsg = SCI_REPLACETARGET; + pszReplace2 = EditGetClipboardText(hwnd); + } + else { + //lstrcpyA(szReplace2,lpefr->szReplace); + pszReplace2 = StrDupA(lpefr->szReplace); + if (lpefr->bTransformBS) + TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + } + + if (!pszReplace2) + pszReplace2 = StrDupA(""); + + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); // Start! + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + ttf.lpstrText = szFind2; + + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + + if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) { + if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { + ttf.chrg.cpMin = 0; + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + } + else + bSuppressNotFound = TRUE; + } + + if (iPos == -1) + { + // notfound + LocalFree(pszReplace2); + if (!bSuppressNotFound) + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + + if (iSelStart != ttf.chrgText.cpMin || iSelEnd != ttf.chrgText.cpMax) { + LocalFree(pszReplace2); + EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); + return FALSE; + } + + SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); + SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); + SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); + + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + + bSuppressNotFound = FALSE; + if (iPos == -1 && ttf.chrg.cpMin > 0 && !lpefr->bNoFindWrap) { + if (IDOK == InfoBox(MBOKCANCEL,L"MsgFindWrap1",IDS_FIND_WRAPFW)) { + ttf.chrg.cpMin = 0; + iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf); + } + else + bSuppressNotFound = TRUE; + } + + if (iPos != -1) + EditSelectEx(hwnd,ttf.chrgText.cpMin,ttf.chrgText.cpMax); + + else { + EditSelectEx(hwnd, + (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0), + (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0)); + if (!bSuppressNotFound) + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + } + + LocalFree(pszReplace2); + return TRUE; + +} + +//============================================================================= +// +// CompleteWord() +// Auto-complete words (by Aleksandar Lekov) +// +struct WLIST { + char* word; + struct WLIST* next; +}; + +void CompleteWord(HWND hwnd, BOOL autoInsert) { + const char* NON_WORD = " \t\r\n@#$%^&*~-=+()[]{}\\/.,:;'\"!?<>`|"; + int iCurrentPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); + int iLine = (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iCurrentPos, 0); + int iCurrentLinePos = iCurrentPos - (int)SendMessage(hwnd, SCI_POSITIONFROMLINE, (WPARAM)iLine, 0); + int iStartWordPos = iCurrentLinePos; + char *pLine; + char *pRoot; + char *pWord; + int iNumWords = 0; + int iRootLen = 0; + int iDocLen; + int iPosFind; + struct Sci_TextRange tr = { { 0, -1 }, NULL }; + struct Sci_TextToFind ft = {{0, 0}, 0, {0, 0}}; + BOOL bWordAllNumbers = TRUE; + struct WLIST* lListHead = NULL; + int iWListSize = 0; + + pLine = LocalAlloc(LPTR, (int)SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, 0) + 1); + SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, (LPARAM)pLine); + + while (iStartWordPos > 0 && !StrChrIA(NON_WORD, pLine[iStartWordPos - 1])) { + iStartWordPos--; + if (pLine[iStartWordPos] < '0' || pLine[iStartWordPos] > '9') { + bWordAllNumbers = FALSE; + } + } + + if (iStartWordPos == iCurrentLinePos || bWordAllNumbers || iCurrentLinePos - iStartWordPos < 2) { + LocalFree(pLine); + return; + } + + pRoot = LocalAlloc(LPTR, iCurrentLinePos - iStartWordPos + 2); + lstrcpynA(pRoot, pLine + iStartWordPos, iCurrentLinePos - iStartWordPos + 1); + LocalFree(pLine); + iRootLen = lstrlenA(pRoot); + + iDocLen = (int)SendMessage(hwnd, SCI_GETLENGTH, 0, 0); + + ft.lpstrText = pRoot; + ft.chrg.cpMax = iDocLen; + + iPosFind = (int)SendMessage(hwnd, SCI_FINDTEXT, SCFIND_WORDSTART, (LPARAM)&ft); + + while (iPosFind >= 0 && iPosFind < iDocLen) { + int wordLength; + int wordEnd = iPosFind + iRootLen; + + if (iPosFind != iCurrentPos - iRootLen) { + while (wordEnd < iDocLen && !StrChrIA(NON_WORD, (char)SendMessage(hwnd, SCI_GETCHARAT, (WPARAM)wordEnd, 0))) + wordEnd++; + + wordLength = wordEnd - iPosFind; + if (wordLength > iRootLen) { + struct WLIST* p = lListHead; + struct WLIST* t = NULL; + int lastCmp = 0; + BOOL found = FALSE; + + pWord = LocalAlloc(LPTR, wordEnd - iPosFind + 2); + + tr.lpstrText = pWord; + tr.chrg.cpMin = iPosFind; + tr.chrg.cpMax = wordEnd; + SendMessage(hwnd, SCI_GETTEXTRANGE, 0, (LPARAM)&tr); + + while(p) { + int cmp = lstrcmpA(pWord, p->word); + if (!cmp) { + found = TRUE; + break; + } else if (cmp < 0) { + break; + } + t = p; + p = p->next; + } + if (!found) { + struct WLIST* el = (struct WLIST*)LocalAlloc(LPTR, sizeof(struct WLIST)); + el->word = LocalAlloc(LPTR, wordEnd - iPosFind + 2); + lstrcpyA(el->word, pWord); + el->next = p; + if (t) { + t->next = el; + } else { + lListHead = el; + } + + iNumWords++; + iWListSize += lstrlenA(pWord) + 1; + } + LocalFree(pWord); + } + } + ft.chrg.cpMin = wordEnd; + iPosFind = (int)SendMessage(hwnd, SCI_FINDTEXT, SCFIND_WORDSTART, (LPARAM)&ft); + } + + if (iNumWords > 0) { + char *pList; + struct WLIST* p = lListHead; + struct WLIST* t; + + pList = LocalAlloc(LPTR, iWListSize + 1); + while (p) { + lstrcatA(pList, " "); + lstrcatA(pList, p->word); + LocalFree(p->word); + t = p; + p = p->next; + LocalFree(t); + } + + SendMessage(hwnd, SCI_AUTOCSETIGNORECASE, 1, 0); + SendMessage(hwnd, SCI_AUTOCSETSEPARATOR, ' ', 0); + SendMessage(hwnd, SCI_AUTOCSETFILLUPS, 0, (LPARAM)"\t\n\r"); + SendMessage(hwnd, SCI_AUTOCSETCHOOSESINGLE, autoInsert, 0); + SendMessage(hwnd, SCI_AUTOCSHOW, iRootLen, (LPARAM)(pList + 1)); + LocalFree(pList); + } + + LocalFree(pRoot); +} + +//============================================================================= +// +// EditMarkAll() +// Mark all occurrences of the text currently selected (by Aleksandar Lekov) +// +void EditMarkAll(HWND hwnd, int iMarkOccurrences, BOOL bMarkOccurrencesMatchCase, BOOL bMarkOccurrencesMatchWords) +{ + struct Sci_TextToFind ttf; + int iPos; + char *pszText; + int iTextLen; + int iSelStart; + int iSelEnd; + int iSelCount; + int iMatchesCount; + + // feature is off + if (!iMarkOccurrences) + return; + + + iTextLen = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + // get current selection + iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + iSelEnd = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + iSelCount = iSelEnd - iSelStart; + + // clear existing indicator + SendMessage(hwnd, SCI_SETINDICATORCURRENT, 1, 0); + SendMessage(hwnd, SCI_INDICATORCLEARRANGE, 0, iTextLen); + + // if nothing selected or multiple lines are selected exit + if (iSelCount == 0 || + (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iSelStart, 0) != + (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iSelEnd, 0)) + return; + + + // scintilla/src/Editor.h SelectionText.LengthWithTerminator() + iSelCount = (int)SendMessage(hwnd,SCI_GETSELTEXT,0,0) - 1; + pszText = LocalAlloc(LPTR,iSelCount + 1); + (int)SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)pszText); + + + // exit if selection is not a word and Match whole words only is enabled + if (bMarkOccurrencesMatchWords) + { + iSelStart = 0; + while (pszText[iSelStart]) + { + if (StrChrIA(" \t\r\n@#$%^&*~-=+()[]{}\\/:;'\"", pszText[iSelStart])) + { + LocalFree(pszText); + return; + } + iSelStart++; + } + } + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = 0; + ttf.chrg.cpMax = iTextLen; + ttf.lpstrText = pszText; + + // set style + SendMessage(hwnd, SCI_INDICSETALPHA, 1, 100); + SendMessage(hwnd, SCI_INDICSETFORE, 1, Style_GetOccurrenceColor(iMarkOccurrences)); + SendMessage(hwnd, SCI_INDICSETSTYLE, 1, INDIC_ROUNDBOX); + + iMatchesCount = 0; + while ((iPos = (int)SendMessage(hwnd, SCI_FINDTEXT, + (bMarkOccurrencesMatchCase ? SCFIND_MATCHCASE : 0) | (bMarkOccurrencesMatchWords ? SCFIND_WHOLEWORD : 0), + (LPARAM)&ttf)) != -1 + && ++iMatchesCount < 2000) + { + // mark this match + SendMessage(hwnd, SCI_INDICATORFILLRANGE, iPos, iSelCount); + ttf.chrg.cpMin = ttf.chrgText.cpMin + iSelCount; + if (ttf.chrg.cpMin == ttf.chrg.cpMax) + break; + } + + LocalFree(pszText); + return; +} + + +//============================================================================= +// +// EditReplaceAll() +// +BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) +{ + + struct Sci_TextToFind ttf; + int iPos; + int iCount = 0; + int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; + char szFind2[512]; + char *pszReplace2; + BOOL bRegexStartOfLine; + BOOL bRegexStartOrEndOfLine; + + if (!lstrlenA(lpefr->szFind)) + return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; + + // Show wait cursor... + BeginWaitCursor(); + + lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); + if (lpefr->bTransformBS) + TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + + if (lstrlenA(szFind2) == 0) + { + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + +#ifdef BOOKMARK_EDITION + if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); +#endif + + bRegexStartOfLine = + (szFind2[0] == '^'); + bRegexStartOrEndOfLine = + (lpefr->fuFlags & SCFIND_REGEXP && + (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$"))); + + if (lstrcmpA(lpefr->szReplace,"^c") == 0) { + iReplaceMsg = SCI_REPLACETARGET; + pszReplace2 = EditGetClipboardText(hwnd); + } + else { + //lstrcpyA(szReplace2,lpefr->szReplace); + pszReplace2 = StrDupA(lpefr->szReplace); + if (lpefr->bTransformBS) + TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + } + + if (!pszReplace2) + pszReplace2 = StrDupA(""); + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = 0; + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + ttf.lpstrText = szFind2; + + while ((iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1) + { + int iReplacedLen; + //char ch; + + if (iCount == 0 && bRegexStartOrEndOfLine) { + if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) { + iPos = 0; + ttf.chrgText.cpMin = 0; + ttf.chrgText.cpMax = 0; + } + } + + if (++iCount == 1) + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); + SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); + iReplacedLen = (int)SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); + + ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen; + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + if (ttf.chrg.cpMin == ttf.chrg.cpMax) + break; + + //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0); + + if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */ + ttf.chrgText.cpMin == ttf.chrgText.cpMax && + !(bRegexStartOrEndOfLine && iReplacedLen > 0)) + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0); + if (bRegexStartOfLine) { + int iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0); + int ilPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + if (ilPos == ttf.chrg.cpMin) + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0); + if (ttf.chrg.cpMin == ttf.chrg.cpMax) + break; + } + } + + if (iCount) + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + + // Remove wait cursor + EndWaitCursor(); + + if (bShowInfo) { + if (iCount > 0) + InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount); + else + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + } + + LocalFree(pszReplace2); + return TRUE; + +} + + +//============================================================================= +// +// EditReplaceAllInSelection() +// +BOOL EditReplaceAllInSelection(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) +{ + + struct Sci_TextToFind ttf; + int iPos; + int iCount = 0; + int iReplaceMsg = (lpefr->fuFlags & SCFIND_REGEXP) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET; + BOOL fCancel = FALSE; + char szFind2[512]; + char *pszReplace2; + BOOL bRegexStartOfLine; + BOOL bRegexStartOrEndOfLine; + + if (SC_SEL_RECTANGLE == SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) + { + MsgBox(MBWARN,IDS_SELRECT); + return FALSE; + } + + if (!lstrlenA(lpefr->szFind)) + return /*EditFindReplaceDlg(hwnd,lpefr,TRUE)*/FALSE; + + // Show wait cursor... + BeginWaitCursor(); + + lstrcpynA(szFind2,lpefr->szFind,COUNTOF(szFind2)); + if (lpefr->bTransformBS) + TransformBackslashes(szFind2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + + if (lstrlenA(szFind2) == 0) + { + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + return FALSE; + } + +#ifdef BOOKMARK_EDITION + if( lpefr->bWildcardSearch ) EscapeWildcards( szFind2 , lpefr ); +#endif + + bRegexStartOfLine = + (szFind2[0] == '^'); + bRegexStartOrEndOfLine = + (lpefr->fuFlags & SCFIND_REGEXP && + (!lstrcmpA(szFind2,"$") || !lstrcmpA(szFind2,"^") || !lstrcmpA(szFind2,"^$"))); + + if (lstrcmpA(lpefr->szReplace,"^c") == 0) { + iReplaceMsg = SCI_REPLACETARGET; + pszReplace2 = EditGetClipboardText(hwnd); + } + else { + //lstrcpyA(szReplace2,lpefr->szReplace); + pszReplace2 = StrDupA(lpefr->szReplace); + if (lpefr->bTransformBS) + TransformBackslashes(pszReplace2,(lpefr->fuFlags & SCFIND_REGEXP), + (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0)); + } + + if (!pszReplace2) + pszReplace2 = StrDupA(""); + + ZeroMemory(&ttf,sizeof(ttf)); + + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + ttf.lpstrText = szFind2; + + while ((iPos = (int)SendMessage(hwnd,SCI_FINDTEXT,lpefr->fuFlags,(LPARAM)&ttf)) != -1 && !fCancel) + { + if (ttf.chrgText.cpMin >= SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0) && + ttf.chrgText.cpMax <= SendMessage(hwnd,SCI_GETSELECTIONEND,0,0)) + { + int iReplacedLen; + //char ch; + + if (ttf.chrg.cpMin == 0 && iCount == 0 && bRegexStartOrEndOfLine) { + if (0 == SendMessage(hwnd,SCI_GETLINEENDPOSITION,0,0)) { + iPos = 0; + ttf.chrgText.cpMin = 0; + ttf.chrgText.cpMax = 0; + } + } + + if (++iCount == 1) + SendMessage(hwnd,SCI_BEGINUNDOACTION,0,0); + + SendMessage(hwnd,SCI_SETTARGETSTART,ttf.chrgText.cpMin,0); + SendMessage(hwnd,SCI_SETTARGETEND,ttf.chrgText.cpMax,0); + iReplacedLen = (int)SendMessage(hwnd,iReplaceMsg,(WPARAM)-1,(LPARAM)pszReplace2); + + ttf.chrg.cpMin = ttf.chrgText.cpMin + iReplacedLen; + ttf.chrg.cpMax = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + + if (ttf.chrg.cpMin == ttf.chrg.cpMax) + fCancel = TRUE; + + //ch = (char)SendMessage(hwnd,SCI_GETCHARAT,SendMessage(hwnd,SCI_GETTARGETEND,0,0),0); + + if (/*ch == '\r' || ch == '\n' || iReplacedLen == 0 || */ + ttf.chrgText.cpMin == ttf.chrgText.cpMax && + !(bRegexStartOrEndOfLine && iReplacedLen > 0)) + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONAFTER,ttf.chrg.cpMin,0); + if (bRegexStartOfLine) { + int iLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)ttf.chrg.cpMin,0); + int ilPos = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + if (ilPos == ttf.chrg.cpMin) + ttf.chrg.cpMin = (int)SendMessage(hwnd,SCI_POSITIONFROMLINE,(WPARAM)iLine+1,0); + if (ttf.chrg.cpMin == ttf.chrg.cpMax) + break; + } + } + + else + // gone across selection, cancel + fCancel = TRUE; + } + + if (iCount) { + + if (SendMessage(hwnd,SCI_GETSELECTIONEND,0,0) < + SendMessage(hwnd,SCI_GETTARGETEND,0,0)) { + + int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); + int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); + + if (iAnchorPos > iCurrentPos) + iAnchorPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + else + iCurrentPos = (int)SendMessage(hwnd,SCI_GETTARGETEND,0,0); + + EditSelectEx(hwnd,iAnchorPos,iCurrentPos); + } + + SendMessage(hwnd,SCI_ENDUNDOACTION,0,0); + } + + // Remove wait cursor + EndWaitCursor(); + + if (bShowInfo) { + if (iCount > 0) + InfoBox(0,L"MsgReplaceCount",IDS_REPLCOUNT,iCount); + else + InfoBox(0,L"MsgNotFound",IDS_NOTFOUND); + } + + LocalFree(pszReplace2); + return TRUE; + +} + + +//============================================================================= +// +// EditLinenumDlgProc() +// +INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + switch(umsg) + { + + case WM_INITDIALOG: + { + + int iCurLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, + SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0),0)+1; + + SetDlgItemInt(hwnd,IDC_LINENUM,iCurLine,FALSE); + SendDlgItemMessage(hwnd,IDC_LINENUM,EM_LIMITTEXT,15,0); + + SendDlgItemMessage(hwnd,IDC_COLNUM,EM_LIMITTEXT,15,0); + + CenterDlgInParent(hwnd); + + } + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDOK: { + + BOOL fTranslated; + BOOL fTranslated2; + + int iNewCol; + + int iNewLine = (int)GetDlgItemInt(hwnd,IDC_LINENUM,&fTranslated,FALSE); + int iMaxLine = (int)SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0); + + if (SendDlgItemMessage(hwnd,IDC_COLNUM,WM_GETTEXTLENGTH,0,0) > 0) + iNewCol = GetDlgItemInt(hwnd,IDC_COLNUM,&fTranslated2,FALSE); + else { + iNewCol = 1; + fTranslated2 = TRUE; + } + + if (!fTranslated || !fTranslated2) + { + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!fTranslated) ? IDC_LINENUM : IDC_COLNUM)),1); + return TRUE; + } + + if (iNewLine > 0 && iNewLine <= iMaxLine && iNewCol > 0) + { + //int iNewPos = SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iNewLine-1,0); + //int iLineEndPos = SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iNewLine-1,0); + + //while (iNewCol-1 > SendMessage(hwndEdit,SCI_GETCOLUMN,(WPARAM)iNewPos,0)) + //{ + // if (iNewPos >= iLineEndPos) + // break; + + // iNewPos = SendMessage(hwndEdit,SCI_POSITIONAFTER,(WPARAM)iNewPos,0); + //} + + //iNewPos = min(iNewPos,iLineEndPos); + //SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0); + //SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); + + EditJumpTo(hwndEdit,iNewLine,iNewCol); + + EndDialog(hwnd,IDOK); + } + + else + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,(!(iNewLine > 0 && iNewLine <= iMaxLine)) ? IDC_LINENUM : IDC_COLNUM)),1); + + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// EditLinenumDlg() +// +BOOL EditLinenumDlg(HWND hwnd) +{ + + if (IDOK == ThemedDialogBoxParam(g_hInstance,MAKEINTRESOURCE(IDD_LINENUM), + GetParent(hwnd),EditLinenumDlgProc,(LPARAM)hwnd)) + return TRUE; + + else + return FALSE; + +} + + +//============================================================================= +// +// EditModifyLinesDlg() +// +// Controls: 100 Input +// 101 Input +// +typedef struct _modlinesdata { + LPWSTR pwsz1; + LPWSTR pwsz2; +} MODLINESDATA, *PMODLINESDATA; + + +INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static PMODLINESDATA pdata; + + static int id_hover; + static int id_capture; + + static HFONT hFontNormal; + static HFONT hFontHover; + + static HCURSOR hCursorNormal; + static HCURSOR hCursorHover; + + switch(umsg) + { + case WM_INITDIALOG: + { + LOGFONT lf; + + id_hover = 0; + id_capture = 0; + + if (NULL == (hFontNormal = (HFONT)SendDlgItemMessage(hwnd,200,WM_GETFONT,0,0))) + hFontNormal = GetStockObject(DEFAULT_GUI_FONT); + GetObject(hFontNormal,sizeof(LOGFONT),&lf); + lf.lfUnderline = TRUE; + hFontHover = CreateFontIndirect(&lf); + + hCursorNormal = LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW)); + if (!(hCursorHover = LoadCursor(NULL,MAKEINTRESOURCE(IDC_HAND)))) + hCursorHover = LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_ARROW)); + + pdata = (PMODLINESDATA)lParam; + SetDlgItemTextW(hwnd,100,pdata->pwsz1); + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0); + SetDlgItemTextW(hwnd,101,pdata->pwsz2); + SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); + CenterDlgInParent(hwnd); + } + return TRUE; + + case WM_DESTROY: + DeleteObject(hFontHover); + return FALSE; + + case WM_NCACTIVATE: + if (!(BOOL)wParam) { + if (id_hover != 0) { + //int _id_hover = id_hover; + id_hover = 0; + id_capture = 0; + //InvalidateRect(GetDlgItem(hwnd,id_hover),NULL,FALSE); + } + } + return FALSE; + + case WM_CTLCOLORSTATIC: + { + DWORD dwId = GetWindowLong((HWND)lParam,GWL_ID); + HDC hdc = (HDC)wParam; + + if (dwId >= 200 && dwId <= 205) { + SetBkMode(hdc,TRANSPARENT); + if (GetSysColorBrush(COLOR_HOTLIGHT)) + SetTextColor(hdc,GetSysColor(COLOR_HOTLIGHT)); + else + SetTextColor(hdc,RGB(0,0,255)); + SelectObject(hdc,/*dwId == id_hover?*/hFontHover/*:hFontNormal*/); + return(LONG_PTR)GetSysColorBrush(COLOR_BTNFACE); + } + } + break; + + case WM_MOUSEMOVE: + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + HWND hwndHover = ChildWindowFromPoint(hwnd,pt); + DWORD dwId = GetWindowLong(hwndHover,GWL_ID); + + if (GetActiveWindow() == hwnd) { + if (dwId >= 200 && dwId <= 205) { + if (id_capture == dwId || id_capture == 0) { + if (id_hover != id_capture || id_hover == 0) { + id_hover = dwId; + //InvalidateRect(GetDlgItem(hwnd,dwId),NULL,FALSE); + } + } + else if (id_hover != 0) { + //int _id_hover = id_hover; + id_hover = 0; + //InvalidateRect(GetDlgItem(hwnd,_id_hover),NULL,FALSE); + } + } + else if (id_hover != 0) { + //int _id_hover = id_hover; + id_hover = 0; + //InvalidateRect(GetDlgItem(hwnd,_id_hover),NULL,FALSE); + } + SetCursor(id_hover != 0?hCursorHover:hCursorNormal); + } + } + break; + + case WM_LBUTTONDOWN: + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + HWND hwndHover = ChildWindowFromPoint(hwnd,pt); + DWORD dwId = GetWindowLong(hwndHover,GWL_ID); + + if (dwId >= 200 && dwId <= 205) { + GetCapture(); + id_hover = dwId; + id_capture = dwId; + //InvalidateRect(GetDlgItem(hwnd,dwId),NULL,FALSE); + } + SetCursor(id_hover != 0?hCursorHover:hCursorNormal); + } + break; + + case WM_LBUTTONUP: + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + HWND hwndHover = ChildWindowFromPoint(hwnd,pt); + DWORD dwId = GetWindowLong(hwndHover,GWL_ID); + if (id_capture != 0) { + ReleaseCapture(); + if (id_hover == id_capture) { + int id_focus = GetWindowLong(GetFocus(),GWL_ID); + if (id_focus == 100 || id_focus == 101) { + WCHAR wch[8]; + GetDlgItemText(hwnd,id_capture,wch,COUNTOF(wch)); + SendDlgItemMessage(hwnd,id_focus,EM_SETSEL,(WPARAM)0,(LPARAM)-1); + SendDlgItemMessage(hwnd,id_focus,EM_REPLACESEL,(WPARAM)TRUE,(LPARAM)wch); + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetFocus()),1); + } + } + id_capture = 0; + } + SetCursor(id_hover != 0?hCursorHover:hCursorNormal); + } + break; + + case WM_CANCELMODE: + if (id_capture != 0) { + ReleaseCapture(); + id_hover = 0; + id_capture = 0; + SetCursor(hCursorNormal); + } + break; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); + GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); + EndDialog(hwnd,IDOK); + } + break; + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// EditModifyLinesDlg() +// +BOOL EditModifyLinesDlg(HWND hwnd,LPWSTR pwsz1,LPWSTR pwsz2) +{ + + INT_PTR iResult; + MODLINESDATA data = { pwsz1, pwsz2 }; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_MODIFYLINES), + hwnd, + EditModifyLinesDlgProc, + (LPARAM)&data); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// EditAlignDlgProc() +// +// Controls: 100 Radio Button +// 101 Radio Button +// 102 Radio Button +// 103 Radio Button +// 104 Radio Button +// +INT_PTR CALLBACK EditAlignDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static int *piAlignMode; + switch(umsg) + { + case WM_INITDIALOG: + { + piAlignMode = (int*)lParam; + CheckRadioButton(hwnd,100,104,*piAlignMode+100); + CenterDlgInParent(hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + *piAlignMode = 0; + if (IsDlgButtonChecked(hwnd,100) == BST_CHECKED) + *piAlignMode = ALIGN_LEFT; + else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) + *piAlignMode = ALIGN_RIGHT; + else if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED) + *piAlignMode = ALIGN_CENTER; + else if (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) + *piAlignMode = ALIGN_JUSTIFY; + else if (IsDlgButtonChecked(hwnd,104) == BST_CHECKED) + *piAlignMode = ALIGN_JUSTIFY_EX; + EndDialog(hwnd,IDOK); + } + break; + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// EditAlignDlg() +// +BOOL EditAlignDlg(HWND hwnd,int *piAlignMode) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_ALIGN), + hwnd, + EditAlignDlgProc, + (LPARAM)piAlignMode); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// EditEncloseSelectionDlgProc() +// +// Controls: 100 Input +// 101 Input +// +typedef struct _encloseselectiondata { + LPWSTR pwsz1; + LPWSTR pwsz2; +} ENCLOSESELDATA, *PENCLOSESELDATA; + + +INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static PENCLOSESELDATA pdata; + switch(umsg) + { + case WM_INITDIALOG: + { + pdata = (PENCLOSESELDATA)lParam; + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0); + SetDlgItemTextW(hwnd,100,pdata->pwsz1); + SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); + SetDlgItemTextW(hwnd,101,pdata->pwsz2); + CenterDlgInParent(hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); + GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); + EndDialog(hwnd,IDOK); + } + break; + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// EditEncloseSelectionDlg() +// +BOOL EditEncloseSelectionDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) +{ + + INT_PTR iResult; + ENCLOSESELDATA data = { pwszOpen, pwszClose }; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_ENCLOSESELECTION), + hwnd, + EditEncloseSelectionDlgProc, + (LPARAM)&data); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// EditInsertTagDlgProc() +// +// Controls: 100 Input +// 101 Input +// +typedef struct _tagsdata { + LPWSTR pwsz1; + LPWSTR pwsz2; +} TAGSDATA, *PTAGSDATA; + + +INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static PTAGSDATA pdata; + switch(umsg) + { + case WM_INITDIALOG: + { + pdata = (PTAGSDATA)lParam; + SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,254,0); + SetDlgItemTextW(hwnd,100,L""); + SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); + SetDlgItemTextW(hwnd,101,L""); + SetFocus(GetDlgItem(hwnd,100)); + PostMessage(GetDlgItem(hwnd,100),EM_SETSEL,1,4); + CenterDlgInParent(hwnd); + } + return FALSE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case 100: { + if (HIWORD(wParam) == EN_CHANGE) { + + WCHAR wchBuf[256]; + WCHAR wchIns[256] = L"= 3) { + + if (wchBuf[0] == L'<') { + + const WCHAR* pwCur = &wchBuf[1]; + + while ( + *pwCur && + *pwCur != L'<' && + *pwCur != L'>' && + *pwCur != L' ' && + *pwCur != L'\t' && + (StrChr(L":_-.",*pwCur) || IsCharAlphaNumericW(*pwCur))) + + wchIns[cchIns++] = *pwCur++; + + while ( + *pwCur && + *pwCur != L'>') + + pwCur++; + + if (*pwCur == L'>' && *(pwCur-1) != L'/') { + wchIns[cchIns++] = L'>'; + wchIns[cchIns] = L'\0'; + + if (cchIns > 3 && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"
") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"") && + lstrcmpi(wchIns,L"")) { + + SetDlgItemTextW(hwnd,101,wchIns); + bClear = FALSE; + } + } + } + } + if (bClear) + SetDlgItemTextW(hwnd,101,L""); + } + } + break; + case IDOK: { + GetDlgItemTextW(hwnd,100,pdata->pwsz1,256); + GetDlgItemTextW(hwnd,101,pdata->pwsz2,256); + EndDialog(hwnd,IDOK); + } + break; + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// EditInsertTagDlg() +// +BOOL EditInsertTagDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) +{ + + INT_PTR iResult; + TAGSDATA data = { pwszOpen, pwszClose }; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_INSERTTAG), + hwnd, + EditInsertTagDlgProc, + (LPARAM)&data); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// EditSortDlgProc() +// +// Controls: 100-102 Radio Button +// 103-108 Check Box +// +INT_PTR CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static int *piSortFlags; + static BOOL bEnableLogicalSort; + + switch(umsg) + { + case WM_INITDIALOG: + { + piSortFlags = (int*)lParam; + if (*piSortFlags & SORT_DESCENDING) + CheckRadioButton(hwnd,100,102,101); + else if (*piSortFlags & SORT_SHUFFLE) { + CheckRadioButton(hwnd,100,102,102); + EnableWindow(GetDlgItem(hwnd,103),FALSE); + EnableWindow(GetDlgItem(hwnd,104),FALSE); + EnableWindow(GetDlgItem(hwnd,105),FALSE); + EnableWindow(GetDlgItem(hwnd,106),FALSE); + EnableWindow(GetDlgItem(hwnd,107),FALSE); + } + else + CheckRadioButton(hwnd,100,102,100); + if (*piSortFlags & SORT_MERGEDUP) + CheckDlgButton(hwnd,103,BST_CHECKED); + if (*piSortFlags & SORT_UNIQDUP) { + CheckDlgButton(hwnd,104,BST_CHECKED); + EnableWindow(GetDlgItem(hwnd,103),FALSE); + } + if (*piSortFlags & SORT_UNIQUNIQ) + CheckDlgButton(hwnd,105,BST_CHECKED); + if (*piSortFlags & SORT_NOCASE) + CheckDlgButton(hwnd,106,BST_CHECKED); + if (GetProcAddress(GetModuleHandle(L"shlwapi"),"StrCmpLogicalW")) { + if (*piSortFlags & SORT_LOGICAL) + CheckDlgButton(hwnd,107,BST_CHECKED); + bEnableLogicalSort = TRUE; + } + else { + EnableWindow(GetDlgItem(hwnd,107),FALSE); + bEnableLogicalSort = FALSE; + } + if (SC_SEL_RECTANGLE != SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0)) { + *piSortFlags &= ~SORT_COLUMN; + EnableWindow(GetDlgItem(hwnd,108),FALSE); + } + else { + *piSortFlags |= SORT_COLUMN; + CheckDlgButton(hwnd,108,BST_CHECKED); + } + CenterDlgInParent(hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + *piSortFlags = 0; + if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED) + *piSortFlags |= SORT_DESCENDING; + if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED) + *piSortFlags |= SORT_SHUFFLE; + if (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) + *piSortFlags |= SORT_MERGEDUP; + if (IsDlgButtonChecked(hwnd,104) == BST_CHECKED) + *piSortFlags |= SORT_UNIQDUP; + if (IsDlgButtonChecked(hwnd,105) == BST_CHECKED) + *piSortFlags |= SORT_UNIQUNIQ; + if (IsDlgButtonChecked(hwnd,106) == BST_CHECKED) + *piSortFlags |= SORT_NOCASE; + if (IsDlgButtonChecked(hwnd,107) == BST_CHECKED) + *piSortFlags |= SORT_LOGICAL; + if (IsDlgButtonChecked(hwnd,108) == BST_CHECKED) + *piSortFlags |= SORT_COLUMN; + EndDialog(hwnd,IDOK); + } + break; + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + case 100: + case 101: + EnableWindow(GetDlgItem(hwnd,103),IsDlgButtonChecked(hwnd,105) != BST_CHECKED); + EnableWindow(GetDlgItem(hwnd,104),TRUE); + EnableWindow(GetDlgItem(hwnd,105),TRUE); + EnableWindow(GetDlgItem(hwnd,106),TRUE); + EnableWindow(GetDlgItem(hwnd,107),bEnableLogicalSort); + break; + case 102: + EnableWindow(GetDlgItem(hwnd,103),FALSE); + EnableWindow(GetDlgItem(hwnd,104),FALSE); + EnableWindow(GetDlgItem(hwnd,105),FALSE); + EnableWindow(GetDlgItem(hwnd,106),FALSE); + EnableWindow(GetDlgItem(hwnd,107),FALSE); + break; + case 104: + EnableWindow(GetDlgItem(hwnd,103),IsDlgButtonChecked(hwnd,104) != BST_CHECKED); + break; + } + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// EditSortDlg() +// +BOOL EditSortDlg(HWND hwnd,int *piSortFlags) +{ + + INT_PTR iResult; + + iResult = ThemedDialogBoxParam( + g_hInstance, + MAKEINTRESOURCEW(IDD_SORT), + hwnd, + EditSortDlgProc, + (LPARAM)piSortFlags); + + return (iResult == IDOK) ? TRUE : FALSE; + +} + + +//============================================================================= +// +// FileVars_Init() +// +extern BOOL bNoEncodingTags; +extern int fNoFileVariables; + +BOOL FileVars_Init(char *lpData,DWORD cbData,LPFILEVARS lpfv) { + + int i; + char tch[512]; + BOOL bDisableFileVariables = FALSE; + + ZeroMemory(lpfv,sizeof(FILEVARS)); + if ((fNoFileVariables && bNoEncodingTags) || !lpData || !cbData) + return(TRUE); + + lstrcpynA(tch,lpData,min(cbData+1,COUNTOF(tch))); + + if (!fNoFileVariables) { + if (FileVars_ParseInt(tch,"enable-local-variables",&i) && (!i)) + bDisableFileVariables = TRUE; + + if (!bDisableFileVariables) { + + if (FileVars_ParseInt(tch,"tab-width",&i)) { + lpfv->iTabWidth = max(min(i,256),1); + lpfv->mask |= FV_TABWIDTH; + } + + if (FileVars_ParseInt(tch,"c-basic-indent",&i)) { + lpfv->iIndentWidth = max(min(i,256),0); + lpfv->mask |= FV_INDENTWIDTH; + } + + if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) { + lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE; + lpfv->mask |= FV_TABSASSPACES; + } + + if (FileVars_ParseInt(tch,"c-tab-always-indent",&i)) { + lpfv->bTabIndents = (i) ? TRUE : FALSE; + lpfv->mask |= FV_TABINDENTS; + } + + if (FileVars_ParseInt(tch,"truncate-lines",&i)) { + lpfv->fWordWrap = (i) ? FALSE : TRUE; + lpfv->mask |= FV_WORDWRAP; + } + + if (FileVars_ParseInt(tch,"fill-column",&i)) { + lpfv->iLongLinesLimit = max(min(i,4096),0); + lpfv->mask |= FV_LONGLINESLIMIT; + } + } + } + + if (!IsUTF8Signature(lpData) && !bNoEncodingTags && !bDisableFileVariables) { + + if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + } + + if (!fNoFileVariables && !bDisableFileVariables) { + if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode))) + lpfv->mask |= FV_MODE; + } + + if (lpfv->mask == 0 && cbData > COUNTOF(tch)) { + + lstrcpynA(tch,lpData+cbData-COUNTOF(tch)+1,COUNTOF(tch)); + + if (!fNoFileVariables) { + if (FileVars_ParseInt(tch,"enable-local-variables",&i) && (!i)) + bDisableFileVariables = TRUE; + + if (!bDisableFileVariables) { + + if (FileVars_ParseInt(tch,"tab-width",&i)) { + lpfv->iTabWidth = max(min(i,256),1); + lpfv->mask |= FV_TABWIDTH; + } + + if (FileVars_ParseInt(tch,"c-basic-indent",&i)) { + lpfv->iIndentWidth = max(min(i,256),0); + lpfv->mask |= FV_INDENTWIDTH; + } + + if (FileVars_ParseInt(tch,"indent-tabs-mode",&i)) { + lpfv->bTabsAsSpaces = (i) ? FALSE : TRUE; + lpfv->mask |= FV_TABSASSPACES; + } + + if (FileVars_ParseInt(tch,"c-tab-always-indent",&i)) { + lpfv->bTabIndents = (i) ? TRUE : FALSE; + lpfv->mask |= FV_TABINDENTS; + } + + if (FileVars_ParseInt(tch,"truncate-lines",&i)) { + lpfv->fWordWrap = (i) ? FALSE : TRUE; + lpfv->mask |= FV_WORDWRAP; + } + + if (FileVars_ParseInt(tch,"fill-column",&i)) { + lpfv->iLongLinesLimit = max(min(i,4096),0); + lpfv->mask |= FV_LONGLINESLIMIT; + } + } + } + + if (!IsUTF8Signature(lpData) && !bNoEncodingTags && !bDisableFileVariables) { + + if (FileVars_ParseStr(tch,"encoding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + else if (FileVars_ParseStr(tch,"charset",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + else if (FileVars_ParseStr(tch,"coding",lpfv->tchEncoding,COUNTOF(lpfv->tchEncoding))) + lpfv->mask |= FV_ENCODING; + } + + if (!fNoFileVariables && !bDisableFileVariables) { + if (FileVars_ParseStr(tch,"mode",lpfv->tchMode,COUNTOF(lpfv->tchMode))) + lpfv->mask |= FV_MODE; + } + } + + if (lpfv->mask & FV_ENCODING) + lpfv->iEncoding = Encoding_MatchA(lpfv->tchEncoding); + + return(TRUE); +} + + +//============================================================================= +// +// FileVars_Apply() +// +extern int iTabWidth; +extern int iTabWidthG; +extern int iIndentWidth; +extern int iIndentWidthG; +extern BOOL bTabsAsSpaces; +extern BOOL bTabsAsSpacesG; +extern BOOL bTabIndents; +extern BOOL bTabIndentsG; +extern int fWordWrap; +extern int fWordWrapG; +extern int iWordWrapMode; +extern int iLongLinesLimit; +extern int iLongLinesLimitG; +extern int iWrapCol; + +BOOL FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) { + + if (lpfv->mask & FV_TABWIDTH) + iTabWidth = lpfv->iTabWidth; + else + iTabWidth = iTabWidthG; + SendMessage(hwnd,SCI_SETTABWIDTH,iTabWidth,0); + + if (lpfv->mask & FV_INDENTWIDTH) + iIndentWidth = lpfv->iIndentWidth; + else if (lpfv->mask & FV_TABWIDTH) + iIndentWidth = 0; + else + iIndentWidth = iIndentWidthG; + SendMessage(hwnd,SCI_SETINDENT,iIndentWidth,0); + + if (lpfv->mask & FV_TABSASSPACES) + bTabsAsSpaces = lpfv->bTabsAsSpaces; + else + bTabsAsSpaces = bTabsAsSpacesG; + SendMessage(hwnd,SCI_SETUSETABS,!bTabsAsSpaces,0); + + if (lpfv->mask & FV_TABINDENTS) + bTabIndents = lpfv->bTabIndents; + else + bTabIndents = bTabIndentsG; + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + + if (lpfv->mask & FV_WORDWRAP) + fWordWrap = lpfv->fWordWrap; + else + fWordWrap = fWordWrapG; + if (!fWordWrap) + SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); + else + SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); + + if (lpfv->mask & FV_LONGLINESLIMIT) + iLongLinesLimit = lpfv->iLongLinesLimit; + else + iLongLinesLimit = iLongLinesLimitG; + SendMessage(hwnd,SCI_SETEDGECOLUMN,iLongLinesLimit,0); + + iWrapCol = 0; + + return(TRUE); +} + + +//============================================================================= +// +// FileVars_ParseInt() +// +BOOL FileVars_ParseInt(char* pszData,char* pszName,int* piValue) { + + char tch[32]; + char *pvStart = pszData; + char chPrev; + char *pvEnd; + int itok; + + while (pvStart = StrStrIA(pvStart,pszName)) { + chPrev = (pvStart > pszData) ? *(pvStart-1) : 0; + if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') { + pvStart += lstrlenA(pszName); + while (*pvStart == ' ') + pvStart++; + if (*pvStart == ':' || *pvStart == '=') + break; + } + else + pvStart += lstrlenA(pszName); + } + + if (pvStart) { + + while (*pvStart && StrChrIA(":=\"' \t",*pvStart)) + pvStart++; + + lstrcpynA(tch,pvStart,COUNTOF(tch)); + + pvEnd = tch; + while (*pvEnd && IsCharAlphaNumericA(*pvEnd)) + pvEnd++; + *pvEnd = 0; + StrTrimA(tch," \t:=\"'"); + + itok = sscanf(tch,"%i",piValue); + if (itok == 1) + return(TRUE); + + if (tch[0] == 't') { + *piValue = 1; + return(TRUE); + } + + if (tch[0] == 'n' || tch[0] == 'f') { + *piValue = 0; + return(TRUE); + } + } + return(FALSE); +} + + +//============================================================================= +// +// FileVars_ParseStr() +// +BOOL FileVars_ParseStr(char* pszData,char* pszName,char* pszValue,int cchValue) { + + char tch[32]; + char *pvStart = pszData; + char chPrev; + char *pvEnd; + BOOL bQuoted = FALSE; + + while (pvStart = StrStrIA(pvStart,pszName)) { + chPrev = (pvStart > pszData) ? *(pvStart-1) : 0; + if (!IsCharAlphaNumericA(chPrev) && chPrev != '-' && chPrev != '_') { + pvStart += lstrlenA(pszName); + while (*pvStart == ' ') + pvStart++; + if (*pvStart == ':' || *pvStart == '=') + break; + } + else + pvStart += lstrlenA(pszName); + } + + if (pvStart) { + + while (*pvStart && StrChrIA(":=\"' \t",*pvStart)) { + if (*pvStart == '\'' || *pvStart == '"') + bQuoted = TRUE; + pvStart++; + } + lstrcpynA(tch,pvStart,COUNTOF(tch)); + + pvEnd = tch; + while (*pvEnd && (IsCharAlphaNumericA(*pvEnd) || StrChrIA("+-/_",*pvEnd) || (bQuoted && *pvEnd == ' '))) + pvEnd++; + *pvEnd = 0; + StrTrimA(tch," \t:=\"'"); + + lstrcpynA(pszValue,tch,cchValue); + return(TRUE); + } + return(FALSE); +} + + +//============================================================================= +// +// FileVars_IsUTF8() +// +BOOL FileVars_IsUTF8(LPFILEVARS lpfv) { + if (lpfv->mask & FV_ENCODING) { + if (lstrcmpiA(lpfv->tchEncoding,"utf-8") == 0 || + lstrcmpiA(lpfv->tchEncoding,"utf8") == 0) + return(TRUE); + } + return(FALSE); +} + + +//============================================================================= +// +// FileVars_IsNonUTF8() +// +BOOL FileVars_IsNonUTF8(LPFILEVARS lpfv) { + if (lpfv->mask & FV_ENCODING) { + if (lstrlenA(lpfv->tchEncoding) && + lstrcmpiA(lpfv->tchEncoding,"utf-8") != 0 && + lstrcmpiA(lpfv->tchEncoding,"utf8") != 0) + return(TRUE); + } + return(FALSE); +} + + +//============================================================================= +// +// FileVars_IsValidEncoding() +// +BOOL FileVars_IsValidEncoding(LPFILEVARS lpfv) { + CPINFO cpi; + if (lpfv->mask & FV_ENCODING && + lpfv->iEncoding >= 0 && + lpfv->iEncoding < COUNTOF(mEncoding)) { + if ((mEncoding[lpfv->iEncoding].uFlags & NCP_INTERNAL) || + IsValidCodePage(mEncoding[lpfv->iEncoding].uCodePage) && + GetCPInfo(mEncoding[lpfv->iEncoding].uCodePage,&cpi)) { + return(TRUE); + } + } + return(FALSE); +} + + +//============================================================================= +// +// FileVars_GetEncoding() +// +int FileVars_GetEncoding(LPFILEVARS lpfv) { + if (lpfv->mask & FV_ENCODING) + return(lpfv->iEncoding); + else + return(-1); +} + + +//============================================================================= +// +// SciInitThemes() +// +//WNDPROC pfnSciWndProc = NULL; +// +//FARPROC pfnOpenThemeData = NULL; +//FARPROC pfnCloseThemeData = NULL; +//FARPROC pfnDrawThemeBackground = NULL; +//FARPROC pfnGetThemeBackgroundContentRect = NULL; +//FARPROC pfnIsThemeActive = NULL; +//FARPROC pfnDrawThemeParentBackground = NULL; +//FARPROC pfnIsThemeBackgroundPartiallyTransparent = NULL; +// +//BOOL bThemesPresent = FALSE; +//extern BOOL bIsAppThemed; +//extern HMODULE hModUxTheme; +// +//void SciInitThemes(HWND hwnd) +//{ +// if (hModUxTheme) { +// +// pfnOpenThemeData = GetProcAddress(hModUxTheme,"OpenThemeData"); +// pfnCloseThemeData = GetProcAddress(hModUxTheme,"CloseThemeData"); +// pfnDrawThemeBackground = GetProcAddress(hModUxTheme,"DrawThemeBackground"); +// pfnGetThemeBackgroundContentRect = GetProcAddress(hModUxTheme,"GetThemeBackgroundContentRect"); +// pfnIsThemeActive = GetProcAddress(hModUxTheme,"IsThemeActive"); +// pfnDrawThemeParentBackground = GetProcAddress(hModUxTheme,"DrawThemeParentBackground"); +// pfnIsThemeBackgroundPartiallyTransparent = GetProcAddress(hModUxTheme,"IsThemeBackgroundPartiallyTransparent"); +// +// pfnSciWndProc = (WNDPROC)SetWindowLongPtrW(hwnd,GWLP_WNDPROC,(LONG_PTR)&SciThemedWndProc); +// bThemesPresent = TRUE; +// } +//} +// +// +////============================================================================= +//// +//// SciThemedWndProc() +//// +//LRESULT CALLBACK SciThemedWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +//{ +// static RECT rcContent; +// +// if (umsg == WM_NCCALCSIZE) { +// if (wParam) { +// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCCALCSIZE,wParam,lParam); +// NCCALCSIZE_PARAMS *csp = (NCCALCSIZE_PARAMS*)lParam; +// +// if (bThemesPresent && bIsAppThemed) { +// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit"); +// if(hTheme) { +// BOOL bSuccess = FALSE; +// RECT rcClient; +// +// if(pfnGetThemeBackgroundContentRect( +// hTheme,NULL,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1,&csp->rgrc[0],&rcClient) == S_OK) { +// InflateRect(&rcClient,-1,-1); +// +// rcContent.left = rcClient.left-csp->rgrc[0].left; +// rcContent.top = rcClient.top-csp->rgrc[0].top; +// rcContent.right = csp->rgrc[0].right-rcClient.right; +// rcContent.bottom = csp->rgrc[0].bottom-rcClient.bottom; +// +// CopyRect(&csp->rgrc[0],&rcClient); +// bSuccess = TRUE; +// } +// pfnCloseThemeData(hTheme); +// +// if (bSuccess) +// return WVR_REDRAW; +// } +// } +// return lresult; +// } +// } +// +// else if (umsg == WM_NCPAINT) { +// LRESULT lresult = CallWindowProcW(pfnSciWndProc,hwnd,WM_NCPAINT,wParam,lParam); +// if(bThemesPresent && bIsAppThemed) { +// +// HANDLE hTheme = (HANDLE)pfnOpenThemeData(hwnd,L"edit"); +// if(hTheme) { +// RECT rcBorder; +// RECT rcClient; +// int nState; +// +// HDC hdc = GetWindowDC(hwnd); +// +// GetWindowRect(hwnd,&rcBorder); +// OffsetRect(&rcBorder,-rcBorder.left,-rcBorder.top); +// +// CopyRect(&rcClient,&rcBorder); +// rcClient.left += rcContent.left; +// rcClient.top += rcContent.top; +// rcClient.right -= rcContent.right; +// rcClient.bottom -= rcContent.bottom; +// +// ExcludeClipRect(hdc,rcClient.left,rcClient.top,rcClient.right,rcClient.bottom); +// +// if(pfnIsThemeBackgroundPartiallyTransparent(hTheme,/*EP_EDITTEXT*/1,/*ETS_NORMAL*/1)) +// pfnDrawThemeParentBackground(hwnd,hdc,&rcBorder); +// +// /* +// ETS_NORMAL = 1 +// ETS_HOT = 2 +// ETS_SELECTED = 3 +// ETS_DISABLED = 4 +// ETS_FOCUSED = 5 +// ETS_READONLY = 6 +// ETS_ASSIST = 7 +// */ +// +// if(!IsWindowEnabled(hwnd)) +// nState = /*ETS_DISABLED*/4; +// else if (GetFocus() == hwnd) +// nState = /*ETS_FOCUSED*/5; +// else if(SendMessage(hwnd,SCI_GETREADONLY,0,0)) +// nState = /*ETS_READONLY*/6; +// else +// nState = /*ETS_NORMAL*/1; +// +// pfnDrawThemeBackground(hTheme,hdc,/*EP_EDITTEXT*/1,nState,&rcBorder,NULL); +// pfnCloseThemeData(hTheme); +// +// ReleaseDC(hwnd,hdc); +// return 0; +// } +// } +// return lresult; +// } +// +// return CallWindowProcW(pfnSciWndProc,hwnd,umsg,wParam,lParam); +//} + + + +/// End of Edit.c \\\ diff --git a/src/Edit.h b/src/Edit.h index bc3f59bc..7f5f3f55 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -1,225 +1,225 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Edit.h -* Text File Editing Helper Stuff -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - - - -// extern "C" declarations of Scintilla functions -BOOL Scintilla_RegisterClasses(void*); -BOOL Scintilla_ReleaseResources(); - - -typedef struct _editfindreplace -{ - char szFind[512]; - char szReplace[512]; - char szFindUTF8[3*512]; - char szReplaceUTF8[3*512]; - UINT fuFlags; - BOOL bTransformBS; - BOOL bObsolete /* was bFindUp */; - BOOL bFindClose; - BOOL bReplaceClose; - BOOL bNoFindWrap; - HWND hwnd; -#ifdef BOOKMARK_EDITION - BOOL bWildcardSearch; -#endif - //HANDLE hMRUFind; - //HANDLE hMRUReplace; - -} EDITFINDREPLACE, *LPEDITFINDREPLACE, *LPCEDITFINDREPLACE; - - -#define IDMSG_SWITCHTOFIND 300 -#define IDMSG_SWITCHTOREPLACE 301 - - -#define ALIGN_LEFT 0 -#define ALIGN_RIGHT 1 -#define ALIGN_CENTER 2 -#define ALIGN_JUSTIFY 3 -#define ALIGN_JUSTIFY_EX 4 - - -#define SORT_ASCENDING 0 -#define SORT_DESCENDING 1 -#define SORT_SHUFFLE 2 -#define SORT_MERGEDUP 4 -#define SORT_UNIQDUP 8 -#define SORT_UNIQUNIQ 16 -#define SORT_NOCASE 32 -#define SORT_LOGICAL 64 -#define SORT_COLUMN 128 - - -HWND EditCreate(HWND); -void EditSetNewText(HWND,char*,DWORD); -BOOL EditConvertText(HWND,UINT,UINT,BOOL); -BOOL EditSetNewEncoding(HWND,int,int,BOOL,BOOL); -char* EditGetClipboardText(HWND); -BOOL EditCopyAppend(HWND); -int EditDetectEOLMode(HWND,char*,DWORD); -BOOL EditLoadFile(HWND,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*); -BOOL EditSaveFile(HWND,LPCWSTR,int,BOOL*,BOOL); - -void EditInvertCase(HWND); -void EditTitleCase(HWND); -void EditSentenceCase(HWND); - -void EditURLEncode(HWND); -void EditURLDecode(HWND); -void EditEscapeCChars(HWND); -void EditUnescapeCChars(HWND); -void EditChar2Hex(HWND); -void EditHex2Char(HWND); -void EditModifyNumber(HWND,BOOL); - -void EditTabsToSpaces(HWND,int,BOOL); -void EditSpacesToTabs(HWND,int,BOOL); - -void EditMoveUp(HWND); -void EditMoveDown(HWND); -void EditModifyLines(HWND,LPCWSTR,LPCWSTR); -void EditAlignText(HWND,int); -void EditEncloseSelection(HWND,LPCWSTR,LPCWSTR); -void EditToggleLineComments(HWND,LPCWSTR,BOOL); -void EditPadWithSpaces(HWND,BOOL,BOOL); -void EditStripFirstCharacter(HWND); -void EditStripLastCharacter(HWND); -void EditStripTrailingBlanks(HWND,BOOL); -void EditCompressSpaces(HWND); -void EditRemoveBlankLines(HWND,BOOL); -void EditWrapToColumn(HWND,int); -void EditJoinLinesEx(HWND); -void EditSortLines(HWND,int); - -void EditJumpTo(HWND,int,int); -void EditSelectEx(HWND,int,int); -void EditFixPositions(HWND); -void EditEnsureSelectionVisible(HWND); -void EditGetExcerpt(HWND,LPWSTR,DWORD); - -HWND EditFindReplaceDlg(HWND,LPCEDITFINDREPLACE,BOOL); -BOOL EditFindNext(HWND,LPCEDITFINDREPLACE,BOOL); -BOOL EditFindPrev(HWND,LPCEDITFINDREPLACE,BOOL); -BOOL EditReplace(HWND,LPCEDITFINDREPLACE); -BOOL EditReplaceAll(HWND,LPCEDITFINDREPLACE,BOOL); -BOOL EditReplaceAllInSelection(HWND,LPCEDITFINDREPLACE,BOOL); -BOOL EditLinenumDlg(HWND); -BOOL EditModifyLinesDlg(HWND,LPWSTR,LPWSTR); -BOOL EditEncloseSelectionDlg(HWND,LPWSTR,LPWSTR); -BOOL EditInsertTagDlg(HWND,LPWSTR,LPWSTR); -BOOL EditSortDlg(HWND,int*); -BOOL EditAlignDlg(HWND,int*); -BOOL EditPrint(HWND,LPCWSTR,LPCWSTR); -void EditPrintSetup(HWND); -void EditPrintInit(); -void EditMarkAll(HWND,int,BOOL,BOOL); -void CompleteWord(HWND, BOOL); - -extern int g_DOSEncoding; - -#define NCP_DEFAULT 1 -#define NCP_UTF8 2 -#define NCP_UTF8_SIGN 4 -#define NCP_UNICODE 8 -#define NCP_UNICODE_REVERSE 16 -#define NCP_UNICODE_BOM 32 -#define NCP_8BIT 64 -#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM) -#define NCP_RECODE 128 -#define CPI_NONE -1 -#define CPI_DEFAULT 0 -#define CPI_OEM 1 -#define CPI_UNICODEBOM 2 -#define CPI_UNICODEBEBOM 3 -#define CPI_UNICODE 4 -#define CPI_UNICODEBE 5 -#define CPI_UTF8 6 -#define CPI_UTF8SIGN 7 -#define CPI_UTF7 8 - -#define IDS_ENCODINGNAME0 61000 -#define IDS_EOLMODENAME0 62000 - -typedef struct _np2encoding { - UINT uFlags; - UINT uCodePage; - char* pszParseNames; - int idsName; - WCHAR wchLabel[32]; -} NP2ENCODING; - -void Encoding_InitDefaults(); -int Encoding_MapIniSetting(BOOL,int); -void Encoding_GetLabel(int); -int Encoding_MatchW(LPCWSTR); -int Encoding_MatchA(char*); -BOOL Encoding_IsValid(int); -void Encoding_AddToListView(HWND,int,BOOL); -BOOL Encoding_GetFromListView(HWND,int *); -void Encoding_AddToComboboxEx(HWND,int,BOOL); -BOOL Encoding_GetFromComboboxEx(HWND,int *); - -BOOL IsUnicode(const char*,int,LPBOOL,LPBOOL); -BOOL IsUTF8(const char*,int); -BOOL IsUTF7(const char*,int); - - -//void SciInitThemes(HWND); -//LRESULT CALLBACK SciThemedWndProc(HWND,UINT,WPARAM,LPARAM); - - -#define FV_TABWIDTH 1 -#define FV_INDENTWIDTH 2 -#define FV_TABSASSPACES 4 -#define FV_TABINDENTS 8 -#define FV_WORDWRAP 16 -#define FV_LONGLINESLIMIT 32 -#define FV_ENCODING 64 -#define FV_MODE 128 - -typedef struct _filevars { - - int mask; - int iTabWidth; - int iIndentWidth; - BOOL bTabsAsSpaces; - BOOL bTabIndents; - BOOL fWordWrap; - int iLongLinesLimit; - char tchEncoding[32]; - int iEncoding; - char tchMode[32]; - -} FILEVARS, *LPFILEVARS; - -BOOL FileVars_Init(char*,DWORD,LPFILEVARS); -BOOL FileVars_Apply(HWND,LPFILEVARS); -BOOL FileVars_ParseInt(char*,char*,int*); -BOOL FileVars_ParseStr(char*,char*,char*,int); -BOOL FileVars_IsUTF8(LPFILEVARS); -BOOL FileVars_IsNonUTF8(LPFILEVARS); -BOOL FileVars_IsValidEncoding(LPFILEVARS); -int FileVars_GetEncoding(LPFILEVARS); - - - -/// End of Edit.h \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Edit.h +* Text File Editing Helper Stuff +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + + + +// extern "C" declarations of Scintilla functions +BOOL Scintilla_RegisterClasses(void*); +BOOL Scintilla_ReleaseResources(); + + +typedef struct _editfindreplace +{ + char szFind[512]; + char szReplace[512]; + char szFindUTF8[3*512]; + char szReplaceUTF8[3*512]; + UINT fuFlags; + BOOL bTransformBS; + BOOL bObsolete /* was bFindUp */; + BOOL bFindClose; + BOOL bReplaceClose; + BOOL bNoFindWrap; + HWND hwnd; +#ifdef BOOKMARK_EDITION + BOOL bWildcardSearch; +#endif + //HANDLE hMRUFind; + //HANDLE hMRUReplace; + +} EDITFINDREPLACE, *LPEDITFINDREPLACE, *LPCEDITFINDREPLACE; + + +#define IDMSG_SWITCHTOFIND 300 +#define IDMSG_SWITCHTOREPLACE 301 + + +#define ALIGN_LEFT 0 +#define ALIGN_RIGHT 1 +#define ALIGN_CENTER 2 +#define ALIGN_JUSTIFY 3 +#define ALIGN_JUSTIFY_EX 4 + + +#define SORT_ASCENDING 0 +#define SORT_DESCENDING 1 +#define SORT_SHUFFLE 2 +#define SORT_MERGEDUP 4 +#define SORT_UNIQDUP 8 +#define SORT_UNIQUNIQ 16 +#define SORT_NOCASE 32 +#define SORT_LOGICAL 64 +#define SORT_COLUMN 128 + + +HWND EditCreate(HWND); +void EditSetNewText(HWND,char*,DWORD); +BOOL EditConvertText(HWND,UINT,UINT,BOOL); +BOOL EditSetNewEncoding(HWND,int,int,BOOL,BOOL); +char* EditGetClipboardText(HWND); +BOOL EditCopyAppend(HWND); +int EditDetectEOLMode(HWND,char*,DWORD); +BOOL EditLoadFile(HWND,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*); +BOOL EditSaveFile(HWND,LPCWSTR,int,BOOL*,BOOL); + +void EditInvertCase(HWND); +void EditTitleCase(HWND); +void EditSentenceCase(HWND); + +void EditURLEncode(HWND); +void EditURLDecode(HWND); +void EditEscapeCChars(HWND); +void EditUnescapeCChars(HWND); +void EditChar2Hex(HWND); +void EditHex2Char(HWND); +void EditModifyNumber(HWND,BOOL); + +void EditTabsToSpaces(HWND,int,BOOL); +void EditSpacesToTabs(HWND,int,BOOL); + +void EditMoveUp(HWND); +void EditMoveDown(HWND); +void EditModifyLines(HWND,LPCWSTR,LPCWSTR); +void EditAlignText(HWND,int); +void EditEncloseSelection(HWND,LPCWSTR,LPCWSTR); +void EditToggleLineComments(HWND,LPCWSTR,BOOL); +void EditPadWithSpaces(HWND,BOOL,BOOL); +void EditStripFirstCharacter(HWND); +void EditStripLastCharacter(HWND); +void EditStripTrailingBlanks(HWND,BOOL); +void EditCompressSpaces(HWND); +void EditRemoveBlankLines(HWND,BOOL); +void EditWrapToColumn(HWND,int); +void EditJoinLinesEx(HWND); +void EditSortLines(HWND,int); + +void EditJumpTo(HWND,int,int); +void EditSelectEx(HWND,int,int); +void EditFixPositions(HWND); +void EditEnsureSelectionVisible(HWND); +void EditGetExcerpt(HWND,LPWSTR,DWORD); + +HWND EditFindReplaceDlg(HWND,LPCEDITFINDREPLACE,BOOL); +BOOL EditFindNext(HWND,LPCEDITFINDREPLACE,BOOL); +BOOL EditFindPrev(HWND,LPCEDITFINDREPLACE,BOOL); +BOOL EditReplace(HWND,LPCEDITFINDREPLACE); +BOOL EditReplaceAll(HWND,LPCEDITFINDREPLACE,BOOL); +BOOL EditReplaceAllInSelection(HWND,LPCEDITFINDREPLACE,BOOL); +BOOL EditLinenumDlg(HWND); +BOOL EditModifyLinesDlg(HWND,LPWSTR,LPWSTR); +BOOL EditEncloseSelectionDlg(HWND,LPWSTR,LPWSTR); +BOOL EditInsertTagDlg(HWND,LPWSTR,LPWSTR); +BOOL EditSortDlg(HWND,int*); +BOOL EditAlignDlg(HWND,int*); +BOOL EditPrint(HWND,LPCWSTR,LPCWSTR); +void EditPrintSetup(HWND); +void EditPrintInit(); +void EditMarkAll(HWND,int,BOOL,BOOL); +void CompleteWord(HWND, BOOL); + +extern int g_DOSEncoding; + +#define NCP_DEFAULT 1 +#define NCP_UTF8 2 +#define NCP_UTF8_SIGN 4 +#define NCP_UNICODE 8 +#define NCP_UNICODE_REVERSE 16 +#define NCP_UNICODE_BOM 32 +#define NCP_8BIT 64 +#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM) +#define NCP_RECODE 128 +#define CPI_NONE -1 +#define CPI_DEFAULT 0 +#define CPI_OEM 1 +#define CPI_UNICODEBOM 2 +#define CPI_UNICODEBEBOM 3 +#define CPI_UNICODE 4 +#define CPI_UNICODEBE 5 +#define CPI_UTF8 6 +#define CPI_UTF8SIGN 7 +#define CPI_UTF7 8 + +#define IDS_ENCODINGNAME0 61000 +#define IDS_EOLMODENAME0 62000 + +typedef struct _np2encoding { + UINT uFlags; + UINT uCodePage; + char* pszParseNames; + int idsName; + WCHAR wchLabel[32]; +} NP2ENCODING; + +void Encoding_InitDefaults(); +int Encoding_MapIniSetting(BOOL,int); +void Encoding_GetLabel(int); +int Encoding_MatchW(LPCWSTR); +int Encoding_MatchA(char*); +BOOL Encoding_IsValid(int); +void Encoding_AddToListView(HWND,int,BOOL); +BOOL Encoding_GetFromListView(HWND,int *); +void Encoding_AddToComboboxEx(HWND,int,BOOL); +BOOL Encoding_GetFromComboboxEx(HWND,int *); + +BOOL IsUnicode(const char*,int,LPBOOL,LPBOOL); +BOOL IsUTF8(const char*,int); +BOOL IsUTF7(const char*,int); + + +//void SciInitThemes(HWND); +//LRESULT CALLBACK SciThemedWndProc(HWND,UINT,WPARAM,LPARAM); + + +#define FV_TABWIDTH 1 +#define FV_INDENTWIDTH 2 +#define FV_TABSASSPACES 4 +#define FV_TABINDENTS 8 +#define FV_WORDWRAP 16 +#define FV_LONGLINESLIMIT 32 +#define FV_ENCODING 64 +#define FV_MODE 128 + +typedef struct _filevars { + + int mask; + int iTabWidth; + int iIndentWidth; + BOOL bTabsAsSpaces; + BOOL bTabIndents; + BOOL fWordWrap; + int iLongLinesLimit; + char tchEncoding[32]; + int iEncoding; + char tchMode[32]; + +} FILEVARS, *LPFILEVARS; + +BOOL FileVars_Init(char*,DWORD,LPFILEVARS); +BOOL FileVars_Apply(HWND,LPFILEVARS); +BOOL FileVars_ParseInt(char*,char*,int*); +BOOL FileVars_ParseStr(char*,char*,char*,int); +BOOL FileVars_IsUTF8(LPFILEVARS); +BOOL FileVars_IsNonUTF8(LPFILEVARS); +BOOL FileVars_IsValidEncoding(LPFILEVARS); +int FileVars_GetEncoding(LPFILEVARS); + + + +/// End of Edit.h \\\ diff --git a/src/Helpers.c b/src/Helpers.c index 8138467b..3870c26e 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -1,2389 +1,2389 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Helpers.c -* General helper functions -* Parts taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org -* MinimizeToTray (c) 2000 Matthew Ellis -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include -#include -#include "scintilla.h" -#include "helpers.h" -#include "resource.h" - - -//============================================================================= -// -// Manipulation of (cached) ini file sections -// -int IniSectionGetString( - LPCWSTR lpCachedIniSection, - LPCWSTR lpName, - LPCWSTR lpDefault, - LPWSTR lpReturnedString, - int cchReturnedString) -{ - WCHAR *p = (WCHAR *)lpCachedIniSection; - WCHAR tch[256]; - int ich; - - if (p) { - lstrcpy(tch,lpName); - lstrcat(tch,L"="); - ich = lstrlen(tch); - - while (*p) { - if (StrCmpNI(p,tch,ich) == 0) { - lstrcpyn(lpReturnedString,p + ich,cchReturnedString); - return(lstrlen(lpReturnedString)); - } - else - p = StrEnd(p) + 1; - } - } - lstrcpyn(lpReturnedString,lpDefault,cchReturnedString); - return(lstrlen(lpReturnedString)); -} - - -int IniSectionGetInt( - LPCWSTR lpCachedIniSection, - LPCWSTR lpName, - int iDefault) -{ - WCHAR *p = (WCHAR *)lpCachedIniSection; - WCHAR tch[256]; - int ich; - int i; - - if (p) { - lstrcpy(tch,lpName); - lstrcat(tch,L"="); - ich = lstrlen(tch); - - while (*p) { - if (StrCmpNI(p,tch,ich) == 0) { - if (swscanf(p + ich,L"%i",&i) == 1) - return(i); - else - return(iDefault); - } - else - p = StrEnd(p) + 1; - } - } - return(iDefault); -} - - -BOOL IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpString) -{ - WCHAR tch[32+512*3+32]; - WCHAR *p = lpCachedIniSection; - - if (p) { - while (*p) { - p = StrEnd(p) + 1; - } - wsprintf(tch,L"%s=%s",lpName,lpString); - lstrcpy(p,tch); - p = StrEnd(p) + 1; - *p = 0; - return(TRUE); - } - return(FALSE); -} - - -//============================================================================= -// -// PrivateIsAppThemed() -// -extern HMODULE hModUxTheme; -BOOL PrivateIsAppThemed() -{ - FARPROC pfnIsAppThemed; - BOOL bIsAppThemed = FALSE; - - if (hModUxTheme) { - pfnIsAppThemed = GetProcAddress(hModUxTheme,"IsAppThemed"); - - if (pfnIsAppThemed) - bIsAppThemed = (BOOL)pfnIsAppThemed(); - } - return bIsAppThemed; -} - - -//============================================================================= -// -// PrivateSetCurrentProcessExplicitAppUserModelID() -// -HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR AppID) -{ - FARPROC pfnSetCurrentProcessExplicitAppUserModelID; - - if (lstrlen(AppID) == 0) - return(S_OK); - - if (lstrcmpi(AppID,L"(default)") == 0) - return(S_OK); - - pfnSetCurrentProcessExplicitAppUserModelID = - GetProcAddress(GetModuleHandleA("shell32.dll"),"SetCurrentProcessExplicitAppUserModelID"); - - if (pfnSetCurrentProcessExplicitAppUserModelID) - return((HRESULT)pfnSetCurrentProcessExplicitAppUserModelID(AppID)); - - else - return(S_OK); -} - - -//============================================================================= -// -// IsElevated() -// -BOOL IsElevated() { - - BOOL bIsElevated = FALSE; - HANDLE hToken = NULL; - - if (!IsVista()) - return(FALSE); - - if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)) { - - struct { - DWORD TokenIsElevated; - } /*TOKEN_ELEVATION*/te; - DWORD dwReturnLength = 0; - - if (GetTokenInformation(hToken,/*TokenElevation*/20,&te,sizeof(te),&dwReturnLength)) { - if (dwReturnLength == sizeof(te)) - bIsElevated = te.TokenIsElevated; - } - CloseHandle(hToken); - } - return bIsElevated; -} - - -//============================================================================= -// -// SetExplorerTheme() -// -//BOOL SetExplorerTheme(HWND hwnd) -//{ -// FARPROC pfnSetWindowTheme; -// -// if (IsVista()) { -// if (hModUxTheme) { -// pfnSetWindowTheme = GetProcAddress(hModUxTheme,"SetWindowTheme"); -// -// if (pfnSetWindowTheme) -// return (S_OK == pfnSetWindowTheme(hwnd,L"Explorer",NULL)); -// } -// } -// return FALSE; -//} - - -//============================================================================= -// -// BitmapMergeAlpha() -// Merge alpha channel into color channel -// -BOOL BitmapMergeAlpha(HBITMAP hbmp,COLORREF crDest) -{ - BITMAP bmp; - if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { - - if (bmp.bmBitsPixel == 32) { - - int x,y; - RGBQUAD *prgba = bmp.bmBits; - - for (y = 0; y < bmp.bmHeight; y++) { - for (x = 0; x < bmp.bmWidth; x++) { - BYTE alpha = prgba[x].rgbReserved; - prgba[x].rgbRed = ((prgba[x].rgbRed * alpha) + (GetRValue(crDest) * (255-alpha))) >> 8; - prgba[x].rgbGreen = ((prgba[x].rgbGreen * alpha) + (GetGValue(crDest) * (255-alpha))) >> 8; - prgba[x].rgbBlue = ((prgba[x].rgbBlue * alpha) + (GetBValue(crDest) * (255-alpha))) >> 8; - prgba[x].rgbReserved = 0xFF; - } - prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); - } - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// BitmapAlphaBlend() -// Perform alpha blending to color channel only -// -BOOL BitmapAlphaBlend(HBITMAP hbmp,COLORREF crDest,BYTE alpha) -{ - BITMAP bmp; - if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { - - if (bmp.bmBitsPixel == 32) { - - int x,y; - RGBQUAD *prgba = bmp.bmBits; - - for (y = 0; y < bmp.bmHeight; y++) { - for (x = 0; x < bmp.bmWidth; x++) { - prgba[x].rgbRed = ((prgba[x].rgbRed * alpha) + (GetRValue(crDest) * (255-alpha))) >> 8; - prgba[x].rgbGreen = ((prgba[x].rgbGreen * alpha) + (GetGValue(crDest) * (255-alpha))) >> 8; - prgba[x].rgbBlue = ((prgba[x].rgbBlue * alpha) + (GetBValue(crDest) * (255-alpha))) >> 8; - } - prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); - } - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// BitmapGrayScale() -// Gray scale color channel only -// -BOOL BitmapGrayScale(HBITMAP hbmp) -{ - BITMAP bmp; - if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { - - if (bmp.bmBitsPixel == 32) { - - int x,y; - RGBQUAD *prgba = bmp.bmBits; - - for (y = 0; y < bmp.bmHeight; y++) { - for (x = 0; x < bmp.bmWidth; x++) { - prgba[x].rgbRed = prgba[x].rgbGreen = prgba[x].rgbBlue = - (((BYTE)((prgba[x].rgbRed * 38 + prgba[x].rgbGreen * 75 + prgba[x].rgbBlue * 15) >> 7) * 0x80) + (0xD0 * (255-0x80))) >> 8; - } - prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); - } - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// VerifyContrast() -// Check if two colors can be distinguished -// -BOOL VerifyContrast(COLORREF cr1,COLORREF cr2) -{ - BYTE r1 = GetRValue(cr1); - BYTE g1 = GetGValue(cr1); - BYTE b1 = GetBValue(cr1); - BYTE r2 = GetRValue(cr2); - BYTE g2 = GetGValue(cr2); - BYTE b2 = GetBValue(cr2); - - return( - ((abs((3*r1 + 5*g1 + 1*b1) - (3*r2 + 6*g2 + 1*b2))) >= 400) || - ((abs(r1-r2) + abs(b1-b2) + abs(g1-g2)) >= 400)); -} - - -//============================================================================= -// -// IsFontAvailable() -// Test if a certain font is installed on the system -// -int CALLBACK EnumFontsProc(CONST LOGFONT *plf,CONST TEXTMETRIC *ptm,DWORD FontType,LPARAM lParam) -{ - *((PBOOL)lParam) = TRUE; - return(FALSE); -} - -BOOL IsFontAvailable(LPCWSTR lpszFontName) -{ - BOOL fFound = FALSE; - - HDC hDC = GetDC(NULL); - EnumFonts(hDC,lpszFontName,EnumFontsProc,(LPARAM)&fFound); - ReleaseDC(NULL,hDC); - - return(fFound); -} - - -//============================================================================= -// -// SetWindowTitle() -// -BOOL bFreezeAppTitle = FALSE; - -BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled, - LPCWSTR lpszFile,int iFormat,BOOL bModified, - UINT uIDReadOnly,BOOL bReadOnly,LPCWSTR lpszExcerpt) -{ - - WCHAR szUntitled[128]; - WCHAR szExcrptQuot[256]; - WCHAR szExcrptFmt[32]; - WCHAR szAppName[128]; - WCHAR szElevatedAppName[128]; - WCHAR szReadOnly[32]; - WCHAR szTitle[512]; - static WCHAR szCachedFile[MAX_PATH]; - static WCHAR szCachedDisplayName[MAX_PATH]; - static const WCHAR *pszSep = L" - "; - static const WCHAR *pszMod = L"* "; - - if (bFreezeAppTitle) - return FALSE; - - if (!GetString(uIDAppName,szAppName,COUNTOF(szAppName)) || - !GetString(uIDUntitled,szUntitled,COUNTOF(szUntitled))) - return FALSE; - - if (bIsElevated) { - FormatString(szElevatedAppName,COUNTOF(szElevatedAppName),IDS_APPTITLE_ELEVATED,szAppName); - StrCpyN(szAppName,szElevatedAppName,COUNTOF(szAppName)); - } - - if (bModified) - lstrcpy(szTitle,pszMod); - else - lstrcpy(szTitle,L""); - - if (lstrlen(lpszExcerpt)) { - GetString(IDS_TITLEEXCERPT,szExcrptFmt,COUNTOF(szExcrptFmt)); - wsprintf(szExcrptQuot,szExcrptFmt,lpszExcerpt); - StrCat(szTitle,szExcrptQuot); - } - - else if (lstrlen(lpszFile)) - { - if (iFormat < 2 && !PathIsRoot(lpszFile)) - { - if (lstrcmp(szCachedFile,lpszFile) != 0) { - SHFILEINFO shfi; - lstrcpy(szCachedFile,lpszFile); - if (SHGetFileInfo2(lpszFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME)) - lstrcpy(szCachedDisplayName,shfi.szDisplayName); - else - lstrcpy(szCachedDisplayName,PathFindFileName(lpszFile)); - } - lstrcat(szTitle,szCachedDisplayName); - if (iFormat == 1) { - WCHAR tchPath[MAX_PATH]; - StrCpyN(tchPath,lpszFile,COUNTOF(tchPath)); - PathRemoveFileSpec(tchPath); - StrCat(szTitle,L" ["); - StrCat(szTitle,tchPath); - StrCat(szTitle,L"]"); - } - } - else - lstrcat(szTitle,lpszFile); - } - - else { - lstrcpy(szCachedFile,L""); - lstrcpy(szCachedDisplayName,L""); - lstrcat(szTitle,szUntitled); - } - - if (bReadOnly && GetString(uIDReadOnly,szReadOnly,COUNTOF(szReadOnly))) - { - lstrcat(szTitle,L" "); - lstrcat(szTitle,szReadOnly); - } - - lstrcat(szTitle,pszSep); - lstrcat(szTitle,szAppName); - - return SetWindowText(hwnd,szTitle); - -} - - -//============================================================================= -// -// SetWindowTransparentMode() -// -void SetWindowTransparentMode(HWND hwnd,BOOL bTransparentMode) -{ - FARPROC fp; - int iAlphaPercent; - BYTE bAlpha; - - if (bTransparentMode) { - if (fp = GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes")) { - SetWindowLongPtr(hwnd,GWL_EXSTYLE, - GetWindowLongPtr(hwnd,GWL_EXSTYLE) | WS_EX_LAYERED); - - // get opacity level from registry - iAlphaPercent = IniGetInt(L"Settings2",L"OpacityLevel",75); - if (iAlphaPercent < 0 || iAlphaPercent > 100) - iAlphaPercent = 75; - bAlpha = iAlphaPercent * 255 / 100; - - fp(hwnd,0,bAlpha,LWA_ALPHA); - } - } - - else - SetWindowLongPtr(hwnd,GWL_EXSTYLE, - GetWindowLongPtr(hwnd,GWL_EXSTYLE) & ~WS_EX_LAYERED); -} - - -//============================================================================= -// -// CenterDlgInParent() -// -void CenterDlgInParent(HWND hDlg) -{ - - RECT rcDlg; - HWND hParent; - RECT rcParent; - MONITORINFO mi; - HMONITOR hMonitor; - - int xMin, yMin, xMax, yMax, x, y; - - GetWindowRect(hDlg,&rcDlg); - - hParent = GetParent(hDlg); - GetWindowRect(hParent,&rcParent); - - hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor,&mi); - - xMin = mi.rcWork.left; - yMin = mi.rcWork.top; - - xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); - yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); - - if ((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left) > 20) - x = rcParent.left + (((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left)) / 2); - else - x = rcParent.left + 70; - - if ((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top) > 20) - y = rcParent.top + (((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top)) / 2); - else - y = rcParent.top + 60; - - SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); - -} - - -//============================================================================= -// -// GetDlgPos() -// -void GetDlgPos(HWND hDlg,LPINT xDlg,LPINT yDlg) -{ - - RECT rcDlg; - HWND hParent; - RECT rcParent; - - GetWindowRect(hDlg,&rcDlg); - - hParent = GetParent(hDlg); - GetWindowRect(hParent,&rcParent); - - // return positions relative to parent window - *xDlg = rcDlg.left - rcParent.left; - *yDlg = rcDlg.top - rcParent.top; - -} - - -//============================================================================= -// -// SetDlgPos() -// -void SetDlgPos(HWND hDlg,int xDlg,int yDlg) -{ - - RECT rcDlg; - HWND hParent; - RECT rcParent; - MONITORINFO mi; - HMONITOR hMonitor; - - int xMin, yMin, xMax, yMax, x, y; - - GetWindowRect(hDlg,&rcDlg); - - hParent = GetParent(hDlg); - GetWindowRect(hParent,&rcParent); - - hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor,&mi); - - xMin = mi.rcWork.left; - yMin = mi.rcWork.top; - - xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); - yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); - - // desired positions relative to parent window - x = rcParent.left + xDlg; - y = rcParent.top + yDlg; - - SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); - -} - - -//============================================================================= -// -// Resize Dialog Helpers() -// -typedef struct _resizedlg { - int cxClient; - int cyClient; - int cxFrame; - int cyFrame; - int mmiPtMinX; - int mmiPtMinY; -} RESIZEDLG, *PRESIZEDLG; - -void ResizeDlg_Init(HWND hwnd,int cxFrame,int cyFrame,int nIdGrip) -{ - RECT rc; - WCHAR wch[64]; - int cGrip; - RESIZEDLG *pm = LocalAlloc(LPTR,sizeof(RESIZEDLG)); - - GetClientRect(hwnd,&rc); - pm->cxClient = rc.right - rc.left; - pm->cyClient = rc.bottom - rc.top; - - pm->cxFrame = cxFrame; - pm->cyFrame = cyFrame; - - AdjustWindowRectEx(&rc,GetWindowLong(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0); - pm->mmiPtMinX = rc.right-rc.left; - pm->mmiPtMinY = rc.bottom-rc.top; - - if (pm->cxFrame < (rc.right-rc.left)) - pm->cxFrame = rc.right-rc.left; - if (pm->cyFrame < (rc.bottom-rc.top)) - pm->cyFrame = rc.bottom-rc.top; - - SetProp(hwnd,L"ResizeDlg",(HANDLE)pm); - - SetWindowPos(hwnd,NULL,rc.left,rc.top,pm->cxFrame,pm->cyFrame,SWP_NOZORDER); - - SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); - SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,wch,COUNTOF(wch),MF_BYCOMMAND); - InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,wch); - InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); - - SetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE, - GetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS); - cGrip = GetSystemMetrics(SM_CXHTHUMB); - SetWindowPos(GetDlgItem(hwnd,nIdGrip),NULL,pm->cxClient-cGrip,pm->cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER); -} - -void ResizeDlg_Destroy(HWND hwnd,int *cxFrame,int *cyFrame) -{ - RECT rc; - PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); - - GetWindowRect(hwnd,&rc); - *cxFrame = rc.right-rc.left; - *cyFrame = rc.bottom-rc.top; - - RemoveProp(hwnd,L"ResizeDlg"); - LocalFree(pm); -} - -void ResizeDlg_Size(HWND hwnd,LPARAM lParam,int *cx,int *cy) -{ - PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); - - *cx = LOWORD(lParam) - pm->cxClient; - *cy = HIWORD(lParam) - pm->cyClient; - pm->cxClient = LOWORD(lParam); - pm->cyClient = HIWORD(lParam); -} - -void ResizeDlg_GetMinMaxInfo(HWND hwnd,LPARAM lParam) -{ - PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); - - LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; - lpmmi->ptMinTrackSize.x = pm->mmiPtMinX; - lpmmi->ptMinTrackSize.y = pm->mmiPtMinY; -} - -HDWP DeferCtlPos(HDWP hdwp,HWND hwndDlg,int nCtlId,int dx,int dy,UINT uFlags) -{ - RECT rc; - HWND hwndCtl = GetDlgItem(hwndDlg,nCtlId); - GetWindowRect(hwndCtl,&rc); - MapWindowPoints(NULL,hwndDlg,(LPPOINT)&rc,2); - if (uFlags & SWP_NOSIZE) - return(DeferWindowPos(hdwp,hwndCtl,NULL,rc.left+dx,rc.top+dy,0,0,SWP_NOZORDER|SWP_NOSIZE)); - else - return(DeferWindowPos(hdwp,hwndCtl,NULL,0,0,rc.right-rc.left+dx,rc.bottom-rc.top+dy,SWP_NOZORDER|SWP_NOMOVE)); -} - - -//============================================================================= -// -// MakeBitmapButton() -// -void MakeBitmapButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,UINT uBmpId) -{ - HWND hwndCtl = GetDlgItem(hwnd,nCtlId); - BITMAP bmp; - BUTTON_IMAGELIST bi; - HBITMAP hBmp = LoadImage(hInstance,MAKEINTRESOURCE(uBmpId),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - GetObject(hBmp,sizeof(BITMAP),&bmp); - bi.himl = ImageList_Create(bmp.bmWidth,bmp.bmHeight,ILC_COLOR32|ILC_MASK,1,0); - ImageList_AddMasked(bi.himl,hBmp,CLR_DEFAULT); - DeleteObject(hBmp); - SetRect(&bi.margin,0,0,0,0); - bi.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; - SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi); -} - - -//============================================================================= -// -// MakeColorPickButton() -// -void MakeColorPickButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,COLORREF crColor) -{ - HWND hwndCtl = GetDlgItem(hwnd,nCtlId); - BUTTON_IMAGELIST bi; - HIMAGELIST himlOld = NULL; - HBITMAP hBmp; - COLORMAP colormap[2]; - - if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi)) - himlOld = bi.himl; - - if (IsWindowEnabled(hwndCtl) && crColor != -1) { - colormap[0].from = RGB(0x00,0x00,0x00); - colormap[0].to = GetSysColor(COLOR_3DSHADOW); - } - else { - colormap[0].from = RGB(0x00,0x00,0x00); - colormap[0].to = RGB(0xFF,0xFF,0xFF); - } - - if (IsWindowEnabled(hwndCtl) && crColor != -1) { - if (crColor == RGB(0xFF,0xFF,0xFF)) - crColor = RGB(0xFF,0xFF,0xFE); - - colormap[1].from = RGB(0xFF,0xFF,0xFF); - colormap[1].to = crColor; - } - else { - colormap[1].from = RGB(0xFF,0xFF,0xFF); - colormap[1].to = RGB(0xFF,0xFF,0xFF); - } - - hBmp = CreateMappedBitmap(hInstance,IDB_PICK,0,colormap,2); - - bi.himl = ImageList_Create(10,10,ILC_COLORDDB|ILC_MASK,1,0); - ImageList_AddMasked(bi.himl,hBmp,RGB(0xFF,0xFF,0xFF)); - DeleteObject(hBmp); - - SetRect(&bi.margin,0,0,4,0); - bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT; - - SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi); - InvalidateRect(hwndCtl,NULL,TRUE); - - if (himlOld) - ImageList_Destroy(himlOld); -} - - -//============================================================================= -// -// DeleteBitmapButton() -// -void DeleteBitmapButton(HWND hwnd,int nCtlId) -{ - HWND hwndCtl = GetDlgItem(hwnd,nCtlId); - BUTTON_IMAGELIST bi; - if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi)) - ImageList_Destroy(bi.himl); -} - - -//============================================================================= -// -// StatusSetText() -// -BOOL StatusSetText(HWND hwnd,UINT nPart,LPCWSTR lpszText) -{ - - UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart; - return (BOOL)SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)lpszText); - -} - - -//============================================================================= -// -// SendWMSize() -// -LRESULT SendWMSize(HWND hwnd) -{ - RECT rc; GetClientRect(hwnd,&rc); - return(SendMessage(hwnd,WM_SIZE,SIZE_RESTORED, - MAKELPARAM(rc.right,rc.bottom))); -} - - -//============================================================================= -// -// StatusSetTextID() -// -BOOL StatusSetTextID(HWND hwnd,UINT nPart,UINT uID) -{ - - WCHAR szText[256]; - UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart; - - if (!uID) - { - SendMessage(hwnd,SB_SETTEXT,uFlags,0); - return TRUE; - } - - if (!GetString(uID,szText,256)) - return FALSE; - - return (BOOL)SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)szText); - -} - - -//============================================================================= -// -// StatusCalcPaneWidth() -// -int StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz) -{ - SIZE size; - HDC hdc = GetDC(hwnd); - HFONT hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0); - HFONT hfold = SelectObject(hdc,hfont); - int mmode = SetMapMode(hdc,MM_TEXT); - - GetTextExtentPoint32(hdc,lpsz,lstrlen(lpsz),&size); - - SetMapMode(hdc,mmode); - SelectObject(hdc,hfold); - ReleaseDC(hwnd,hdc); - - return(size.cx + 9); -} - - -//============================================================================= -// -// Toolbar_Get/SetButtons() -// -int Toolbar_GetButtons(HWND hwnd,int cmdBase,LPWSTR lpszButtons,int cchButtons) -{ - WCHAR tchButtons[512]; - WCHAR tchItem[32]; - int i,c; - TBBUTTON tbb; - - lstrcpy(tchButtons,L""); - c = min(50,(int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0)); - - for (i = 0; i < c; i++) { - SendMessage(hwnd,TB_GETBUTTON,(WPARAM)i,(LPARAM)&tbb); - wsprintf(tchItem,L"%i ", - (tbb.idCommand==0)?0:tbb.idCommand-cmdBase+1); - lstrcat(tchButtons,tchItem); - } - TrimString(tchButtons); - lstrcpyn(lpszButtons,tchButtons,cchButtons); - return(c); -} - -int Toolbar_SetButtons(HWND hwnd,int cmdBase,LPCWSTR lpszButtons,LPCTBBUTTON ptbb,int ctbb) -{ - WCHAR tchButtons[512]; - WCHAR *p; - int i,c; - int iCmd; - - ZeroMemory(tchButtons,COUNTOF(tchButtons)*sizeof(tchButtons[0])); - lstrcpyn(tchButtons,lpszButtons,COUNTOF(tchButtons)-2); - TrimString(tchButtons); - while (p = StrStr(tchButtons,L" ")) - MoveMemory((WCHAR*)p,(WCHAR*)p+1,(lstrlen(p) + 1) * sizeof(WCHAR)); - - c = (int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0); - for (i = 0; i < c; i++) - SendMessage(hwnd,TB_DELETEBUTTON,0,0); - - for (i = 0; i < COUNTOF(tchButtons); i++) - if (tchButtons[i] == L' ') tchButtons[i] = 0; - - p = tchButtons; - while (*p) { - if (swscanf(p,L"%i",&iCmd) == 1) { - iCmd = (iCmd==0)?0:iCmd+cmdBase-1; - for (i = 0; i < ctbb; i++) { - if (ptbb[i].idCommand == iCmd) { - SendMessage(hwnd,TB_ADDBUTTONS,(WPARAM)1,(LPARAM)&ptbb[i]); - break; - } - } - } - p = StrEnd(p)+1; - } - return((int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0)); -} - - -//============================================================================= -// -// IsCmdEnabled() -// -BOOL IsCmdEnabled(HWND hwnd,UINT uId) -{ - - HMENU hmenu; - UINT ustate; - - hmenu = GetMenu(hwnd); - - SendMessage(hwnd,WM_INITMENU,(WPARAM)hmenu,0); - - ustate = GetMenuState(hmenu,uId,MF_BYCOMMAND); - - if (ustate == 0xFFFFFFFF) - return TRUE; - - else - return (!(ustate & (MF_GRAYED|MF_DISABLED))); - -} - - -//============================================================================= -// -// FormatString() -// -int FormatString(LPWSTR lpOutput,int nOutput,UINT uIdFormat,...) -{ - - WCHAR *p = LocalAlloc(LPTR,sizeof(WCHAR)*nOutput); - - if (GetString(uIdFormat,p,nOutput)) - wvsprintf(lpOutput,p,(LPVOID)((PUINT_PTR)&uIdFormat+1)); - - LocalFree(p); - - return lstrlen(lpOutput); - -} - - -//============================================================================= -// -// PathRelativeToApp() -// -void PathRelativeToApp( - LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bSrcIsFile, - BOOL bUnexpandEnv,BOOL bUnexpandMyDocs) { - - WCHAR wchAppPath[MAX_PATH]; - WCHAR wchWinDir[MAX_PATH]; - WCHAR wchUserFiles[MAX_PATH]; - WCHAR wchPath[MAX_PATH]; - WCHAR wchResult[MAX_PATH]; - DWORD dwAttrTo = (bSrcIsFile) ? 0 : FILE_ATTRIBUTE_DIRECTORY; - - GetModuleFileName(NULL,wchAppPath,COUNTOF(wchAppPath)); - PathRemoveFileSpec(wchAppPath); - GetWindowsDirectory(wchWinDir,COUNTOF(wchWinDir)); - SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchUserFiles); - - if (bUnexpandMyDocs && - !PathIsRelative(lpszSrc) && - !PathIsPrefix(wchUserFiles,wchAppPath) && - PathIsPrefix(wchUserFiles,lpszSrc) && - PathRelativePathTo(wchPath,wchUserFiles,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) { - lstrcpy(wchUserFiles,L"%CSIDL:MYDOCUMENTS%"); - PathAppend(wchUserFiles,wchPath); - lstrcpy(wchPath,wchUserFiles); - } - else if (PathIsRelative(lpszSrc) || PathCommonPrefix(wchAppPath,wchWinDir,NULL)) - lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); - else { - if (!PathRelativePathTo(wchPath,wchAppPath,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) - lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); - } - - if (bUnexpandEnv) { - if (!PathUnExpandEnvStrings(wchPath,wchResult,COUNTOF(wchResult))) - lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); - } - else - lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); - - if (lpszDest == NULL || lpszSrc == lpszDest) - lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); - else - lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); -} - - -//============================================================================= -// -// PathAbsoluteFromApp() -// -void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpandEnv) { - - WCHAR wchPath[MAX_PATH]; - WCHAR wchResult[MAX_PATH]; - - if (StrCmpNI(lpszSrc,L"%CSIDL:MYDOCUMENTS%",CSTRLEN("%CSIDL:MYDOCUMENTS%")) == 0) { - SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchPath); - PathAppend(wchPath,lpszSrc+CSTRLEN("%CSIDL:MYDOCUMENTS%")); - } - else - lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); - - if (bExpandEnv) - ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath)); - - if (PathIsRelative(wchPath)) { - GetModuleFileName(NULL,wchResult,COUNTOF(wchResult)); - PathRemoveFileSpec(wchResult); - PathAppend(wchResult,wchPath); - } - else - lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); - - PathCanonicalizeEx(wchResult); - if (PathGetDriveNumber(wchResult) != -1) - CharUpperBuff(wchResult,1); - - if (lpszDest == NULL || lpszSrc == lpszDest) - lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); - else - lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); -} - - -/////////////////////////////////////////////////////////////////////////////// -// -// -// Name: PathIsLnkFile() -// -// Purpose: Determine wheter pszPath is a Windows Shell Link File by -// comparing the filename extension with L".lnk" -// -// Manipulates: -// -BOOL PathIsLnkFile(LPCWSTR pszPath) -{ - - //WCHAR *pszExt; - - WCHAR tchResPath[256]; - - if (!pszPath || !*pszPath) - return FALSE; - -/*pszExt = StrRChr(pszPath,NULL,L'.'); - - if (!pszExt) - return FALSE; - - if (!lstrcmpi(pszExt,L".lnk")) - return TRUE; - - else - return FALSE;*/ - - //if (!lstrcmpi(PathFindExtension(pszPath),L".lnk")) - // return TRUE; - - //else - // return FALSE; - - if (lstrcmpi(PathFindExtension(pszPath),L".lnk")) - return FALSE; - - else - return PathGetLnkPath(pszPath,tchResPath,COUNTOF(tchResPath)); - -} - - -/////////////////////////////////////////////////////////////////////////////// -// -// -// Name: PathGetLnkPath() -// -// Purpose: Try to get the path to which a lnk-file is linked -// -// -// Manipulates: pszResPath -// -BOOL PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath) -{ - - IShellLink *psl; - WIN32_FIND_DATA fd; - BOOL bSucceeded = FALSE; - - if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLink,&psl))) - { - IPersistFile *ppf; - - if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) - { - WORD wsz[MAX_PATH]; - - /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, - pszLnkFile,-1,wsz,MAX_PATH);*/ - lstrcpy(wsz,pszLnkFile); - - if (SUCCEEDED(ppf->lpVtbl->Load(ppf,wsz,STGM_READ))) - { - if (NOERROR == psl->lpVtbl->GetPath(psl,pszResPath,cchResPath,&fd,0)) - bSucceeded = TRUE; - } - ppf->lpVtbl->Release(ppf); - } - psl->lpVtbl->Release(psl); - } - - // This additional check seems reasonable - if (!lstrlen(pszResPath)) - bSucceeded = FALSE; - - if (bSucceeded) { - ExpandEnvironmentStringsEx(pszResPath,cchResPath); - PathCanonicalizeEx(pszResPath); - } - - return(bSucceeded); - -} - - -/////////////////////////////////////////////////////////////////////////////// -// -// -// Name: PathIsLnkToDirectory() -// -// Purpose: Determine wheter pszPath is a Windows Shell Link File which -// refers to a directory -// -// Manipulates: pszResPath -// -BOOL PathIsLnkToDirectory(LPCWSTR pszPath,LPWSTR pszResPath,int cchResPath) -{ - - WCHAR tchResPath[MAX_PATH]; - - if (PathIsLnkFile(pszPath)) { - - if (PathGetLnkPath(pszPath,tchResPath,sizeof(WCHAR)*COUNTOF(tchResPath))) { - - if (PathIsDirectory(tchResPath)) { - - lstrcpyn(pszResPath,tchResPath,cchResPath); - return (TRUE); - } - - else - return FALSE; - } - - else - return FALSE; - } - - else - return FALSE; - -} - - -/////////////////////////////////////////////////////////////////////////////// -// -// -// Name: PathCreateDeskLnk() -// -// Purpose: Modified to create a desktop link to Notepad2 -// -// Manipulates: -// -BOOL PathCreateDeskLnk(LPCWSTR pszDocument) -{ - - WCHAR tchExeFile[MAX_PATH]; - WCHAR tchDocTemp[MAX_PATH]; - WCHAR tchArguments[MAX_PATH+16]; - WCHAR tchLinkDir[MAX_PATH]; - WCHAR tchDescription[64]; - - WCHAR tchLnkFileName[MAX_PATH]; - - IShellLink *psl; - BOOL bSucceeded = FALSE; - BOOL fMustCopy; - - if (!pszDocument || lstrlen(pszDocument) == 0) - return TRUE; - - // init strings - GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile)); - - lstrcpy(tchDocTemp,pszDocument); - PathQuoteSpaces(tchDocTemp); - - lstrcpy(tchArguments,L"-n "); - lstrcat(tchArguments,tchDocTemp); - - SHGetSpecialFolderPath(NULL,tchLinkDir,CSIDL_DESKTOPDIRECTORY,TRUE); - - GetString(IDS_LINKDESCRIPTION,tchDescription,COUNTOF(tchDescription)); - - // Try to construct a valid filename... - if (!SHGetNewLinkInfo(pszDocument,tchLinkDir,tchLnkFileName,&fMustCopy,SHGNLI_PREFIXNAME)) - return(FALSE); - - if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLink,&psl))) - { - IPersistFile *ppf; - - if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) - { - WORD wsz[MAX_PATH]; - - /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, - tchLnkFileName,-1,wsz,MAX_PATH);*/ - lstrcpy(wsz,tchLnkFileName); - - psl->lpVtbl->SetPath(psl,tchExeFile); - psl->lpVtbl->SetArguments(psl,tchArguments); - psl->lpVtbl->SetDescription(psl,tchDescription); - - if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE))) - bSucceeded = TRUE; - - ppf->lpVtbl->Release(ppf); - } - psl->lpVtbl->Release(psl); - } - - return(bSucceeded); - -} - - -/////////////////////////////////////////////////////////////////////////////// -// -// -// Name: PathCreateFavLnk() -// -// Purpose: Modified to create a Notepad2 favorites link -// -// Manipulates: -// -BOOL PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir) -{ - - WCHAR tchLnkFileName[MAX_PATH]; - - IShellLink *psl; - BOOL bSucceeded = FALSE; - - if (!pszName || lstrlen(pszName) == 0) - return TRUE; - - lstrcpy(tchLnkFileName,pszDir); - PathAppend(tchLnkFileName,pszName); - lstrcat(tchLnkFileName,L".lnk"); - - if (PathFileExists(tchLnkFileName)) - return FALSE; - - if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, - CLSCTX_INPROC_SERVER, - &IID_IShellLink,&psl))) - { - IPersistFile *ppf; - - if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) - { - WORD wsz[MAX_PATH]; - - /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, - tchLnkFileName,-1,wsz,MAX_PATH);*/ - lstrcpy(wsz,tchLnkFileName); - - psl->lpVtbl->SetPath(psl,pszTarget); - - if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE))) - bSucceeded = TRUE; - - ppf->lpVtbl->Release(ppf); - } - psl->lpVtbl->Release(psl); - } - - return(bSucceeded); - -} - - -//============================================================================= -// -// StrLTrim() -// -BOOL StrLTrim(LPWSTR pszSource,LPCWSTR pszTrimChars) -{ - LPWSTR psz; - - if (!pszSource || !*pszSource) - return FALSE; - - psz = pszSource; - while (StrChrI(pszTrimChars,*psz)) - psz++; - - MoveMemory(pszSource,psz,sizeof(WCHAR)*(lstrlen(psz) + 1)); - - return TRUE; -} - - -//============================================================================= -// -// TrimString() -// -BOOL TrimString(LPWSTR lpString) -{ - - LPWSTR psz; - - if (!lpString || !*lpString) - return FALSE; - - // Trim left - psz = lpString; - - while (*psz == L' ') - psz = CharNext(psz); - - MoveMemory(lpString,psz,sizeof(WCHAR)*(lstrlen(psz) + 1)); - - // Trim right - psz = StrEnd(lpString); - - while (*(psz = CharPrev(lpString,psz)) == L' ') - *psz = L'\0'; - - return TRUE; - -} - - -//============================================================================= -// -// ExtractFirstArgument() -// -BOOL ExtractFirstArgument(LPCWSTR lpArgs,LPWSTR lpArg1,LPWSTR lpArg2) -{ - - LPWSTR psz; - BOOL bQuoted = FALSE; - - lstrcpy(lpArg1,lpArgs); - if (lpArg2) - *lpArg2 = L'\0'; - - if (!TrimString(lpArg1)) - return FALSE; - - if (*lpArg1 == L'\"') - { - *lpArg1 = L' '; - TrimString(lpArg1); - bQuoted = TRUE; - } - - if (bQuoted) - psz = StrChr(lpArg1,L'\"'); - else - psz = StrChr(lpArg1,L' ');; - - if (psz) - { - *psz = L'\0'; - if (lpArg2) - lstrcpy(lpArg2,psz + 1); - } - - TrimString(lpArg1); - - if (lpArg2) - TrimString(lpArg2); - - return TRUE; - -} - - -//============================================================================= -// -// PrepareFilterStr() -// -void PrepareFilterStr(LPWSTR lpFilter) -{ - LPWSTR psz = StrEnd(lpFilter); - while (psz != lpFilter) - { - if (*(psz = CharPrev(lpFilter,psz)) == L'|') - *psz = L'\0'; - } -} - - -//============================================================================= -// -// StrTab2Space() - in place conversion -// -void StrTab2Space(LPWSTR lpsz) -{ - WCHAR *c = lpsz; - while (c = StrChr(lpsz,L'\t')) - *c = L' '; -} - - -//============================================================================= -// -// PathFixBackslashes() - in place conversion -// -void PathFixBackslashes(LPWSTR lpsz) -{ - WCHAR *c = lpsz; - while (c = StrChr(c,L'/')) { - if (*CharPrev(lpsz,c) == L':' && *CharNext(c) == L'/') - c += 2; - else - *c = L'\\'; - } -} - - -//============================================================================= -// -// ExpandEnvironmentStringsEx() -// -// Adjusted for Windows 95 -// -void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc) -{ - WCHAR szBuf[312]; - - if (ExpandEnvironmentStrings(lpSrc,szBuf,COUNTOF(szBuf))) - lstrcpyn(lpSrc,szBuf,dwSrc); -} - - -//============================================================================= -// -// PathCanonicalizeEx() -// -// -void PathCanonicalizeEx(LPWSTR lpSrc) -{ - WCHAR szDst[MAX_PATH]; - - if (PathCanonicalize(szDst,lpSrc)) - lstrcpy(lpSrc,szDst); -} - - -//============================================================================= -// -// GetLongPathNameEx() -// -// -DWORD GetLongPathNameEx(LPWSTR lpszPath,DWORD cchBuffer) -{ - DWORD dwRet = GetLongPathName(lpszPath,lpszPath,cchBuffer); - if (dwRet) { - if (PathGetDriveNumber(lpszPath) != -1) - CharUpperBuff(lpszPath,1); - return(dwRet); - } - return(0); -} - - -//============================================================================= -// -// SHGetFileInfo2() -// -// Return a default name when the file has been removed, and always append -// a filename extension -// -DWORD_PTR SHGetFileInfo2(LPCWSTR pszPath,DWORD dwFileAttributes, - SHFILEINFO *psfi,UINT cbFileInfo,UINT uFlags) -{ - - if (PathFileExists(pszPath)) { - - DWORD_PTR dw = SHGetFileInfo(pszPath,dwFileAttributes,psfi,cbFileInfo,uFlags); - if (lstrlen(psfi->szDisplayName) < lstrlen(PathFindFileName(pszPath))) - StrCatBuff(psfi->szDisplayName,PathFindExtension(pszPath),COUNTOF(psfi->szDisplayName)); - return(dw); - } - - else { - DWORD_PTR dw = SHGetFileInfo(pszPath,FILE_ATTRIBUTE_NORMAL,psfi,cbFileInfo,uFlags|SHGFI_USEFILEATTRIBUTES); - if (lstrlen(psfi->szDisplayName) < lstrlen(PathFindFileName(pszPath))) - StrCatBuff(psfi->szDisplayName,PathFindExtension(pszPath),COUNTOF(psfi->szDisplayName)); - return(dw); - } - -} - - -//============================================================================= -// -// FormatNumberStr() -// -int FormatNumberStr(LPWSTR lpNumberStr) -{ - WCHAR *c; - WCHAR szSep[8]; - int i = 0; - - if (!lstrlen(lpNumberStr)) - return(0); - - if (!GetLocaleInfo(LOCALE_USER_DEFAULT, - LOCALE_STHOUSAND, - szSep, - COUNTOF(szSep))) - szSep[0] = L'\''; - - c = StrEnd(lpNumberStr); - - while ((c = CharPrev(lpNumberStr,c)) != lpNumberStr) - { - if (++i == 3) - { - i = 0; - MoveMemory(c+1,c,sizeof(WCHAR)*(lstrlen(c)+1)); - *c = szSep[0]; - } - } - - return(lstrlen(lpNumberStr)); -} - - -//============================================================================= -// -// SetDlgItemIntEx() -// -BOOL SetDlgItemIntEx(HWND hwnd,int nIdItem,UINT uValue) -{ - WCHAR szBuf[64]; - - wsprintf(szBuf,L"%u",uValue); - FormatNumberStr(szBuf); - - return(SetDlgItemText(hwnd,nIdItem,szBuf)); -} - - -//============================================================================= -// -// A2W: Convert Dialog Item Text form Unicode to UTF-8 and vice versa -// -UINT GetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString,int nMaxCount) -{ - WCHAR wsz[1024] = L""; - UINT uRet = GetDlgItemTextW(hDlg,nIDDlgItem,wsz,COUNTOF(wsz)); - ZeroMemory(lpString,nMaxCount); - WCharToMBCS(uCP,wsz,lpString,nMaxCount-2); - return uRet; -} - -UINT SetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString) -{ - WCHAR wsz[1024] = L""; - MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz)); - return SetDlgItemTextW(hDlg,nIDDlgItem,wsz); -} - -LRESULT ComboBox_AddStringA2W(UINT uCP,HWND hwnd,LPCSTR lpString) -{ - WCHAR wsz[1024] = L""; - MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz)); - return SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)wsz); -} - - -//============================================================================= -// -// CodePageFromCharSet() -// -UINT CodePageFromCharSet(UINT uCharSet) -{ - CHARSETINFO ci; - if (TranslateCharsetInfo((DWORD*)(UINT_PTR)uCharSet,&ci,TCI_SRCCHARSET)) - return(ci.ciACP); - else - return(GetACP()); -} - - -//============================================================================= -// -// MRU functions -// -LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize) { - - LPMRULIST pmru = LocalAlloc(LPTR,sizeof(MRULIST)); - ZeroMemory(pmru,sizeof(MRULIST)); - lstrcpyn(pmru->szRegKey,pszRegKey,COUNTOF(pmru->szRegKey)); - pmru->iFlags = iFlags; - pmru->iSize = min(iSize,MRU_MAXITEMS); - return(pmru); -} - -BOOL MRU_Destroy(LPMRULIST pmru) { - - int i; - for (i = 0; i < pmru->iSize; i++) { - if (pmru->pszItems[i]) - LocalFree(pmru->pszItems[i]); - } - ZeroMemory(pmru,sizeof(MRULIST)); - LocalFree(pmru); - return(1); -} - -int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2) { - - if (pmru->iFlags & MRU_NOCASE) - return(lstrcmpi(psz1,psz2)); - else - return(lstrcmp(psz1,psz2)); -} - -BOOL MRU_Add(LPMRULIST pmru,LPCWSTR pszNew) { - - int i; - for (i = 0; i < pmru->iSize; i++) { - if (MRU_Compare(pmru,pmru->pszItems[i],pszNew) == 0) { - LocalFree(pmru->pszItems[i]); - break; - } - } - i = min(i,pmru->iSize-1); - for (; i > 0; i--) - pmru->pszItems[i] = pmru->pszItems[i-1]; - pmru->pszItems[0] = StrDup(pszNew); - return(1); -} - -BOOL MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,BOOL bRelativePath,BOOL bUnexpandMyDocs) { - - int i; - for (i = 0; i < pmru->iSize; i++) { - if (lstrcmpi(pmru->pszItems[i],pszFile) == 0) { - LocalFree(pmru->pszItems[i]); - break; - } - else { - WCHAR wchItem[MAX_PATH]; - PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE); - if (lstrcmpi(wchItem,pszFile) == 0) { - LocalFree(pmru->pszItems[i]); - break; - } - } - } - i = min(i,pmru->iSize-1); - for (; i > 0; i--) - pmru->pszItems[i] = pmru->pszItems[i-1]; - - if (bRelativePath) { - WCHAR wchFile[MAX_PATH]; - PathRelativeToApp((LPWSTR)pszFile,wchFile,COUNTOF(wchFile),TRUE,TRUE,bUnexpandMyDocs); - pmru->pszItems[0] = StrDup(wchFile); - } - else - pmru->pszItems[0] = StrDup(pszFile); - -/* notepad2-mod custom code start */ - // Needed to make W7 jump lists work when NP2 is not explicitly associated - if (IsW7()) SHAddToRecentDocs(SHARD_PATHW, pszFile); -/* notepad2-mod custom code end */ - - return(1); -} - -BOOL MRU_Delete(LPMRULIST pmru,int iIndex) { - - int i; - if (iIndex < 0 || iIndex > pmru->iSize-1) - return(0); - if (pmru->pszItems[iIndex]) - LocalFree(pmru->pszItems[iIndex]); - for (i = iIndex; i < pmru->iSize-1; i++) { - pmru->pszItems[i] = pmru->pszItems[i+1]; - pmru->pszItems[i+1] = NULL; - } - return(1); -} - -BOOL MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile) { - - int i = 0; - LPMRULIST pmruStore; - WCHAR wchItem[256]; - - pmruStore = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize); - MRU_Load(pmruStore); - - while (MRU_Enum(pmruStore,i,wchItem,COUNTOF(wchItem)) != -1) { - PathAbsoluteFromApp(wchItem,wchItem,COUNTOF(wchItem),TRUE); - if (lstrcmpi(wchItem,pszFile) == 0) - MRU_Delete(pmruStore,i); - else - i++; - } - - MRU_Save(pmruStore); - MRU_Destroy(pmruStore); - return(1); -} - -BOOL MRU_Empty(LPMRULIST pmru) { - - int i; - for (i = 0; i < pmru->iSize; i++) { - if (pmru->pszItems[i]) { - LocalFree(pmru->pszItems[i]); - pmru->pszItems[i] = NULL; - } - } - return(1); -} - -int MRU_Enum(LPMRULIST pmru,int iIndex,LPWSTR pszItem,int cchItem) { - - if (pszItem == NULL || cchItem == 0) { - int i = 0; - while (i < pmru->iSize && pmru->pszItems[i]) - i++; - return(i); - } - else { - if (iIndex < 0 || iIndex > pmru->iSize-1 || !pmru->pszItems[iIndex]) - return(-1); - else { - lstrcpyn(pszItem,pmru->pszItems[iIndex],cchItem); - return(lstrlen(pszItem)); - } - } -} - -BOOL MRU_Load(LPMRULIST pmru) { - - int i,n = 0; - WCHAR tchName[32]; - WCHAR tchItem[1024]; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - - MRU_Empty(pmru); - LoadIniSection(pmru->szRegKey,pIniSection,(int)LocalSize(pIniSection)/sizeof(WCHAR)); - - for (i = 0; i < pmru->iSize; i++) { - wsprintf(tchName,L"%.2i",i+1); - if (IniSectionGetString(pIniSection,tchName,L"",tchItem,COUNTOF(tchItem))) { - /*if (pmru->iFlags & MRU_UTF8) { - WCHAR wchItem[1024]; - int cbw = MultiByteToWideChar(CP_UTF7,0,tchItem,-1,wchItem,COUNTOF(wchItem)); - WideCharToMultiByte(CP_UTF8,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL); - pmru->pszItems[n++] = StrDup(tchItem); - } - else*/ - pmru->pszItems[n++] = StrDup(tchItem); - } - } - LocalFree(pIniSection); - return(1); -} - -BOOL MRU_Save(LPMRULIST pmru) { - - int i; - WCHAR tchName[32]; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - - //IniDeleteSection(pmru->szRegKey); - - for (i = 0; i < pmru->iSize; i++) { - if (pmru->pszItems[i]) { - wsprintf(tchName,L"%.2i",i+1); - /*if (pmru->iFlags & MRU_UTF8) { - WCHAR tchItem[1024]; - WCHAR wchItem[1024]; - int cbw = MultiByteToWideChar(CP_UTF8,0,pmru->pszItems[i],-1,wchItem,COUNTOF(wchItem)); - WideCharToMultiByte(CP_UTF7,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL); - IniSectionSetString(pIniSection,tchName,tchItem); - } - else*/ - IniSectionSetString(pIniSection,tchName,pmru->pszItems[i]); - } - } - SaveIniSection(pmru->szRegKey,pIniSection); - LocalFree(pIniSection); - return(1); -} - - -BOOL MRU_MergeSave(LPMRULIST pmru,BOOL bAddFiles,BOOL bRelativePath,BOOL bUnexpandMyDocs) { - - int i; - LPMRULIST pmruBase; - - pmruBase = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize); - MRU_Load(pmruBase); - - if (bAddFiles) { - for (i = pmru->iSize-1; i >= 0; i--) { - if (pmru->pszItems[i]) { - WCHAR wchItem[MAX_PATH]; - PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE); - MRU_AddFile(pmruBase,wchItem,bRelativePath,bUnexpandMyDocs); - } - } - } - - else { - for (i = pmru->iSize-1; i >= 0; i--) { - if (pmru->pszItems[i]) - MRU_Add(pmruBase,pmru->pszItems[i]); - } - } - - MRU_Save(pmruBase); - MRU_Destroy(pmruBase); - return(1); -} - - -/* - - Themed Dialogs - Modify dialog templates to use current theme font - Based on code of MFC helper class CDialogTemplate - -*/ - -BOOL GetThemedDialogFont(LPWSTR lpFaceName,WORD* wSize) -{ - HDC hDC; - int iLogPixelsY; - HMODULE hModUxTheme; - HTHEME hTheme; - LOGFONT lf; - BOOL bSucceed = FALSE; - - hDC = GetDC(NULL); - iLogPixelsY = GetDeviceCaps(hDC,LOGPIXELSY); - ReleaseDC(NULL,hDC); - - if (hModUxTheme = GetModuleHandle(L"uxtheme.dll")) { - if ((BOOL)(GetProcAddress(hModUxTheme,"IsAppThemed"))()) { - hTheme = (HTHEME)(INT_PTR)(GetProcAddress(hModUxTheme,"OpenThemeData"))(NULL,L"WINDOWSTYLE;WINDOW"); - if (hTheme) { - if (S_OK == (HRESULT)(GetProcAddress(hModUxTheme,"GetThemeSysFont"))(hTheme,/*TMT_MSGBOXFONT*/805,&lf)) { - if (lf.lfHeight < 0) - lf.lfHeight = -lf.lfHeight; - *wSize = (WORD)MulDiv(lf.lfHeight,72,iLogPixelsY); - if (*wSize == 0) - *wSize = 8; - StrCpyN(lpFaceName,lf.lfFaceName,LF_FACESIZE); - bSucceed = TRUE; - } - (GetProcAddress(hModUxTheme,"CloseThemeData"))(hTheme); - } - } - } - - /* - if (!bSucceed) { - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&ncm,0); - if (ncm.lfMessageFont.lfHeight < 0) - ncm.lfMessageFont.lfHeight = -ncm.lfMessageFont.lfHeight; - *wSize = (WORD)MulDiv(ncm.lfMessageFont.lfHeight,72,iLogPixelsY); - if (*wSize == 0) - *wSize = 8; - StrCpyN(lpFaceName,ncm.lfMessageFont.lfFaceName,LF_FACESIZE); - }*/ - - return(bSucceed); -} - -__inline BOOL DialogTemplate_IsDialogEx(const DLGTEMPLATE* pTemplate) { - - return ((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF; -} - -__inline BOOL DialogTemplate_HasFont(const DLGTEMPLATE* pTemplate) { - - return (DS_SETFONT & - (DialogTemplate_IsDialogEx(pTemplate) ? ((DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style)); -} - -__inline int DialogTemplate_FontAttrSize(BOOL bDialogEx) { - - return (int)sizeof(WORD) * (bDialogEx ? 3 : 1); -} - -__inline BYTE* DialogTemplate_GetFontSizeField(const DLGTEMPLATE* pTemplate) { - - BOOL bDialogEx = DialogTemplate_IsDialogEx(pTemplate); - WORD* pw; - - if (bDialogEx) - pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1); - else - pw = (WORD*)(pTemplate + 1); - - if (*pw == (WORD)-1) - pw += 2; - else - while(*pw++); - - if (*pw == (WORD)-1) - pw += 2; - else - while(*pw++); - - while (*pw++); - - return (BYTE*)pw; -} - -DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID,HINSTANCE hInstance) { - - HRSRC hRsrc; - HGLOBAL hRsrcMem; - DLGTEMPLATE *pRsrcMem; - DLGTEMPLATE *pTemplate; - UINT dwTemplateSize = 0; - WCHAR wchFaceName[LF_FACESIZE]; - WORD wFontSize; - BOOL bDialogEx; - BOOL bHasFont; - int cbFontAttr; - int cbNew; - int cbOld; - BYTE* pbNew; - BYTE* pb; - BYTE* pOldControls; - BYTE* pNewControls; - WORD nCtrl; - - hRsrc = FindResource(hInstance,lpDialogTemplateID,RT_DIALOG); - if (hRsrc == NULL) - return(NULL); - - hRsrcMem = LoadResource(hInstance,hRsrc); - pRsrcMem = (DLGTEMPLATE*)LockResource(hRsrcMem); - dwTemplateSize = (UINT)SizeofResource(hInstance,hRsrc); - - if ((dwTemplateSize == 0) || - (pTemplate = LocalAlloc(LPTR,dwTemplateSize+LF_FACESIZE*2)) == NULL) { - UnlockResource(hRsrcMem); - FreeResource(hRsrcMem); - return(NULL); - } - - CopyMemory((BYTE*)pTemplate,pRsrcMem,(size_t)dwTemplateSize); - UnlockResource(hRsrcMem); - FreeResource(hRsrcMem); - - if (!GetThemedDialogFont(wchFaceName,&wFontSize)) - return(pTemplate); - - bDialogEx = DialogTemplate_IsDialogEx(pTemplate); - bHasFont = DialogTemplate_HasFont(pTemplate); - cbFontAttr = DialogTemplate_FontAttrSize(bDialogEx); - - if (bDialogEx) - ((DLGTEMPLATEEX*)pTemplate)->style |= DS_SHELLFONT; - else - pTemplate->style |= DS_SHELLFONT; - - cbNew = cbFontAttr + ((lstrlen(wchFaceName) + 1) * sizeof(WCHAR)); - pbNew = (BYTE*)wchFaceName; - - pb = DialogTemplate_GetFontSizeField(pTemplate); - cbOld = (int)(bHasFont ? cbFontAttr + 2 * (lstrlen((WCHAR*)(pb + cbFontAttr)) + 1) : 0); - - pOldControls = (BYTE*)(((DWORD_PTR)pb + cbOld + 3) & ~(DWORD_PTR)3); - pNewControls = (BYTE*)(((DWORD_PTR)pb + cbNew + 3) & ~(DWORD_PTR)3); - - nCtrl = bDialogEx ? - (WORD)((DLGTEMPLATEEX*)pTemplate)->cDlgItems : - (WORD)pTemplate->cdit; - - if (cbNew != cbOld && nCtrl > 0) - MoveMemory(pNewControls,pOldControls,(size_t)(dwTemplateSize - (pOldControls - (BYTE*)pTemplate))); - - *(WORD*)pb = wFontSize; - MoveMemory(pb + cbFontAttr,pbNew,(size_t)(cbNew - cbFontAttr)); - - return(pTemplate); -} - -INT_PTR ThemedDialogBoxParam( - HINSTANCE hInstance, - LPCTSTR lpTemplate, - HWND hWndParent, - DLGPROC lpDialogFunc, - LPARAM dwInitParam) { - - INT_PTR ret; - DLGTEMPLATE *pDlgTemplate; - - pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance); - ret = DialogBoxIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam); - if (pDlgTemplate) - LocalFree(pDlgTemplate); - - return(ret); -} - -HWND CreateThemedDialogParam( - HINSTANCE hInstance, - LPCTSTR lpTemplate, - HWND hWndParent, - DLGPROC lpDialogFunc, - LPARAM dwInitParam) { - - HWND hwnd; - DLGTEMPLATE *pDlgTemplate; - - pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance); - hwnd = CreateDialogIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam); - if (pDlgTemplate) - LocalFree(pDlgTemplate); - - return(hwnd); -} - - -/****************************************************************************** -* -* UnSlash functions -* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org -* -/ - -/** - * Is the character an octal digit? - */ -static BOOL IsOctalDigit(char ch) { - return ch >= '0' && ch <= '7'; -} - -/** - * If the character is an hexa digit, get its value. - */ -static int GetHexDigit(char ch) { - if (ch >= '0' && ch <= '9') { - return ch - '0'; - } - if (ch >= 'A' && ch <= 'F') { - return ch - 'A' + 10; - } - if (ch >= 'a' && ch <= 'f') { - return ch - 'a' + 10; - } - return -1; -} - -/** - * Convert C style \a, \b, \f, \n, \r, \t, \v, \xhh and \uhhhh into their indicated characters. - */ -unsigned int UnSlash(char *s,UINT cpEdit) { - char *sStart = s; - char *o = s; - - while (*s) { - if (*s == '\\') { - s++; - if (*s == 'a') - *o = '\a'; - else if (*s == 'b') - *o = '\b'; - else if (*s == 'f') - *o = '\f'; - else if (*s == 'n') - *o = '\n'; - else if (*s == 'r') - *o = '\r'; - else if (*s == 't') - *o = '\t'; - else if (*s == 'v') - *o = '\v'; - else if (*s == 'x' || *s == 'u') { - BOOL bShort = (*s == 'x'); - char ch[8]; - char *pch = ch; - WCHAR val[2] = L""; - int hex; - val[0] = 0; - hex = GetHexDigit(*(s+1)); - if (hex >= 0) { - s++; - val[0] = hex; - hex = GetHexDigit(*(s+1)); - if (hex >= 0) { - s++; - val[0] *= 16; - val[0] += hex; - if (!bShort) { - hex = GetHexDigit(*(s+1)); - if (hex >= 0) { - s++; - val[0] *= 16; - val[0] += hex; - hex = GetHexDigit(*(s+1)); - if (hex >= 0) { - s++; - val[0] *= 16; - val[0] += hex; - } - } - } - } - if (val[0]) { - val[1] = 0; - WideCharToMultiByte(cpEdit,0,val,-1,ch,COUNTOF(ch),NULL,NULL); - *o = *pch++; - while (*pch) - *++o = *pch++; - } - else - o--; - } - else - o--; - } - else - *o = *s; - } - else - *o = *s; - o++; - if (*s) { - s++; - } - } - *o = '\0'; - return (unsigned int)(o - sStart); -} - -/** - * Convert C style \0oo into their indicated characters. - * This is used to get control characters into the regular expresion engine. - */ -unsigned int UnSlashLowOctal(char *s) { - char *sStart = s; - char *o = s; - while (*s) { - if ((s[0] == '\\') && (s[1] == '0') && IsOctalDigit(s[2]) && IsOctalDigit(s[3])) { - *o = (char)(8 * (s[2] - '0') + (s[3] - '0')); - s += 3; - } else { - *o = *s; - } - o++; - if (*s) - s++; - } - *o = '\0'; - return (unsigned int)(o - sStart); -} - -void TransformBackslashes(char* pszInput,BOOL bRegEx,UINT cpEdit) -{ - if (bRegEx) - UnSlashLowOctal(pszInput); - else - UnSlash(pszInput,cpEdit); -} - - -/* - - MinimizeToTray - Copyright 2000 Matthew Ellis - - Changes made by flo: - - Commented out: #include "stdafx.h" - - Moved variable declaration: APPBARDATA appBarData; - -*/ - -// MinimizeToTray -// -// A couple of routines to show how to make it produce a custom caption -// animation to make it look like we are minimizing to and maximizing -// from the system tray -// -// These routines are public domain, but it would be nice if you dropped -// me a line if you use them! -// -// 1.0 29.06.2000 Initial version -// 1.1 01.07.2000 The window retains it's place in the Z-order of windows -// when minimized/hidden. This means that when restored/shown, it doen't -// always appear as the foreground window unless we call SetForegroundWindow -// -// Copyright 2000 Matthew Ellis -/*#include "stdafx.h"*/ - -// Odd. VC++6 winuser.h has IDANI_CAPTION defined (as well as IDANI_OPEN and -// IDANI_CLOSE), but the Platform SDK only has IDANI_OPEN... - -// I don't know what IDANI_OPEN or IDANI_CLOSE do. Trying them in this code -// produces nothing. Perhaps they were intended for window opening and closing -// like the MAC provides... -#ifndef IDANI_OPEN -#define IDANI_OPEN 1 -#endif -#ifndef IDANI_CLOSE -#define IDANI_CLOSE 2 -#endif -#ifndef IDANI_CAPTION -#define IDANI_CAPTION 3 -#endif - -#define DEFAULT_RECT_WIDTH 150 -#define DEFAULT_RECT_HEIGHT 30 - -// Returns the rect of where we think the system tray is. This will work for -// all current versions of the shell. If explorer isn't running, we try our -// best to work with a 3rd party shell. If we still can't find anything, we -// return a rect in the lower right hand corner of the screen -static VOID GetTrayWndRect(LPRECT lpTrayRect) -{ - APPBARDATA appBarData; - // First, we'll use a quick hack method. We know that the taskbar is a window - // of class Shell_TrayWnd, and the status tray is a child of this of class - // TrayNotifyWnd. This provides us a window rect to minimize to. Note, however, - // that this is not guaranteed to work on future versions of the shell. If we - // use this method, make sure we have a backup! - HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); - if(hShellTrayWnd) - { - HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL); - if(hTrayNotifyWnd) - { - GetWindowRect(hTrayNotifyWnd,lpTrayRect); - return; - } - } - - // OK, we failed to get the rect from the quick hack. Either explorer isn't - // running or it's a new version of the shell with the window class names - // changed (how dare Microsoft change these undocumented class names!) So, we - // try to find out what side of the screen the taskbar is connected to. We - // know that the system tray is either on the right or the bottom of the - // taskbar, so we can make a good guess at where to minimize to - /*APPBARDATA appBarData;*/ - appBarData.cbSize=sizeof(appBarData); - if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) - { - // We know the edge the taskbar is connected to, so guess the rect of the - // system tray. Use various fudge factor to make it look good - switch(appBarData.uEdge) - { - case ABE_LEFT: - case ABE_RIGHT: - // We want to minimize to the bottom of the taskbar - lpTrayRect->top=appBarData.rc.bottom-100; - lpTrayRect->bottom=appBarData.rc.bottom-16; - lpTrayRect->left=appBarData.rc.left; - lpTrayRect->right=appBarData.rc.right; - break; - - case ABE_TOP: - case ABE_BOTTOM: - // We want to minimize to the right of the taskbar - lpTrayRect->top=appBarData.rc.top; - lpTrayRect->bottom=appBarData.rc.bottom; - lpTrayRect->left=appBarData.rc.right-100; - lpTrayRect->right=appBarData.rc.right-16; - break; - } - - return; - } - - // Blimey, we really aren't in luck. It's possible that a third party shell - // is running instead of explorer. This shell might provide support for the - // system tray, by providing a Shell_TrayWnd window (which receives the - // messages for the icons) So, look for a Shell_TrayWnd window and work out - // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd, - // and stretches either the width or the height of the screen. We can't rely - // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't - // rely on it being any size. The best we can do is just blindly use the - // window rect, perhaps limiting the width and height to, say 150 square. - // Note that if the 3rd party shell supports the same configuraion as - // explorer (the icons hosted in NotifyTrayWnd, which is a child window of - // Shell_TrayWnd), we would already have caught it above - hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); - if(hShellTrayWnd) - { - GetWindowRect(hShellTrayWnd,lpTrayRect); - if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH) - lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; - if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT) - lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; - - return; - } - - // OK. Haven't found a thing. Provide a default rect based on the current work - // area - SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0); - lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; - lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; -} - -// Check to see if the animation has been disabled -/*static */BOOL GetDoAnimateMinimize(VOID) -{ - ANIMATIONINFO ai; - - ai.cbSize=sizeof(ai); - SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); - - return ai.iMinAnimate?TRUE:FALSE; -} - -VOID MinimizeWndToTray(HWND hWnd) -{ - if(GetDoAnimateMinimize()) - { - RECT rcFrom,rcTo; - - // Get the rect of the window. It is safe to use the rect of the whole - // window - DrawAnimatedRects will only draw the caption - GetWindowRect(hWnd,&rcFrom); - GetTrayWndRect(&rcTo); - - // Get the system to draw our animation for us - DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); - } - - // Add the tray icon. If we add it before the call to DrawAnimatedRects, - // the taskbar gets erased, but doesn't get redrawn until DAR finishes. - // This looks untidy, so call the functions in this order - - // Hide the window - ShowWindow(hWnd,SW_HIDE); -} - -VOID RestoreWndFromTray(HWND hWnd) -{ - if(GetDoAnimateMinimize()) - { - // Get the rect of the tray and the window. Note that the window rect - // is still valid even though the window is hidden - RECT rcFrom,rcTo; - GetTrayWndRect(&rcFrom); - GetWindowRect(hWnd,&rcTo); - - // Get the system to draw our animation for us - DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); - } - - // Show the window, and make sure we're the foreground window - ShowWindow(hWnd,SW_SHOW); - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); - - // Remove the tray icon. As described above, remove the icon after the - // call to DrawAnimatedRects, or the taskbar will not refresh itself - // properly until DAR finished -} - - - -/// End of Helpers.c \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Helpers.c +* General helper functions +* Parts taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org +* MinimizeToTray (c) 2000 Matthew Ellis +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include +#include +#include "scintilla.h" +#include "helpers.h" +#include "resource.h" + + +//============================================================================= +// +// Manipulation of (cached) ini file sections +// +int IniSectionGetString( + LPCWSTR lpCachedIniSection, + LPCWSTR lpName, + LPCWSTR lpDefault, + LPWSTR lpReturnedString, + int cchReturnedString) +{ + WCHAR *p = (WCHAR *)lpCachedIniSection; + WCHAR tch[256]; + int ich; + + if (p) { + lstrcpy(tch,lpName); + lstrcat(tch,L"="); + ich = lstrlen(tch); + + while (*p) { + if (StrCmpNI(p,tch,ich) == 0) { + lstrcpyn(lpReturnedString,p + ich,cchReturnedString); + return(lstrlen(lpReturnedString)); + } + else + p = StrEnd(p) + 1; + } + } + lstrcpyn(lpReturnedString,lpDefault,cchReturnedString); + return(lstrlen(lpReturnedString)); +} + + +int IniSectionGetInt( + LPCWSTR lpCachedIniSection, + LPCWSTR lpName, + int iDefault) +{ + WCHAR *p = (WCHAR *)lpCachedIniSection; + WCHAR tch[256]; + int ich; + int i; + + if (p) { + lstrcpy(tch,lpName); + lstrcat(tch,L"="); + ich = lstrlen(tch); + + while (*p) { + if (StrCmpNI(p,tch,ich) == 0) { + if (swscanf(p + ich,L"%i",&i) == 1) + return(i); + else + return(iDefault); + } + else + p = StrEnd(p) + 1; + } + } + return(iDefault); +} + + +BOOL IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpString) +{ + WCHAR tch[32+512*3+32]; + WCHAR *p = lpCachedIniSection; + + if (p) { + while (*p) { + p = StrEnd(p) + 1; + } + wsprintf(tch,L"%s=%s",lpName,lpString); + lstrcpy(p,tch); + p = StrEnd(p) + 1; + *p = 0; + return(TRUE); + } + return(FALSE); +} + + +//============================================================================= +// +// PrivateIsAppThemed() +// +extern HMODULE hModUxTheme; +BOOL PrivateIsAppThemed() +{ + FARPROC pfnIsAppThemed; + BOOL bIsAppThemed = FALSE; + + if (hModUxTheme) { + pfnIsAppThemed = GetProcAddress(hModUxTheme,"IsAppThemed"); + + if (pfnIsAppThemed) + bIsAppThemed = (BOOL)pfnIsAppThemed(); + } + return bIsAppThemed; +} + + +//============================================================================= +// +// PrivateSetCurrentProcessExplicitAppUserModelID() +// +HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR AppID) +{ + FARPROC pfnSetCurrentProcessExplicitAppUserModelID; + + if (lstrlen(AppID) == 0) + return(S_OK); + + if (lstrcmpi(AppID,L"(default)") == 0) + return(S_OK); + + pfnSetCurrentProcessExplicitAppUserModelID = + GetProcAddress(GetModuleHandleA("shell32.dll"),"SetCurrentProcessExplicitAppUserModelID"); + + if (pfnSetCurrentProcessExplicitAppUserModelID) + return((HRESULT)pfnSetCurrentProcessExplicitAppUserModelID(AppID)); + + else + return(S_OK); +} + + +//============================================================================= +// +// IsElevated() +// +BOOL IsElevated() { + + BOOL bIsElevated = FALSE; + HANDLE hToken = NULL; + + if (!IsVista()) + return(FALSE); + + if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)) { + + struct { + DWORD TokenIsElevated; + } /*TOKEN_ELEVATION*/te; + DWORD dwReturnLength = 0; + + if (GetTokenInformation(hToken,/*TokenElevation*/20,&te,sizeof(te),&dwReturnLength)) { + if (dwReturnLength == sizeof(te)) + bIsElevated = te.TokenIsElevated; + } + CloseHandle(hToken); + } + return bIsElevated; +} + + +//============================================================================= +// +// SetExplorerTheme() +// +//BOOL SetExplorerTheme(HWND hwnd) +//{ +// FARPROC pfnSetWindowTheme; +// +// if (IsVista()) { +// if (hModUxTheme) { +// pfnSetWindowTheme = GetProcAddress(hModUxTheme,"SetWindowTheme"); +// +// if (pfnSetWindowTheme) +// return (S_OK == pfnSetWindowTheme(hwnd,L"Explorer",NULL)); +// } +// } +// return FALSE; +//} + + +//============================================================================= +// +// BitmapMergeAlpha() +// Merge alpha channel into color channel +// +BOOL BitmapMergeAlpha(HBITMAP hbmp,COLORREF crDest) +{ + BITMAP bmp; + if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { + + if (bmp.bmBitsPixel == 32) { + + int x,y; + RGBQUAD *prgba = bmp.bmBits; + + for (y = 0; y < bmp.bmHeight; y++) { + for (x = 0; x < bmp.bmWidth; x++) { + BYTE alpha = prgba[x].rgbReserved; + prgba[x].rgbRed = ((prgba[x].rgbRed * alpha) + (GetRValue(crDest) * (255-alpha))) >> 8; + prgba[x].rgbGreen = ((prgba[x].rgbGreen * alpha) + (GetGValue(crDest) * (255-alpha))) >> 8; + prgba[x].rgbBlue = ((prgba[x].rgbBlue * alpha) + (GetBValue(crDest) * (255-alpha))) >> 8; + prgba[x].rgbReserved = 0xFF; + } + prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); + } + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// BitmapAlphaBlend() +// Perform alpha blending to color channel only +// +BOOL BitmapAlphaBlend(HBITMAP hbmp,COLORREF crDest,BYTE alpha) +{ + BITMAP bmp; + if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { + + if (bmp.bmBitsPixel == 32) { + + int x,y; + RGBQUAD *prgba = bmp.bmBits; + + for (y = 0; y < bmp.bmHeight; y++) { + for (x = 0; x < bmp.bmWidth; x++) { + prgba[x].rgbRed = ((prgba[x].rgbRed * alpha) + (GetRValue(crDest) * (255-alpha))) >> 8; + prgba[x].rgbGreen = ((prgba[x].rgbGreen * alpha) + (GetGValue(crDest) * (255-alpha))) >> 8; + prgba[x].rgbBlue = ((prgba[x].rgbBlue * alpha) + (GetBValue(crDest) * (255-alpha))) >> 8; + } + prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); + } + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// BitmapGrayScale() +// Gray scale color channel only +// +BOOL BitmapGrayScale(HBITMAP hbmp) +{ + BITMAP bmp; + if (GetObject(hbmp,sizeof(BITMAP),&bmp)) { + + if (bmp.bmBitsPixel == 32) { + + int x,y; + RGBQUAD *prgba = bmp.bmBits; + + for (y = 0; y < bmp.bmHeight; y++) { + for (x = 0; x < bmp.bmWidth; x++) { + prgba[x].rgbRed = prgba[x].rgbGreen = prgba[x].rgbBlue = + (((BYTE)((prgba[x].rgbRed * 38 + prgba[x].rgbGreen * 75 + prgba[x].rgbBlue * 15) >> 7) * 0x80) + (0xD0 * (255-0x80))) >> 8; + } + prgba = (RGBQUAD*)((LPBYTE)prgba + bmp.bmWidthBytes); + } + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// VerifyContrast() +// Check if two colors can be distinguished +// +BOOL VerifyContrast(COLORREF cr1,COLORREF cr2) +{ + BYTE r1 = GetRValue(cr1); + BYTE g1 = GetGValue(cr1); + BYTE b1 = GetBValue(cr1); + BYTE r2 = GetRValue(cr2); + BYTE g2 = GetGValue(cr2); + BYTE b2 = GetBValue(cr2); + + return( + ((abs((3*r1 + 5*g1 + 1*b1) - (3*r2 + 6*g2 + 1*b2))) >= 400) || + ((abs(r1-r2) + abs(b1-b2) + abs(g1-g2)) >= 400)); +} + + +//============================================================================= +// +// IsFontAvailable() +// Test if a certain font is installed on the system +// +int CALLBACK EnumFontsProc(CONST LOGFONT *plf,CONST TEXTMETRIC *ptm,DWORD FontType,LPARAM lParam) +{ + *((PBOOL)lParam) = TRUE; + return(FALSE); +} + +BOOL IsFontAvailable(LPCWSTR lpszFontName) +{ + BOOL fFound = FALSE; + + HDC hDC = GetDC(NULL); + EnumFonts(hDC,lpszFontName,EnumFontsProc,(LPARAM)&fFound); + ReleaseDC(NULL,hDC); + + return(fFound); +} + + +//============================================================================= +// +// SetWindowTitle() +// +BOOL bFreezeAppTitle = FALSE; + +BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled, + LPCWSTR lpszFile,int iFormat,BOOL bModified, + UINT uIDReadOnly,BOOL bReadOnly,LPCWSTR lpszExcerpt) +{ + + WCHAR szUntitled[128]; + WCHAR szExcrptQuot[256]; + WCHAR szExcrptFmt[32]; + WCHAR szAppName[128]; + WCHAR szElevatedAppName[128]; + WCHAR szReadOnly[32]; + WCHAR szTitle[512]; + static WCHAR szCachedFile[MAX_PATH]; + static WCHAR szCachedDisplayName[MAX_PATH]; + static const WCHAR *pszSep = L" - "; + static const WCHAR *pszMod = L"* "; + + if (bFreezeAppTitle) + return FALSE; + + if (!GetString(uIDAppName,szAppName,COUNTOF(szAppName)) || + !GetString(uIDUntitled,szUntitled,COUNTOF(szUntitled))) + return FALSE; + + if (bIsElevated) { + FormatString(szElevatedAppName,COUNTOF(szElevatedAppName),IDS_APPTITLE_ELEVATED,szAppName); + StrCpyN(szAppName,szElevatedAppName,COUNTOF(szAppName)); + } + + if (bModified) + lstrcpy(szTitle,pszMod); + else + lstrcpy(szTitle,L""); + + if (lstrlen(lpszExcerpt)) { + GetString(IDS_TITLEEXCERPT,szExcrptFmt,COUNTOF(szExcrptFmt)); + wsprintf(szExcrptQuot,szExcrptFmt,lpszExcerpt); + StrCat(szTitle,szExcrptQuot); + } + + else if (lstrlen(lpszFile)) + { + if (iFormat < 2 && !PathIsRoot(lpszFile)) + { + if (lstrcmp(szCachedFile,lpszFile) != 0) { + SHFILEINFO shfi; + lstrcpy(szCachedFile,lpszFile); + if (SHGetFileInfo2(lpszFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME)) + lstrcpy(szCachedDisplayName,shfi.szDisplayName); + else + lstrcpy(szCachedDisplayName,PathFindFileName(lpszFile)); + } + lstrcat(szTitle,szCachedDisplayName); + if (iFormat == 1) { + WCHAR tchPath[MAX_PATH]; + StrCpyN(tchPath,lpszFile,COUNTOF(tchPath)); + PathRemoveFileSpec(tchPath); + StrCat(szTitle,L" ["); + StrCat(szTitle,tchPath); + StrCat(szTitle,L"]"); + } + } + else + lstrcat(szTitle,lpszFile); + } + + else { + lstrcpy(szCachedFile,L""); + lstrcpy(szCachedDisplayName,L""); + lstrcat(szTitle,szUntitled); + } + + if (bReadOnly && GetString(uIDReadOnly,szReadOnly,COUNTOF(szReadOnly))) + { + lstrcat(szTitle,L" "); + lstrcat(szTitle,szReadOnly); + } + + lstrcat(szTitle,pszSep); + lstrcat(szTitle,szAppName); + + return SetWindowText(hwnd,szTitle); + +} + + +//============================================================================= +// +// SetWindowTransparentMode() +// +void SetWindowTransparentMode(HWND hwnd,BOOL bTransparentMode) +{ + FARPROC fp; + int iAlphaPercent; + BYTE bAlpha; + + if (bTransparentMode) { + if (fp = GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes")) { + SetWindowLongPtr(hwnd,GWL_EXSTYLE, + GetWindowLongPtr(hwnd,GWL_EXSTYLE) | WS_EX_LAYERED); + + // get opacity level from registry + iAlphaPercent = IniGetInt(L"Settings2",L"OpacityLevel",75); + if (iAlphaPercent < 0 || iAlphaPercent > 100) + iAlphaPercent = 75; + bAlpha = iAlphaPercent * 255 / 100; + + fp(hwnd,0,bAlpha,LWA_ALPHA); + } + } + + else + SetWindowLongPtr(hwnd,GWL_EXSTYLE, + GetWindowLongPtr(hwnd,GWL_EXSTYLE) & ~WS_EX_LAYERED); +} + + +//============================================================================= +// +// CenterDlgInParent() +// +void CenterDlgInParent(HWND hDlg) +{ + + RECT rcDlg; + HWND hParent; + RECT rcParent; + MONITORINFO mi; + HMONITOR hMonitor; + + int xMin, yMin, xMax, yMax, x, y; + + GetWindowRect(hDlg,&rcDlg); + + hParent = GetParent(hDlg); + GetWindowRect(hParent,&rcParent); + + hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor,&mi); + + xMin = mi.rcWork.left; + yMin = mi.rcWork.top; + + xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); + yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); + + if ((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left) > 20) + x = rcParent.left + (((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left)) / 2); + else + x = rcParent.left + 70; + + if ((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top) > 20) + y = rcParent.top + (((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top)) / 2); + else + y = rcParent.top + 60; + + SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); + +} + + +//============================================================================= +// +// GetDlgPos() +// +void GetDlgPos(HWND hDlg,LPINT xDlg,LPINT yDlg) +{ + + RECT rcDlg; + HWND hParent; + RECT rcParent; + + GetWindowRect(hDlg,&rcDlg); + + hParent = GetParent(hDlg); + GetWindowRect(hParent,&rcParent); + + // return positions relative to parent window + *xDlg = rcDlg.left - rcParent.left; + *yDlg = rcDlg.top - rcParent.top; + +} + + +//============================================================================= +// +// SetDlgPos() +// +void SetDlgPos(HWND hDlg,int xDlg,int yDlg) +{ + + RECT rcDlg; + HWND hParent; + RECT rcParent; + MONITORINFO mi; + HMONITOR hMonitor; + + int xMin, yMin, xMax, yMax, x, y; + + GetWindowRect(hDlg,&rcDlg); + + hParent = GetParent(hDlg); + GetWindowRect(hParent,&rcParent); + + hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor,&mi); + + xMin = mi.rcWork.left; + yMin = mi.rcWork.top; + + xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); + yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); + + // desired positions relative to parent window + x = rcParent.left + xDlg; + y = rcParent.top + yDlg; + + SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); + +} + + +//============================================================================= +// +// Resize Dialog Helpers() +// +typedef struct _resizedlg { + int cxClient; + int cyClient; + int cxFrame; + int cyFrame; + int mmiPtMinX; + int mmiPtMinY; +} RESIZEDLG, *PRESIZEDLG; + +void ResizeDlg_Init(HWND hwnd,int cxFrame,int cyFrame,int nIdGrip) +{ + RECT rc; + WCHAR wch[64]; + int cGrip; + RESIZEDLG *pm = LocalAlloc(LPTR,sizeof(RESIZEDLG)); + + GetClientRect(hwnd,&rc); + pm->cxClient = rc.right - rc.left; + pm->cyClient = rc.bottom - rc.top; + + pm->cxFrame = cxFrame; + pm->cyFrame = cyFrame; + + AdjustWindowRectEx(&rc,GetWindowLong(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0); + pm->mmiPtMinX = rc.right-rc.left; + pm->mmiPtMinY = rc.bottom-rc.top; + + if (pm->cxFrame < (rc.right-rc.left)) + pm->cxFrame = rc.right-rc.left; + if (pm->cyFrame < (rc.bottom-rc.top)) + pm->cyFrame = rc.bottom-rc.top; + + SetProp(hwnd,L"ResizeDlg",(HANDLE)pm); + + SetWindowPos(hwnd,NULL,rc.left,rc.top,pm->cxFrame,pm->cyFrame,SWP_NOZORDER); + + SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); + SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,wch,COUNTOF(wch),MF_BYCOMMAND); + InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,wch); + InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); + + SetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE, + GetWindowLongPtr(GetDlgItem(hwnd,nIdGrip),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS); + cGrip = GetSystemMetrics(SM_CXHTHUMB); + SetWindowPos(GetDlgItem(hwnd,nIdGrip),NULL,pm->cxClient-cGrip,pm->cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER); +} + +void ResizeDlg_Destroy(HWND hwnd,int *cxFrame,int *cyFrame) +{ + RECT rc; + PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); + + GetWindowRect(hwnd,&rc); + *cxFrame = rc.right-rc.left; + *cyFrame = rc.bottom-rc.top; + + RemoveProp(hwnd,L"ResizeDlg"); + LocalFree(pm); +} + +void ResizeDlg_Size(HWND hwnd,LPARAM lParam,int *cx,int *cy) +{ + PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); + + *cx = LOWORD(lParam) - pm->cxClient; + *cy = HIWORD(lParam) - pm->cyClient; + pm->cxClient = LOWORD(lParam); + pm->cyClient = HIWORD(lParam); +} + +void ResizeDlg_GetMinMaxInfo(HWND hwnd,LPARAM lParam) +{ + PRESIZEDLG pm = GetProp(hwnd,L"ResizeDlg"); + + LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; + lpmmi->ptMinTrackSize.x = pm->mmiPtMinX; + lpmmi->ptMinTrackSize.y = pm->mmiPtMinY; +} + +HDWP DeferCtlPos(HDWP hdwp,HWND hwndDlg,int nCtlId,int dx,int dy,UINT uFlags) +{ + RECT rc; + HWND hwndCtl = GetDlgItem(hwndDlg,nCtlId); + GetWindowRect(hwndCtl,&rc); + MapWindowPoints(NULL,hwndDlg,(LPPOINT)&rc,2); + if (uFlags & SWP_NOSIZE) + return(DeferWindowPos(hdwp,hwndCtl,NULL,rc.left+dx,rc.top+dy,0,0,SWP_NOZORDER|SWP_NOSIZE)); + else + return(DeferWindowPos(hdwp,hwndCtl,NULL,0,0,rc.right-rc.left+dx,rc.bottom-rc.top+dy,SWP_NOZORDER|SWP_NOMOVE)); +} + + +//============================================================================= +// +// MakeBitmapButton() +// +void MakeBitmapButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,UINT uBmpId) +{ + HWND hwndCtl = GetDlgItem(hwnd,nCtlId); + BITMAP bmp; + BUTTON_IMAGELIST bi; + HBITMAP hBmp = LoadImage(hInstance,MAKEINTRESOURCE(uBmpId),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + GetObject(hBmp,sizeof(BITMAP),&bmp); + bi.himl = ImageList_Create(bmp.bmWidth,bmp.bmHeight,ILC_COLOR32|ILC_MASK,1,0); + ImageList_AddMasked(bi.himl,hBmp,CLR_DEFAULT); + DeleteObject(hBmp); + SetRect(&bi.margin,0,0,0,0); + bi.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi); +} + + +//============================================================================= +// +// MakeColorPickButton() +// +void MakeColorPickButton(HWND hwnd,int nCtlId,HINSTANCE hInstance,COLORREF crColor) +{ + HWND hwndCtl = GetDlgItem(hwnd,nCtlId); + BUTTON_IMAGELIST bi; + HIMAGELIST himlOld = NULL; + HBITMAP hBmp; + COLORMAP colormap[2]; + + if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi)) + himlOld = bi.himl; + + if (IsWindowEnabled(hwndCtl) && crColor != -1) { + colormap[0].from = RGB(0x00,0x00,0x00); + colormap[0].to = GetSysColor(COLOR_3DSHADOW); + } + else { + colormap[0].from = RGB(0x00,0x00,0x00); + colormap[0].to = RGB(0xFF,0xFF,0xFF); + } + + if (IsWindowEnabled(hwndCtl) && crColor != -1) { + if (crColor == RGB(0xFF,0xFF,0xFF)) + crColor = RGB(0xFF,0xFF,0xFE); + + colormap[1].from = RGB(0xFF,0xFF,0xFF); + colormap[1].to = crColor; + } + else { + colormap[1].from = RGB(0xFF,0xFF,0xFF); + colormap[1].to = RGB(0xFF,0xFF,0xFF); + } + + hBmp = CreateMappedBitmap(hInstance,IDB_PICK,0,colormap,2); + + bi.himl = ImageList_Create(10,10,ILC_COLORDDB|ILC_MASK,1,0); + ImageList_AddMasked(bi.himl,hBmp,RGB(0xFF,0xFF,0xFF)); + DeleteObject(hBmp); + + SetRect(&bi.margin,0,0,4,0); + bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT; + + SendMessage(hwndCtl,BCM_SETIMAGELIST,0,(LPARAM)&bi); + InvalidateRect(hwndCtl,NULL,TRUE); + + if (himlOld) + ImageList_Destroy(himlOld); +} + + +//============================================================================= +// +// DeleteBitmapButton() +// +void DeleteBitmapButton(HWND hwnd,int nCtlId) +{ + HWND hwndCtl = GetDlgItem(hwnd,nCtlId); + BUTTON_IMAGELIST bi; + if (SendMessage(hwndCtl,BCM_GETIMAGELIST,0,(LPARAM)&bi)) + ImageList_Destroy(bi.himl); +} + + +//============================================================================= +// +// StatusSetText() +// +BOOL StatusSetText(HWND hwnd,UINT nPart,LPCWSTR lpszText) +{ + + UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart; + return (BOOL)SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)lpszText); + +} + + +//============================================================================= +// +// SendWMSize() +// +LRESULT SendWMSize(HWND hwnd) +{ + RECT rc; GetClientRect(hwnd,&rc); + return(SendMessage(hwnd,WM_SIZE,SIZE_RESTORED, + MAKELPARAM(rc.right,rc.bottom))); +} + + +//============================================================================= +// +// StatusSetTextID() +// +BOOL StatusSetTextID(HWND hwnd,UINT nPart,UINT uID) +{ + + WCHAR szText[256]; + UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart; + + if (!uID) + { + SendMessage(hwnd,SB_SETTEXT,uFlags,0); + return TRUE; + } + + if (!GetString(uID,szText,256)) + return FALSE; + + return (BOOL)SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)szText); + +} + + +//============================================================================= +// +// StatusCalcPaneWidth() +// +int StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz) +{ + SIZE size; + HDC hdc = GetDC(hwnd); + HFONT hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0); + HFONT hfold = SelectObject(hdc,hfont); + int mmode = SetMapMode(hdc,MM_TEXT); + + GetTextExtentPoint32(hdc,lpsz,lstrlen(lpsz),&size); + + SetMapMode(hdc,mmode); + SelectObject(hdc,hfold); + ReleaseDC(hwnd,hdc); + + return(size.cx + 9); +} + + +//============================================================================= +// +// Toolbar_Get/SetButtons() +// +int Toolbar_GetButtons(HWND hwnd,int cmdBase,LPWSTR lpszButtons,int cchButtons) +{ + WCHAR tchButtons[512]; + WCHAR tchItem[32]; + int i,c; + TBBUTTON tbb; + + lstrcpy(tchButtons,L""); + c = min(50,(int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0)); + + for (i = 0; i < c; i++) { + SendMessage(hwnd,TB_GETBUTTON,(WPARAM)i,(LPARAM)&tbb); + wsprintf(tchItem,L"%i ", + (tbb.idCommand==0)?0:tbb.idCommand-cmdBase+1); + lstrcat(tchButtons,tchItem); + } + TrimString(tchButtons); + lstrcpyn(lpszButtons,tchButtons,cchButtons); + return(c); +} + +int Toolbar_SetButtons(HWND hwnd,int cmdBase,LPCWSTR lpszButtons,LPCTBBUTTON ptbb,int ctbb) +{ + WCHAR tchButtons[512]; + WCHAR *p; + int i,c; + int iCmd; + + ZeroMemory(tchButtons,COUNTOF(tchButtons)*sizeof(tchButtons[0])); + lstrcpyn(tchButtons,lpszButtons,COUNTOF(tchButtons)-2); + TrimString(tchButtons); + while (p = StrStr(tchButtons,L" ")) + MoveMemory((WCHAR*)p,(WCHAR*)p+1,(lstrlen(p) + 1) * sizeof(WCHAR)); + + c = (int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0); + for (i = 0; i < c; i++) + SendMessage(hwnd,TB_DELETEBUTTON,0,0); + + for (i = 0; i < COUNTOF(tchButtons); i++) + if (tchButtons[i] == L' ') tchButtons[i] = 0; + + p = tchButtons; + while (*p) { + if (swscanf(p,L"%i",&iCmd) == 1) { + iCmd = (iCmd==0)?0:iCmd+cmdBase-1; + for (i = 0; i < ctbb; i++) { + if (ptbb[i].idCommand == iCmd) { + SendMessage(hwnd,TB_ADDBUTTONS,(WPARAM)1,(LPARAM)&ptbb[i]); + break; + } + } + } + p = StrEnd(p)+1; + } + return((int)SendMessage(hwnd,TB_BUTTONCOUNT,0,0)); +} + + +//============================================================================= +// +// IsCmdEnabled() +// +BOOL IsCmdEnabled(HWND hwnd,UINT uId) +{ + + HMENU hmenu; + UINT ustate; + + hmenu = GetMenu(hwnd); + + SendMessage(hwnd,WM_INITMENU,(WPARAM)hmenu,0); + + ustate = GetMenuState(hmenu,uId,MF_BYCOMMAND); + + if (ustate == 0xFFFFFFFF) + return TRUE; + + else + return (!(ustate & (MF_GRAYED|MF_DISABLED))); + +} + + +//============================================================================= +// +// FormatString() +// +int FormatString(LPWSTR lpOutput,int nOutput,UINT uIdFormat,...) +{ + + WCHAR *p = LocalAlloc(LPTR,sizeof(WCHAR)*nOutput); + + if (GetString(uIdFormat,p,nOutput)) + wvsprintf(lpOutput,p,(LPVOID)((PUINT_PTR)&uIdFormat+1)); + + LocalFree(p); + + return lstrlen(lpOutput); + +} + + +//============================================================================= +// +// PathRelativeToApp() +// +void PathRelativeToApp( + LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bSrcIsFile, + BOOL bUnexpandEnv,BOOL bUnexpandMyDocs) { + + WCHAR wchAppPath[MAX_PATH]; + WCHAR wchWinDir[MAX_PATH]; + WCHAR wchUserFiles[MAX_PATH]; + WCHAR wchPath[MAX_PATH]; + WCHAR wchResult[MAX_PATH]; + DWORD dwAttrTo = (bSrcIsFile) ? 0 : FILE_ATTRIBUTE_DIRECTORY; + + GetModuleFileName(NULL,wchAppPath,COUNTOF(wchAppPath)); + PathRemoveFileSpec(wchAppPath); + GetWindowsDirectory(wchWinDir,COUNTOF(wchWinDir)); + SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchUserFiles); + + if (bUnexpandMyDocs && + !PathIsRelative(lpszSrc) && + !PathIsPrefix(wchUserFiles,wchAppPath) && + PathIsPrefix(wchUserFiles,lpszSrc) && + PathRelativePathTo(wchPath,wchUserFiles,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) { + lstrcpy(wchUserFiles,L"%CSIDL:MYDOCUMENTS%"); + PathAppend(wchUserFiles,wchPath); + lstrcpy(wchPath,wchUserFiles); + } + else if (PathIsRelative(lpszSrc) || PathCommonPrefix(wchAppPath,wchWinDir,NULL)) + lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); + else { + if (!PathRelativePathTo(wchPath,wchAppPath,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) + lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); + } + + if (bUnexpandEnv) { + if (!PathUnExpandEnvStrings(wchPath,wchResult,COUNTOF(wchResult))) + lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); + } + else + lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); + + if (lpszDest == NULL || lpszSrc == lpszDest) + lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); + else + lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); +} + + +//============================================================================= +// +// PathAbsoluteFromApp() +// +void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpandEnv) { + + WCHAR wchPath[MAX_PATH]; + WCHAR wchResult[MAX_PATH]; + + if (StrCmpNI(lpszSrc,L"%CSIDL:MYDOCUMENTS%",CSTRLEN("%CSIDL:MYDOCUMENTS%")) == 0) { + SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchPath); + PathAppend(wchPath,lpszSrc+CSTRLEN("%CSIDL:MYDOCUMENTS%")); + } + else + lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); + + if (bExpandEnv) + ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath)); + + if (PathIsRelative(wchPath)) { + GetModuleFileName(NULL,wchResult,COUNTOF(wchResult)); + PathRemoveFileSpec(wchResult); + PathAppend(wchResult,wchPath); + } + else + lstrcpyn(wchResult,wchPath,COUNTOF(wchResult)); + + PathCanonicalizeEx(wchResult); + if (PathGetDriveNumber(wchResult) != -1) + CharUpperBuff(wchResult,1); + + if (lpszDest == NULL || lpszSrc == lpszDest) + lstrcpyn(lpszSrc,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); + else + lstrcpyn(lpszDest,wchResult,(cchDest == 0) ? MAX_PATH : cchDest); +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// +// Name: PathIsLnkFile() +// +// Purpose: Determine wheter pszPath is a Windows Shell Link File by +// comparing the filename extension with L".lnk" +// +// Manipulates: +// +BOOL PathIsLnkFile(LPCWSTR pszPath) +{ + + //WCHAR *pszExt; + + WCHAR tchResPath[256]; + + if (!pszPath || !*pszPath) + return FALSE; + +/*pszExt = StrRChr(pszPath,NULL,L'.'); + + if (!pszExt) + return FALSE; + + if (!lstrcmpi(pszExt,L".lnk")) + return TRUE; + + else + return FALSE;*/ + + //if (!lstrcmpi(PathFindExtension(pszPath),L".lnk")) + // return TRUE; + + //else + // return FALSE; + + if (lstrcmpi(PathFindExtension(pszPath),L".lnk")) + return FALSE; + + else + return PathGetLnkPath(pszPath,tchResPath,COUNTOF(tchResPath)); + +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// +// Name: PathGetLnkPath() +// +// Purpose: Try to get the path to which a lnk-file is linked +// +// +// Manipulates: pszResPath +// +BOOL PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath) +{ + + IShellLink *psl; + WIN32_FIND_DATA fd; + BOOL bSucceeded = FALSE; + + if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, + CLSCTX_INPROC_SERVER, + &IID_IShellLink,&psl))) + { + IPersistFile *ppf; + + if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) + { + WORD wsz[MAX_PATH]; + + /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, + pszLnkFile,-1,wsz,MAX_PATH);*/ + lstrcpy(wsz,pszLnkFile); + + if (SUCCEEDED(ppf->lpVtbl->Load(ppf,wsz,STGM_READ))) + { + if (NOERROR == psl->lpVtbl->GetPath(psl,pszResPath,cchResPath,&fd,0)) + bSucceeded = TRUE; + } + ppf->lpVtbl->Release(ppf); + } + psl->lpVtbl->Release(psl); + } + + // This additional check seems reasonable + if (!lstrlen(pszResPath)) + bSucceeded = FALSE; + + if (bSucceeded) { + ExpandEnvironmentStringsEx(pszResPath,cchResPath); + PathCanonicalizeEx(pszResPath); + } + + return(bSucceeded); + +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// +// Name: PathIsLnkToDirectory() +// +// Purpose: Determine wheter pszPath is a Windows Shell Link File which +// refers to a directory +// +// Manipulates: pszResPath +// +BOOL PathIsLnkToDirectory(LPCWSTR pszPath,LPWSTR pszResPath,int cchResPath) +{ + + WCHAR tchResPath[MAX_PATH]; + + if (PathIsLnkFile(pszPath)) { + + if (PathGetLnkPath(pszPath,tchResPath,sizeof(WCHAR)*COUNTOF(tchResPath))) { + + if (PathIsDirectory(tchResPath)) { + + lstrcpyn(pszResPath,tchResPath,cchResPath); + return (TRUE); + } + + else + return FALSE; + } + + else + return FALSE; + } + + else + return FALSE; + +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// +// Name: PathCreateDeskLnk() +// +// Purpose: Modified to create a desktop link to Notepad2 +// +// Manipulates: +// +BOOL PathCreateDeskLnk(LPCWSTR pszDocument) +{ + + WCHAR tchExeFile[MAX_PATH]; + WCHAR tchDocTemp[MAX_PATH]; + WCHAR tchArguments[MAX_PATH+16]; + WCHAR tchLinkDir[MAX_PATH]; + WCHAR tchDescription[64]; + + WCHAR tchLnkFileName[MAX_PATH]; + + IShellLink *psl; + BOOL bSucceeded = FALSE; + BOOL fMustCopy; + + if (!pszDocument || lstrlen(pszDocument) == 0) + return TRUE; + + // init strings + GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile)); + + lstrcpy(tchDocTemp,pszDocument); + PathQuoteSpaces(tchDocTemp); + + lstrcpy(tchArguments,L"-n "); + lstrcat(tchArguments,tchDocTemp); + + SHGetSpecialFolderPath(NULL,tchLinkDir,CSIDL_DESKTOPDIRECTORY,TRUE); + + GetString(IDS_LINKDESCRIPTION,tchDescription,COUNTOF(tchDescription)); + + // Try to construct a valid filename... + if (!SHGetNewLinkInfo(pszDocument,tchLinkDir,tchLnkFileName,&fMustCopy,SHGNLI_PREFIXNAME)) + return(FALSE); + + if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, + CLSCTX_INPROC_SERVER, + &IID_IShellLink,&psl))) + { + IPersistFile *ppf; + + if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) + { + WORD wsz[MAX_PATH]; + + /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, + tchLnkFileName,-1,wsz,MAX_PATH);*/ + lstrcpy(wsz,tchLnkFileName); + + psl->lpVtbl->SetPath(psl,tchExeFile); + psl->lpVtbl->SetArguments(psl,tchArguments); + psl->lpVtbl->SetDescription(psl,tchDescription); + + if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE))) + bSucceeded = TRUE; + + ppf->lpVtbl->Release(ppf); + } + psl->lpVtbl->Release(psl); + } + + return(bSucceeded); + +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// +// Name: PathCreateFavLnk() +// +// Purpose: Modified to create a Notepad2 favorites link +// +// Manipulates: +// +BOOL PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir) +{ + + WCHAR tchLnkFileName[MAX_PATH]; + + IShellLink *psl; + BOOL bSucceeded = FALSE; + + if (!pszName || lstrlen(pszName) == 0) + return TRUE; + + lstrcpy(tchLnkFileName,pszDir); + PathAppend(tchLnkFileName,pszName); + lstrcat(tchLnkFileName,L".lnk"); + + if (PathFileExists(tchLnkFileName)) + return FALSE; + + if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL, + CLSCTX_INPROC_SERVER, + &IID_IShellLink,&psl))) + { + IPersistFile *ppf; + + if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,&ppf))) + { + WORD wsz[MAX_PATH]; + + /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, + tchLnkFileName,-1,wsz,MAX_PATH);*/ + lstrcpy(wsz,tchLnkFileName); + + psl->lpVtbl->SetPath(psl,pszTarget); + + if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,TRUE))) + bSucceeded = TRUE; + + ppf->lpVtbl->Release(ppf); + } + psl->lpVtbl->Release(psl); + } + + return(bSucceeded); + +} + + +//============================================================================= +// +// StrLTrim() +// +BOOL StrLTrim(LPWSTR pszSource,LPCWSTR pszTrimChars) +{ + LPWSTR psz; + + if (!pszSource || !*pszSource) + return FALSE; + + psz = pszSource; + while (StrChrI(pszTrimChars,*psz)) + psz++; + + MoveMemory(pszSource,psz,sizeof(WCHAR)*(lstrlen(psz) + 1)); + + return TRUE; +} + + +//============================================================================= +// +// TrimString() +// +BOOL TrimString(LPWSTR lpString) +{ + + LPWSTR psz; + + if (!lpString || !*lpString) + return FALSE; + + // Trim left + psz = lpString; + + while (*psz == L' ') + psz = CharNext(psz); + + MoveMemory(lpString,psz,sizeof(WCHAR)*(lstrlen(psz) + 1)); + + // Trim right + psz = StrEnd(lpString); + + while (*(psz = CharPrev(lpString,psz)) == L' ') + *psz = L'\0'; + + return TRUE; + +} + + +//============================================================================= +// +// ExtractFirstArgument() +// +BOOL ExtractFirstArgument(LPCWSTR lpArgs,LPWSTR lpArg1,LPWSTR lpArg2) +{ + + LPWSTR psz; + BOOL bQuoted = FALSE; + + lstrcpy(lpArg1,lpArgs); + if (lpArg2) + *lpArg2 = L'\0'; + + if (!TrimString(lpArg1)) + return FALSE; + + if (*lpArg1 == L'\"') + { + *lpArg1 = L' '; + TrimString(lpArg1); + bQuoted = TRUE; + } + + if (bQuoted) + psz = StrChr(lpArg1,L'\"'); + else + psz = StrChr(lpArg1,L' ');; + + if (psz) + { + *psz = L'\0'; + if (lpArg2) + lstrcpy(lpArg2,psz + 1); + } + + TrimString(lpArg1); + + if (lpArg2) + TrimString(lpArg2); + + return TRUE; + +} + + +//============================================================================= +// +// PrepareFilterStr() +// +void PrepareFilterStr(LPWSTR lpFilter) +{ + LPWSTR psz = StrEnd(lpFilter); + while (psz != lpFilter) + { + if (*(psz = CharPrev(lpFilter,psz)) == L'|') + *psz = L'\0'; + } +} + + +//============================================================================= +// +// StrTab2Space() - in place conversion +// +void StrTab2Space(LPWSTR lpsz) +{ + WCHAR *c = lpsz; + while (c = StrChr(lpsz,L'\t')) + *c = L' '; +} + + +//============================================================================= +// +// PathFixBackslashes() - in place conversion +// +void PathFixBackslashes(LPWSTR lpsz) +{ + WCHAR *c = lpsz; + while (c = StrChr(c,L'/')) { + if (*CharPrev(lpsz,c) == L':' && *CharNext(c) == L'/') + c += 2; + else + *c = L'\\'; + } +} + + +//============================================================================= +// +// ExpandEnvironmentStringsEx() +// +// Adjusted for Windows 95 +// +void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc) +{ + WCHAR szBuf[312]; + + if (ExpandEnvironmentStrings(lpSrc,szBuf,COUNTOF(szBuf))) + lstrcpyn(lpSrc,szBuf,dwSrc); +} + + +//============================================================================= +// +// PathCanonicalizeEx() +// +// +void PathCanonicalizeEx(LPWSTR lpSrc) +{ + WCHAR szDst[MAX_PATH]; + + if (PathCanonicalize(szDst,lpSrc)) + lstrcpy(lpSrc,szDst); +} + + +//============================================================================= +// +// GetLongPathNameEx() +// +// +DWORD GetLongPathNameEx(LPWSTR lpszPath,DWORD cchBuffer) +{ + DWORD dwRet = GetLongPathName(lpszPath,lpszPath,cchBuffer); + if (dwRet) { + if (PathGetDriveNumber(lpszPath) != -1) + CharUpperBuff(lpszPath,1); + return(dwRet); + } + return(0); +} + + +//============================================================================= +// +// SHGetFileInfo2() +// +// Return a default name when the file has been removed, and always append +// a filename extension +// +DWORD_PTR SHGetFileInfo2(LPCWSTR pszPath,DWORD dwFileAttributes, + SHFILEINFO *psfi,UINT cbFileInfo,UINT uFlags) +{ + + if (PathFileExists(pszPath)) { + + DWORD_PTR dw = SHGetFileInfo(pszPath,dwFileAttributes,psfi,cbFileInfo,uFlags); + if (lstrlen(psfi->szDisplayName) < lstrlen(PathFindFileName(pszPath))) + StrCatBuff(psfi->szDisplayName,PathFindExtension(pszPath),COUNTOF(psfi->szDisplayName)); + return(dw); + } + + else { + DWORD_PTR dw = SHGetFileInfo(pszPath,FILE_ATTRIBUTE_NORMAL,psfi,cbFileInfo,uFlags|SHGFI_USEFILEATTRIBUTES); + if (lstrlen(psfi->szDisplayName) < lstrlen(PathFindFileName(pszPath))) + StrCatBuff(psfi->szDisplayName,PathFindExtension(pszPath),COUNTOF(psfi->szDisplayName)); + return(dw); + } + +} + + +//============================================================================= +// +// FormatNumberStr() +// +int FormatNumberStr(LPWSTR lpNumberStr) +{ + WCHAR *c; + WCHAR szSep[8]; + int i = 0; + + if (!lstrlen(lpNumberStr)) + return(0); + + if (!GetLocaleInfo(LOCALE_USER_DEFAULT, + LOCALE_STHOUSAND, + szSep, + COUNTOF(szSep))) + szSep[0] = L'\''; + + c = StrEnd(lpNumberStr); + + while ((c = CharPrev(lpNumberStr,c)) != lpNumberStr) + { + if (++i == 3) + { + i = 0; + MoveMemory(c+1,c,sizeof(WCHAR)*(lstrlen(c)+1)); + *c = szSep[0]; + } + } + + return(lstrlen(lpNumberStr)); +} + + +//============================================================================= +// +// SetDlgItemIntEx() +// +BOOL SetDlgItemIntEx(HWND hwnd,int nIdItem,UINT uValue) +{ + WCHAR szBuf[64]; + + wsprintf(szBuf,L"%u",uValue); + FormatNumberStr(szBuf); + + return(SetDlgItemText(hwnd,nIdItem,szBuf)); +} + + +//============================================================================= +// +// A2W: Convert Dialog Item Text form Unicode to UTF-8 and vice versa +// +UINT GetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString,int nMaxCount) +{ + WCHAR wsz[1024] = L""; + UINT uRet = GetDlgItemTextW(hDlg,nIDDlgItem,wsz,COUNTOF(wsz)); + ZeroMemory(lpString,nMaxCount); + WCharToMBCS(uCP,wsz,lpString,nMaxCount-2); + return uRet; +} + +UINT SetDlgItemTextA2W(UINT uCP,HWND hDlg,int nIDDlgItem,LPSTR lpString) +{ + WCHAR wsz[1024] = L""; + MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz)); + return SetDlgItemTextW(hDlg,nIDDlgItem,wsz); +} + +LRESULT ComboBox_AddStringA2W(UINT uCP,HWND hwnd,LPCSTR lpString) +{ + WCHAR wsz[1024] = L""; + MBCSToWChar(uCP,lpString,wsz,COUNTOF(wsz)); + return SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)wsz); +} + + +//============================================================================= +// +// CodePageFromCharSet() +// +UINT CodePageFromCharSet(UINT uCharSet) +{ + CHARSETINFO ci; + if (TranslateCharsetInfo((DWORD*)(UINT_PTR)uCharSet,&ci,TCI_SRCCHARSET)) + return(ci.ciACP); + else + return(GetACP()); +} + + +//============================================================================= +// +// MRU functions +// +LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize) { + + LPMRULIST pmru = LocalAlloc(LPTR,sizeof(MRULIST)); + ZeroMemory(pmru,sizeof(MRULIST)); + lstrcpyn(pmru->szRegKey,pszRegKey,COUNTOF(pmru->szRegKey)); + pmru->iFlags = iFlags; + pmru->iSize = min(iSize,MRU_MAXITEMS); + return(pmru); +} + +BOOL MRU_Destroy(LPMRULIST pmru) { + + int i; + for (i = 0; i < pmru->iSize; i++) { + if (pmru->pszItems[i]) + LocalFree(pmru->pszItems[i]); + } + ZeroMemory(pmru,sizeof(MRULIST)); + LocalFree(pmru); + return(1); +} + +int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2) { + + if (pmru->iFlags & MRU_NOCASE) + return(lstrcmpi(psz1,psz2)); + else + return(lstrcmp(psz1,psz2)); +} + +BOOL MRU_Add(LPMRULIST pmru,LPCWSTR pszNew) { + + int i; + for (i = 0; i < pmru->iSize; i++) { + if (MRU_Compare(pmru,pmru->pszItems[i],pszNew) == 0) { + LocalFree(pmru->pszItems[i]); + break; + } + } + i = min(i,pmru->iSize-1); + for (; i > 0; i--) + pmru->pszItems[i] = pmru->pszItems[i-1]; + pmru->pszItems[0] = StrDup(pszNew); + return(1); +} + +BOOL MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,BOOL bRelativePath,BOOL bUnexpandMyDocs) { + + int i; + for (i = 0; i < pmru->iSize; i++) { + if (lstrcmpi(pmru->pszItems[i],pszFile) == 0) { + LocalFree(pmru->pszItems[i]); + break; + } + else { + WCHAR wchItem[MAX_PATH]; + PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE); + if (lstrcmpi(wchItem,pszFile) == 0) { + LocalFree(pmru->pszItems[i]); + break; + } + } + } + i = min(i,pmru->iSize-1); + for (; i > 0; i--) + pmru->pszItems[i] = pmru->pszItems[i-1]; + + if (bRelativePath) { + WCHAR wchFile[MAX_PATH]; + PathRelativeToApp((LPWSTR)pszFile,wchFile,COUNTOF(wchFile),TRUE,TRUE,bUnexpandMyDocs); + pmru->pszItems[0] = StrDup(wchFile); + } + else + pmru->pszItems[0] = StrDup(pszFile); + +/* notepad2-mod custom code start */ + // Needed to make W7 jump lists work when NP2 is not explicitly associated + if (IsW7()) SHAddToRecentDocs(SHARD_PATHW, pszFile); +/* notepad2-mod custom code end */ + + return(1); +} + +BOOL MRU_Delete(LPMRULIST pmru,int iIndex) { + + int i; + if (iIndex < 0 || iIndex > pmru->iSize-1) + return(0); + if (pmru->pszItems[iIndex]) + LocalFree(pmru->pszItems[iIndex]); + for (i = iIndex; i < pmru->iSize-1; i++) { + pmru->pszItems[i] = pmru->pszItems[i+1]; + pmru->pszItems[i+1] = NULL; + } + return(1); +} + +BOOL MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile) { + + int i = 0; + LPMRULIST pmruStore; + WCHAR wchItem[256]; + + pmruStore = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize); + MRU_Load(pmruStore); + + while (MRU_Enum(pmruStore,i,wchItem,COUNTOF(wchItem)) != -1) { + PathAbsoluteFromApp(wchItem,wchItem,COUNTOF(wchItem),TRUE); + if (lstrcmpi(wchItem,pszFile) == 0) + MRU_Delete(pmruStore,i); + else + i++; + } + + MRU_Save(pmruStore); + MRU_Destroy(pmruStore); + return(1); +} + +BOOL MRU_Empty(LPMRULIST pmru) { + + int i; + for (i = 0; i < pmru->iSize; i++) { + if (pmru->pszItems[i]) { + LocalFree(pmru->pszItems[i]); + pmru->pszItems[i] = NULL; + } + } + return(1); +} + +int MRU_Enum(LPMRULIST pmru,int iIndex,LPWSTR pszItem,int cchItem) { + + if (pszItem == NULL || cchItem == 0) { + int i = 0; + while (i < pmru->iSize && pmru->pszItems[i]) + i++; + return(i); + } + else { + if (iIndex < 0 || iIndex > pmru->iSize-1 || !pmru->pszItems[iIndex]) + return(-1); + else { + lstrcpyn(pszItem,pmru->pszItems[iIndex],cchItem); + return(lstrlen(pszItem)); + } + } +} + +BOOL MRU_Load(LPMRULIST pmru) { + + int i,n = 0; + WCHAR tchName[32]; + WCHAR tchItem[1024]; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + + MRU_Empty(pmru); + LoadIniSection(pmru->szRegKey,pIniSection,(int)LocalSize(pIniSection)/sizeof(WCHAR)); + + for (i = 0; i < pmru->iSize; i++) { + wsprintf(tchName,L"%.2i",i+1); + if (IniSectionGetString(pIniSection,tchName,L"",tchItem,COUNTOF(tchItem))) { + /*if (pmru->iFlags & MRU_UTF8) { + WCHAR wchItem[1024]; + int cbw = MultiByteToWideChar(CP_UTF7,0,tchItem,-1,wchItem,COUNTOF(wchItem)); + WideCharToMultiByte(CP_UTF8,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL); + pmru->pszItems[n++] = StrDup(tchItem); + } + else*/ + pmru->pszItems[n++] = StrDup(tchItem); + } + } + LocalFree(pIniSection); + return(1); +} + +BOOL MRU_Save(LPMRULIST pmru) { + + int i; + WCHAR tchName[32]; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + + //IniDeleteSection(pmru->szRegKey); + + for (i = 0; i < pmru->iSize; i++) { + if (pmru->pszItems[i]) { + wsprintf(tchName,L"%.2i",i+1); + /*if (pmru->iFlags & MRU_UTF8) { + WCHAR tchItem[1024]; + WCHAR wchItem[1024]; + int cbw = MultiByteToWideChar(CP_UTF8,0,pmru->pszItems[i],-1,wchItem,COUNTOF(wchItem)); + WideCharToMultiByte(CP_UTF7,0,wchItem,cbw,tchItem,COUNTOF(tchItem),NULL,NULL); + IniSectionSetString(pIniSection,tchName,tchItem); + } + else*/ + IniSectionSetString(pIniSection,tchName,pmru->pszItems[i]); + } + } + SaveIniSection(pmru->szRegKey,pIniSection); + LocalFree(pIniSection); + return(1); +} + + +BOOL MRU_MergeSave(LPMRULIST pmru,BOOL bAddFiles,BOOL bRelativePath,BOOL bUnexpandMyDocs) { + + int i; + LPMRULIST pmruBase; + + pmruBase = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize); + MRU_Load(pmruBase); + + if (bAddFiles) { + for (i = pmru->iSize-1; i >= 0; i--) { + if (pmru->pszItems[i]) { + WCHAR wchItem[MAX_PATH]; + PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),TRUE); + MRU_AddFile(pmruBase,wchItem,bRelativePath,bUnexpandMyDocs); + } + } + } + + else { + for (i = pmru->iSize-1; i >= 0; i--) { + if (pmru->pszItems[i]) + MRU_Add(pmruBase,pmru->pszItems[i]); + } + } + + MRU_Save(pmruBase); + MRU_Destroy(pmruBase); + return(1); +} + + +/* + + Themed Dialogs + Modify dialog templates to use current theme font + Based on code of MFC helper class CDialogTemplate + +*/ + +BOOL GetThemedDialogFont(LPWSTR lpFaceName,WORD* wSize) +{ + HDC hDC; + int iLogPixelsY; + HMODULE hModUxTheme; + HTHEME hTheme; + LOGFONT lf; + BOOL bSucceed = FALSE; + + hDC = GetDC(NULL); + iLogPixelsY = GetDeviceCaps(hDC,LOGPIXELSY); + ReleaseDC(NULL,hDC); + + if (hModUxTheme = GetModuleHandle(L"uxtheme.dll")) { + if ((BOOL)(GetProcAddress(hModUxTheme,"IsAppThemed"))()) { + hTheme = (HTHEME)(INT_PTR)(GetProcAddress(hModUxTheme,"OpenThemeData"))(NULL,L"WINDOWSTYLE;WINDOW"); + if (hTheme) { + if (S_OK == (HRESULT)(GetProcAddress(hModUxTheme,"GetThemeSysFont"))(hTheme,/*TMT_MSGBOXFONT*/805,&lf)) { + if (lf.lfHeight < 0) + lf.lfHeight = -lf.lfHeight; + *wSize = (WORD)MulDiv(lf.lfHeight,72,iLogPixelsY); + if (*wSize == 0) + *wSize = 8; + StrCpyN(lpFaceName,lf.lfFaceName,LF_FACESIZE); + bSucceed = TRUE; + } + (GetProcAddress(hModUxTheme,"CloseThemeData"))(hTheme); + } + } + } + + /* + if (!bSucceed) { + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&ncm,0); + if (ncm.lfMessageFont.lfHeight < 0) + ncm.lfMessageFont.lfHeight = -ncm.lfMessageFont.lfHeight; + *wSize = (WORD)MulDiv(ncm.lfMessageFont.lfHeight,72,iLogPixelsY); + if (*wSize == 0) + *wSize = 8; + StrCpyN(lpFaceName,ncm.lfMessageFont.lfFaceName,LF_FACESIZE); + }*/ + + return(bSucceed); +} + +__inline BOOL DialogTemplate_IsDialogEx(const DLGTEMPLATE* pTemplate) { + + return ((DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF; +} + +__inline BOOL DialogTemplate_HasFont(const DLGTEMPLATE* pTemplate) { + + return (DS_SETFONT & + (DialogTemplate_IsDialogEx(pTemplate) ? ((DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style)); +} + +__inline int DialogTemplate_FontAttrSize(BOOL bDialogEx) { + + return (int)sizeof(WORD) * (bDialogEx ? 3 : 1); +} + +__inline BYTE* DialogTemplate_GetFontSizeField(const DLGTEMPLATE* pTemplate) { + + BOOL bDialogEx = DialogTemplate_IsDialogEx(pTemplate); + WORD* pw; + + if (bDialogEx) + pw = (WORD*)((DLGTEMPLATEEX*)pTemplate + 1); + else + pw = (WORD*)(pTemplate + 1); + + if (*pw == (WORD)-1) + pw += 2; + else + while(*pw++); + + if (*pw == (WORD)-1) + pw += 2; + else + while(*pw++); + + while (*pw++); + + return (BYTE*)pw; +} + +DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR lpDialogTemplateID,HINSTANCE hInstance) { + + HRSRC hRsrc; + HGLOBAL hRsrcMem; + DLGTEMPLATE *pRsrcMem; + DLGTEMPLATE *pTemplate; + UINT dwTemplateSize = 0; + WCHAR wchFaceName[LF_FACESIZE]; + WORD wFontSize; + BOOL bDialogEx; + BOOL bHasFont; + int cbFontAttr; + int cbNew; + int cbOld; + BYTE* pbNew; + BYTE* pb; + BYTE* pOldControls; + BYTE* pNewControls; + WORD nCtrl; + + hRsrc = FindResource(hInstance,lpDialogTemplateID,RT_DIALOG); + if (hRsrc == NULL) + return(NULL); + + hRsrcMem = LoadResource(hInstance,hRsrc); + pRsrcMem = (DLGTEMPLATE*)LockResource(hRsrcMem); + dwTemplateSize = (UINT)SizeofResource(hInstance,hRsrc); + + if ((dwTemplateSize == 0) || + (pTemplate = LocalAlloc(LPTR,dwTemplateSize+LF_FACESIZE*2)) == NULL) { + UnlockResource(hRsrcMem); + FreeResource(hRsrcMem); + return(NULL); + } + + CopyMemory((BYTE*)pTemplate,pRsrcMem,(size_t)dwTemplateSize); + UnlockResource(hRsrcMem); + FreeResource(hRsrcMem); + + if (!GetThemedDialogFont(wchFaceName,&wFontSize)) + return(pTemplate); + + bDialogEx = DialogTemplate_IsDialogEx(pTemplate); + bHasFont = DialogTemplate_HasFont(pTemplate); + cbFontAttr = DialogTemplate_FontAttrSize(bDialogEx); + + if (bDialogEx) + ((DLGTEMPLATEEX*)pTemplate)->style |= DS_SHELLFONT; + else + pTemplate->style |= DS_SHELLFONT; + + cbNew = cbFontAttr + ((lstrlen(wchFaceName) + 1) * sizeof(WCHAR)); + pbNew = (BYTE*)wchFaceName; + + pb = DialogTemplate_GetFontSizeField(pTemplate); + cbOld = (int)(bHasFont ? cbFontAttr + 2 * (lstrlen((WCHAR*)(pb + cbFontAttr)) + 1) : 0); + + pOldControls = (BYTE*)(((DWORD_PTR)pb + cbOld + 3) & ~(DWORD_PTR)3); + pNewControls = (BYTE*)(((DWORD_PTR)pb + cbNew + 3) & ~(DWORD_PTR)3); + + nCtrl = bDialogEx ? + (WORD)((DLGTEMPLATEEX*)pTemplate)->cDlgItems : + (WORD)pTemplate->cdit; + + if (cbNew != cbOld && nCtrl > 0) + MoveMemory(pNewControls,pOldControls,(size_t)(dwTemplateSize - (pOldControls - (BYTE*)pTemplate))); + + *(WORD*)pb = wFontSize; + MoveMemory(pb + cbFontAttr,pbNew,(size_t)(cbNew - cbFontAttr)); + + return(pTemplate); +} + +INT_PTR ThemedDialogBoxParam( + HINSTANCE hInstance, + LPCTSTR lpTemplate, + HWND hWndParent, + DLGPROC lpDialogFunc, + LPARAM dwInitParam) { + + INT_PTR ret; + DLGTEMPLATE *pDlgTemplate; + + pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance); + ret = DialogBoxIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam); + if (pDlgTemplate) + LocalFree(pDlgTemplate); + + return(ret); +} + +HWND CreateThemedDialogParam( + HINSTANCE hInstance, + LPCTSTR lpTemplate, + HWND hWndParent, + DLGPROC lpDialogFunc, + LPARAM dwInitParam) { + + HWND hwnd; + DLGTEMPLATE *pDlgTemplate; + + pDlgTemplate = LoadThemedDialogTemplate(lpTemplate,hInstance); + hwnd = CreateDialogIndirectParam(hInstance,pDlgTemplate,hWndParent,lpDialogFunc,dwInitParam); + if (pDlgTemplate) + LocalFree(pDlgTemplate); + + return(hwnd); +} + + +/****************************************************************************** +* +* UnSlash functions +* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org +* +/ + +/** + * Is the character an octal digit? + */ +static BOOL IsOctalDigit(char ch) { + return ch >= '0' && ch <= '7'; +} + +/** + * If the character is an hexa digit, get its value. + */ +static int GetHexDigit(char ch) { + if (ch >= '0' && ch <= '9') { + return ch - '0'; + } + if (ch >= 'A' && ch <= 'F') { + return ch - 'A' + 10; + } + if (ch >= 'a' && ch <= 'f') { + return ch - 'a' + 10; + } + return -1; +} + +/** + * Convert C style \a, \b, \f, \n, \r, \t, \v, \xhh and \uhhhh into their indicated characters. + */ +unsigned int UnSlash(char *s,UINT cpEdit) { + char *sStart = s; + char *o = s; + + while (*s) { + if (*s == '\\') { + s++; + if (*s == 'a') + *o = '\a'; + else if (*s == 'b') + *o = '\b'; + else if (*s == 'f') + *o = '\f'; + else if (*s == 'n') + *o = '\n'; + else if (*s == 'r') + *o = '\r'; + else if (*s == 't') + *o = '\t'; + else if (*s == 'v') + *o = '\v'; + else if (*s == 'x' || *s == 'u') { + BOOL bShort = (*s == 'x'); + char ch[8]; + char *pch = ch; + WCHAR val[2] = L""; + int hex; + val[0] = 0; + hex = GetHexDigit(*(s+1)); + if (hex >= 0) { + s++; + val[0] = hex; + hex = GetHexDigit(*(s+1)); + if (hex >= 0) { + s++; + val[0] *= 16; + val[0] += hex; + if (!bShort) { + hex = GetHexDigit(*(s+1)); + if (hex >= 0) { + s++; + val[0] *= 16; + val[0] += hex; + hex = GetHexDigit(*(s+1)); + if (hex >= 0) { + s++; + val[0] *= 16; + val[0] += hex; + } + } + } + } + if (val[0]) { + val[1] = 0; + WideCharToMultiByte(cpEdit,0,val,-1,ch,COUNTOF(ch),NULL,NULL); + *o = *pch++; + while (*pch) + *++o = *pch++; + } + else + o--; + } + else + o--; + } + else + *o = *s; + } + else + *o = *s; + o++; + if (*s) { + s++; + } + } + *o = '\0'; + return (unsigned int)(o - sStart); +} + +/** + * Convert C style \0oo into their indicated characters. + * This is used to get control characters into the regular expresion engine. + */ +unsigned int UnSlashLowOctal(char *s) { + char *sStart = s; + char *o = s; + while (*s) { + if ((s[0] == '\\') && (s[1] == '0') && IsOctalDigit(s[2]) && IsOctalDigit(s[3])) { + *o = (char)(8 * (s[2] - '0') + (s[3] - '0')); + s += 3; + } else { + *o = *s; + } + o++; + if (*s) + s++; + } + *o = '\0'; + return (unsigned int)(o - sStart); +} + +void TransformBackslashes(char* pszInput,BOOL bRegEx,UINT cpEdit) +{ + if (bRegEx) + UnSlashLowOctal(pszInput); + else + UnSlash(pszInput,cpEdit); +} + + +/* + + MinimizeToTray - Copyright 2000 Matthew Ellis + + Changes made by flo: + - Commented out: #include "stdafx.h" + - Moved variable declaration: APPBARDATA appBarData; + +*/ + +// MinimizeToTray +// +// A couple of routines to show how to make it produce a custom caption +// animation to make it look like we are minimizing to and maximizing +// from the system tray +// +// These routines are public domain, but it would be nice if you dropped +// me a line if you use them! +// +// 1.0 29.06.2000 Initial version +// 1.1 01.07.2000 The window retains it's place in the Z-order of windows +// when minimized/hidden. This means that when restored/shown, it doen't +// always appear as the foreground window unless we call SetForegroundWindow +// +// Copyright 2000 Matthew Ellis +/*#include "stdafx.h"*/ + +// Odd. VC++6 winuser.h has IDANI_CAPTION defined (as well as IDANI_OPEN and +// IDANI_CLOSE), but the Platform SDK only has IDANI_OPEN... + +// I don't know what IDANI_OPEN or IDANI_CLOSE do. Trying them in this code +// produces nothing. Perhaps they were intended for window opening and closing +// like the MAC provides... +#ifndef IDANI_OPEN +#define IDANI_OPEN 1 +#endif +#ifndef IDANI_CLOSE +#define IDANI_CLOSE 2 +#endif +#ifndef IDANI_CAPTION +#define IDANI_CAPTION 3 +#endif + +#define DEFAULT_RECT_WIDTH 150 +#define DEFAULT_RECT_HEIGHT 30 + +// Returns the rect of where we think the system tray is. This will work for +// all current versions of the shell. If explorer isn't running, we try our +// best to work with a 3rd party shell. If we still can't find anything, we +// return a rect in the lower right hand corner of the screen +static VOID GetTrayWndRect(LPRECT lpTrayRect) +{ + APPBARDATA appBarData; + // First, we'll use a quick hack method. We know that the taskbar is a window + // of class Shell_TrayWnd, and the status tray is a child of this of class + // TrayNotifyWnd. This provides us a window rect to minimize to. Note, however, + // that this is not guaranteed to work on future versions of the shell. If we + // use this method, make sure we have a backup! + HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); + if(hShellTrayWnd) + { + HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL); + if(hTrayNotifyWnd) + { + GetWindowRect(hTrayNotifyWnd,lpTrayRect); + return; + } + } + + // OK, we failed to get the rect from the quick hack. Either explorer isn't + // running or it's a new version of the shell with the window class names + // changed (how dare Microsoft change these undocumented class names!) So, we + // try to find out what side of the screen the taskbar is connected to. We + // know that the system tray is either on the right or the bottom of the + // taskbar, so we can make a good guess at where to minimize to + /*APPBARDATA appBarData;*/ + appBarData.cbSize=sizeof(appBarData); + if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) + { + // We know the edge the taskbar is connected to, so guess the rect of the + // system tray. Use various fudge factor to make it look good + switch(appBarData.uEdge) + { + case ABE_LEFT: + case ABE_RIGHT: + // We want to minimize to the bottom of the taskbar + lpTrayRect->top=appBarData.rc.bottom-100; + lpTrayRect->bottom=appBarData.rc.bottom-16; + lpTrayRect->left=appBarData.rc.left; + lpTrayRect->right=appBarData.rc.right; + break; + + case ABE_TOP: + case ABE_BOTTOM: + // We want to minimize to the right of the taskbar + lpTrayRect->top=appBarData.rc.top; + lpTrayRect->bottom=appBarData.rc.bottom; + lpTrayRect->left=appBarData.rc.right-100; + lpTrayRect->right=appBarData.rc.right-16; + break; + } + + return; + } + + // Blimey, we really aren't in luck. It's possible that a third party shell + // is running instead of explorer. This shell might provide support for the + // system tray, by providing a Shell_TrayWnd window (which receives the + // messages for the icons) So, look for a Shell_TrayWnd window and work out + // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd, + // and stretches either the width or the height of the screen. We can't rely + // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't + // rely on it being any size. The best we can do is just blindly use the + // window rect, perhaps limiting the width and height to, say 150 square. + // Note that if the 3rd party shell supports the same configuraion as + // explorer (the icons hosted in NotifyTrayWnd, which is a child window of + // Shell_TrayWnd), we would already have caught it above + hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); + if(hShellTrayWnd) + { + GetWindowRect(hShellTrayWnd,lpTrayRect); + if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH) + lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; + if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT) + lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; + + return; + } + + // OK. Haven't found a thing. Provide a default rect based on the current work + // area + SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0); + lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; + lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; +} + +// Check to see if the animation has been disabled +/*static */BOOL GetDoAnimateMinimize(VOID) +{ + ANIMATIONINFO ai; + + ai.cbSize=sizeof(ai); + SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); + + return ai.iMinAnimate?TRUE:FALSE; +} + +VOID MinimizeWndToTray(HWND hWnd) +{ + if(GetDoAnimateMinimize()) + { + RECT rcFrom,rcTo; + + // Get the rect of the window. It is safe to use the rect of the whole + // window - DrawAnimatedRects will only draw the caption + GetWindowRect(hWnd,&rcFrom); + GetTrayWndRect(&rcTo); + + // Get the system to draw our animation for us + DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); + } + + // Add the tray icon. If we add it before the call to DrawAnimatedRects, + // the taskbar gets erased, but doesn't get redrawn until DAR finishes. + // This looks untidy, so call the functions in this order + + // Hide the window + ShowWindow(hWnd,SW_HIDE); +} + +VOID RestoreWndFromTray(HWND hWnd) +{ + if(GetDoAnimateMinimize()) + { + // Get the rect of the tray and the window. Note that the window rect + // is still valid even though the window is hidden + RECT rcFrom,rcTo; + GetTrayWndRect(&rcFrom); + GetWindowRect(hWnd,&rcTo); + + // Get the system to draw our animation for us + DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); + } + + // Show the window, and make sure we're the foreground window + ShowWindow(hWnd,SW_SHOW); + SetActiveWindow(hWnd); + SetForegroundWindow(hWnd); + + // Remove the tray icon. As described above, remove the icon after the + // call to DrawAnimatedRects, or the taskbar will not refresh itself + // properly until DAR finished +} + + + +/// End of Helpers.c \\\ diff --git a/src/Helpers.h b/src/Helpers.h index 490fac20..2bf5b110 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -1,237 +1,237 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Helpers.h -* Definitions for general helper functions and macros -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - - - -extern HINSTANCE g_hInstance; -extern UINT16 g_uWinVer; - - -#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0])) -#define CSTRLEN(s) (COUNTOF(s)-1) - - -extern WCHAR szIniFile[MAX_PATH]; -#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \ - GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile) -#define IniGetInt(lpSection,lpName,nDefault) \ - GetPrivateProfileInt(lpSection,lpName,nDefault,szIniFile) -#define IniSetString(lpSection,lpName,lpString) \ - WritePrivateProfileString(lpSection,lpName,lpString,szIniFile) -#define IniDeleteSection(lpSection) \ - WritePrivateProfileSection(lpSection,NULL,szIniFile) -__inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) { - WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSetString(lpSection,lpName,tch); -} -#define LoadIniSection(lpSection,lpBuf,cchBuf) \ - GetPrivateProfileSection(lpSection,lpBuf,cchBuf,szIniFile); -#define SaveIniSection(lpSection,lpBuf) \ - WritePrivateProfileSection(lpSection,lpBuf,szIniFile) -int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int); -int IniSectionGetInt(LPCWSTR,LPCWSTR,int); -BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR); -__inline BOOL IniSectionSetInt(LPWSTR lpCachedIniSection,LPCWSTR lpName,int i) { - WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSectionSetString(lpCachedIniSection,lpName,tch); -} - - -extern HWND hwndEdit; -__inline void BeginWaitCursor() -{ - SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORWAIT,0); -} -__inline void EndWaitCursor() -{ - POINT pt; - SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORNORMAL,0); - GetCursorPos(&pt); - SetCursorPos(pt.x,pt.y); -} - - -#define Is2k() (g_uWinVer >= 0x0500) -#define IsXP() (g_uWinVer >= 0x0501) -#define IsVista() (g_uWinVer >= 0x0600) -#define IsW7() (g_uWinVer >= 0x0601) - - -BOOL PrivateIsAppThemed(); -HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR); -BOOL IsElevated(); -//BOOL SetExplorerTheme(HWND); - - -BOOL BitmapMergeAlpha(HBITMAP,COLORREF); -BOOL BitmapAlphaBlend(HBITMAP,COLORREF,BYTE); -BOOL BitmapGrayScale(HBITMAP); -BOOL VerifyContrast(COLORREF,COLORREF); -BOOL IsFontAvailable(LPCWSTR); - - -BOOL SetWindowTitle(HWND,UINT,BOOL,UINT,LPCWSTR,int,BOOL,UINT,BOOL,LPCWSTR); -void SetWindowTransparentMode(HWND,BOOL); - - -void CenterDlgInParent(HWND); -void GetDlgPos(HWND,LPINT,LPINT); -void SetDlgPos(HWND,int,int); -void ResizeDlg_Init(HWND,int,int,int); -void ResizeDlg_Destroy(HWND,int*,int*); -void ResizeDlg_Size(HWND,LPARAM,int*,int*); -void ResizeDlg_GetMinMaxInfo(HWND,LPARAM); -HDWP DeferCtlPos(HDWP,HWND,int,int,int,UINT); -void MakeBitmapButton(HWND,int,HINSTANCE,UINT); -void MakeColorPickButton(HWND,int,HINSTANCE,COLORREF); -void DeleteBitmapButton(HWND,int); - - -#define StatusSetSimple(hwnd,b) SendMessage(hwnd,SB_SIMPLE,(WPARAM)b,0) -BOOL StatusSetText(HWND,UINT,LPCWSTR); -BOOL StatusSetTextID(HWND,UINT,UINT); -int StatusCalcPaneWidth(HWND,LPCWSTR); - -int Toolbar_GetButtons(HWND,int,LPWSTR,int); -int Toolbar_SetButtons(HWND,int,LPCWSTR,void*,int); - -LRESULT SendWMSize(HWND); - -#define EnableCmd(hmenu,id,b) EnableMenuItem(hmenu,id,(b)\ - ?MF_BYCOMMAND|MF_ENABLED:MF_BYCOMMAND|MF_GRAYED) - -#define CheckCmd(hmenu,id,b) CheckMenuItem(hmenu,id,(b)\ - ?MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED) - -BOOL IsCmdEnabled(HWND, UINT); - - -#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb) - -#define StrEnd(pStart) (pStart + lstrlen(pStart)) - -int FormatString(LPWSTR,int,UINT,...); - - -void PathRelativeToApp(LPWSTR,LPWSTR,int,BOOL,BOOL,BOOL); -void PathAbsoluteFromApp(LPWSTR,LPWSTR,int,BOOL); - - -BOOL PathIsLnkFile(LPCWSTR); -BOOL PathGetLnkPath(LPCWSTR,LPWSTR,int); -BOOL PathIsLnkToDirectory(LPCWSTR,LPWSTR,int); -BOOL PathCreateDeskLnk(LPCWSTR); -BOOL PathCreateFavLnk(LPCWSTR,LPCWSTR,LPCWSTR); - - -BOOL StrLTrim(LPWSTR,LPCWSTR); -BOOL TrimString(LPWSTR); -BOOL ExtractFirstArgument(LPCWSTR, LPWSTR, LPWSTR); - -void PrepareFilterStr(LPWSTR); - -void StrTab2Space(LPWSTR); -void PathFixBackslashes(LPWSTR); - - -void ExpandEnvironmentStringsEx(LPWSTR,DWORD); -void PathCanonicalizeEx(LPWSTR); -DWORD GetLongPathNameEx(LPWSTR,DWORD); -DWORD_PTR SHGetFileInfo2(LPCWSTR,DWORD,SHFILEINFO*,UINT,UINT); - - -int FormatNumberStr(LPWSTR); -BOOL SetDlgItemIntEx(HWND,int,UINT); - - -#define MBCSToWChar(c,a,w,i) MultiByteToWideChar(c,0,a,-1,w,i) -#define WCharToMBCS(c,w,a,i) WideCharToMultiByte(c,0,w,-1,a,i,NULL,NULL) - -UINT GetDlgItemTextA2W(UINT,HWND,int,LPSTR,int); -UINT SetDlgItemTextA2W(UINT,HWND,int,LPSTR); -LRESULT ComboBox_AddStringA2W(UINT,HWND,LPCSTR); - - -UINT CodePageFromCharSet(UINT); - - -//==== MRU Functions ========================================================== -#define MRU_MAXITEMS 24 -#define MRU_NOCASE 1 -#define MRU_UTF8 2 - -typedef struct _mrulist { - - WCHAR szRegKey[256]; - int iFlags; - int iSize; - LPWSTR pszItems[MRU_MAXITEMS]; - -} MRULIST, *PMRULIST, *LPMRULIST; - -LPMRULIST MRU_Create(LPCWSTR,int,int); -BOOL MRU_Destroy(LPMRULIST); -BOOL MRU_Add(LPMRULIST,LPCWSTR); -BOOL MRU_AddFile(LPMRULIST,LPCWSTR,BOOL,BOOL); -BOOL MRU_Delete(LPMRULIST,int); -BOOL MRU_DeleteFileFromStore(LPMRULIST,LPCWSTR); -BOOL MRU_Empty(LPMRULIST); -int MRU_Enum(LPMRULIST,int,LPWSTR,int); -BOOL MRU_Load(LPMRULIST); -BOOL MRU_Save(LPMRULIST); -BOOL MRU_MergeSave(LPMRULIST,BOOL,BOOL,BOOL); - - -//==== Themed Dialogs ========================================================= -#ifndef DLGTEMPLATEEX -#pragma pack(push, 1) -typedef struct { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -} DLGTEMPLATEEX; -#pragma pack(pop) -#endif - -BOOL GetThemedDialogFont(LPWSTR,WORD*); -DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR,HINSTANCE); -#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) \ - ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0) -INT_PTR ThemedDialogBoxParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM); -HWND CreateThemedDialogParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM); - - -//==== UnSlash Functions ====================================================== -void TransformBackslashes(char*,BOOL,UINT); - - -//==== MinimizeToTray Functions - see comments in Helpers.c =================== -BOOL GetDoAnimateMinimize(VOID); -VOID MinimizeWndToTray(HWND hWnd); -VOID RestoreWndFromTray(HWND hWnd); - - - -/// End of Helpers.h \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Helpers.h +* Definitions for general helper functions and macros +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + + + +extern HINSTANCE g_hInstance; +extern UINT16 g_uWinVer; + + +#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0])) +#define CSTRLEN(s) (COUNTOF(s)-1) + + +extern WCHAR szIniFile[MAX_PATH]; +#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \ + GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile) +#define IniGetInt(lpSection,lpName,nDefault) \ + GetPrivateProfileInt(lpSection,lpName,nDefault,szIniFile) +#define IniSetString(lpSection,lpName,lpString) \ + WritePrivateProfileString(lpSection,lpName,lpString,szIniFile) +#define IniDeleteSection(lpSection) \ + WritePrivateProfileSection(lpSection,NULL,szIniFile) +__inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) { + WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSetString(lpSection,lpName,tch); +} +#define LoadIniSection(lpSection,lpBuf,cchBuf) \ + GetPrivateProfileSection(lpSection,lpBuf,cchBuf,szIniFile); +#define SaveIniSection(lpSection,lpBuf) \ + WritePrivateProfileSection(lpSection,lpBuf,szIniFile) +int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int); +int IniSectionGetInt(LPCWSTR,LPCWSTR,int); +BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR); +__inline BOOL IniSectionSetInt(LPWSTR lpCachedIniSection,LPCWSTR lpName,int i) { + WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSectionSetString(lpCachedIniSection,lpName,tch); +} + + +extern HWND hwndEdit; +__inline void BeginWaitCursor() +{ + SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORWAIT,0); +} +__inline void EndWaitCursor() +{ + POINT pt; + SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORNORMAL,0); + GetCursorPos(&pt); + SetCursorPos(pt.x,pt.y); +} + + +#define Is2k() (g_uWinVer >= 0x0500) +#define IsXP() (g_uWinVer >= 0x0501) +#define IsVista() (g_uWinVer >= 0x0600) +#define IsW7() (g_uWinVer >= 0x0601) + + +BOOL PrivateIsAppThemed(); +HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR); +BOOL IsElevated(); +//BOOL SetExplorerTheme(HWND); + + +BOOL BitmapMergeAlpha(HBITMAP,COLORREF); +BOOL BitmapAlphaBlend(HBITMAP,COLORREF,BYTE); +BOOL BitmapGrayScale(HBITMAP); +BOOL VerifyContrast(COLORREF,COLORREF); +BOOL IsFontAvailable(LPCWSTR); + + +BOOL SetWindowTitle(HWND,UINT,BOOL,UINT,LPCWSTR,int,BOOL,UINT,BOOL,LPCWSTR); +void SetWindowTransparentMode(HWND,BOOL); + + +void CenterDlgInParent(HWND); +void GetDlgPos(HWND,LPINT,LPINT); +void SetDlgPos(HWND,int,int); +void ResizeDlg_Init(HWND,int,int,int); +void ResizeDlg_Destroy(HWND,int*,int*); +void ResizeDlg_Size(HWND,LPARAM,int*,int*); +void ResizeDlg_GetMinMaxInfo(HWND,LPARAM); +HDWP DeferCtlPos(HDWP,HWND,int,int,int,UINT); +void MakeBitmapButton(HWND,int,HINSTANCE,UINT); +void MakeColorPickButton(HWND,int,HINSTANCE,COLORREF); +void DeleteBitmapButton(HWND,int); + + +#define StatusSetSimple(hwnd,b) SendMessage(hwnd,SB_SIMPLE,(WPARAM)b,0) +BOOL StatusSetText(HWND,UINT,LPCWSTR); +BOOL StatusSetTextID(HWND,UINT,UINT); +int StatusCalcPaneWidth(HWND,LPCWSTR); + +int Toolbar_GetButtons(HWND,int,LPWSTR,int); +int Toolbar_SetButtons(HWND,int,LPCWSTR,void*,int); + +LRESULT SendWMSize(HWND); + +#define EnableCmd(hmenu,id,b) EnableMenuItem(hmenu,id,(b)\ + ?MF_BYCOMMAND|MF_ENABLED:MF_BYCOMMAND|MF_GRAYED) + +#define CheckCmd(hmenu,id,b) CheckMenuItem(hmenu,id,(b)\ + ?MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED) + +BOOL IsCmdEnabled(HWND, UINT); + + +#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb) + +#define StrEnd(pStart) (pStart + lstrlen(pStart)) + +int FormatString(LPWSTR,int,UINT,...); + + +void PathRelativeToApp(LPWSTR,LPWSTR,int,BOOL,BOOL,BOOL); +void PathAbsoluteFromApp(LPWSTR,LPWSTR,int,BOOL); + + +BOOL PathIsLnkFile(LPCWSTR); +BOOL PathGetLnkPath(LPCWSTR,LPWSTR,int); +BOOL PathIsLnkToDirectory(LPCWSTR,LPWSTR,int); +BOOL PathCreateDeskLnk(LPCWSTR); +BOOL PathCreateFavLnk(LPCWSTR,LPCWSTR,LPCWSTR); + + +BOOL StrLTrim(LPWSTR,LPCWSTR); +BOOL TrimString(LPWSTR); +BOOL ExtractFirstArgument(LPCWSTR, LPWSTR, LPWSTR); + +void PrepareFilterStr(LPWSTR); + +void StrTab2Space(LPWSTR); +void PathFixBackslashes(LPWSTR); + + +void ExpandEnvironmentStringsEx(LPWSTR,DWORD); +void PathCanonicalizeEx(LPWSTR); +DWORD GetLongPathNameEx(LPWSTR,DWORD); +DWORD_PTR SHGetFileInfo2(LPCWSTR,DWORD,SHFILEINFO*,UINT,UINT); + + +int FormatNumberStr(LPWSTR); +BOOL SetDlgItemIntEx(HWND,int,UINT); + + +#define MBCSToWChar(c,a,w,i) MultiByteToWideChar(c,0,a,-1,w,i) +#define WCharToMBCS(c,w,a,i) WideCharToMultiByte(c,0,w,-1,a,i,NULL,NULL) + +UINT GetDlgItemTextA2W(UINT,HWND,int,LPSTR,int); +UINT SetDlgItemTextA2W(UINT,HWND,int,LPSTR); +LRESULT ComboBox_AddStringA2W(UINT,HWND,LPCSTR); + + +UINT CodePageFromCharSet(UINT); + + +//==== MRU Functions ========================================================== +#define MRU_MAXITEMS 24 +#define MRU_NOCASE 1 +#define MRU_UTF8 2 + +typedef struct _mrulist { + + WCHAR szRegKey[256]; + int iFlags; + int iSize; + LPWSTR pszItems[MRU_MAXITEMS]; + +} MRULIST, *PMRULIST, *LPMRULIST; + +LPMRULIST MRU_Create(LPCWSTR,int,int); +BOOL MRU_Destroy(LPMRULIST); +BOOL MRU_Add(LPMRULIST,LPCWSTR); +BOOL MRU_AddFile(LPMRULIST,LPCWSTR,BOOL,BOOL); +BOOL MRU_Delete(LPMRULIST,int); +BOOL MRU_DeleteFileFromStore(LPMRULIST,LPCWSTR); +BOOL MRU_Empty(LPMRULIST); +int MRU_Enum(LPMRULIST,int,LPWSTR,int); +BOOL MRU_Load(LPMRULIST); +BOOL MRU_Save(LPMRULIST); +BOOL MRU_MergeSave(LPMRULIST,BOOL,BOOL,BOOL); + + +//==== Themed Dialogs ========================================================= +#ifndef DLGTEMPLATEEX +#pragma pack(push, 1) +typedef struct { + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; +} DLGTEMPLATEEX; +#pragma pack(pop) +#endif + +BOOL GetThemedDialogFont(LPWSTR,WORD*); +DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR,HINSTANCE); +#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) \ + ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0) +INT_PTR ThemedDialogBoxParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM); +HWND CreateThemedDialogParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM); + + +//==== UnSlash Functions ====================================================== +void TransformBackslashes(char*,BOOL,UINT); + + +//==== MinimizeToTray Functions - see comments in Helpers.c =================== +BOOL GetDoAnimateMinimize(VOID); +VOID MinimizeWndToTray(HWND hWnd); +VOID RestoreWndFromTray(HWND hWnd); + + + +/// End of Helpers.h \\\ diff --git a/src/Notepad2.c b/src/Notepad2.c index d6b2523a..dfed1cdb 100644 --- a/src/Notepad2.c +++ b/src/Notepad2.c @@ -1,7907 +1,7916 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Notepad2.c -* Main application window functionality -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "scintilla.h" -#include "scilexer.h" -#include "notepad2.h" -#include "edit.h" -#include "styles.h" -#include "dialogs.h" -#include "helpers.h" -#include "SciCall.h" -#include "resource.h" - - - -/****************************************************************************** -* -* Local and global Variables for Notepad2.c -* -*/ -HWND hwndStatus; -HWND hwndToolbar; -HWND hwndReBar; -HWND hwndEdit; -HWND hwndEditFrame; -HWND hwndMain; -HWND hwndNextCBChain = NULL; -HWND hDlgFindReplace = NULL; - -#define NUMTOOLBITMAPS 25 -#define NUMINITIALTOOLS 24 -#define MARGIN_FOLD_INDEX 2 - -TBBUTTON tbbMainWnd[] = { {0,IDT_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {1,IDT_FILE_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {2,IDT_FILE_BROWSE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {3,IDT_FILE_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {4,IDT_EDIT_UNDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {5,IDT_EDIT_REDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {6,IDT_EDIT_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {7,IDT_EDIT_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {8,IDT_EDIT_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {9,IDT_EDIT_FIND,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {10,IDT_EDIT_REPLACE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {11,IDT_VIEW_WORDWRAP,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {12,IDT_VIEW_ZOOMIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {13,IDT_VIEW_ZOOMOUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {14,IDT_VIEW_SCHEME,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {15,IDT_VIEW_SCHEMECONFIG,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {0,0,0,TBSTYLE_SEP,0,0}, - {16,IDT_FILE_EXIT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {17,IDT_FILE_SAVEAS,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {18,IDT_FILE_SAVECOPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {19,IDT_EDIT_CLEAR,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {20,IDT_FILE_PRINT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {21,IDT_FILE_OPENFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {22,IDT_FILE_ADDTOFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {23,IDT_VIEW_TOGGLEFOLDS,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, - {24,IDT_FILE_LAUNCH,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0} }; - -WCHAR szIniFile[MAX_PATH] = L""; -WCHAR szIniFile2[MAX_PATH] = L""; -BOOL bSaveSettings; -BOOL bSaveRecentFiles; -BOOL bSaveFindReplace; -WCHAR tchLastSaveCopyDir[MAX_PATH] = L""; -WCHAR tchOpenWithDir[MAX_PATH]; -WCHAR tchFavoritesDir[MAX_PATH]; -WCHAR tchDefaultDir[MAX_PATH]; -WCHAR tchDefaultExtension[64]; -WCHAR tchFileDlgFilters[5*1024]; -WCHAR tchToolbarButtons[512]; -WCHAR tchToolbarBitmap[MAX_PATH]; -WCHAR tchToolbarBitmapHot[MAX_PATH]; -WCHAR tchToolbarBitmapDisabled[MAX_PATH]; -int iPathNameFormat; -BOOL fWordWrap; -BOOL fWordWrapG; -int iWordWrapMode; -int iWordWrapIndent; -int iWordWrapSymbols; -BOOL bShowWordWrapSymbols; -BOOL bMatchBraces; -BOOL bAutoIndent; -BOOL bAutoCloseTags; -BOOL bShowIndentGuides; -BOOL bHiliteCurrentLine; -BOOL bTabsAsSpaces; -BOOL bTabsAsSpacesG; -BOOL bTabIndents; -BOOL bTabIndentsG; -BOOL bBackspaceUnindents; -int iTabWidth; -int iTabWidthG; -int iIndentWidth; -int iIndentWidthG; -BOOL bMarkLongLines; -int iLongLinesLimit; -int iLongLinesLimitG; -int iLongLineMode; -int iWrapCol = 0; -BOOL bShowSelectionMargin; -BOOL bShowLineNumbers; -int iMarkOccurrences; -BOOL bMarkOccurrencesMatchCase; -BOOL bMarkOccurrencesMatchWords; -BOOL bAutoCompleteWords; -BOOL bShowCodeFolding; -BOOL bViewWhiteSpace; -BOOL bViewEOLs; -int iDefaultEncoding; -BOOL bSkipUnicodeDetection; -BOOL bLoadASCIIasUTF8; -BOOL bLoadNFOasOEM; -BOOL bNoEncodingTags; -int iSrcEncoding = -1; -int iWeakSrcEncoding = -1; -int iDefaultEOLMode; -BOOL bFixLineEndings; -BOOL bAutoStripBlanks; -int iPrintHeader; -int iPrintFooter; -int iPrintColor; -int iPrintZoom; -RECT pagesetupMargin; -BOOL bSaveBeforeRunningTools; -int iFileWatchingMode; -BOOL bResetFileWatching; -DWORD dwFileCheckInverval; -DWORD dwAutoReloadTimeout; -int iEscFunction; -BOOL bAlwaysOnTop; -BOOL bMinimizeToTray; -BOOL bTransparentMode; -BOOL bTransparentModeAvailable; -BOOL bShowToolbar; -BOOL bShowStatusbar; - -typedef struct _wi -{ - int x; - int y; - int cx; - int cy; - int max; -} WININFO; - -WININFO wi; -BOOL bStickyWinPos; - -BOOL bIsAppThemed; -int cyReBar; -int cyReBarFrame; -int cxEditFrame; -int cyEditFrame; - -int cxEncodingDlg; -int cyEncodingDlg; -int cxRecodeDlg; -int cyRecodeDlg; -int cxFileMRUDlg; -int cyFileMRUDlg; -int cxOpenWithDlg; -int cyOpenWithDlg; -int cxFavoritesDlg; -int cyFavoritesDlg; -int xFindReplaceDlg; -int yFindReplaceDlg; - -LPWSTR lpFileList[32]; -int cFileList = 0; -int cchiFileList = 0; -LPWSTR lpFileArg = NULL; -LPWSTR lpSchemeArg = NULL; -LPWSTR lpMatchArg = NULL; -LPWSTR lpEncodingArg = NULL; -LPMRULIST pFileMRU; -LPMRULIST mruFind; -LPMRULIST mruReplace; - -DWORD dwLastIOError; -WCHAR szCurFile[MAX_PATH+40]; -FILEVARS fvCurFile; -BOOL bModified; -BOOL bReadOnly = FALSE; -int iEncoding; -int iOriginalEncoding; -int iEOLMode; - -int iDefaultCodePage; -int iDefaultCharSet; - -int iInitialLine; -int iInitialColumn; - -int iInitialLexer; - -BOOL bLastCopyFromMe = FALSE; -DWORD dwLastCopyTime; - -UINT uidsAppTitle = IDS_APPTITLE; -WCHAR szTitleExcerpt[128] = L""; -int fKeepTitleExcerpt = 0; - -HANDLE hChangeHandle = NULL; -BOOL bRunningWatch = FALSE; -BOOL dwChangeNotifyTime = 0; -WIN32_FIND_DATA fdCurFile; - -UINT msgTaskbarCreated = 0; - -HMODULE hModUxTheme = NULL; - -EDITFINDREPLACE efrData = { "", "", "", "", 0, 0, 0, 0, 0, 0, NULL }; -UINT cpLastFind = 0; -BOOL bReplaceInitialized = FALSE; - -extern NP2ENCODING mEncoding[]; - -int iLineEndings[3] = { - SC_EOL_CRLF, - SC_EOL_LF, - SC_EOL_CR -}; - -WCHAR wchPrefixSelection[256] = L""; -WCHAR wchAppendSelection[256] = L""; - -WCHAR wchPrefixLines[256] = L""; -WCHAR wchAppendLines[256] = L""; - -int iSortOptions = 0; -int iAlignMode = 0; - -BOOL fIsElevated = FALSE; -WCHAR wchWndClass[16] = WC_NOTEPAD2; - -HINSTANCE g_hInstance; -HANDLE g_hScintilla; -UINT16 g_uWinVer; -WCHAR g_wchAppUserModelID[32] = L""; -WCHAR g_wchWorkingDirectory[MAX_PATH] = L""; - - - -#ifdef BOOKMARK_EDITION - //Graphics for bookmark indicator - /* XPM */ - static char * bookmark_pixmap[] = { - "11 11 44 1", - " c #EBE9ED", - ". c #E5E3E7", - "+ c #767C6D", - "@ c #2A3120", - "# c #1B2312", - "$ c #333B28", - "% c #E3E1E5", - "& c #D8D6DA", - "* c #444D38", - "= c #3F5C19", - "- c #63AD00", - "; c #73C900", - "> c #64AF00", - ", c #3D5718", - "' c #3E4634", - ") c #7B8172", - "! c #42601A", - "~ c #74CB00", - "{ c #71C600", - "] c #3A5317", - "^ c #707668", - "/ c #3F4931", - "( c #262C1D", - "_ c #2F3A1E", - ": c #72C700", - "< c #74CA00", - "[ c #0E1109", - "} c #3C462F", - "| c #62AC00", - "1 c #21271A", - "2 c #7A8071", - "3 c #405D19", - "4 c #3D5A18", - "5 c #D9D7DB", - "6 c #4E5841", - "7 c #72C800", - "8 c #63AC00", - "9 c #3F5B19", - "0 c #3D4533", - "a c #DFDDE0", - "b c #353E29", - "c c #29331B", - "d c #7B8272", - "e c #DDDBDF", - " ", - " .+@#$+% ", - " &*=-;>,' ", - " )!~~~~{]^ ", - " /-~~~~~>( ", - " _:~~~~~<[ ", - " }|~~~~~|1 ", - " 23~~~~;4+ ", - " 56=|7890 ", - " a2bc}de ", - " "}; -#endif - - - -//============================================================================= -// -// Flags -// -int flagNoReuseWindow = 0; -int flagReuseWindow = 0; -int flagMultiFileArg = 0; -int flagSingleFileInstance = 0; -int flagStartAsTrayIcon = 0; -int flagAlwaysOnTop = 0; -int flagRelativeFileMRU = 0; -int flagPortableMyDocs = 0; -int flagNoFadeHidden = 0; -int flagToolbarLook = 0; -int flagSimpleIndentGuides = 0; -int fNoHTMLGuess = 0; -int fNoCGIGuess = 0; -int fNoFileVariables = 0; -int flagPosParam = 0; -int flagDefaultPos = 0; -int flagNewFromClipboard = 0; -int flagPasteBoard = 0; -int flagSetEncoding = 0; -int flagSetEOLMode = 0; -int flagJumpTo = 0; -int flagMatchText = 0; -int flagChangeNotify = 0; -int flagLexerSpecified = 0; -int flagQuietCreate = 0; -int flagUseSystemMRU = 0; -int flagRelaunchElevated = 0; -int flagDisplayHelp = 0; - - - -//============================================================================== -// -// Folding Functions -// -// -typedef enum { - EXPAND = 1, - SNIFF = 0, - FOLD = -1 -} FOLD_ACTION; - -#define FOLD_CHILDREN SCMOD_CTRL -#define FOLD_SIBLINGS SCMOD_SHIFT - -BOOL __stdcall FoldToggleNode( int ln, FOLD_ACTION action ) -{ - BOOL fExpanded = SciCall_GetFoldExpanded(ln); - - if ((action == FOLD && fExpanded) || (action == EXPAND && !fExpanded)) - { - SciCall_ToggleFold(ln); - return(TRUE); - } - - return(FALSE); -} - -void __stdcall FoldToggleAll( FOLD_ACTION action ) -{ - BOOL fToggled = FALSE; - int lnTotal = SciCall_GetLineCount(); - int ln; - - for (ln = 0; ln < lnTotal; ++ln) - { - if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) - { - if (action == SNIFF) - action = SciCall_GetFoldExpanded(ln) ? FOLD : EXPAND; - - if (FoldToggleNode(ln, action)) - fToggled = TRUE; - } - } - - if (fToggled) - { - SciCall_SetXCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,50); - SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,5); - SciCall_ScrollCaret(); - SciCall_SetXCaretPolicy(CARET_SLOP|CARET_EVEN,50); - SciCall_SetYCaretPolicy(CARET_EVEN,0); - } -} - -void __stdcall FoldPerformAction( int ln, int mode, FOLD_ACTION action ) -{ - if (action == SNIFF) - action = SciCall_GetFoldExpanded(ln) ? FOLD : EXPAND; - - if (mode & (FOLD_CHILDREN | FOLD_SIBLINGS)) - { - // ln/lvNode: line and level of the source of this fold action - int lnNode = ln; - int lvNode = SciCall_GetFoldLevel(lnNode) & SC_FOLDLEVELNUMBERMASK; - int lnTotal = SciCall_GetLineCount(); - - // lvStop: the level over which we should not cross - int lvStop = lvNode; - - if (mode & FOLD_SIBLINGS) - { - ln = SciCall_GetFoldParent(lnNode) + 1; // -1 + 1 = 0 if no parent - --lvStop; - } - - for ( ; ln < lnTotal; ++ln) - { - int lv = SciCall_GetFoldLevel(ln); - BOOL fHeader = lv & SC_FOLDLEVELHEADERFLAG; - lv &= SC_FOLDLEVELNUMBERMASK; - - if (lv < lvStop || (lv == lvStop && fHeader && ln != lnNode)) - return; - else if (fHeader && (lv == lvNode || (lv > lvNode && mode & FOLD_CHILDREN))) - FoldToggleNode(ln, action); - } - } - else - { - FoldToggleNode(ln, action); - } -} - -void __stdcall FoldClick( int ln, int mode ) -{ - static struct { - int ln; - int mode; - DWORD dwTickCount; - } prev; - - BOOL fGotoFoldPoint = mode & FOLD_SIBLINGS; - - if (!(SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG)) - { - // Not a fold point: need to look for a double-click - - if ( prev.ln == ln && prev.mode == mode && - GetTickCount() - prev.dwTickCount <= GetDoubleClickTime() ) - { - prev.ln = -1; // Prevent re-triggering on a triple-click - - ln = SciCall_GetFoldParent(ln); - - if (ln >= 0 && SciCall_GetFoldExpanded(ln)) - fGotoFoldPoint = TRUE; - else - return; - } - else - { - // Save the info needed to match this click with the next click - prev.ln = ln; - prev.mode = mode; - prev.dwTickCount = GetTickCount(); - return; - } - } - - FoldPerformAction(ln, mode, SNIFF); - - if (fGotoFoldPoint) - EditJumpTo(hwndEdit, ln + 1, 0); -} - -void __stdcall FoldAltArrow( int key, int mode ) -{ - // Because Alt-Shift is already in use (and because the sibling fold feature - // is not as useful from the keyboard), only the Ctrl modifier is supported - - if (bShowCodeFolding && (mode & (SCMOD_ALT | SCMOD_SHIFT)) == SCMOD_ALT) - { - int ln = SciCall_LineFromPosition(SciCall_GetCurrentPos()); - - // Jump to the next visible fold point - if (key == SCK_DOWN && !(mode & SCMOD_CTRL)) - { - int lnTotal = SciCall_GetLineCount(); - for (ln = ln + 1; ln < lnTotal; ++ln) - { - if ( SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG && - SciCall_GetLineVisible(ln) ) - { - EditJumpTo(hwndEdit, ln + 1, 0); - return; - } - } - } - - // Jump to the previous visible fold point - else if (key == SCK_UP && !(mode & SCMOD_CTRL)) - { - for (ln = ln - 1; ln >= 0; --ln) - { - if ( SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG && - SciCall_GetLineVisible(ln) ) - { - EditJumpTo(hwndEdit, ln + 1, 0); - return; - } - } - } - - // Perform a fold/unfold operation - else if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) - { - if (key == SCK_LEFT ) FoldPerformAction(ln, mode, FOLD); - if (key == SCK_RIGHT) FoldPerformAction(ln, mode, EXPAND); - } - } -} - - - -//============================================================================= -// -// WinMain() -// -// -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow) -{ - - MSG msg; - HWND hwnd; - HACCEL hAccMain; - HACCEL hAccFindReplace; - INITCOMMONCONTROLSEX icex; - //HMODULE hSciLexer; - WCHAR wchWorkingDirectory[MAX_PATH]; - - // Set global variable g_hInstance - g_hInstance = hInstance; - - // Set the Windows version global variable - g_uWinVer = LOWORD(GetVersion()); - g_uWinVer = MAKEWORD(HIBYTE(g_uWinVer),LOBYTE(g_uWinVer)); - - // Don't keep working directory locked - GetCurrentDirectory(COUNTOF(g_wchWorkingDirectory),g_wchWorkingDirectory); - GetModuleFileName(NULL,wchWorkingDirectory,COUNTOF(wchWorkingDirectory)); - PathRemoveFileSpec(wchWorkingDirectory); - SetCurrentDirectory(wchWorkingDirectory); - - SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); - - // check if running at least on Windows 2000 - if (!Is2k()) { - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER| - FORMAT_MESSAGE_FROM_SYSTEM| - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - ERROR_OLD_WIN_VERSION, - MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Default language - (LPWSTR)&lpMsgBuf, - 0, - NULL); - MessageBox(NULL,(LPCWSTR)lpMsgBuf,L"Notepad2-mod",MB_OK|MB_ICONEXCLAMATION); - LocalFree(lpMsgBuf); - return(0); - } - - // Check if running with elevated privileges - fIsElevated = IsElevated(); - - // Default Encodings (may already be used for command line parsing) - Encoding_InitDefaults(); - - // Command Line, Ini File and Flags - ParseCommandLine(); - FindIniFile(); - TestIniFile(); - CreateIniFile(); - LoadFlags(); - - // set AppUserModelID - PrivateSetCurrentProcessExplicitAppUserModelID(g_wchAppUserModelID); - - // Command Line Help Dialog - if (flagDisplayHelp) { - DisplayCmdLineHelp(NULL); - return(0); - } - - // Adapt window class name - if (fIsElevated) - StrCat(wchWndClass,L"U"); - if (flagPasteBoard) - StrCat(wchWndClass,L"B"); - - // Relaunch with elevated privileges - if (RelaunchElevated()) - return(0); - - // Try to run multiple instances - if (RelaunchMultiInst()) - return(0); - - // Try to activate another window - if (ActivatePrevInst()) - return(0); - - // Init OLE and Common Controls - OleInitialize(NULL); - - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES; - InitCommonControlsEx(&icex); - - msgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); - - hModUxTheme = LoadLibrary(L"uxtheme.dll"); - - Scintilla_RegisterClasses(hInstance); - - // Load Settings - LoadSettings(); - - if (!InitApplication(hInstance)) - return FALSE; - - if (!(hwnd = InitInstance(hInstance,lpCmdLine,nCmdShow))) - return FALSE; - - hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); - hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE)); - - while (GetMessage(&msg,NULL,0,0)) - { - if (IsWindow(hDlgFindReplace) && (msg.hwnd == hDlgFindReplace || IsChild(hDlgFindReplace,msg.hwnd))) - if (TranslateAccelerator(hDlgFindReplace,hAccFindReplace,&msg) || IsDialogMessage(hDlgFindReplace,&msg)) - continue; - - if (!TranslateAccelerator(hwnd,hAccMain,&msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - // Save Settings is done elsewhere - - Scintilla_ReleaseResources(); - UnregisterClass(wchWndClass,hInstance); - - if (hModUxTheme) - FreeLibrary(hModUxTheme); - - OleUninitialize(); - - return(int)(msg.wParam); - - hPrevInst; - -} - - -//============================================================================= -// -// InitApplication() -// -// -BOOL InitApplication(HINSTANCE hInstance) -{ - - WNDCLASS wc; - - wc.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)MainWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); - wc.hCursor = LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); - wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINWND); - wc.lpszClassName = wchWndClass; - - return RegisterClass(&wc); - -} - - -//============================================================================= -// -// InitInstance() -// -// -HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) -{ - - RECT rc = { wi.x, wi.y, wi.x+wi.cx, wi.y+wi.cy }; - RECT rc2; - MONITORINFO mi; - - HMONITOR hMonitor = MonitorFromRect(&rc,MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor,&mi); - - if (flagDefaultPos == 1) { - wi.x = wi.y = wi.cx = wi.cy = CW_USEDEFAULT; - wi.max = 0; - } - - else if (flagDefaultPos >= 4) { - SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0); - if (flagDefaultPos & 8) - wi.x = (rc.right - rc.left) / 2; - else - wi.x = rc.left; - wi.cx = rc.right - rc.left; - if (flagDefaultPos & (4|8)) - wi.cx /= 2; - if (flagDefaultPos & 32) - wi.y = (rc.bottom - rc.top) / 2; - else - wi.y = rc.top; - wi.cy = rc.bottom - rc.top; - if (flagDefaultPos & (16|32)) - wi.cy /= 2; - if (flagDefaultPos & 64) { - wi.x = rc.left; - wi.y = rc.top; - wi.cx = rc.right - rc.left; - wi.cy = rc.bottom - rc.top; - } - if (flagDefaultPos & 128) { - wi.x += (flagDefaultPos & 8) ? 4 : 8; - wi.cx -= (flagDefaultPos & (4|8)) ? 12 : 16; - wi.y += (flagDefaultPos & 32) ? 4 : 8; - wi.cy -= (flagDefaultPos & (16|32)) ? 12 : 16; - } - } - - else if (flagDefaultPos == 2 || flagDefaultPos == 3 || - wi.x == CW_USEDEFAULT || wi.y == CW_USEDEFAULT || - wi.cx == CW_USEDEFAULT || wi.cy == CW_USEDEFAULT) { - - // default window position - SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0); - wi.y = rc.top + 16; - wi.cy = rc.bottom - rc.top - 32; - wi.cx = min(rc.right - rc.left - 32,wi.cy); - wi.x = (flagDefaultPos == 3) ? rc.left + 16 : rc.right - wi.cx - 16; - } - - else { - - // fit window into working area of current monitor - wi.x += (mi.rcWork.left - mi.rcMonitor.left); - wi.y += (mi.rcWork.top - mi.rcMonitor.top); - if (wi.x < mi.rcWork.left) - wi.x = mi.rcWork.left; - if (wi.y < mi.rcWork.top) - wi.y = mi.rcWork.top; - if (wi.x + wi.cx > mi.rcWork.right) { - wi.x -= (wi.x + wi.cx - mi.rcWork.right); - if (wi.x < mi.rcWork.left) - wi.x = mi.rcWork.left; - if (wi.x + wi.cx > mi.rcWork.right) - wi.cx = mi.rcWork.right - wi.x; - } - if (wi.y + wi.cy > mi.rcWork.bottom) { - wi.y -= (wi.y + wi.cy - mi.rcWork.bottom); - if (wi.y < mi.rcWork.top) - wi.y = mi.rcWork.top; - if (wi.y + wi.cy > mi.rcWork.bottom) - wi.cy = mi.rcWork.bottom - wi.y; - } - SetRect(&rc,wi.x,wi.y,wi.x+wi.cx,wi.y+wi.cy); - if (!IntersectRect(&rc2,&rc,&mi.rcWork)) { - wi.y = mi.rcWork.top + 16; - wi.cy = mi.rcWork.bottom - mi.rcWork.top - 32; - wi.cx = min(mi.rcWork.right - mi.rcWork.left - 32,wi.cy); - wi.x = mi.rcWork.right - wi.cx - 16; - } - } - - hwndMain = CreateWindowEx( - 0, - wchWndClass, - L"Notepad2", - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, - wi.x, - wi.y, - wi.cx, - wi.cy, - NULL, - NULL, - hInstance, - NULL); - - if (wi.max) - nCmdShow = SW_SHOWMAXIMIZED; - - if ((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1) - SetWindowPos(hwndMain,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); - - if (bTransparentMode) - SetWindowTransparentMode(hwndMain,TRUE); - - // Current file information -- moved in front of ShowWindow() - FileLoad(TRUE,TRUE,FALSE,FALSE,L""); - - if (!flagStartAsTrayIcon) { - ShowWindow(hwndMain,nCmdShow); - UpdateWindow(hwndMain); - } - else { - ShowWindow(hwndMain,SW_HIDE); // trick ShowWindow() - ShowNotifyIcon(hwndMain,TRUE); - } - - // Source Encoding - if (lpEncodingArg) - iSrcEncoding = Encoding_MatchW(lpEncodingArg); - - // Pathname parameter - if (lpFileArg /*&& !flagNewFromClipboard*/) - { - BOOL bOpened = FALSE; - - // Open from Directory - if (PathIsDirectory(lpFileArg)) { - WCHAR tchFile[MAX_PATH]; - if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),lpFileArg)) - bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); - } - else { - if (bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,lpFileArg)) { - if (flagJumpTo) { // Jump to position - EditJumpTo(hwndEdit,iInitialLine,iInitialColumn); - EditEnsureSelectionVisible(hwndEdit); - } - } - } - GlobalFree(lpFileArg); - - if (bOpened) { - if (flagChangeNotify == 1) { - iFileWatchingMode = 0; - bResetFileWatching = TRUE; - InstallFileWatching(szCurFile); - } - else if (flagChangeNotify == 2) { - iFileWatchingMode = 2; - bResetFileWatching = TRUE; - InstallFileWatching(szCurFile); - } - } - } - - else { - if (iSrcEncoding != -1) { - iEncoding = iSrcEncoding; - iOriginalEncoding = iSrcEncoding; - SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); - } - } - - // reset - iSrcEncoding = -1; - flagQuietCreate = 0; - fKeepTitleExcerpt = 0; - - // Check for /c [if no file is specified] -- even if a file is specified - /*else */if (flagNewFromClipboard) { - if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) { - BOOL bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; - EditJumpTo(hwndEdit,-1,0); - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0) - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndEdit,SCI_PASTE,0,0); - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - bAutoIndent = bAutoIndent2; - if (flagJumpTo) - EditJumpTo(hwndEdit,iInitialLine,iInitialColumn); - EditEnsureSelectionVisible(hwndEdit); - } - } - - // Encoding - if (0 != flagSetEncoding) { - SendMessage( - hwndMain, - WM_COMMAND, - MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1), - 0); - flagSetEncoding = 0; - } - - // EOL mode - if (0 != flagSetEOLMode) { - SendMessage( - hwndMain, - WM_COMMAND, - MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1), - 0); - flagSetEOLMode = 0; - } - - // Match Text - if (flagMatchText && lpMatchArg) { - if (lstrlen(lpMatchArg) && SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) { - - UINT cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); - WideCharToMultiByte(cp,0,lpMatchArg,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL); - WideCharToMultiByte(CP_UTF8,0,lpMatchArg,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL); - cpLastFind = cp; - - if (flagMatchText & 4) - efrData.fuFlags |= SCFIND_REGEXP | SCFIND_POSIX; - else if (flagMatchText & 8) - efrData.bTransformBS = TRUE; - - if (flagMatchText & 2) { - if (!flagJumpTo) - EditJumpTo(hwndEdit,-1,0); - EditFindPrev(hwndEdit,&efrData,FALSE); - EditEnsureSelectionVisible(hwndEdit); - } - else { - if (!flagJumpTo) - SendMessage(hwndEdit,SCI_DOCUMENTSTART,0,0); - EditFindNext(hwndEdit,&efrData,FALSE); - EditEnsureSelectionVisible(hwndEdit); - } - } - GlobalFree(lpMatchArg); - } - - // Check for Paste Board option -- after loading files - if (flagPasteBoard) { - bLastCopyFromMe = TRUE; - hwndNextCBChain = SetClipboardViewer(hwndMain); - uidsAppTitle = IDS_APPTITLE_PASTEBOARD; - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - bLastCopyFromMe = FALSE; - - dwLastCopyTime = 0; - SetTimer(hwndMain,ID_PASTEBOARDTIMER,100,PasteBoardTimer); - } - - // check if a lexer was specified from the command line - if (flagLexerSpecified) { - if (lpSchemeArg) { - Style_SetLexerFromName(hwndEdit,szCurFile,lpSchemeArg); - LocalFree(lpSchemeArg); - } - else if (iInitialLexer >=0 && iInitialLexer < NUMLEXERS) - Style_SetLexerFromID(hwndEdit,iInitialLexer); - flagLexerSpecified = 0; - } - - // If start as tray icon, set current filename as tooltip - if (flagStartAsTrayIcon) - SetNotifyIconTitle(hwndMain); - - UpdateToolbar(); - UpdateStatusbar(); - - return(hwndMain); - -} - - -//============================================================================= -// -// MainWndProc() -// -// Messages are distributed to the MsgXXX-handlers -// -// -LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - static BOOL bShutdownOK; - - switch(umsg) - { - - // Quickly handle painting and sizing messages, found in ScintillaWin.cxx - // Cool idea, don't know if this has any effect... ;-) - case WM_MOVE: - case WM_MOUSEACTIVATE: - case WM_NCHITTEST: - case WM_NCCALCSIZE: - case WM_NCPAINT: - case WM_PAINT: - case WM_ERASEBKGND: - case WM_NCMOUSEMOVE: - case WM_NCLBUTTONDOWN: - case WM_WINDOWPOSCHANGING: - case WM_WINDOWPOSCHANGED: - return DefWindowProc(hwnd,umsg,wParam,lParam); - - case WM_CREATE: - return MsgCreate(hwnd,wParam,lParam); - - - case WM_DESTROY: - case WM_ENDSESSION: - if (!bShutdownOK) { - - WINDOWPLACEMENT wndpl; - - // Terminate file watching - InstallFileWatching(NULL); - - // GetWindowPlacement - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hwnd,&wndpl); - - wi.x = wndpl.rcNormalPosition.left; - wi.y = wndpl.rcNormalPosition.top; - wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; - wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; - wi.max = (IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); - - DragAcceptFiles(hwnd,FALSE); - - // Terminate clipboard watching - if (flagPasteBoard) { - KillTimer(hwnd,ID_PASTEBOARDTIMER); - ChangeClipboardChain(hwnd,hwndNextCBChain); - } - - // Destroy find / replace dialog - if (IsWindow(hDlgFindReplace)) - DestroyWindow(hDlgFindReplace); - - // call SaveSettings() when hwndToolbar is still valid - SaveSettings(FALSE); - - if (lstrlen(szIniFile) != 0) { - - // Cleanup unwanted MRU's - if (!bSaveRecentFiles) { - MRU_Empty(pFileMRU); - MRU_Save(pFileMRU); - } - else - MRU_MergeSave(pFileMRU,TRUE,flagRelativeFileMRU,flagPortableMyDocs); - MRU_Destroy(pFileMRU); - - if (!bSaveFindReplace) { - MRU_Empty(mruFind); - MRU_Empty(mruReplace); - MRU_Save(mruFind); - MRU_Save(mruReplace); - } - else { - MRU_MergeSave(mruFind,FALSE,FALSE,FALSE); - MRU_MergeSave(mruReplace,FALSE,FALSE,FALSE); - } - MRU_Destroy(mruFind); - MRU_Destroy(mruReplace); - } - - // Remove tray icon if necessary - ShowNotifyIcon(hwnd,FALSE); - - bShutdownOK = TRUE; - } - if (umsg == WM_DESTROY) - PostQuitMessage(0); - break; - - - case WM_CLOSE: - if (FileSave(FALSE,TRUE,FALSE,FALSE)) - DestroyWindow(hwnd); - break; - - - case WM_QUERYENDSESSION: - if (FileSave(FALSE,TRUE,FALSE,FALSE)) - return TRUE; - else - return FALSE; - - - // Reinitialize theme-dependent values and resize windows - case WM_THEMECHANGED: - MsgThemeChanged(hwnd,wParam,lParam); - break; - - - // update Scintilla colors - case WM_SYSCOLORCHANGE: - { - extern PEDITLEXER pLexCurrent; - Style_SetLexer(hwndEdit,pLexCurrent); - return DefWindowProc(hwnd,umsg,wParam,lParam); - } - - - //case WM_TIMER: - // break; - - - case WM_SIZE: - MsgSize(hwnd,wParam,lParam); - break; - - - case WM_SETFOCUS: - SetFocus(hwndEdit); - - UpdateToolbar(); - UpdateStatusbar(); - - //if (bPendingChangeNotify) - // PostMessage(hwnd,WM_CHANGENOTIFY,0,0); - break; - - - case WM_DROPFILES: - { - WCHAR szBuf[MAX_PATH+40]; - HDROP hDrop = (HDROP)wParam; - - // Reset Change Notify - //bPendingChangeNotify = FALSE; - - if (IsIconic(hwnd)) - ShowWindow(hwnd,SW_RESTORE); - - //SetForegroundWindow(hwnd); - - DragQueryFile(hDrop,0,szBuf,COUNTOF(szBuf)); - - if (PathIsDirectory(szBuf)) { - WCHAR tchFile[MAX_PATH]; - if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),szBuf)) - FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); - } - - else - FileLoad(FALSE,FALSE,FALSE,FALSE,szBuf); - - if (DragQueryFile(hDrop,(UINT)(-1),NULL,0) > 1) - MsgBox(MBWARN,IDS_ERR_DROP); - - DragFinish(hDrop); - } - break; - - - case WM_COPYDATA: - { - PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT)lParam; - - // Reset Change Notify - //bPendingChangeNotify = FALSE; - - SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE); - - if (pcds->dwData == DATA_NOTEPAD2_PARAMS) { - LPNP2PARAMS params = LocalAlloc(LPTR,pcds->cbData); - CopyMemory(params,pcds->lpData,pcds->cbData); - - if (params->flagLexerSpecified) - flagLexerSpecified = 1; - - if (params->flagQuietCreate) - flagQuietCreate = 1; - - if (params->flagFileSpecified) { - - BOOL bOpened = FALSE; - iSrcEncoding = params->iSrcEncoding; - - if (PathIsDirectory(¶ms->wchData)) { - WCHAR tchFile[MAX_PATH]; - if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),¶ms->wchData)) - bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); - } - - else - bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,¶ms->wchData); - - if (bOpened) { - - if (params->flagChangeNotify == 1) { - iFileWatchingMode = 0; - bResetFileWatching = TRUE; - InstallFileWatching(szCurFile); - } - else if (params->flagChangeNotify == 2) { - iFileWatchingMode = 2; - bResetFileWatching = TRUE; - InstallFileWatching(szCurFile); - } - - if (0 != params->flagSetEncoding) { - flagSetEncoding = params->flagSetEncoding; - SendMessage( - hwnd, - WM_COMMAND, - MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1), - 0); - flagSetEncoding = 0; - } - - if (0 != params->flagSetEOLMode) { - flagSetEOLMode = params->flagSetEOLMode; - SendMessage( - hwndMain, - WM_COMMAND, - MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1), - 0); - flagSetEOLMode = 0; - } - - if (params->flagLexerSpecified) { - if (params->iInitialLexer < 0) { - WCHAR wchExt[32] = L"."; - lstrcpyn(CharNext(wchExt),StrEnd(¶ms->wchData)+1,30); - Style_SetLexerFromName(hwndEdit,¶ms->wchData,wchExt); - } - else if (params->iInitialLexer >=0 && params->iInitialLexer < NUMLEXERS) - Style_SetLexerFromID(hwndEdit,params->iInitialLexer); - } - - if (params->flagTitleExcerpt) { - lstrcpyn(szTitleExcerpt,StrEnd(¶ms->wchData)+1,COUNTOF(szTitleExcerpt)); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - } - } - // reset - iSrcEncoding = -1; - } - - if (params->flagJumpTo) { - if (params->iInitialLine == 0) - params->iInitialLine = 1; - EditJumpTo(hwndEdit,params->iInitialLine,params->iInitialColumn); - EditEnsureSelectionVisible(hwndEdit); - } - - flagLexerSpecified = 0; - flagQuietCreate = 0; - - LocalFree(params); - - UpdateStatusbar(); - } - } - return TRUE; - - - case WM_CONTEXTMENU: - { - HMENU hmenu; - int imenu = 0; - POINT pt; - int nID = GetDlgCtrlID((HWND)wParam); - - if ((nID != IDC_EDIT) && (nID != IDC_STATUSBAR) && - (nID != IDC_REBAR) && (nID != IDC_TOOLBAR)) - return DefWindowProc(hwnd,umsg,wParam,lParam); - - hmenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU)); - //SetMenuDefaultItem(GetSubMenu(hmenu,1),0,FALSE); - - pt.x = (int)(short)LOWORD(lParam); - pt.y = (int)(short)HIWORD(lParam); - - switch(nID) - { - case IDC_EDIT: - { - int iSelStart = (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0); - - if (iSelStart == iSelEnd && pt.x != -1 && pt.y != -1) - { - int iNewPos; - POINT ptc = { pt.x, pt.y }; - ScreenToClient(hwndEdit,&ptc); - iNewPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMPOINT,(WPARAM)ptc.x,(LPARAM)ptc.y); - SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0); - } - - if (pt.x == -1 && pt.y == -1) - { - int iCurrentPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - pt.x = (int)SendMessage(hwndEdit,SCI_POINTXFROMPOSITION,0,(LPARAM)iCurrentPos); - pt.y = (int)SendMessage(hwndEdit,SCI_POINTYFROMPOSITION,0,(LPARAM)iCurrentPos); - ClientToScreen(hwndEdit,&pt); - } - imenu = 0; - } - break; - - case IDC_TOOLBAR: - case IDC_STATUSBAR: - case IDC_REBAR: - if (pt.x == -1 && pt.y == -1) - GetCursorPos(&pt); - imenu = 1; - break; - } - - TrackPopupMenuEx(GetSubMenu(hmenu,imenu), - TPM_LEFTBUTTON | TPM_RIGHTBUTTON,pt.x+1,pt.y+1,hwnd,NULL); - - DestroyMenu(hmenu); - } - break; - - - case WM_INITMENU: - MsgInitMenu(hwnd,wParam,lParam); - break; - - - case WM_NOTIFY: - return MsgNotify(hwnd,wParam,lParam); - - - case WM_COMMAND: - return MsgCommand(hwnd,wParam,lParam); - - - case WM_SYSCOMMAND: - switch (wParam) - { - case SC_MINIMIZE: - ShowOwnedPopups(hwnd,FALSE); - if (bMinimizeToTray) { - MinimizeWndToTray(hwnd); - ShowNotifyIcon(hwnd,TRUE); - SetNotifyIconTitle(hwnd); - return(0); - } - else - return DefWindowProc(hwnd,umsg,wParam,lParam); - - case SC_RESTORE: { - LRESULT lrv = DefWindowProc(hwnd,umsg,wParam,lParam); - ShowOwnedPopups(hwnd,TRUE); - return(lrv); - } - } - return DefWindowProc(hwnd,umsg,wParam,lParam); - - - case WM_CHANGENOTIFY: - if (iFileWatchingMode == 1 || bModified || iEncoding != iOriginalEncoding) - SetForegroundWindow(hwnd); - - if (PathFileExists(szCurFile)) { - - if ((iFileWatchingMode == 2 && !bModified && iEncoding == iOriginalEncoding) || - MsgBox(MBYESNO,IDS_FILECHANGENOTIFY) == IDYES) { - - int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iVisTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); - int iDocTopLine = (int)SendMessage(hwndEdit,SCI_DOCLINEFROMVISIBLE,(WPARAM)iVisTopLine,0); - int iXOffset = (int)SendMessage(hwndEdit,SCI_GETXOFFSET,0,0); - BOOL bIsTail = (iCurPos == iAnchorPos) && (iCurPos == SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); - - iWeakSrcEncoding = iEncoding; - if (FileLoad(TRUE,FALSE,TRUE,FALSE,szCurFile)) { - - if (bIsTail && iFileWatchingMode == 2) { - EditJumpTo(hwndEdit,-1,0); - EditEnsureSelectionVisible(hwndEdit); - } - - else if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { - char tch[5] = ""; - SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch); - if (lstrcmpiA(tch,".LOG") != 0) { - int iNewTopLine; - SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos); - SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0); - iNewTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); - SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)iVisTopLine - iNewTopLine); - SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0); - } - } - } - } - } - else { - - if (MsgBox(MBYESNO,IDS_FILECHANGENOTIFY2) == IDYES) - FileSave(TRUE,FALSE,FALSE,FALSE); - } - - if (!bRunningWatch) - InstallFileWatching(szCurFile); - break; - - - //// This message is posted before Notepad2 reactivates itself - //case WM_CHANGENOTIFYCLEAR: - // bPendingChangeNotify = FALSE; - // break; - - - case WM_DRAWCLIPBOARD: - if (!bLastCopyFromMe) - dwLastCopyTime = GetTickCount(); - else - bLastCopyFromMe = FALSE; - if (hwndNextCBChain) - SendMessage(hwndNextCBChain,WM_DRAWCLIPBOARD,wParam,lParam); - break; - - - case WM_CHANGECBCHAIN: - if ((HWND)wParam == hwndNextCBChain) - hwndNextCBChain = (HWND)lParam; - if (hwndNextCBChain) - SendMessage(hwndNextCBChain,WM_CHANGECBCHAIN,lParam,wParam); - break; - - - case WM_TRAYMESSAGE: - switch(lParam) - { - case WM_RBUTTONUP: { - - HMENU hMenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU)); - HMENU hMenuPopup = GetSubMenu(hMenu,2); - - POINT pt; - int iCmd; - - SetForegroundWindow(hwnd); - - GetCursorPos(&pt); - SetMenuDefaultItem(hMenuPopup,IDM_TRAY_RESTORE,FALSE); - iCmd = TrackPopupMenu(hMenuPopup, - TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, - pt.x,pt.y,0,hwnd,NULL); - - PostMessage(hwnd,WM_NULL,0,0); - - DestroyMenu(hMenu); - - if (iCmd == IDM_TRAY_RESTORE) { - ShowNotifyIcon(hwnd,FALSE); - RestoreWndFromTray(hwnd); - ShowOwnedPopups(hwnd,TRUE); - } - - else if (iCmd == IDM_TRAY_EXIT) { - //ShowNotifyIcon(hwnd,FALSE); - SendMessage(hwnd,WM_CLOSE,0,0); - } - } - return TRUE; - - case WM_LBUTTONUP: - ShowNotifyIcon(hwnd,FALSE); - RestoreWndFromTray(hwnd); - ShowOwnedPopups(hwnd,TRUE); - return TRUE; - } - break; - - - default: - - if (umsg == msgTaskbarCreated) { - if (!IsWindowVisible(hwnd)) - ShowNotifyIcon(hwnd,TRUE); - SetNotifyIconTitle(hwnd); - return(0); - } - - return DefWindowProc(hwnd,umsg,wParam,lParam); - - } - - return(0); - -} - - -//============================================================================= -// -// MsgCreate() - Handles WM_CREATE -// -// -LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - - HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance; - - // Setup edit control - hwndEdit = EditCreate(hwnd); - InitScintillaHandle(hwndEdit); - - // Tabs - SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - SendMessage(hwndEdit,SCI_SETBACKSPACEUNINDENTS,bBackspaceUnindents,0); - SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0); - SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0); - - // Indent Guides - Style_SetIndentGuides(hwndEdit,bShowIndentGuides); - - // Word wrap - if (!fWordWrap) - SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); - else - SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); - if (iWordWrapIndent == 5) - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0); - else if (iWordWrapIndent == 6) - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0); - else { - int i = 0; - switch (iWordWrapIndent) { - case 1: i = 1; break; - case 2: i = 2; break; - case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; - case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; - } - SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0); - } - if (bShowWordWrapSymbols) { - int wrapVisualFlags = 0; - int wrapVisualFlagsLocation = 0; - if (iWordWrapSymbols == 0) - iWordWrapSymbols = 22; - switch (iWordWrapSymbols%10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; - } - switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; - } - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); - } - else { - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); - } - - // Long Lines - if (bMarkLongLines) - SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); - else - SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); - SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); - - // Margins - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,2,0); - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0); - UpdateLineNumberWidth(); - //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0, - // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)L"_999999_"):0); - - // Code folding - SciCall_SetMarginType(MARGIN_FOLD_INDEX, SC_MARGIN_SYMBOL); - SciCall_SetMarginMask(MARGIN_FOLD_INDEX, SC_MASK_FOLDERS); - SciCall_SetMarginWidth(MARGIN_FOLD_INDEX, (bShowCodeFolding) ? 11 : 0); - SciCall_SetMarginSensitive(MARGIN_FOLD_INDEX, TRUE); - SciCall_MarkerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS); - SciCall_MarkerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS); - SciCall_MarkerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE); - SciCall_MarkerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER); - SciCall_MarkerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED); - SciCall_MarkerDefine(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED); - SciCall_MarkerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER); - SciCall_SetFoldFlags(16); - - // Nonprinting characters - SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); - SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); - - hwndEditFrame = CreateWindowEx( - WS_EX_CLIENTEDGE, - WC_LISTVIEW, - NULL, - WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,100,100, - hwnd, - (HMENU)IDC_EDITFRAME, - hInstance, - NULL); - - if (PrivateIsAppThemed()) { - - RECT rc, rc2; - - bIsAppThemed = TRUE; - - SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); - SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - - if (IsVista()) { - cxEditFrame = 0; - cyEditFrame = 0; - } - - else { - GetClientRect(hwndEditFrame,&rc); - GetWindowRect(hwndEditFrame,&rc2); - - cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; - cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; - } - } - else { - bIsAppThemed = FALSE; - - cxEditFrame = 0; - cyEditFrame = 0; - } - - // Create Toolbar and Statusbar - CreateBars(hwnd,hInstance); - - // Window Initialization - - CreateWindow( - WC_STATIC, - NULL, - WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,10,10, - hwnd, - (HMENU)IDC_FILENAME, - hInstance, - NULL); - - SetDlgItemText(hwnd,IDC_FILENAME,szCurFile); - - CreateWindow( - WC_STATIC, - NULL, - WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 10,10,10,10, - hwnd, - (HMENU)IDC_REUSELOCK, - hInstance, - NULL); - - SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE); - - // Menu - //SetMenuDefaultItem(GetSubMenu(GetMenu(hwnd),0),0); - - // Drag & Drop - DragAcceptFiles(hwnd,TRUE); - - // File MRU - pFileMRU = MRU_Create(L"Recent Files",MRU_NOCASE,32); - MRU_Load(pFileMRU); - - mruFind = MRU_Create(L"Recent Find",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16); - MRU_Load(mruFind); - - mruReplace = MRU_Create(L"Recent Replace",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16); - MRU_Load(mruReplace); - - if (hwndEdit == NULL || hwndEditFrame == NULL || - hwndStatus == NULL || hwndToolbar == NULL || hwndReBar == NULL) - return(-1); - - return(0); - -} - - -//============================================================================= -// -// CreateBars() - Create Toolbar and Statusbar -// -// -void CreateBars(HWND hwnd,HINSTANCE hInstance) -{ - RECT rc; - - REBARINFO rbi; - REBARBANDINFO rbBand; - - BITMAP bmp; - HBITMAP hbmp, hbmpCopy = NULL; - HIMAGELIST himl; - WCHAR szTmp[MAX_PATH]; - BOOL bExternalBitmap = FALSE; - - DWORD dwToolbarStyle = WS_TOOLBAR; - DWORD dwStatusbarStyle = WS_CHILD | WS_CLIPSIBLINGS; - DWORD dwReBarStyle = WS_REBAR; - - BOOL bIsAppThemed = PrivateIsAppThemed(); - - int i,n; - WCHAR tchDesc[256]; - WCHAR tchIndex[256]; - - WCHAR *pIniSection = NULL; - int cchIniSection = 0; - - if (bShowToolbar) - dwReBarStyle |= WS_VISIBLE; - - hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle, - 0,0,0,0,hwnd,(HMENU)IDC_TOOLBAR,hInstance,NULL); - - SendMessage(hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0); - - // Add normal Toolbar Bitmap - hbmp = NULL; - if (lstrlen(tchToolbarBitmap)) - { - if (!SearchPath(NULL,tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL)) - lstrcpy(szTmp,tchToolbarBitmap); - hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); - } - if (hbmp) - bExternalBitmap = TRUE; - else { - hbmp = LoadImage(hInstance,MAKEINTRESOURCE(IDR_MAINWND),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - hbmpCopy = CopyImage(hbmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - } - GetObject(hbmp,sizeof(BITMAP),&bmp); - if (!IsXP()) - BitmapMergeAlpha(hbmp,GetSysColor(COLOR_3DFACE)); - himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); - DeleteObject(hbmp); - SendMessage(hwndToolbar,TB_SETIMAGELIST,0,(LPARAM)himl); - - // Optionally add hot Toolbar Bitmap - hbmp = NULL; - if (lstrlen(tchToolbarBitmapHot)) - { - if (!SearchPath(NULL,tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL)) - lstrcpy(szTmp,tchToolbarBitmapHot); - if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE)) - { - GetObject(hbmp,sizeof(BITMAP),&bmp); - himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); - DeleteObject(hbmp); - SendMessage(hwndToolbar,TB_SETHOTIMAGELIST,0,(LPARAM)himl); - } - } - - // Optionally add disabled Toolbar Bitmap - hbmp = NULL; - if (lstrlen(tchToolbarBitmapDisabled)) - { - if (!SearchPath(NULL,tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL)) - lstrcpy(szTmp,tchToolbarBitmapDisabled); - if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE)) - { - GetObject(hbmp,sizeof(BITMAP),&bmp); - himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); - DeleteObject(hbmp); - SendMessage(hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); - bExternalBitmap = TRUE; - } - } - - if (!bExternalBitmap) { - BOOL fProcessed = FALSE; - if (flagToolbarLook == 1) - fProcessed = BitmapAlphaBlend(hbmpCopy,GetSysColor(COLOR_3DFACE),0x60); - else if (flagToolbarLook == 2 || (!IsXP() && flagToolbarLook == 0)) - fProcessed = BitmapGrayScale(hbmpCopy); - if (fProcessed && !IsXP()) - BitmapMergeAlpha(hbmpCopy,GetSysColor(COLOR_3DFACE)); - if (fProcessed) { - himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); - ImageList_AddMasked(himl,hbmpCopy,CLR_DEFAULT); - SendMessage(hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); - } - } - if (hbmpCopy) - DeleteObject(hbmpCopy); - - // Load toolbar labels - pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - LoadIniSection(L"Toolbar Labels",pIniSection,cchIniSection); - n = 1; - for (i = 0; i < COUNTOF(tbbMainWnd); i++) { - - if (tbbMainWnd[i].fsStyle == TBSTYLE_SEP) - continue; - - wsprintf(tchIndex,L"%02i",n++); - - if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) { - tbbMainWnd[i].iString = SendMessage(hwndToolbar,TB_ADDSTRING,0,(LPARAM)tchDesc); - tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT; - } - - else - tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT); - } - LocalFree(pIniSection); - - SendMessage(hwndToolbar,TB_SETEXTENDEDSTYLE,0, - SendMessage(hwndToolbar,TB_GETEXTENDEDSTYLE,0,0) | TBSTYLE_EX_MIXEDBUTTONS); - - SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); - if (Toolbar_SetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,tbbMainWnd,COUNTOF(tbbMainWnd)) == 0) - SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); - SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); - //SendMessage(hwndToolbar,TB_SETINDENT,2,0); - - if (bShowStatusbar) - dwStatusbarStyle |= WS_VISIBLE; - - hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR); - - // Create ReBar and add Toolbar - hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle, - 0,0,0,0,hwnd,(HMENU)IDC_REBAR,hInstance,NULL); - - rbi.cbSize = sizeof(REBARINFO); - rbi.fMask = 0; - rbi.himl = (HIMAGELIST)NULL; - SendMessage(hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi); - - rbBand.cbSize = sizeof(REBARBANDINFO); - rbBand.fMask = /*RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | */ - RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE /*| RBBIM_SIZE*/; - rbBand.fStyle = /*RBBS_CHILDEDGE |*//* RBBS_BREAK |*/ RBBS_FIXEDSIZE /*| RBBS_GRIPPERALWAYS*/; - if (bIsAppThemed) - rbBand.fStyle |= RBBS_CHILDEDGE; - rbBand.hbmBack = NULL; - rbBand.lpText = L"Toolbar"; - rbBand.hwndChild = hwndToolbar; - rbBand.cxMinChild = (rc.right - rc.left) * COUNTOF(tbbMainWnd); - rbBand.cyMinChild = (rc.bottom - rc.top) + 2 * rc.top; - rbBand.cx = 0; - SendMessage(hwndReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbBand); - - SetWindowPos(hwndReBar,NULL,0,0,0,0,SWP_NOZORDER); - GetWindowRect(hwndReBar,&rc); - cyReBar = rc.bottom - rc.top; - - cyReBarFrame = bIsAppThemed ? 0 : 2; -} - - -//============================================================================= -// -// MsgThemeChanged() - Handle WM_THEMECHANGED -// -// -void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - RECT rc, rc2; - HINSTANCE hInstance = (HINSTANCE)(INT_PTR)GetWindowLongPtr(hwnd,GWLP_HINSTANCE); - - // reinitialize edit frame - - if (PrivateIsAppThemed()) { - bIsAppThemed = TRUE; - - SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); - SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE); - - if (IsVista()) { - cxEditFrame = 0; - cyEditFrame = 0; - } - - else { - SetWindowPos(hwndEditFrame,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - GetClientRect(hwndEditFrame,&rc); - GetWindowRect(hwndEditFrame,&rc2); - - cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; - cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; - } - } - - else { - bIsAppThemed = FALSE; - - SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(hwndEdit,GWL_EXSTYLE)); - SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - - cxEditFrame = 0; - cyEditFrame = 0; - } - - // recreate toolbar and statusbar - Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons)); - - DestroyWindow(hwndToolbar); - DestroyWindow(hwndReBar); - DestroyWindow(hwndStatus); - CreateBars(hwnd,hInstance); - UpdateToolbar(); - - GetClientRect(hwnd,&rc); - SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,MAKELONG(rc.right,rc.bottom)); - UpdateStatusbar(); -} - - -//============================================================================= -// -// MsgSize() - Handles WM_SIZE -// -// -void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - - RECT rc; - int x,y,cx,cy; - HDWP hdwp; - - // Statusbar - int aWidth[6]; - - if (wParam == SIZE_MINIMIZED) - return; - - x = 0; - y = 0; - - cx = LOWORD(lParam); - cy = HIWORD(lParam); - - if (bShowToolbar) - { -/* SendMessage(hwndToolbar,WM_SIZE,0,0); - GetWindowRect(hwndToolbar,&rc); - y = (rc.bottom - rc.top); - cy -= (rc.bottom - rc.top);*/ - - //SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); - SetWindowPos(hwndReBar,NULL,0,0,LOWORD(lParam),cyReBar,SWP_NOZORDER); - // the ReBar automatically sets the correct height - // calling SetWindowPos() with the height of one toolbar button - // causes the control not to temporarily use the whole client area - // and prevents flickering - - //GetWindowRect(hwndReBar,&rc); - y = cyReBar + cyReBarFrame; // define - cy -= cyReBar + cyReBarFrame; // border - } - - if (bShowStatusbar) - { - SendMessage(hwndStatus,WM_SIZE,0,0); - GetWindowRect(hwndStatus,&rc); - cy -= (rc.bottom - rc.top); - } - - hdwp = BeginDeferWindowPos(2); - - DeferWindowPos(hdwp,hwndEditFrame,NULL,x,y,cx,cy, - SWP_NOZORDER | SWP_NOACTIVATE); - - DeferWindowPos(hdwp,hwndEdit,NULL,x+cxEditFrame,y+cyEditFrame, - cx-2*cxEditFrame,cy-2*cyEditFrame, - SWP_NOZORDER | SWP_NOACTIVATE); - - EndDeferWindowPos(hdwp); - - // Statusbar width - aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L"Ln 9'999'999 : 9'999'999 Col 9'999'999 : 999 Sel 9'999'999"))); - aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes"); - aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM"); - aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"CR+LF"); - aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"OVR"); - aWidth[5] = -1; - - SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth); - - //UpdateStatusbar(); - -} - - -//============================================================================= -// -// MsgInitMenu() - Handles WM_INITMENU -// -// -void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - - int i,i2; - HMENU hmenu = (HMENU)wParam; - - i = lstrlen(szCurFile); - EnableCmd(hmenu,IDM_FILE_REVERT,i); - EnableCmd(hmenu, CMD_RELOADASCIIASUTF8, i); - EnableCmd(hmenu, CMD_RELOADANSI, i); - EnableCmd(hmenu, CMD_RELOADOEM, i); - EnableCmd(hmenu, CMD_RELOADNOFILEVARS, i); - EnableCmd(hmenu, CMD_RECODEDEFAULT, i); - EnableCmd(hmenu,IDM_FILE_LAUNCH,i); - EnableCmd(hmenu,IDM_FILE_PROPERTIES,i); - EnableCmd(hmenu,IDM_FILE_CREATELINK,i); - EnableCmd(hmenu,IDM_FILE_ADDTOFAV,i); - - EnableCmd(hmenu,IDM_FILE_READONLY,i); - CheckCmd(hmenu,IDM_FILE_READONLY,bReadOnly); - - //EnableCmd(hmenu,IDM_ENCODING_UNICODEREV,!bReadOnly); - //EnableCmd(hmenu,IDM_ENCODING_UNICODE,!bReadOnly); - //EnableCmd(hmenu,IDM_ENCODING_UTF8SIGN,!bReadOnly); - //EnableCmd(hmenu,IDM_ENCODING_UTF8,!bReadOnly); - //EnableCmd(hmenu,IDM_ENCODING_ANSI,!bReadOnly); - //EnableCmd(hmenu,IDM_LINEENDINGS_CRLF,!bReadOnly); - //EnableCmd(hmenu,IDM_LINEENDINGS_LF,!bReadOnly); - //EnableCmd(hmenu,IDM_LINEENDINGS_CR,!bReadOnly); - - EnableCmd(hmenu,IDM_ENCODING_RECODE,i); - - if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) - i = IDM_ENCODING_UNICODEREV; - else if (mEncoding[iEncoding].uFlags & NCP_UNICODE) - i = IDM_ENCODING_UNICODE; - else if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) - i = IDM_ENCODING_UTF8SIGN; - else if (mEncoding[iEncoding].uFlags & NCP_UTF8) - i = IDM_ENCODING_UTF8; - else if (mEncoding[iEncoding].uFlags & NCP_DEFAULT) - i = IDM_ENCODING_ANSI; - else - i = -1; - CheckMenuRadioItem(hmenu,IDM_ENCODING_ANSI,IDM_ENCODING_UTF8SIGN,i,MF_BYCOMMAND); - - if (iEOLMode == SC_EOL_CRLF) - i = IDM_LINEENDINGS_CRLF; - else if (iEOLMode == SC_EOL_LF) - i = IDM_LINEENDINGS_LF; - else - i = IDM_LINEENDINGS_CR; - CheckMenuRadioItem(hmenu,IDM_LINEENDINGS_CRLF,IDM_LINEENDINGS_CR,i,MF_BYCOMMAND); - - EnableCmd(hmenu,IDM_FILE_RECENT,(MRU_Enum(pFileMRU,0,NULL,0) > 0)); - - EnableCmd(hmenu,IDM_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/); - - i = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - i2 = (int)SendMessage(hwndEdit,SCI_CANPASTE,0,0); - - EnableCmd(hmenu,IDM_EDIT_CUT,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_COPY,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_COPYALL,SendMessage(hwndEdit,SCI_GETLENGTH,0,0) /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_COPYADD,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_PASTE,i2 /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_SWAP,i || i2 /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_CLEAR,i /*&& !bReadOnly*/); - - OpenClipboard(hwnd); - EnableCmd(hmenu,IDM_EDIT_CLEARCLIPBOARD,CountClipboardFormats()); - CloseClipboard(); - - //EnableCmd(hmenu,IDM_EDIT_MOVELINEUP,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_MOVELINEDOWN,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_DUPLICATELINE,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_CUTLINE,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_COPYLINE,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_DELETELINE,!bReadOnly); - - //EnableCmd(hmenu,IDM_EDIT_INDENT,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_UNINDENT,!bReadOnly); - - //EnableCmd(hmenu,IDM_EDIT_PADWITHSPACES,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_STRIP1STCHAR,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_STRIPLASTCHAR,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_TRIMLINES,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_MERGEBLANKLINES,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_REMOVEBLANKLINES,!bReadOnly); - - EnableCmd(hmenu,IDM_EDIT_SORTLINES, - SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0) - - SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0) >= 1); - - EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/); - EnableCmd(hmenu,IDM_EDIT_SPLITLINES,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_JOINLINES,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_JOINLINESEX,i /*&& !bReadOnly*/); - - EnableCmd(hmenu,IDM_EDIT_CONVERTUPPERCASE,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_CONVERTLOWERCASE,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_INVERTCASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); - EnableCmd(hmenu,IDM_EDIT_TITLECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); - EnableCmd(hmenu,IDM_EDIT_SENTENCECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); - - EnableCmd(hmenu,IDM_EDIT_CONVERTTABS,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_CONVERTTABS2,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES2,i /*&& !bReadOnly*/); - - EnableCmd(hmenu,IDM_EDIT_URLENCODE,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_URLDECODE,i /*&& !bReadOnly*/); - - EnableCmd(hmenu,IDM_EDIT_ESCAPECCHARS,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_UNESCAPECCHARS,i /*&& !bReadOnly*/); - - EnableCmd(hmenu,IDM_EDIT_CHAR2HEX,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_HEX2CHAR,i /*&& !bReadOnly*/); - - //EnableCmd(hmenu,IDM_EDIT_INCREASENUM,i /*&& !bReadOnly*/); - //EnableCmd(hmenu,IDM_EDIT_DECREASENUM,i /*&& !bReadOnly*/); - - EnableCmd(hmenu,IDM_VIEW_SHOWEXCERPT,i); - - i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); - EnableCmd(hmenu,IDM_EDIT_LINECOMMENT, - !(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF)); - EnableCmd(hmenu,IDM_EDIT_STREAMCOMMENT, - !(i == SCLEX_NULL || i == SCLEX_VBSCRIPT || i == SCLEX_MAKEFILE || i == SCLEX_VB || i == SCLEX_ASM || - i == SCLEX_SQL || i == SCLEX_PERL || i == SCLEX_PYTHON || i == SCLEX_PROPERTIES ||i == SCLEX_CONF || - i == SCLEX_POWERSHELL || i == SCLEX_BATCH || i == SCLEX_DIFF || i == SCLEX_BASH || i == SCLEX_TCL || - i == SCLEX_AU3 || i == SCLEX_LATEX || i == SCLEX_AHK || i == SCLEX_RUBY || i == SCLEX_CMAKE || i == SCLEX_MARKDOWN || - i == SCLEX_YAML)); - - EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING,*mEncoding[iEncoding].pszParseNames); - - //EnableCmd(hmenu,IDM_EDIT_INSERT_SHORTDATE,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_INSERT_LONGDATE,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_INSERT_FILENAME,!bReadOnly); - //EnableCmd(hmenu,IDM_EDIT_INSERT_PATHNAME,!bReadOnly); - - i = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); - EnableCmd(hmenu,IDM_EDIT_FIND,i); - EnableCmd(hmenu,IDM_EDIT_SAVEFIND,i); - EnableCmd(hmenu,IDM_EDIT_FINDNEXT,i); - EnableCmd(hmenu,IDM_EDIT_FINDPREV,i && lstrlenA(efrData.szFind)); - EnableCmd(hmenu,IDM_EDIT_REPLACE,i /*&& !bReadOnly*/); - EnableCmd(hmenu,IDM_EDIT_REPLACENEXT,i); - EnableCmd(hmenu,IDM_EDIT_SELTONEXT,i && lstrlenA(efrData.szFind)); - EnableCmd(hmenu,IDM_EDIT_SELTOPREV,i && lstrlenA(efrData.szFind)); - EnableCmd(hmenu,IDM_EDIT_FINDMATCHINGBRACE,i); - EnableCmd(hmenu,IDM_EDIT_SELTOMATCHINGBRACE,i); -#ifdef BOOKMARK_EDITION - EnableCmd(hmenu,BME_EDIT_BOOKMARKPREV,i); - EnableCmd(hmenu,BME_EDIT_BOOKMARKNEXT,i); - EnableCmd(hmenu,BME_EDIT_BOOKMARKTOGGLE,i); - EnableCmd(hmenu,BME_EDIT_BOOKMARKCLEAR,i); -#endif - EnableCmd(hmenu, IDM_EDIT_DELETELINELEFT, i); - EnableCmd(hmenu, IDM_EDIT_DELETELINERIGHT, i); - EnableCmd(hmenu, CMD_CTRLBACK, i); - EnableCmd(hmenu, CMD_CTRLDEL, i); - EnableCmd(hmenu, CMD_TIMESTAMPS, i); - EnableCmd(hmenu,IDM_VIEW_TOGGLEFOLDS,i && bShowCodeFolding); - CheckCmd(hmenu,IDM_VIEW_FOLDING,bShowCodeFolding); - - CheckCmd(hmenu,IDM_VIEW_USE2NDDEFAULT,Style_GetUse2ndDefault(hwndEdit)); - - CheckCmd(hmenu,IDM_VIEW_WORDWRAP,fWordWrap); - CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,bMarkLongLines); - CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,bTabsAsSpaces); - CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,bShowIndentGuides); - CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,bAutoIndent); - CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,bShowLineNumbers); - CheckCmd(hmenu,IDM_VIEW_MARGIN,bShowSelectionMargin); - - EnableCmd(hmenu,IDM_EDIT_COMPLETEWORD,i); - CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,bAutoCompleteWords); - - switch (iMarkOccurrences) - { - case 0: i = IDM_VIEW_MARKOCCURRENCES_OFF; break; - case 3: i = IDM_VIEW_MARKOCCURRENCES_BLUE; break; - case 2: i = IDM_VIEW_MARKOCCURRENCES_GREEN; break; - case 1: i = IDM_VIEW_MARKOCCURRENCES_RED; break; - } - CheckMenuRadioItem(hmenu,IDM_VIEW_MARKOCCURRENCES_OFF,IDM_VIEW_MARKOCCURRENCES_RED,i,MF_BYCOMMAND); - CheckCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_CASE,bMarkOccurrencesMatchCase); - CheckCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_WORD,bMarkOccurrencesMatchWords); - EnableCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_CASE,iMarkOccurrences != 0); - EnableCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_WORD,iMarkOccurrences != 0); - - CheckCmd(hmenu,IDM_VIEW_SHOWWHITESPACE,bViewWhiteSpace); - CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,bViewEOLs); - CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,bShowWordWrapSymbols); - CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,bMatchBraces); - CheckCmd(hmenu,IDM_VIEW_TOOLBAR,bShowToolbar); - EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB,bShowToolbar); - CheckCmd(hmenu,IDM_VIEW_STATUSBAR,bShowStatusbar); - - i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); - //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML)); - CheckCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); - CheckCmd(hmenu,IDM_VIEW_HILITECURRENTLINE,bHiliteCurrentLine); - - i = IniGetInt(L"Settings2",L"ReuseWindow",0); - CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); - i = IniGetInt(L"Settings2",L"SingleFileInstance",0); - CheckCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); - bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",0); - CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,bStickyWinPos); - CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1)); - CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,bMinimizeToTray); - CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentMode && bTransparentModeAvailable); - EnableCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentModeAvailable); - - CheckCmd(hmenu,IDM_VIEW_NOSAVERECENT,bSaveRecentFiles); - CheckCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,bSaveFindReplace); - CheckCmd(hmenu,IDM_VIEW_SAVEBEFORERUNNINGTOOLS,bSaveBeforeRunningTools); - - CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,iFileWatchingMode); - - if (lstrlen(szTitleExcerpt)) - i = IDM_VIEW_SHOWEXCERPT; - else if (iPathNameFormat == 0) - i = IDM_VIEW_SHOWFILENAMEONLY; - else if (iPathNameFormat == 1) - i = IDM_VIEW_SHOWFILENAMEFIRST; - else - i = IDM_VIEW_SHOWFULLPATH; - CheckMenuRadioItem(hmenu,IDM_VIEW_SHOWFILENAMEONLY,IDM_VIEW_SHOWEXCERPT,i,MF_BYCOMMAND); - - if (iEscFunction == 1) - i = IDM_VIEW_ESCMINIMIZE; - else if (iEscFunction == 2) - i = IDM_VIEW_ESCEXIT; - else - i = IDM_VIEW_NOESCFUNC; - CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND); - - i = lstrlen(szIniFile); - CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,bSaveSettings && i); - - EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); - EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i); - EnableCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); - EnableCmd(hmenu,IDM_VIEW_NOSAVERECENT,i); - EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i); - EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,i); - - i = (lstrlen(szIniFile) > 0 || lstrlen(szIniFile2) > 0); - EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,i); - -} - - -//============================================================================= -// -// MsgCommand() - Handles WM_COMMAND -// -// -LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - - switch(LOWORD(wParam)) - { - - case IDM_FILE_NEW: - FileLoad(FALSE,TRUE,FALSE,FALSE,L""); - break; - - - case IDM_FILE_OPEN: - FileLoad(FALSE,FALSE,FALSE,FALSE,L""); - break; - - - case IDM_FILE_REVERT: - { - if (lstrlen(szCurFile)) { - - WCHAR tchCurFile2[MAX_PATH]; - - int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iVisTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); - int iDocTopLine = (int)SendMessage(hwndEdit,SCI_DOCLINEFROMVISIBLE,(WPARAM)iVisTopLine,0); - int iXOffset = (int)SendMessage(hwndEdit,SCI_GETXOFFSET,0,0); - - if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_REVERT) != IDOK) - return(0); - - lstrcpy(tchCurFile2,szCurFile); - - iWeakSrcEncoding = iEncoding; - if (FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2)) - { - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { - char tch[5] = ""; - SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch); - if (lstrcmpiA(tch,".LOG") != 0) { - int iNewTopLine; - SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos); - SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0); - iNewTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); - SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)iVisTopLine - iNewTopLine); - SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0); - } - } - } - } - } - break; - - - case IDM_FILE_SAVE: - FileSave(TRUE,FALSE,FALSE,FALSE); - break; - - - case IDM_FILE_SAVEAS: - FileSave(TRUE,FALSE,TRUE,FALSE); - break; - - - case IDM_FILE_SAVECOPY: - FileSave(TRUE,FALSE,TRUE,TRUE); - break; - - - case IDM_FILE_READONLY: - //bReadOnly = (bReadOnly) ? FALSE : TRUE; - //SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0); - //UpdateToolbar(); - //UpdateStatusbar(); - if (lstrlen(szCurFile)) - { - DWORD dwFileAttributes = GetFileAttributes(szCurFile); - if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) { - if (bReadOnly) - dwFileAttributes = (dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); - else - dwFileAttributes |= FILE_ATTRIBUTE_READONLY; - if (!SetFileAttributes(szCurFile,dwFileAttributes)) - MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile); - } - else - MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile); - - dwFileAttributes = GetFileAttributes(szCurFile); - if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) - bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); - - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - } - break; - - - case IDM_FILE_BROWSE: - { - SHELLEXECUTEINFO sei; - WCHAR tchParam[MAX_PATH+4] = L""; - WCHAR tchExeFile[MAX_PATH+4]; - WCHAR tchTemp[MAX_PATH+4]; - - if (!IniGetString(L"Settings2",L"filebrowser.exe",L"",tchTemp,COUNTOF(tchTemp))) { - if (!SearchPath(NULL,L"metapath.exe",NULL,COUNTOF(tchExeFile),tchExeFile,NULL)) { - GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile)); - PathRemoveFileSpec(tchExeFile); - PathAppend(tchExeFile,L"metapath.exe"); - } - } - - else { - ExtractFirstArgument(tchTemp,tchExeFile,tchParam); - if (PathIsRelative(tchExeFile)) { - if (!SearchPath(NULL,tchExeFile,NULL,COUNTOF(tchTemp),tchTemp,NULL)) { - GetModuleFileName(NULL,tchTemp,COUNTOF(tchTemp)); - PathRemoveFileSpec(tchTemp); - PathAppend(tchTemp,tchExeFile); - lstrcpy(tchExeFile,tchTemp); - } - } - } - - if (lstrlen(tchParam) && lstrlen(szCurFile)) - StrCatBuff(tchParam,L" ",COUNTOF(tchParam)); - - if (lstrlen(szCurFile)) { - lstrcpy(tchTemp,szCurFile); - PathQuoteSpaces(tchTemp); - StrCatBuff(tchParam,tchTemp,COUNTOF(tchParam)); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOZONECHECKS*/0x00800000; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = tchExeFile; - sei.lpParameters = tchParam; - sei.lpDirectory = NULL; - sei.nShow = SW_SHOWNORMAL; - - ShellExecuteEx(&sei); - - if ((INT_PTR)sei.hInstApp < 32) - MsgBox(MBWARN,IDS_ERR_BROWSE); - } - break; - - - case IDM_FILE_NEWWINDOW: - case IDM_FILE_NEWWINDOW2: - { - SHELLEXECUTEINFO sei; - WCHAR szModuleName[MAX_PATH]; - WCHAR szFileName[MAX_PATH]; - WCHAR szParameters[2*MAX_PATH+64]; - - MONITORINFO mi; - HMONITOR hMonitor; - WINDOWPLACEMENT wndpl; - int x,y,cx,cy,imax; - WCHAR tch[64]; - - if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) - break; - - GetModuleFileName(NULL,szModuleName,COUNTOF(szModuleName)); - - wsprintf(tch,L"\"-appid=%s\"",g_wchAppUserModelID); - lstrcpy(szParameters,tch); - - wsprintf(tch,L" \"-sysmru=%i\"",(flagUseSystemMRU == 2) ? 1 : 0); - lstrcat(szParameters,tch); - - lstrcat(szParameters,L" -f"); - if (lstrlen(szIniFile)) { - lstrcat(szParameters,L" \""); - lstrcat(szParameters,szIniFile); - lstrcat(szParameters,L"\""); - } - else - lstrcat(szParameters,L"0"); - - lstrcat(szParameters,L" -n"); - - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hwnd,&wndpl); - - hMonitor = MonitorFromRect(&wndpl.rcNormalPosition,MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor,&mi); - - // offset new window position +10/+10 - x = wndpl.rcNormalPosition.left + 10; - y = wndpl.rcNormalPosition.top + 10; - cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; - cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; - - // check if window fits monitor - if ((x + cx) > mi.rcWork.right || (y + cy) > mi.rcWork.bottom) { - x = mi.rcMonitor.left; - y = mi.rcMonitor.top; - } - - imax = IsZoomed(hwnd); - - wsprintf(tch,L" -pos %i,%i,%i,%i,%i",x,y,cx,cy,imax); - lstrcat(szParameters,tch); - - if (LOWORD(wParam) != IDM_FILE_NEWWINDOW2 && lstrlen(szCurFile)) { - lstrcpy(szFileName,szCurFile); - PathQuoteSpaces(szFileName); - lstrcat(szParameters,L" "); - lstrcat(szParameters,szFileName); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = szModuleName; - sei.lpParameters = szParameters; - sei.lpDirectory = g_wchWorkingDirectory; - sei.nShow = SW_SHOWNORMAL; - - ShellExecuteEx(&sei); - } - break; - - - case IDM_FILE_LAUNCH: - { - SHELLEXECUTEINFO sei; - WCHAR wchDirectory[MAX_PATH] = L""; - - if (!lstrlen(szCurFile)) - break; - - if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) - break; - - if (lstrlen(szCurFile)) { - lstrcpy(wchDirectory,szCurFile); - PathRemoveFileSpec(wchDirectory); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = 0; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = szCurFile; - sei.lpParameters = NULL; - sei.lpDirectory = wchDirectory; - sei.nShow = SW_SHOWNORMAL; - - ShellExecuteEx(&sei); - } - break; - - - case IDM_FILE_RUN: - { - WCHAR tchCmdLine[MAX_PATH+4]; - - if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) - break; - - lstrcpy(tchCmdLine,szCurFile); - PathQuoteSpaces(tchCmdLine); - - RunDlg(hwnd,tchCmdLine); - } - break; - - - case IDM_FILE_OPENWITH: - if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) - break; - OpenWithDlg(hwnd,szCurFile); - break; - - - case IDM_FILE_PAGESETUP: - EditPrintSetup(hwndEdit); - break; - - case IDM_FILE_PRINT: - { - SHFILEINFO shfi; - WCHAR *pszTitle; - WCHAR tchUntitled[32]; - WCHAR tchPageFmt[32]; - - if (lstrlen(szCurFile)) { - SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); - pszTitle = shfi.szDisplayName; - } - else { - GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); - pszTitle = tchUntitled; - } - - GetString(IDS_PRINT_PAGENUM,tchPageFmt,COUNTOF(tchPageFmt)); - - if (!EditPrint(hwndEdit,pszTitle,tchPageFmt)) - MsgBox(MBWARN,IDS_PRINT_ERROR,pszTitle); - } - break; - - - case IDM_FILE_PROPERTIES: - { - SHELLEXECUTEINFO sei; - - if (lstrlen(szCurFile) == 0) - break; - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = SEE_MASK_INVOKEIDLIST; - sei.hwnd = hwnd; - sei.lpVerb = L"properties"; - sei.lpFile = szCurFile; - sei.nShow = SW_SHOWNORMAL; - - ShellExecuteEx(&sei); - } - break; - - case IDM_FILE_CREATELINK: - { - if (!lstrlen(szCurFile)) - break; - - if (!PathCreateDeskLnk(szCurFile)) - MsgBox(MBWARN,IDS_ERR_CREATELINK); - } - break; - - - case IDM_FILE_OPENFAV: - if (FileSave(FALSE,TRUE,FALSE,FALSE)) { - - WCHAR tchSelItem[MAX_PATH]; - - if (FavoritesDlg(hwnd,tchSelItem)) - { - if (PathIsLnkToDirectory(tchSelItem,NULL,0)) - PathGetLnkPath(tchSelItem,tchSelItem,COUNTOF(tchSelItem)); - - if (PathIsDirectory(tchSelItem)) - { - WCHAR tchFile[MAX_PATH]; - - if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchSelItem)) - FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile); - } - else - FileLoad(TRUE,FALSE,FALSE,FALSE,tchSelItem); - } - } - break; - - - case IDM_FILE_ADDTOFAV: - if (lstrlen(szCurFile)) { - SHFILEINFO shfi; - SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); - AddToFavDlg(hwnd,shfi.szDisplayName,szCurFile); - } - break; - - - case IDM_FILE_MANAGEFAV: - { - SHELLEXECUTEINFO sei; - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = 0; - sei.hwnd = hwnd; - sei.lpVerb = NULL; - sei.lpFile = tchFavoritesDir; - sei.lpParameters = NULL; - sei.lpDirectory = NULL; - sei.nShow = SW_SHOWNORMAL; - - // Run favorites directory - ShellExecuteEx(&sei); - } - break; - - - case IDM_FILE_RECENT: - if (MRU_Enum(pFileMRU,0,NULL,0) > 0) { - if (FileSave(FALSE,TRUE,FALSE,FALSE)) { - WCHAR tchFile[MAX_PATH]; - if (FileMRUDlg(hwnd,tchFile)) - FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile); - } - } - break; - - - case IDM_FILE_EXIT: - SendMessage(hwnd,WM_CLOSE,0,0); - break; - - - case IDM_ENCODING_ANSI: - case IDM_ENCODING_UNICODE: - case IDM_ENCODING_UNICODEREV: - case IDM_ENCODING_UTF8: - case IDM_ENCODING_UTF8SIGN: - case IDM_ENCODING_SELECT: - { - int iNewEncoding = iEncoding; - if (LOWORD(wParam) == IDM_ENCODING_SELECT && !SelectEncodingDlg(hwnd,&iNewEncoding)) - break; - else { - switch (LOWORD(wParam)) { - case IDM_ENCODING_UNICODE: iNewEncoding = CPI_UNICODEBOM; break; - case IDM_ENCODING_UNICODEREV: iNewEncoding = CPI_UNICODEBEBOM; break; - case IDM_ENCODING_UTF8: iNewEncoding = CPI_UTF8; break; - case IDM_ENCODING_UTF8SIGN: iNewEncoding = CPI_UTF8SIGN; break; - case IDM_ENCODING_ANSI: iNewEncoding = CPI_DEFAULT; break; - } - } - - if (EditSetNewEncoding(hwndEdit, - iEncoding,iNewEncoding, - (flagSetEncoding),lstrlen(szCurFile) == 0)) { - - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) { - iEncoding = iNewEncoding; - iOriginalEncoding = iNewEncoding; - } - else { - if (iEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) - iOriginalEncoding = -1; - iEncoding = iNewEncoding; - } - - UpdateToolbar(); - UpdateStatusbar(); - - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - } - } - break; - - - case IDM_ENCODING_RECODE: - { - if (lstrlen(szCurFile)) { - - WCHAR tchCurFile2[MAX_PATH]; - - int iNewEncoding = -1; - if (iEncoding != CPI_DEFAULT) - iNewEncoding = iEncoding; - if (iEncoding == CPI_UTF8SIGN) - iNewEncoding = CPI_UTF8; - if (iEncoding == CPI_UNICODEBOM) - iNewEncoding = CPI_UNICODE; - if (iEncoding == CPI_UNICODEBEBOM) - iNewEncoding = CPI_UNICODEBE; - - if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_RECODE) != IDOK) - return(0); - - if (RecodeDlg(hwnd,&iNewEncoding)) { - - lstrcpy(tchCurFile2,szCurFile); - iSrcEncoding = iNewEncoding; - FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2); - } - } - } - break; - - - case IDM_ENCODING_SETDEFAULT: - SelectDefEncodingDlg(hwnd,&iDefaultEncoding); - break; - - - case IDM_LINEENDINGS_CRLF: - case IDM_LINEENDINGS_LF: - case IDM_LINEENDINGS_CR: - { - int iNewEOLMode = iLineEndings[LOWORD(wParam)-IDM_LINEENDINGS_CRLF]; - iEOLMode = iNewEOLMode; - SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0); - SendMessage(hwndEdit,SCI_CONVERTEOLS,iEOLMode,0); - EditFixPositions(hwndEdit); - UpdateToolbar(); - UpdateStatusbar(); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - } - break; - - - case IDM_LINEENDINGS_SETDEFAULT: - SelectDefLineEndingDlg(hwnd,&iDefaultEOLMode); - break; - - - case IDM_EDIT_UNDO: - SendMessage(hwndEdit,SCI_UNDO,0,0); - break; - - - case IDM_EDIT_REDO: - SendMessage(hwndEdit,SCI_REDO,0,0); - break; - - - case IDM_EDIT_CUT: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_CUT,0,0); - break; - - - case IDM_EDIT_COPY: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_COPY,0,0); - UpdateToolbar(); - break; - - - case IDM_EDIT_COPYALL: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_COPYRANGE,0,SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); - UpdateToolbar(); - break; - - - case IDM_EDIT_COPYADD: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - EditCopyAppend(hwndEdit); - UpdateToolbar(); - break; - - - case IDM_EDIT_PASTE: - SendMessage(hwndEdit,SCI_PASTE,0,0); - break; - - - case IDM_EDIT_SWAP: - if (SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) == 0) { - int iNewPos; - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - SendMessage(hwndEdit,SCI_PASTE,0,0); - iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - SendMessage(hwndEdit,SCI_SETSEL,iPos,iNewPos); - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEARCLIPBOARD,1),0); - } - else { - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - char *pClip = EditGetClipboardText(hwndEdit); - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwndEdit,SCI_CUT,0,0); - SendMessage(hwndEdit,SCI_REPLACESEL,(WPARAM)0,(LPARAM)pClip); - if (iPos > iAnchor) - SendMessage(hwndEdit,SCI_SETSEL,iAnchor,iAnchor + lstrlenA(pClip)); - else - SendMessage(hwndEdit,SCI_SETSEL,iPos + lstrlenA(pClip),iPos); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - LocalFree(pClip); - } - break; - - - case IDM_EDIT_CLEAR: - SendMessage(hwndEdit,SCI_CLEAR,0,0); - break; - - - case IDM_EDIT_CLEARCLIPBOARD: - if (OpenClipboard(hwnd)) { - if (CountClipboardFormats() > 0) { - EmptyClipboard(); - UpdateToolbar(); - UpdateStatusbar(); - } - CloseClipboard(); - } - break; - - - case IDM_EDIT_SELECTALL: - SendMessage(hwndEdit,SCI_SELECTALL,0,0); - //SendMessage(hwndEdit,SCI_SETSEL,0,(LPARAM)-1); - break; - - - case IDM_EDIT_SELECTWORD: - { - int iSel = - (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - - if (iSel == 0) { - - int iWordStart = (int)SendMessage(hwndEdit,SCI_WORDSTARTPOSITION,iPos,TRUE); - int iWordEnd = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,TRUE); - - if (iWordStart == iWordEnd) // we are in whitespace salad... - { - iWordStart = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,FALSE); - iWordEnd = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iWordStart,TRUE); - if (iWordStart != iWordEnd) { - //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) && - // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) && - // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0)) - // iWordStart--; - SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd); - } - } - else { - //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) && - // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) && - // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0)) - // iWordStart--; - SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd); - } - - iSel = - (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - - if (iSel == 0) { - int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0); - int iLineStart = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0); - int iLineEnd = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0); - SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd); - } - } - else { - int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0); - int iLineStart = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0); - int iLineEnd = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0); - SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd); - } - } - - break; - - - case IDM_EDIT_SELECTLINE: - { - int iSelStart = (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - int iSelEnd = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0); - int iLineStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelStart,0); - int iLineEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelEnd,0); - iSelStart = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineStart,0); - iSelEnd = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineEnd+1,0); - SendMessage(hwndEdit,SCI_SETSEL,iSelStart,iSelEnd); - SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); - } - break; - - - case IDM_EDIT_MOVELINEUP: - EditMoveUp(hwndEdit); - break; - - - case IDM_EDIT_MOVELINEDOWN: - EditMoveDown(hwndEdit); - break; - - - case IDM_EDIT_DUPLICATELINE: - SendMessage(hwndEdit,SCI_LINEDUPLICATE,0,0); - break; - - - case IDM_EDIT_CUTLINE: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_LINECUT,0,0); - break; - - - case IDM_EDIT_COPYLINE: - if (flagPasteBoard) - bLastCopyFromMe = TRUE; - SendMessage(hwndEdit,SCI_LINECOPY,0,0); - UpdateToolbar(); - break; - - - case IDM_EDIT_DELETELINE: - SendMessage(hwndEdit,SCI_LINEDELETE,0,0); - break; - - - case IDM_EDIT_DELETELINELEFT: - SendMessage(hwndEdit,SCI_DELLINELEFT,0,0); - break; - - - case IDM_EDIT_DELETELINERIGHT: - SendMessage(hwndEdit,SCI_DELLINERIGHT,0,0); - break; - - - case IDM_EDIT_INDENT: - { - int iLineSelStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0); - int iLineSelEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, - (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0); - - SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0); - if (iLineSelStart == iLineSelEnd) { - SendMessage(hwndEdit,SCI_VCHOME,0,0); - SendMessage(hwndEdit,SCI_TAB,0,0); - } - else - SendMessage(hwndEdit,SCI_TAB,0,0); - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - } - break; - - - case IDM_EDIT_UNINDENT: - { - int iLineSelStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0); - int iLineSelEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, - (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0); - - SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0); - if (iLineSelStart == iLineSelEnd) { - SendMessage(hwndEdit,SCI_VCHOME,0,0); - SendMessage(hwndEdit,SCI_BACKTAB,0,0); - } - else - SendMessage(hwndEdit,SCI_BACKTAB,0,0); - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - } - break; - - - case IDM_EDIT_ENCLOSESELECTION: - if (EditEncloseSelectionDlg(hwnd,wchPrefixSelection,wchAppendSelection)) { - BeginWaitCursor(); - EditEncloseSelection(hwndEdit,wchPrefixSelection,wchAppendSelection); - EndWaitCursor(); - } - break; - - - case IDM_EDIT_SELECTIONDUPLICATE: - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwndEdit,SCI_SELECTIONDUPLICATE,0,0); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - break; - - - case IDM_EDIT_PADWITHSPACES: - BeginWaitCursor(); - EditPadWithSpaces(hwndEdit,FALSE,FALSE); - EndWaitCursor(); - break; - - - case IDM_EDIT_STRIP1STCHAR: - BeginWaitCursor(); - EditStripFirstCharacter(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_STRIPLASTCHAR: - BeginWaitCursor(); - EditStripLastCharacter(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_TRIMLINES: - BeginWaitCursor(); - EditStripTrailingBlanks(hwndEdit,FALSE); - EndWaitCursor(); - break; - - - case IDM_EDIT_COMPRESSWS: - BeginWaitCursor(); - EditCompressSpaces(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_MERGEBLANKLINES: - BeginWaitCursor(); - EditRemoveBlankLines(hwndEdit,TRUE); - EndWaitCursor(); - break; - - - case IDM_EDIT_REMOVEBLANKLINES: - BeginWaitCursor(); - EditRemoveBlankLines(hwndEdit,FALSE); - EndWaitCursor(); - break; - - - case IDM_EDIT_MODIFYLINES: - if (EditModifyLinesDlg(hwnd,wchPrefixLines,wchAppendLines)) { - BeginWaitCursor(); - EditModifyLines(hwndEdit,wchPrefixLines,wchAppendLines); - EndWaitCursor(); - } - break; - - - case IDM_EDIT_ALIGN: - if (EditAlignDlg(hwnd,&iAlignMode)) { - BeginWaitCursor(); - EditAlignText(hwndEdit,iAlignMode); - EndWaitCursor(); - } - break; - - - case IDM_EDIT_SORTLINES: - if (EditSortDlg(hwnd,&iSortOptions)) { - BeginWaitCursor(); - StatusSetText(hwndStatus,255,L"..."); - StatusSetSimple(hwndStatus,TRUE); - InvalidateRect(hwndStatus,NULL,TRUE); - UpdateWindow(hwndStatus); - EditSortLines(hwndEdit,iSortOptions); - StatusSetSimple(hwndStatus,FALSE); - EndWaitCursor(); - } - break; - - - case IDM_EDIT_COLUMNWRAP: - { - if (iWrapCol == 0) - iWrapCol = iLongLinesLimit; - - if (ColumnWrapDlg(hwnd,IDD_COLUMNWRAP,&iWrapCol)) - { - iWrapCol = max(min(iWrapCol,512),1); - BeginWaitCursor(); - EditWrapToColumn(hwndEdit,iWrapCol); - EndWaitCursor(); - } - } - break; - - - case IDM_EDIT_SPLITLINES: - BeginWaitCursor(); - SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0); - SendMessage(hwndEdit,SCI_LINESSPLIT,0,0); - EndWaitCursor(); - break; - - - case IDM_EDIT_JOINLINES: - BeginWaitCursor(); - SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0); - SendMessage(hwndEdit,SCI_LINESJOIN,0,0); - EditJoinLinesEx(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_JOINLINESEX: - BeginWaitCursor(); - EditJoinLinesEx(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTUPPERCASE: - BeginWaitCursor(); - SendMessage(hwndEdit,SCI_UPPERCASE,0,0); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTLOWERCASE: - BeginWaitCursor(); - SendMessage(hwndEdit,SCI_LOWERCASE,0,0); - EndWaitCursor(); - break; - - - case IDM_EDIT_INVERTCASE: - BeginWaitCursor(); - EditInvertCase(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_TITLECASE: - BeginWaitCursor(); - EditTitleCase(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_SENTENCECASE: - BeginWaitCursor(); - EditSentenceCase(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTTABS: - BeginWaitCursor(); - EditTabsToSpaces(hwndEdit,iTabWidth,FALSE); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTSPACES: - BeginWaitCursor(); - EditSpacesToTabs(hwndEdit,iTabWidth,FALSE); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTTABS2: - BeginWaitCursor(); - EditTabsToSpaces(hwndEdit,iTabWidth,TRUE); - EndWaitCursor(); - break; - - - case IDM_EDIT_CONVERTSPACES2: - BeginWaitCursor(); - EditSpacesToTabs(hwndEdit,iTabWidth,TRUE); - EndWaitCursor(); - break; - - - case IDM_EDIT_INSERT_TAG: - { - WCHAR wszOpen[256] = L""; - WCHAR wszClose[256] = L""; - if (EditInsertTagDlg(hwnd,wszOpen,wszClose)) - EditEncloseSelection(hwndEdit,wszOpen,wszClose); - } - break; - - - case IDM_EDIT_INSERT_ENCODING: - { - if (*mEncoding[iEncoding].pszParseNames) { - char msz[32]; - char *p; - //int iSelStart; - lstrcpynA(msz,mEncoding[iEncoding].pszParseNames,COUNTOF(msz)); - if (p = StrChrA(msz,',')) - *p = 0; - //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz); - //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); - } - } - break; - - - case IDM_EDIT_INSERT_SHORTDATE: - case IDM_EDIT_INSERT_LONGDATE: - { - WCHAR tchDate[128]; - WCHAR tchTime[128]; - WCHAR tchDateTime[256]; - WCHAR tchTemplate[256]; - SYSTEMTIME st; - char mszBuf[MAX_PATH*3]; - UINT uCP; - //int iSelStart; - - GetLocalTime(&st); - - if (IniGetString(L"Settings2", - (LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? L"DateTimeShort" : L"DateTimeLong", - L"",tchTemplate,COUNTOF(tchTemplate))) { - struct tm sst; - sst.tm_isdst = -1; - sst.tm_sec = (int)st.wSecond; - sst.tm_min = (int)st.wMinute; - sst.tm_hour = (int)st.wHour; - sst.tm_mday = (int)st.wDay; - sst.tm_mon = (int)st.wMonth - 1; - sst.tm_year = (int)st.wYear - 1900; - sst.tm_wday = (int)st.wDayOfWeek; - mktime(&sst); - wcsftime(tchDateTime,COUNTOF(tchDateTime),tchTemplate,&sst); - } - else { - GetDateFormat(LOCALE_USER_DEFAULT,( - LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? DATE_SHORTDATE : DATE_LONGDATE, - &st,NULL,tchDate,COUNTOF(tchDate)); - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,tchTime,COUNTOF(tchTime)); - - wsprintf(tchDateTime,L"%s %s",tchTime,tchDate); - } - - uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; - WideCharToMultiByte(uCP,0,tchDateTime,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL); - //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); - //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); - } - break; - - - case IDM_EDIT_INSERT_FILENAME: - case IDM_EDIT_INSERT_PATHNAME: - { - SHFILEINFO shfi; - WCHAR *pszInsert; - WCHAR tchUntitled[32]; - char mszBuf[MAX_PATH*3]; - UINT uCP; - //int iSelStart; - - if (lstrlen(szCurFile)) { - if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) { - SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); - pszInsert = shfi.szDisplayName; - } - else - pszInsert = szCurFile; - } - - else { - GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); - pszInsert = tchUntitled; - } - - uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; - WideCharToMultiByte(uCP,0,pszInsert,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL); - //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); - //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); - } - break; - - - case IDM_EDIT_LINECOMMENT: - switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) { - case SCLEX_NULL: - case SCLEX_CSS: - case SCLEX_DIFF: - case SCLEX_MARKDOWN: - break; - case SCLEX_HTML: - case SCLEX_XML: - case SCLEX_CPP: - case SCLEX_PASCAL: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"//",FALSE); - EndWaitCursor(); - break; - case SCLEX_VBSCRIPT: - case SCLEX_VB: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"'",FALSE); - EndWaitCursor(); - break; - case SCLEX_MAKEFILE: - case SCLEX_PERL: - case SCLEX_PYTHON: - case SCLEX_CONF: - case SCLEX_BASH: - case SCLEX_TCL: - case SCLEX_RUBY: - case SCLEX_POWERSHELL: - case SCLEX_CMAKE: - case SCLEX_AVS: - case SCLEX_YAML: - case SCLEX_COFFEESCRIPT: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"#",TRUE); - EndWaitCursor(); - break; - case SCLEX_ASM: - case SCLEX_PROPERTIES: - case SCLEX_AU3: - case SCLEX_AHK: - case SCLEX_NSIS: // # could also be used instead - case SCLEX_INNOSETUP: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L";",TRUE); - EndWaitCursor(); - break; - case SCLEX_SQL: - case SCLEX_LUA: - case SCLEX_VHDL: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"--",TRUE); - EndWaitCursor(); - break; - case SCLEX_BATCH: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"rem ",TRUE); - EndWaitCursor(); - break; - case SCLEX_LATEX: - BeginWaitCursor(); - EditToggleLineComments(hwndEdit,L"%",TRUE); - EndWaitCursor(); - break; - } - break; - - - case IDM_EDIT_STREAMCOMMENT: - switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) { - case SCLEX_NULL: - case SCLEX_VBSCRIPT: - case SCLEX_MAKEFILE: - case SCLEX_VB: - case SCLEX_ASM: - case SCLEX_SQL: - case SCLEX_PERL: - case SCLEX_PYTHON: - case SCLEX_PROPERTIES: - case SCLEX_CONF: - case SCLEX_POWERSHELL: - case SCLEX_BATCH: - case SCLEX_DIFF: - case SCLEX_BASH: - case SCLEX_TCL: - case SCLEX_AU3: - case SCLEX_LATEX: - case SCLEX_AHK: - case SCLEX_RUBY: - case SCLEX_CMAKE: - case SCLEX_MARKDOWN: - case SCLEX_YAML: - break; - case SCLEX_HTML: - case SCLEX_XML: - case SCLEX_CSS: - case SCLEX_CPP: - case SCLEX_NSIS: - case SCLEX_AVS: - case SCLEX_VHDL: - EditEncloseSelection(hwndEdit,L"/*",L"*/"); - break; - case SCLEX_PASCAL: - case SCLEX_INNOSETUP: - EditEncloseSelection(hwndEdit,L"{",L"}"); - break; - case SCLEX_LUA: - EditEncloseSelection(hwndEdit,L"--[[",L"]]"); - break; - case SCLEX_COFFEESCRIPT: - EditEncloseSelection(hwndEdit,L"###",L"###"); - } - break; - - - case IDM_EDIT_URLENCODE: - BeginWaitCursor(); - EditURLEncode(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_URLDECODE: - BeginWaitCursor(); - EditURLDecode(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_ESCAPECCHARS: - BeginWaitCursor(); - EditEscapeCChars(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_UNESCAPECCHARS: - BeginWaitCursor(); - EditUnescapeCChars(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_CHAR2HEX: - BeginWaitCursor(); - EditChar2Hex(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_HEX2CHAR: - BeginWaitCursor(); - EditHex2Char(hwndEdit); - EndWaitCursor(); - break; - - - case IDM_EDIT_FINDMATCHINGBRACE: - { - int iBrace2 = -1; - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) - iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - // Try one before - else { - iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); - c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) - iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - } - if (iBrace2 != -1) - SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iBrace2,0); - } - break; - - - case IDM_EDIT_SELTOMATCHINGBRACE: - { - int iBrace2 = -1; - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) - iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - // Try one before - else { - iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); - c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) - iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - } - if (iBrace2 != -1) { - if (iBrace2 > iPos) - SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iBrace2+1); - else - SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos+1,(LPARAM)iBrace2); - } - } - break; - - - case IDM_EDIT_FIND: - if (!IsWindow(hDlgFindReplace)) - hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE); - else { - if (GetDlgItem(hDlgFindReplace,IDC_REPLACE)) { - SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOFIND,1),0); - DestroyWindow(hDlgFindReplace); - hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE); - } - else { - SetForegroundWindow(hDlgFindReplace); - PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1); - } - } - break; - - -#ifdef BOOKMARK_EDITION - // Main Bookmark Functions - //case IDM_EDIT_BOOKMARKNEXT: - case BME_EDIT_BOOKMARKNEXT: - { - int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); - int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); - - int bitmask = 1; - int iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERNEXT , iLine+1 , bitmask ); - if( iNextLine == -1 ) - { - iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERNEXT , 0 , bitmask ); - } - - if( iNextLine != -1 ) - { - SciCall_EnsureVisible(iNextLine); - SendMessage( hwndEdit , SCI_GOTOLINE , iNextLine , 0 ); - SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,10); - SciCall_ScrollCaret(); - SciCall_SetYCaretPolicy(CARET_EVEN,0); - } - break; - } - - //case IMD_EDIT_BOOKMARKPREV: - case BME_EDIT_BOOKMARKPREV: - { - int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); - int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); - - int bitmask = 1; - int iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); - if( iNextLine == -1 ) - { - int nLines = (int)SendMessage( hwndEdit , SCI_GETLINECOUNT , 0 , 0 ); - iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERPREVIOUS , nLines , bitmask ); - } - - if( iNextLine != -1 ) - { - SciCall_EnsureVisible(iNextLine); - SendMessage( hwndEdit , SCI_GOTOLINE , iNextLine , 0 ); - SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,10); - SciCall_ScrollCaret(); - SciCall_SetYCaretPolicy(CARET_EVEN,0); - } - - break; - } - - //case IDM_EDIT_BOOKMARKTOGGLE: - case BME_EDIT_BOOKMARKTOGGLE: - { - int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); - int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); - - int bitmask = (int)SendMessage( hwndEdit , SCI_MARKERGET , iLine , 0 ); - if( bitmask & 1 ) - { - // unset - SendMessage( hwndEdit , SCI_MARKERDELETE , iLine , 0 ); - } - else - { - - if( bShowSelectionMargin ) - { - SendMessage( hwndEdit , SCI_MARKERDEFINEPIXMAP , 0 , (LPARAM)bookmark_pixmap ); - } - else - { - SendMessage( hwndEdit , SCI_MARKERSETBACK , 0 , 0xff << 8 ); - SendMessage( hwndEdit , SCI_MARKERSETALPHA , 0 , 20); - SendMessage( hwndEdit , SCI_MARKERDEFINE , 0 , SC_MARK_BACKGROUND ); - } - - // set - SendMessage( hwndEdit , SCI_MARKERADD , iLine , 0 ); - } - - break; - } - - //case IDM_EDIT_BOOKMARKCLEAR: - case BME_EDIT_BOOKMARKCLEAR: - { - SendMessage( hwndEdit , SCI_MARKERDELETEALL , -1 , 0 ); - - break; - } -#endif - - - case IDM_EDIT_FINDNEXT: - case IDM_EDIT_FINDPREV: - case IDM_EDIT_REPLACENEXT: - case IDM_EDIT_SELTONEXT: - case IDM_EDIT_SELTOPREV: - - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) - break; - - if (!lstrlenA(efrData.szFind)) { - if (LOWORD(wParam) != IDM_EDIT_REPLACENEXT) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); - else - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); - } - - else { - - UINT cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); - if (cpLastFind != cp) { - if (cp != SC_CP_UTF8) { - - WCHAR wch[512]; - - MultiByteToWideChar(CP_UTF8,0,efrData.szFindUTF8,-1,wch,COUNTOF(wch)); - WideCharToMultiByte(cp,0,wch,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL); - - MultiByteToWideChar(CP_UTF8,0,efrData.szReplaceUTF8,-1,wch,COUNTOF(wch)); - WideCharToMultiByte(cp,0,wch,-1,efrData.szReplace,COUNTOF(efrData.szReplace),NULL,NULL); - } - else { - - lstrcpyA(efrData.szFind,efrData.szFindUTF8); - lstrcpyA(efrData.szReplace,efrData.szReplaceUTF8); - } - } - cpLastFind = cp; - switch (LOWORD(wParam)) { - - case IDM_EDIT_FINDNEXT: - EditFindNext(hwndEdit,&efrData,FALSE); - break; - - case IDM_EDIT_FINDPREV: - EditFindPrev(hwndEdit,&efrData,FALSE); - break; - - case IDM_EDIT_REPLACENEXT: - if (bReplaceInitialized) - EditReplace(hwndEdit,&efrData); - else - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); - break; - - case IDM_EDIT_SELTONEXT: - EditFindNext(hwndEdit,&efrData,TRUE); - break; - - case IDM_EDIT_SELTOPREV: - EditFindPrev(hwndEdit,&efrData,TRUE); - break; - } - } - break; - - case IDM_EDIT_COMPLETEWORD: - CompleteWord(hwndEdit, TRUE); - break; - - - case IDM_EDIT_REPLACE: - if (!IsWindow(hDlgFindReplace)) - hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE); - else { - if (!GetDlgItem(hDlgFindReplace,IDC_REPLACE)) { - SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOREPLACE,1),0); - DestroyWindow(hDlgFindReplace); - hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE); - } - else { - SetForegroundWindow(hDlgFindReplace); - PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1); - } - } - break; - - - case IDM_EDIT_GOTOLINE: - EditLinenumDlg(hwndEdit); - break; - - - case IDM_VIEW_SCHEME: - Style_SelectLexerDlg(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_USE2NDDEFAULT: - Style_ToggleUse2ndDefault(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_SCHEMECONFIG: - Style_ConfigDlg(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_FONT: - Style_SetDefaultFont(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_WORDWRAP: - fWordWrap = (fWordWrap) ? FALSE : TRUE; - if (!fWordWrap) - SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); - else - SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); - fWordWrapG = fWordWrap; - UpdateToolbar(); - break; - - - case IDM_VIEW_WORDWRAPSETTINGS: - if (WordWrapSettingsDlg(hwnd,IDD_WORDWRAP,&iWordWrapIndent)) - { - if (fWordWrap) - SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); - if (iWordWrapIndent == 5) - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0); - else if (iWordWrapIndent == 6) - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0); - else { - int i = 0; - switch (iWordWrapIndent) { - case 1: i = 1; break; - case 2: i = 2; break; - case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; - case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; - } - SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); - SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0); - } - if (bShowWordWrapSymbols) { - int wrapVisualFlags = 0; - int wrapVisualFlagsLocation = 0; - if (iWordWrapSymbols == 0) - iWordWrapSymbols = 22; - switch (iWordWrapSymbols%10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; - } - switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; - } - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); - } - else { - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); - } - } - break; - - - case IDM_VIEW_LONGLINEMARKER: - bMarkLongLines = (bMarkLongLines) ? FALSE: TRUE; - if (bMarkLongLines) { - SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); - Style_SetLongLineColors(hwndEdit); - } - else - SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); - UpdateStatusbar(); - break; - - - case IDM_VIEW_LONGLINESETTINGS: - if (LongLineSettingsDlg(hwnd,IDD_LONGLINES,&iLongLinesLimit)) { - bMarkLongLines = TRUE; - SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); - Style_SetLongLineColors(hwndEdit); - iLongLinesLimit = max(min(iLongLinesLimit,4096),0); - SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); - UpdateStatusbar(); - iLongLinesLimitG = iLongLinesLimit; - } - break; - - - case IDM_VIEW_TABSASSPACES: - bTabsAsSpaces = (bTabsAsSpaces) ? FALSE : TRUE; - SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); - bTabsAsSpacesG = bTabsAsSpaces; - break; - - - case IDM_VIEW_TABSETTINGS: - if (TabSettingsDlg(hwnd,IDD_TABSETTINGS,NULL)) - { - SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - SendMessage(hwndEdit,SCI_SETBACKSPACEUNINDENTS,bBackspaceUnindents,0); - iTabWidth = max(min(iTabWidth,256),1); - iIndentWidth = max(min(iIndentWidth,256),0); - SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0); - SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0); - bTabsAsSpacesG = bTabsAsSpaces; - bTabIndentsG = bTabIndents; - iTabWidthG = iTabWidth; - iIndentWidthG = iIndentWidth; - if (SendMessage(hwndEdit,SCI_GETWRAPINDENTMODE,0,0) == SC_WRAPINDENT_FIXED) { - int i = 0; - switch (iWordWrapIndent) { - case 1: i = 1; break; - case 2: i = 2; break; - case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; - case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; - } - SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); - } - } - break; - - - case IDM_VIEW_SHOWINDENTGUIDES: - bShowIndentGuides = (bShowIndentGuides) ? FALSE : TRUE; - Style_SetIndentGuides(hwndEdit,bShowIndentGuides); - break; - - - case IDM_VIEW_AUTOINDENTTEXT: - bAutoIndent = (bAutoIndent) ? FALSE : TRUE; - break; - - - case IDM_VIEW_LINENUMBERS: - bShowLineNumbers = (bShowLineNumbers) ? FALSE : TRUE; - UpdateLineNumberWidth(); - //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0, - // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)"_999999_"):0); - break; - - - case IDM_VIEW_MARGIN: - bShowSelectionMargin = (bShowSelectionMargin) ? FALSE : TRUE; - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0); - -#ifdef BOOKMARK_EDITION - //Depending on if the margin is visible or not, choose different bookmark indication - if( bShowSelectionMargin ) - { - SendMessage( hwndEdit , SCI_MARKERDEFINEPIXMAP , 0 , (LPARAM)bookmark_pixmap ); - } - else - { - SendMessage( hwndEdit , SCI_MARKERSETBACK , 0 , 0xff << 8 ); - SendMessage( hwndEdit , SCI_MARKERSETALPHA , 0 , 20); - SendMessage( hwndEdit , SCI_MARKERDEFINE , 0 , SC_MARK_BACKGROUND ); - } -#endif - - break; - - case IDM_VIEW_AUTOCOMPLETEWORDS: - if (bAutoCompleteWords) { - // close the autocompletion list - SendMessage(hwndEdit, SCI_AUTOCCANCEL, 0, 0); - bAutoCompleteWords = FALSE; - } - else { - bAutoCompleteWords = TRUE; - } - break; - - case IDM_VIEW_MARKOCCURRENCES_OFF: - iMarkOccurrences = 0; - // clear all marks - SendMessage(hwndEdit, SCI_SETINDICATORCURRENT, 1, 0); - SendMessage(hwndEdit, SCI_INDICATORCLEARRANGE, 0, (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); - break; - - case IDM_VIEW_MARKOCCURRENCES_RED: - iMarkOccurrences = 1; - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - break; - - case IDM_VIEW_MARKOCCURRENCES_GREEN: - iMarkOccurrences = 2; - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - break; - - case IDM_VIEW_MARKOCCURRENCES_BLUE: - iMarkOccurrences = 3; - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - break; - - case IDM_VIEW_MARKOCCURRENCES_CASE: - bMarkOccurrencesMatchCase = (bMarkOccurrencesMatchCase) ? FALSE : TRUE; - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - break; - - case IDM_VIEW_MARKOCCURRENCES_WORD: - bMarkOccurrencesMatchWords = (bMarkOccurrencesMatchWords) ? FALSE : TRUE; - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - break; - - case IDM_VIEW_FOLDING: - bShowCodeFolding = (bShowCodeFolding) ? FALSE : TRUE; - SciCall_SetMarginWidth(MARGIN_FOLD_INDEX, (bShowCodeFolding) ? 11 : 0); - UpdateToolbar(); - if (!bShowCodeFolding) - FoldToggleAll(EXPAND); - break; - - - case IDM_VIEW_TOGGLEFOLDS: - FoldToggleAll(SNIFF); - break; - - - case IDM_VIEW_SHOWWHITESPACE: - bViewWhiteSpace = (bViewWhiteSpace) ? FALSE : TRUE; - SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); - break; - - - case IDM_VIEW_SHOWEOLS: - bViewEOLs = (bViewEOLs) ? FALSE : TRUE; - SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); - break; - - - case IDM_VIEW_WORDWRAPSYMBOLS: - bShowWordWrapSymbols = (bShowWordWrapSymbols) ? 0 : 1; - if (bShowWordWrapSymbols) { - int wrapVisualFlags = 0; - int wrapVisualFlagsLocation = 0; - if (iWordWrapSymbols == 0) - iWordWrapSymbols = 22; - switch (iWordWrapSymbols%10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; - } - switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { - case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; - case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; - } - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); - } - else { - SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); - } - break; - - - case IDM_VIEW_MATCHBRACES: - bMatchBraces = (bMatchBraces) ? FALSE : TRUE; - if (bMatchBraces) { - struct SCNotification scn; - scn.nmhdr.hwndFrom = hwndEdit; - scn.nmhdr.idFrom = IDC_EDIT; - scn.nmhdr.code = SCN_UPDATEUI; - scn.updated = SC_UPDATE_CONTENT; - SendMessage(hwnd,WM_NOTIFY,IDC_EDIT,(LPARAM)&scn); - } - else - SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1); - break; - - - case IDM_VIEW_AUTOCLOSETAGS: - bAutoCloseTags = (bAutoCloseTags) ? FALSE : TRUE; - break; - - - case IDM_VIEW_HILITECURRENTLINE: - bHiliteCurrentLine = (bHiliteCurrentLine) ? FALSE : TRUE; - Style_SetCurrentLineBackground(hwndEdit); - break; - - - case IDM_VIEW_ZOOMIN: - SendMessage(hwndEdit,SCI_ZOOMIN,0,0); - //UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_ZOOMOUT: - SendMessage(hwndEdit,SCI_ZOOMOUT,0,0); - //UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_RESETZOOM: - SendMessage(hwndEdit,SCI_SETZOOM,0,0); - //UpdateLineNumberWidth(); - break; - - - case IDM_VIEW_TOOLBAR: - if (bShowToolbar) { - bShowToolbar = 0; - ShowWindow(hwndReBar,SW_HIDE); - } - else { - bShowToolbar = 1; - UpdateToolbar(); - ShowWindow(hwndReBar,SW_SHOW); - } - SendWMSize(hwnd); - break; - - - case IDM_VIEW_CUSTOMIZETB: - SendMessage(hwndToolbar,TB_CUSTOMIZE,0,0); - break; - - - case IDM_VIEW_STATUSBAR: - if (bShowStatusbar) { - bShowStatusbar = 0; - ShowWindow(hwndStatus,SW_HIDE); - } - else { - bShowStatusbar = 1; - UpdateStatusbar(); - ShowWindow(hwndStatus,SW_SHOW); - } - SendWMSize(hwnd); - break; - - - case IDM_VIEW_STICKYWINPOS: - bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",bStickyWinPos); - if (!bStickyWinPos) { - WINDOWPLACEMENT wndpl; - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; - - int ResX = GetSystemMetrics(SM_CXSCREEN); - int ResY = GetSystemMetrics(SM_CYSCREEN); - - // GetWindowPlacement - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hwndMain,&wndpl); - - wi.x = wndpl.rcNormalPosition.left; - wi.y = wndpl.rcNormalPosition.top; - wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; - wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; - wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); - - wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); - wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); - wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); - wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); - wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); - - bStickyWinPos = 1; - IniSetInt(L"Settings2",L"StickyWindowPosition",1); - - IniSetInt(L"Window",tchPosX,wi.x); - IniSetInt(L"Window",tchPosY,wi.y); - IniSetInt(L"Window",tchSizeX,wi.cx); - IniSetInt(L"Window",tchSizeY,wi.cy); - IniSetInt(L"Window",tchMaximized,wi.max); - - InfoBox(0,L"MsgStickyWinPos",IDS_STICKYWINPOS); - } - else { - bStickyWinPos = 0; - IniSetInt(L"Settings2",L"StickyWindowPosition",0); - } - break; - - - case IDM_VIEW_REUSEWINDOW: - if (IniGetInt(L"Settings2",L"ReuseWindow",0)) - IniSetInt(L"Settings2",L"ReuseWindow",0); - else - IniSetInt(L"Settings2",L"ReuseWindow",1); - break; - - - case IDM_VIEW_SINGLEFILEINSTANCE: - if (IniGetInt(L"Settings2",L"SingleFileInstance",0)) - IniSetInt(L"Settings2",L"SingleFileInstance",0); - else - IniSetInt(L"Settings2",L"SingleFileInstance",1); - break; - - - case IDM_VIEW_ALWAYSONTOP: - if ((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1) { - bAlwaysOnTop = 0; - flagAlwaysOnTop = 0; - SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); - } - else { - bAlwaysOnTop = 1; - flagAlwaysOnTop = 0; - SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); - } - break; - - - case IDM_VIEW_MINTOTRAY: - bMinimizeToTray =(bMinimizeToTray) ? FALSE : TRUE; - break; - - - case IDM_VIEW_TRANSPARENT: - bTransparentMode =(bTransparentMode) ? FALSE : TRUE; - SetWindowTransparentMode(hwnd,bTransparentMode); - break; - - - case IDM_VIEW_SHOWFILENAMEONLY: - iPathNameFormat = 0; - lstrcpy(szTitleExcerpt,L""); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - - case IDM_VIEW_SHOWFILENAMEFIRST: - iPathNameFormat = 1; - lstrcpy(szTitleExcerpt,L""); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - - case IDM_VIEW_SHOWFULLPATH: - iPathNameFormat = 2; - lstrcpy(szTitleExcerpt,L""); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - - case IDM_VIEW_SHOWEXCERPT: - EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - - case IDM_VIEW_NOSAVERECENT: - bSaveRecentFiles = (bSaveRecentFiles) ? FALSE : TRUE; - break; - - - case IDM_VIEW_NOSAVEFINDREPL: - bSaveFindReplace = (bSaveFindReplace) ? FALSE : TRUE; - break; - - - case IDM_VIEW_SAVEBEFORERUNNINGTOOLS: - bSaveBeforeRunningTools = (bSaveBeforeRunningTools) ? FALSE : TRUE; - break; - - - case IDM_VIEW_CHANGENOTIFY: - if (ChangeNotifyDlg(hwnd)) - InstallFileWatching(szCurFile); - break; - - - case IDM_VIEW_NOESCFUNC: - iEscFunction = 0; - break; - - - case IDM_VIEW_ESCMINIMIZE: - iEscFunction = 1; - break; - - - case IDM_VIEW_ESCEXIT: - iEscFunction = 2; - break; - - - case IDM_VIEW_SAVESETTINGS: - bSaveSettings = (bSaveSettings) ? FALSE : TRUE; - break; - - - case IDM_VIEW_SAVESETTINGSNOW: - { - BOOL bCreateFailure = FALSE; - - if (lstrlen(szIniFile) == 0) { - - if (lstrlen(szIniFile2) > 0) { - if (CreateIniFileEx(szIniFile2)) { - lstrcpy(szIniFile,szIniFile2); - lstrcpy(szIniFile2,L""); - } - else - bCreateFailure = TRUE; - } - - else - break; - } - - if (!bCreateFailure) { - - if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",szIniFile)) { - - BeginWaitCursor(); - StatusSetTextID(hwndStatus,STATUS_HELP,IDS_SAVINGSETTINGS); - StatusSetSimple(hwndStatus,TRUE); - InvalidateRect(hwndStatus,NULL,TRUE); - UpdateWindow(hwndStatus); - SaveSettings(TRUE); - StatusSetSimple(hwndStatus,FALSE); - EndWaitCursor(); - MsgBox(MBINFO,IDS_SAVEDSETTINGS); - } - else { - dwLastIOError = GetLastError(); - MsgBox(MBWARN,IDS_WRITEINI_FAIL); - } - } - else - MsgBox(MBWARN,IDS_CREATEINI_FAIL); - } - break; - - - case IDM_HELP_ABOUT: - ThemedDialogBox(g_hInstance,MAKEINTRESOURCE(IDD_ABOUT), - hwnd,AboutDlgProc); - break; - - - case IDM_CMDLINE_HELP: - DisplayCmdLineHelp(hwnd); - break; - - - case CMD_ESCAPE: - //close the autocomplete box - SendMessage(hwndEdit,SCI_AUTOCCANCEL,0, 0); - - if (iEscFunction == 1) - SendMessage(hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0); - else if (iEscFunction == 2) - SendMessage(hwnd,WM_CLOSE,0,0); - break; - - - case CMD_SHIFTESC: - if (FileSave(TRUE,FALSE,FALSE,FALSE)) - SendMessage(hwnd,WM_CLOSE,0,0); - break; - - - // Newline with toggled auto indent setting - case CMD_CTRLENTER: - bAutoIndent = (bAutoIndent) ? 0 : 1; - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - bAutoIndent = (bAutoIndent) ? 0 : 1; - break; - - - case CMD_CTRLBACK: - { - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0); - int iStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - int iIndentPos = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); - - if (iPos != iAnchor) - SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos); - else { - if (iPos == iStartPos) - SendMessage(hwndEdit,SCI_DELETEBACK,0,0); - else if (iPos <= iIndentPos) - SendMessage(hwndEdit,SCI_DELLINELEFT,0,0); - else - SendMessage(hwndEdit,SCI_DELWORDLEFT,0,0); - } - } - break; - - - case CMD_CTRLDEL: - { - int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0); - int iStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); - int iEndPos = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); - - if (iPos != iAnchor) - SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos); - else { - if (iStartPos != iEndPos) - SendMessage(hwndEdit,SCI_DELWORDRIGHT,0,0); - else // iStartPos == iEndPos - SendMessage(hwndEdit,SCI_LINEDELETE,0,0); - } - } - break; - - - case CMD_CTRLTAB: - SendMessage(hwndEdit,SCI_SETTABINDENTS,FALSE,0); - SendMessage(hwndEdit,SCI_SETUSETABS,TRUE,0); - SendMessage(hwndEdit,SCI_TAB,0,0); - SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); - SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); - break; - - - case CMD_RECODEDEFAULT: - { - WCHAR tchCurFile2[MAX_PATH]; - if (lstrlen(szCurFile)) { - if (iDefaultEncoding == CPI_UNICODEBOM) - iSrcEncoding = CPI_UNICODE; - else if (iDefaultEncoding == CPI_UNICODEBEBOM) - iSrcEncoding = CPI_UNICODEBE; - else if (iDefaultEncoding == CPI_UTF8SIGN) - iSrcEncoding = CPI_UTF8; - else - iSrcEncoding = iDefaultEncoding; - lstrcpy(tchCurFile2,szCurFile); - FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); - } - } - break; - - - case CMD_RELOADANSI: - { - WCHAR tchCurFile2[MAX_PATH]; - if (lstrlen(szCurFile)) { - iSrcEncoding = CPI_DEFAULT; - lstrcpy(tchCurFile2,szCurFile); - FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); - } - } - break; - - - case CMD_RELOADOEM: - { - WCHAR tchCurFile2[MAX_PATH]; - if (lstrlen(szCurFile)) { - iSrcEncoding = CPI_OEM; - lstrcpy(tchCurFile2,szCurFile); - FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); - } - } - break; - - - case CMD_RELOADASCIIASUTF8: - { - WCHAR tchCurFile2[MAX_PATH]; - BOOL _bLoadASCIIasUTF8 = bLoadASCIIasUTF8; - if (lstrlen(szCurFile)) { - bLoadASCIIasUTF8 = 1; - lstrcpy(tchCurFile2,szCurFile); - FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); - bLoadASCIIasUTF8 = _bLoadASCIIasUTF8; - } - } - break; - - - case CMD_RELOADNOFILEVARS: - { - WCHAR tchCurFile2[MAX_PATH]; - if (lstrlen(szCurFile)) { - int _fNoFileVariables = fNoFileVariables; - BOOL _bNoEncodingTags = bNoEncodingTags; - fNoFileVariables = 1; - bNoEncodingTags = 1; - lstrcpy(tchCurFile2,szCurFile); - FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); - fNoFileVariables = _fNoFileVariables; - bNoEncodingTags = _bNoEncodingTags; - } - } - break; - - - case CMD_LEXDEFAULT: - Style_SetDefaultLexer(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case CMD_LEXHTML: - Style_SetHTMLLexer(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case CMD_LEXXML: - Style_SetXMLLexer(hwndEdit); - UpdateStatusbar(); - UpdateLineNumberWidth(); - break; - - - case CMD_TIMESTAMPS: - { - WCHAR wchFind[256] = {0}; - WCHAR wchTemplate[256] = {0}; - WCHAR *pwchSep; - WCHAR wchReplace[256]; - - SYSTEMTIME st; - struct tm sst; - - UINT cp; - EDITFINDREPLACE efrTS = { "", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwndEdit }; - - IniGetString(L"Settings2",L"TimeStamp",L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $",wchFind,COUNTOF(wchFind)); - - if (pwchSep = StrChr(wchFind,L'|')) { - lstrcpy(wchTemplate,pwchSep+1); - *pwchSep = 0; - } - - StrTrim(wchFind,L" "); - StrTrim(wchTemplate,L" "); - - if (lstrlen(wchFind) == 0 || lstrlen(wchTemplate) == 0) - break; - - GetLocalTime(&st); - sst.tm_isdst = -1; - sst.tm_sec = (int)st.wSecond; - sst.tm_min = (int)st.wMinute; - sst.tm_hour = (int)st.wHour; - sst.tm_mday = (int)st.wDay; - sst.tm_mon = (int)st.wMonth - 1; - sst.tm_year = (int)st.wYear - 1900; - sst.tm_wday = (int)st.wDayOfWeek; - mktime(&sst); - wcsftime(wchReplace,COUNTOF(wchReplace),wchTemplate,&sst); - - cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); - WideCharToMultiByte(cp,0,wchFind,-1,efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL); - WideCharToMultiByte(cp,0,wchReplace,-1,efrTS.szReplace,COUNTOF(efrTS.szReplace),NULL,NULL); - - if (SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) != - SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0)) - EditReplaceAllInSelection(hwndEdit,&efrTS,TRUE); - else - EditReplaceAll(hwndEdit,&efrTS,TRUE); - } - break; - - - case CMD_WEBACTION1: - case CMD_WEBACTION2: - { - BOOL bCmdEnabled; - LPWSTR lpszTemplateName; - WCHAR szCmdTemplate[256]; - char mszSelection[512] = { 0 }; - DWORD cchSelection; - char *lpsz; - LPWSTR lpszCommand; - LPWSTR lpszArgs; - SHELLEXECUTEINFO sei; - WCHAR wchDirectory[MAX_PATH] = L""; - - lpszTemplateName = (LOWORD(wParam) == CMD_WEBACTION1) ? L"WebTemplate1" : L"WebTemplate2"; - - bCmdEnabled = IniGetString(L"Settings2",lpszTemplateName,L"",szCmdTemplate,COUNTOF(szCmdTemplate)); - - if (bCmdEnabled) { - - cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - - if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < COUNTOF(mszSelection)) - { - SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection); - mszSelection[cchSelection] = 0; // zero terminate - - // Check lpszSelection and truncate bad WCHARs - lpsz = StrChrA(mszSelection,13); - if (lpsz) *lpsz = '\0'; - - lpsz = StrChrA(mszSelection,10); - if (lpsz) *lpsz = '\0'; - - lpsz = StrChrA(mszSelection,9); - if (lpsz) *lpsz = '\0'; - - if (lstrlenA(mszSelection)) { - - WCHAR wszSelection[512]; - UINT uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; - MultiByteToWideChar(uCP,0,mszSelection,-1,wszSelection,COUNTOF(wszSelection)); - - lpszCommand = GlobalAlloc(GPTR,sizeof(WCHAR)*(512+COUNTOF(szCmdTemplate)+MAX_PATH+32)); - wsprintf(lpszCommand,szCmdTemplate,wszSelection); - ExpandEnvironmentStringsEx(lpszCommand,(DWORD)GlobalSize(lpszCommand)/sizeof(WCHAR)); - - lpszArgs = GlobalAlloc(GPTR,GlobalSize(lpszCommand)); - ExtractFirstArgument(lpszCommand,lpszCommand,lpszArgs); - - if (lstrlen(szCurFile)) { - lstrcpy(wchDirectory,szCurFile); - PathRemoveFileSpec(wchDirectory); - } - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000; - sei.hwnd = NULL; - sei.lpVerb = NULL; - sei.lpFile = lpszCommand; - sei.lpParameters = lpszArgs; - sei.lpDirectory = wchDirectory; - sei.nShow = SW_SHOWNORMAL; - - ShellExecuteEx(&sei); - - GlobalFree(lpszCommand); - GlobalFree(lpszArgs); - } - } - } - } - break; - - - case CMD_FINDNEXTSEL: - case CMD_FINDPREVSEL: - case IDM_EDIT_SAVEFIND: - { - int cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - - if (cchSelection == 0) - { - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_SELECTWORD,1),0); - cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - } - - if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < 512) - { - char mszSelection[512]; - char *lpsz; - - SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection); - mszSelection[cchSelection] = 0; // zero terminate - - // Check lpszSelection and truncate newlines - lpsz = StrChrA(mszSelection,'\n'); - if (lpsz) *lpsz = '\0'; - - lpsz = StrChrA(mszSelection,'\r'); - if (lpsz) *lpsz = '\0'; - - cpLastFind = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); - lstrcpyA(efrData.szFind,mszSelection); - - if (cpLastFind != SC_CP_UTF8) - { - WCHAR wszBuf[512]; - - MultiByteToWideChar(cpLastFind,0,mszSelection,-1,wszBuf,COUNTOF(wszBuf)); - WideCharToMultiByte(CP_UTF8,0,wszBuf,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL); - } - else - lstrcpyA(efrData.szFindUTF8,mszSelection); - - efrData.fuFlags &= (~(SCFIND_REGEXP|SCFIND_POSIX)); - efrData.bTransformBS = FALSE; - - switch (LOWORD(wParam)) { - - case IDM_EDIT_SAVEFIND: - break; - - case CMD_FINDNEXTSEL: - EditFindNext(hwndEdit,&efrData,FALSE); - break; - - case CMD_FINDPREVSEL: - EditFindPrev(hwndEdit,&efrData,FALSE); - break; - } - } - } - break; - - - case CMD_INCLINELIMIT: - case CMD_DECLINELIMIT: - if (!bMarkLongLines) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_LONGLINEMARKER,1),0); - else { - if (LOWORD(wParam) == CMD_INCLINELIMIT) - iLongLinesLimit++; - else - iLongLinesLimit--; - iLongLinesLimit = max(min(iLongLinesLimit,4096),0); - SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); - UpdateStatusbar(); - iLongLinesLimitG = iLongLinesLimit; - } - break; - - - case CMD_STRINGIFY: - EditEncloseSelection(hwndEdit,L"'",L"'"); - break; - - - case CMD_STRINGIFY2: - EditEncloseSelection(hwndEdit,L"\"",L"\""); - break; - - - case CMD_EMBRACE: - EditEncloseSelection(hwndEdit,L"(",L")"); - break; - - - case CMD_EMBRACE2: - EditEncloseSelection(hwndEdit,L"[",L"]"); - break; - - - case CMD_EMBRACE3: - EditEncloseSelection(hwndEdit,L"{",L"}"); - break; - - - case CMD_EMBRACE4: - EditEncloseSelection(hwndEdit,L"`",L"`"); - break; - - - case CMD_INCREASENUM: - EditModifyNumber(hwndEdit,TRUE); - break; - - - case CMD_DECREASENUM: - EditModifyNumber(hwndEdit,FALSE); - break; - - - case CMD_TOGGLETITLE: - EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - - case CMD_JUMP2SELSTART: - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iCursorPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - if (iCursorPos > iAnchorPos) { - SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos); - SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); - } - } - break; - - - case CMD_JUMP2SELEND: - if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iCursorPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - if (iCursorPos < iAnchorPos) { - SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos); - SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); - } - } - break; - - - case CMD_COPYPATHNAME: { - - WCHAR *pszCopy; - WCHAR tchUntitled[32]; - if (lstrlen(szCurFile)) - pszCopy = szCurFile; - else { - GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); - pszCopy = tchUntitled; - } - - if (OpenClipboard(hwnd)) { - HANDLE hData; - WCHAR *pData; - EmptyClipboard(); - hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (lstrlen(pszCopy) + 1)); - pData = GlobalLock(hData); - StrCpyN(pData,pszCopy,(int)GlobalSize(hData) / sizeof(WCHAR)); - GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT,hData); - CloseClipboard(); - } - } - break; - - - case CMD_COPYWINPOS: { - - WCHAR wszWinPos[256]; - WINDOWPLACEMENT wndpl; - int x, y, cx, cy, max; - - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hwndMain,&wndpl); - - x = wndpl.rcNormalPosition.left; - y = wndpl.rcNormalPosition.top; - cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; - cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; - max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); - - wsprintf(wszWinPos,L"/pos %i,%i,%i,%i,%i",x,y,cx,cy,max); - - if (OpenClipboard(hwnd)) { - HANDLE hData; - WCHAR *pData; - EmptyClipboard(); - hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (lstrlen(wszWinPos) + 1)); - pData = GlobalLock(hData); - StrCpyN(pData,wszWinPos,(int)GlobalSize(hData) / sizeof(WCHAR)); - GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT,hData); - CloseClipboard(); - } - - UpdateToolbar(); - } - break; - - - case CMD_DEFAULTWINPOS: - SnapToDefaultPos(hwnd); - break; - - - case CMD_OPENINIFILE: - if (lstrlen(szIniFile)) { - CreateIniFile(); - FileLoad(FALSE,FALSE,FALSE,FALSE,szIniFile); - } - break; - - - case IDT_FILE_NEW: - if (IsCmdEnabled(hwnd,IDM_FILE_NEW)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_NEW,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_OPEN: - if (IsCmdEnabled(hwnd,IDM_FILE_OPEN)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPEN,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_BROWSE: - if (IsCmdEnabled(hwnd,IDM_FILE_BROWSE)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_BROWSE,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_SAVE: - if (IsCmdEnabled(hwnd,IDM_FILE_SAVE)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVE,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_UNDO: - if (IsCmdEnabled(hwnd,IDM_EDIT_UNDO)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_UNDO,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_REDO: - if (IsCmdEnabled(hwnd,IDM_EDIT_REDO)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REDO,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_CUT: - if (IsCmdEnabled(hwnd,IDM_EDIT_CUT)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUT,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_COPY: - if (IsCmdEnabled(hwnd,IDM_EDIT_COPY)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPY,1),0); - else - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPYALL,1),0); - break; - - - case IDT_EDIT_PASTE: - if (IsCmdEnabled(hwnd,IDM_EDIT_PASTE)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_PASTE,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_FIND: - if (IsCmdEnabled(hwnd,IDM_EDIT_FIND)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_REPLACE: - if (IsCmdEnabled(hwnd,IDM_EDIT_REPLACE)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_WORDWRAP: - if (IsCmdEnabled(hwnd,IDM_VIEW_WORDWRAP)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_WORDWRAP,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_ZOOMIN: - if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMIN)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMIN,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_ZOOMOUT: - if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMOUT)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMOUT,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_SCHEME: - if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEME)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_SCHEMECONFIG: - if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEMECONFIG)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEMECONFIG,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_EXIT: - SendMessage(hwnd,WM_CLOSE,0,0); - break; - - - case IDT_FILE_SAVEAS: - if (IsCmdEnabled(hwnd,IDM_FILE_SAVEAS)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVEAS,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_SAVECOPY: - if (IsCmdEnabled(hwnd,IDM_FILE_SAVECOPY)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVECOPY,1),0); - else - MessageBeep(0); - break; - - - case IDT_EDIT_CLEAR: - if (IsCmdEnabled(hwnd,IDM_EDIT_CLEAR)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEAR,1),0); - else - SendMessage(hwndEdit,SCI_CLEARALL,0,0); - break; - - - case IDT_FILE_PRINT: - if (IsCmdEnabled(hwnd,IDM_FILE_PRINT)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_PRINT,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_OPENFAV: - if (IsCmdEnabled(hwnd,IDM_FILE_OPENFAV)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPENFAV,1),0); - else - MessageBeep(0); - break; - - - case IDT_FILE_ADDTOFAV: - if (IsCmdEnabled(hwnd,IDM_FILE_ADDTOFAV)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_ADDTOFAV,1),0); - else - MessageBeep(0); - break; - - - case IDT_VIEW_TOGGLEFOLDS: - if (IsCmdEnabled(hwnd,IDM_VIEW_TOGGLEFOLDS)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_TOGGLEFOLDS,1),0); - else - MessageBeep(0); - break; - - case IDT_FILE_LAUNCH: - if (IsCmdEnabled(hwnd,IDM_FILE_LAUNCH)) - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_LAUNCH,1),0); - else - MessageBeep(0); - break; - - } - - return(0); - -} - - -//============================================================================= -// -// MsgNotify() - Handles WM_NOTIFY -// -// -LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) -{ - - LPNMHDR pnmh = (LPNMHDR)lParam; - struct SCNotification* scn = (struct SCNotification*)lParam; - - switch(pnmh->idFrom) - { - - case IDC_EDIT: - - switch(pnmh->code) - { - case SCN_UPDATEUI: - - if (scn->updated & ~(SC_UPDATE_V_SCROLL | SC_UPDATE_H_SCROLL)) { - - UpdateToolbar(); - UpdateStatusbar(); - - // Invalidate invalid selections - // #pragma message("TODO: Remove check for invalid selections once fixed in Scintilla") - if (SendMessage(hwndEdit,SCI_GETSELECTIONS,0,0) > 1 && - SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0) != SC_SEL_RECTANGLE) { - int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - SendMessage(hwndEdit,WM_CANCELMODE,0,0); - SendMessage(hwndEdit,SCI_CLEARSELECTIONS,0,0); - SendMessage(hwndEdit,SCI_SETSELECTION,(WPARAM)iCurPos,(LPARAM)iCurPos); - } - - // mark occurrences of text currently selected - EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); - - // Brace Match - if (bMatchBraces) - { - int iPos; - char c; - - int iEndStyled = (int)SendMessage(hwndEdit,SCI_GETENDSTYLED,0,0); - if (iEndStyled < (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) { - int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iEndStyled,0); - int iEndStyled = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLine,0); - SendMessage(hwndEdit,SCI_COLOURISE,iEndStyled,-1); - } - - iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) { - int iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - if (iBrace2 != -1) { - int col1 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0); - int col2 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0); - SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2); - SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0); - } - else { - SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0); - SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); - } - } - // Try one before - else - { - iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); - c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); - if (StrChrA("()[]{}",c)) { - int iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); - if (iBrace2 != -1) { - int col1 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0); - int col2 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0); - SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2); - SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0); - } - else { - SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0); - SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); - } - } - else { - SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1); - SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); - } - } - } - } - break; - - case SCN_CHARADDED: - // Auto indent - if (bAutoIndent && (scn->ch == '\x0D' || scn->ch == '\x0A')) - { - // in CRLF mode handle LF only... - if ((SC_EOL_CRLF == iEOLMode && scn->ch != '\x0A') || SC_EOL_CRLF != iEOLMode) - { - char *pLineBuf; - char *pPos; - //int iIndentLen; - - int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - //int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); - int iCurLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); - //int iLineLength = (int)SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine,0); - //int iIndentBefore = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine-1,0); - -#ifdef BOOKMARK_EDITION - // Move bookmark along with line if inserting lines (pressing return at beginning of line) because Scintilla does not do this for us - if( iCurLine > 0 ) - { - int iPrevLineLength = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iCurLine-1,0) - (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iCurLine-1,0) ; - if( iPrevLineLength == 0 ) - { - int bitmask = (int)SendMessage( hwndEdit , SCI_MARKERGET , iCurLine-1 , 0 ); - if( bitmask & 1 ) - { - SendMessage( hwndEdit , SCI_MARKERDELETE , iCurLine-1 , 0 ); - SendMessage( hwndEdit , SCI_MARKERADD , iCurLine , 0 ); - } - } - } -#endif - - if (iCurLine > 0/* && iLineLength <= 2*/) - { - int iPrevLineLength = (int)SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine-1,0); - if (pLineBuf = GlobalAlloc(GPTR,iPrevLineLength+1)) - { - SendMessage(hwndEdit,SCI_GETLINE,iCurLine-1,(LPARAM)pLineBuf); - *(pLineBuf+iPrevLineLength) = '\0'; - for (pPos = pLineBuf; *pPos; pPos++) { - if (*pPos != ' ' && *pPos != '\t') - *pPos = '\0'; - } - if (*pLineBuf) { - //int iPrevLineStartPos; - //int iPrevLineEndPos; - //int iPrevLineIndentPos; - - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwndEdit,SCI_ADDTEXT,lstrlenA(pLineBuf),(LPARAM)pLineBuf); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - - //iPrevLineStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0); - //iPrevLineEndPos = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iCurLine-1,0); - //iPrevLineIndentPos = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iCurLine-1,0); - - //if (iPrevLineEndPos == iPrevLineIndentPos) { - // SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - // SendMessage(hwndEdit,SCI_SETTARGETSTART,(WPARAM)iPrevLineStartPos,0); - // SendMessage(hwndEdit,SCI_SETTARGETEND,(WPARAM)iPrevLineEndPos,0); - // SendMessage(hwndEdit,SCI_REPLACETARGET,0,(LPARAM)""); - // SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - //} - } - GlobalFree(pLineBuf); - //int iIndent = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0); - //SendMessage(hwndEdit,SCI_SETLINEINDENTATION,(WPARAM)iCurLine,(LPARAM)iIndentBefore); - //iIndentLen = /*- iIndent +*/ SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0); - //if (iIndentLen > 0) - // SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iAnchorPos+iIndentLen,(LPARAM)iCurPos+iIndentLen); - } - } - } - } - // Auto close tags - else if (bAutoCloseTags && scn->ch == '>') - { - //int iLexer = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); - if (/*iLexer == SCLEX_HTML || iLexer == SCLEX_XML*/ 1) - { - char tchBuf[512] = { 0 }; - char tchIns[516] = "= 3) { - - struct Sci_TextRange tr = { { iStartPos, iCurPos }, tchBuf }; - SendMessage(hwndEdit,SCI_GETTEXTRANGE,0,(LPARAM)&tr); - - if (tchBuf[iSize - 2] != '/') { - - const char* pBegin = &tchBuf[0]; - const char* pCur = &tchBuf[iSize - 2]; - - while (pCur > pBegin && *pCur != '<' && *pCur != '>') - --pCur; - - if (*pCur == '<') { - pCur++; - while (StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) { - tchIns[cchIns++] = *pCur; - pCur++; - } - } - - tchIns[cchIns++] = '>'; - tchIns[cchIns] = 0; - - if (cchIns > 3 && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"
") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"") && - lstrcmpiA(tchIns,"")) - { - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)tchIns); - SendMessage(hwndEdit,SCI_SETSEL,iCurPos,iCurPos); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - } - } - } - } - } - else if (bAutoCompleteWords && !SendMessage(hwndEdit, SCI_AUTOCACTIVE, 0, 0)) - CompleteWord(hwndEdit, FALSE); - break; - - case SCN_MODIFIED: - case SCN_ZOOM: - UpdateLineNumberWidth(); - break; - - case SCN_SAVEPOINTREACHED: - bModified = FALSE; - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - - case SCN_MARGINCLICK: - if (scn->margin == MARGIN_FOLD_INDEX) - FoldClick(SciCall_LineFromPosition(scn->position), scn->modifiers); - break; - - case SCN_KEY: - // Also see the corresponding patch in scintilla\src\Editor.cxx - FoldAltArrow(scn->ch, scn->modifiers); - break; - - case SCN_SAVEPOINTLEFT: - bModified = TRUE; - SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - break; - } - break; - - - case IDC_TOOLBAR: - - switch(pnmh->code) - { - - case TBN_ENDADJUST: - UpdateToolbar(); - break; - - case TBN_QUERYDELETE: - case TBN_QUERYINSERT: - return TRUE; - - case TBN_GETBUTTONINFO: - { - if (((LPTBNOTIFY)lParam)->iItem < COUNTOF(tbbMainWnd)) - { - WCHAR tch[256]; - GetString(tbbMainWnd[((LPTBNOTIFY)lParam)->iItem].idCommand,tch,COUNTOF(tch)); - lstrcpyn(((LPTBNOTIFY)lParam)->pszText,/*StrChr(tch,L'\n')+1*/tch,((LPTBNOTIFY)lParam)->cchText); - CopyMemory(&((LPTBNOTIFY)lParam)->tbButton,&tbbMainWnd[((LPTBNOTIFY)lParam)->iItem],sizeof(TBBUTTON)); - return TRUE; - } - } - return FALSE; - - case TBN_RESET: - { - int i; int c = (int)SendMessage(hwndToolbar,TB_BUTTONCOUNT,0,0); - for (i = 0; i < c; i++) - SendMessage(hwndToolbar,TB_DELETEBUTTON,0,0); - SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); - return(0); - } - - } - break; - - - case IDC_STATUSBAR: - - switch(pnmh->code) - { - - case NM_CLICK: - { - LPNMMOUSE pnmm = (LPNMMOUSE)lParam; - - switch (pnmm->dwItemSpec) - { - case STATUS_EOLMODE: - SendMessage(hwndEdit,SCI_CONVERTEOLS,SendMessage(hwndEdit,SCI_GETEOLMODE,0,0),0); - EditFixPositions(hwndEdit); - return TRUE; - - default: - return FALSE; - } - } - - case NM_DBLCLK: - { - int i; - LPNMMOUSE pnmm = (LPNMMOUSE)lParam; - - switch (pnmm->dwItemSpec) - { - case STATUS_CODEPAGE: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_ENCODING_SELECT,1),0); - return TRUE; - - case STATUS_EOLMODE: - if (iEOLMode == SC_EOL_CRLF) - i = IDM_LINEENDINGS_CRLF; - else if (iEOLMode == SC_EOL_LF) - i = IDM_LINEENDINGS_LF; - else - i = IDM_LINEENDINGS_CR; - i++; - if (i > IDM_LINEENDINGS_CR) - i = IDM_LINEENDINGS_CRLF; - SendMessage(hwnd,WM_COMMAND,MAKELONG(i,1),0); - return TRUE; - - case STATUS_LEXER: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0); - return TRUE; - - case STATUS_OVRMODE: - SendMessage(hwndEdit,SCI_EDITTOGGLEOVERTYPE,0,0); - return TRUE; - - default: - return FALSE; - } - } - break; - - } - break; - - - default: - - switch(pnmh->code) - { - - case TTN_NEEDTEXT: - { - WCHAR tch[256]; - - if (((LPTOOLTIPTEXT)lParam)->uFlags & TTF_IDISHWND) - { - ; - } - - else - { - GetString((UINT)pnmh->idFrom,tch,COUNTOF(tch)); - lstrcpyn(((LPTOOLTIPTEXT)lParam)->szText,/*StrChr(tch,L'\n')+1*/tch,80); - } - } - break; - - } - break; - - } - - - return(0); - -} - - -//============================================================================= -// -// LoadSettings() -// -// -void LoadSettings() -{ - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - LoadIniSection(L"Settings",pIniSection,cchIniSection); - - bSaveSettings = - IniSectionGetInt(pIniSection,L"SaveSettings",1); - if (bSaveSettings) bSaveSettings = 1; - - bSaveRecentFiles = - IniSectionGetInt(pIniSection,L"SaveRecentFiles",0); - if (bSaveRecentFiles) bSaveRecentFiles = 1; - - bSaveFindReplace = - IniSectionGetInt(pIniSection,L"SaveFindReplace",0); - if (bSaveFindReplace) bSaveFindReplace = 1; - - efrData.bFindClose = IniSectionGetInt(pIniSection,L"CloseFind",0); - if (efrData.bFindClose) efrData.bReplaceClose = TRUE; - - efrData.bReplaceClose = IniSectionGetInt(pIniSection,L"CloseReplace",0); - if (efrData.bReplaceClose) efrData.bReplaceClose = TRUE; - - efrData.bNoFindWrap = IniSectionGetInt(pIniSection,L"NoFindWrap",0); - if (efrData.bNoFindWrap) efrData.bNoFindWrap = TRUE; - - if (!IniSectionGetString(pIniSection,L"OpenWithDir",L"", - tchOpenWithDir,COUNTOF(tchOpenWithDir))) - SHGetSpecialFolderPath(NULL,tchOpenWithDir,CSIDL_DESKTOPDIRECTORY,TRUE); - else - PathAbsoluteFromApp(tchOpenWithDir,NULL,COUNTOF(tchOpenWithDir),TRUE); - - if (!IniSectionGetString(pIniSection,L"Favorites",L"", - tchFavoritesDir,COUNTOF(tchFavoritesDir))) - SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,tchFavoritesDir); - else - PathAbsoluteFromApp(tchFavoritesDir,NULL,COUNTOF(tchFavoritesDir),TRUE); - - iPathNameFormat = IniSectionGetInt(pIniSection,L"PathNameFormat",0); - iPathNameFormat = max(min(iPathNameFormat,2),0); - - fWordWrap = IniSectionGetInt(pIniSection,L"WordWrap",0); - if (fWordWrap) fWordWrap = 1; - fWordWrapG = fWordWrap; - - iWordWrapMode = IniSectionGetInt(pIniSection,L"WordWrapMode",0); - iWordWrapMode = max(min(iWordWrapMode,1),0); - - iWordWrapIndent = IniSectionGetInt(pIniSection,L"WordWrapIndent",0); - iWordWrapIndent = max(min(iWordWrapIndent,6),0); - - iWordWrapSymbols = IniSectionGetInt(pIniSection,L"WordWrapSymbols",22); - iWordWrapSymbols = max(min(iWordWrapSymbols%10,2),0)+max(min((iWordWrapSymbols%100-iWordWrapSymbols%10)/10,2),0)*10; - - bShowWordWrapSymbols = IniSectionGetInt(pIniSection,L"ShowWordWrapSymbols",0); - if (bShowWordWrapSymbols) bShowWordWrapSymbols = 1; - - bMatchBraces = IniSectionGetInt(pIniSection,L"MatchBraces",1); - if (bMatchBraces) bMatchBraces = 1; - - bAutoCloseTags = IniSectionGetInt(pIniSection,L"AutoCloseTags",0); - if (bAutoCloseTags) bAutoCloseTags = 1; - - bHiliteCurrentLine = IniSectionGetInt(pIniSection,L"HighlightCurrentLine",0); - if (bHiliteCurrentLine) bHiliteCurrentLine = 1; - - bAutoIndent = IniSectionGetInt(pIniSection,L"AutoIndent",1); - if (bAutoIndent) bAutoIndent = 1; - - bAutoCompleteWords = IniSectionGetInt(pIniSection,L"AutoCompleteWords",0); - if (bAutoCompleteWords) bAutoCompleteWords = 1; - - bShowIndentGuides = IniSectionGetInt(pIniSection,L"ShowIndentGuides",0); - if (bShowIndentGuides) bShowIndentGuides = 1; - - bTabsAsSpaces = IniSectionGetInt(pIniSection,L"TabsAsSpaces",1); - if (bTabsAsSpaces) bTabsAsSpaces = 1; - bTabsAsSpacesG = bTabsAsSpaces; - - bTabIndents = IniSectionGetInt(pIniSection,L"TabIndents",1); - if (bTabIndents) bTabIndents = 1; - bTabIndentsG = bTabIndents; - - bBackspaceUnindents = IniSectionGetInt(pIniSection,L"BackspaceUnindents",0); - if (bBackspaceUnindents) bBackspaceUnindents = 1; - - iTabWidth = IniSectionGetInt(pIniSection,L"TabWidth",2); - iTabWidth = max(min(iTabWidth,256),1); - iTabWidthG = iTabWidth; - - iIndentWidth = IniSectionGetInt(pIniSection,L"IndentWidth",0); - iIndentWidth = max(min(iIndentWidth,256),0); - iIndentWidthG = iIndentWidth; - - bMarkLongLines = IniSectionGetInt(pIniSection,L"MarkLongLines",0); - if (bMarkLongLines) bMarkLongLines = 1; - - iLongLinesLimit = IniSectionGetInt(pIniSection,L"LongLinesLimit",72); - iLongLinesLimit = max(min(iLongLinesLimit,4096),0); - iLongLinesLimitG = iLongLinesLimit; - - iLongLineMode = IniSectionGetInt(pIniSection,L"LongLineMode",EDGE_LINE); - iLongLineMode = max(min(iLongLineMode,EDGE_BACKGROUND),EDGE_LINE); - - bShowSelectionMargin = IniSectionGetInt(pIniSection,L"ShowSelectionMargin",0); - if (bShowSelectionMargin) bShowSelectionMargin = 1; - - bShowLineNumbers = IniSectionGetInt(pIniSection,L"ShowLineNumbers",1); - if (bShowLineNumbers) bShowLineNumbers = 1; - - bShowCodeFolding = IniSectionGetInt(pIniSection,L"ShowCodeFolding",1); - if (bShowCodeFolding) bShowCodeFolding = 1; - - iMarkOccurrences = IniSectionGetInt(pIniSection,L"MarkOccurrences",3); - bMarkOccurrencesMatchCase = IniSectionGetInt(pIniSection,L"MarkOccurrencesMatchCase",0); - bMarkOccurrencesMatchWords = IniSectionGetInt(pIniSection,L"MarkOccurrencesMatchWholeWords",1); - - bViewWhiteSpace = IniSectionGetInt(pIniSection,L"ViewWhiteSpace",0); - if (bViewWhiteSpace) bViewWhiteSpace = 1; - - bViewEOLs = IniSectionGetInt(pIniSection,L"ViewEOLs",0); - if (bViewEOLs) bViewEOLs = 1; - - iDefaultEncoding = IniSectionGetInt(pIniSection,L"DefaultEncoding",0); - iDefaultEncoding = Encoding_MapIniSetting(TRUE,iDefaultEncoding); - if (!Encoding_IsValid(iDefaultEncoding)) iDefaultEncoding = CPI_UTF8; - - bSkipUnicodeDetection = IniSectionGetInt(pIniSection,L"SkipUnicodeDetection",0); - if (bSkipUnicodeDetection) bSkipUnicodeDetection = 1; - - bLoadASCIIasUTF8 = IniSectionGetInt(pIniSection,L"LoadASCIIasUTF8",0); - if (bLoadASCIIasUTF8) bLoadASCIIasUTF8 = 1; - - bLoadNFOasOEM = IniSectionGetInt(pIniSection,L"LoadNFOasOEM",1); - if (bLoadNFOasOEM) bLoadNFOasOEM = 1; - - bNoEncodingTags = IniSectionGetInt(pIniSection,L"NoEncodingTags",0); - if (bNoEncodingTags) bNoEncodingTags = 1; - - iDefaultEOLMode = IniSectionGetInt(pIniSection,L"DefaultEOLMode",0); - iDefaultEOLMode = max(min(iDefaultEOLMode,2),0); - - bFixLineEndings = IniSectionGetInt(pIniSection,L"FixLineEndings",1); - if (bFixLineEndings) bFixLineEndings = 1; - - bAutoStripBlanks = IniSectionGetInt(pIniSection,L"FixTrailingBlanks",0); - if (bAutoStripBlanks) bAutoStripBlanks = 1; - - iPrintHeader = IniSectionGetInt(pIniSection,L"PrintHeader",1); - iPrintHeader = max(min(iPrintHeader,3),0); - - iPrintFooter = IniSectionGetInt(pIniSection,L"PrintFooter",0); - iPrintFooter = max(min(iPrintFooter,1),0); - - iPrintColor = IniSectionGetInt(pIniSection,L"PrintColorMode",3); - iPrintColor = max(min(iPrintColor,4),0); - - iPrintZoom = IniSectionGetInt(pIniSection,L"PrintZoom",10)-10; - iPrintZoom = max(min(iPrintZoom,20),-10); - - pagesetupMargin.left = IniSectionGetInt(pIniSection,L"PrintMarginLeft",-1); - pagesetupMargin.left = max(pagesetupMargin.left,-1); - - pagesetupMargin.top = IniSectionGetInt(pIniSection,L"PrintMarginTop",-1); - pagesetupMargin.top = max(pagesetupMargin.top,-1); - - pagesetupMargin.right = IniSectionGetInt(pIniSection,L"PrintMarginRight",-1); - pagesetupMargin.right = max(pagesetupMargin.right,-1); - - pagesetupMargin.bottom = IniSectionGetInt(pIniSection,L"PrintMarginBottom",-1); - pagesetupMargin.bottom = max(pagesetupMargin.bottom,-1); - - bSaveBeforeRunningTools = IniSectionGetInt(pIniSection,L"SaveBeforeRunningTools",0); - if (bSaveBeforeRunningTools) bSaveBeforeRunningTools = 1; - - iFileWatchingMode = IniSectionGetInt(pIniSection,L"FileWatchingMode",0); - iFileWatchingMode = max(min(iFileWatchingMode,2),0); - - bResetFileWatching = IniSectionGetInt(pIniSection,L"ResetFileWatching",1); - if (bResetFileWatching) bResetFileWatching = 1; - - iEscFunction = IniSectionGetInt(pIniSection,L"EscFunction",0); - iEscFunction = max(min(iEscFunction,2),0); - - bAlwaysOnTop = IniSectionGetInt(pIniSection,L"AlwaysOnTop",0); - if (bAlwaysOnTop) bAlwaysOnTop = 1; - - bMinimizeToTray = IniSectionGetInt(pIniSection,L"MinimizeToTray",0); - if (bMinimizeToTray) bMinimizeToTray = 1; - - bTransparentMode = IniSectionGetInt(pIniSection,L"TransparentMode",0); - if (bTransparentMode) bTransparentMode = 1; - - // Check if SetLayeredWindowAttributes() is available - bTransparentModeAvailable = - (GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes") != NULL); - - IniSectionGetString(pIniSection,L"ToolbarButtons",L"", - tchToolbarButtons,COUNTOF(tchToolbarButtons)); - - bShowToolbar = IniSectionGetInt(pIniSection,L"ShowToolbar",1); - if (bShowToolbar) bShowToolbar = 1; - - bShowStatusbar = IniSectionGetInt(pIniSection,L"ShowStatusbar",1); - if (bShowStatusbar) bShowStatusbar = 1; - - cxEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeX",256); - cxEncodingDlg = max(cxEncodingDlg,0); - - cyEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeY",262); - cyEncodingDlg = max(cyEncodingDlg,0); - - cxRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeX",256); - cxRecodeDlg = max(cxRecodeDlg,0); - - cyRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeY",262); - cyRecodeDlg = max(cyRecodeDlg,0); - - cxFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeX",412); - cxFileMRUDlg = max(cxFileMRUDlg,0); - - cyFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeY",376); - cyFileMRUDlg = max(cyFileMRUDlg,0); - - cxOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeX",384); - cxOpenWithDlg = max(cxOpenWithDlg,0); - - cyOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeY",386); - cyOpenWithDlg = max(cyOpenWithDlg,0); - - cxFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeX",334); - cxFavoritesDlg = max(cxFavoritesDlg,0); - - cyFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeY",316); - cyFavoritesDlg = max(cyFavoritesDlg,0); - - xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0); - yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0); - - LoadIniSection(L"Settings2",pIniSection,cchIniSection); - - bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0); - if (bStickyWinPos) bStickyWinPos = 1; - - IniSectionGetString(pIniSection,L"DefaultExtension",L"txt", - tchDefaultExtension,COUNTOF(tchDefaultExtension)); - StrTrim(tchDefaultExtension,L" \t.\""); - - IniSectionGetString(pIniSection,L"DefaultDirectory",L"", - tchDefaultDir,COUNTOF(tchDefaultDir)); - - ZeroMemory(tchFileDlgFilters,sizeof(WCHAR)*COUNTOF(tchFileDlgFilters)); - IniSectionGetString(pIniSection,L"FileDlgFilters",L"", - tchFileDlgFilters,COUNTOF(tchFileDlgFilters)-2); - - dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000); - dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000); - - LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection); - IniSectionGetString(pIniSection,L"BitmapDefault",L"", - tchToolbarBitmap,COUNTOF(tchToolbarBitmap)); - IniSectionGetString(pIniSection,L"BitmapHot",L"", - tchToolbarBitmapHot,COUNTOF(tchToolbarBitmap)); - IniSectionGetString(pIniSection,L"BitmapDisabled",L"", - tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmap)); - - if (!flagPosParam /*|| bStickyWinPos*/) { // ignore window position if /p was specified - - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; - - int ResX = GetSystemMetrics(SM_CXSCREEN); - int ResY = GetSystemMetrics(SM_CYSCREEN); - - wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); - wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); - wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); - wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); - wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); - - LoadIniSection(L"Window",pIniSection,cchIniSection); - - wi.x = IniSectionGetInt(pIniSection,tchPosX,CW_USEDEFAULT); - wi.y = IniSectionGetInt(pIniSection,tchPosY,CW_USEDEFAULT); - wi.cx = IniSectionGetInt(pIniSection,tchSizeX,CW_USEDEFAULT); - wi.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT); - wi.max = IniSectionGetInt(pIniSection,tchMaximized,0); - if (wi.max) wi.max = 1; - } - - LocalFree(pIniSection); - - iDefaultCodePage = 0; { - int acp = GetACP(); - if (acp == 932 || acp == 936 || acp == 949 || acp == 950 || acp == 1361) - iDefaultCodePage = acp; - } - - { - CHARSETINFO ci; - if (TranslateCharsetInfo((DWORD*)(UINT_PTR)iDefaultCodePage,&ci,TCI_SRCCODEPAGE)) - iDefaultCharSet = ci.ciCharset; - else - iDefaultCharSet = ANSI_CHARSET; - } - - // Scintilla Styles - Style_Load(); - -} - - -//============================================================================= -// -// SaveSettings() -// -// -void SaveSettings(BOOL bSaveSettingsNow) -{ - WCHAR *pIniSection = NULL; - int cchIniSection = 0; - - WCHAR wchTmp[MAX_PATH]; - - if (lstrlen(szIniFile) == 0) - return; - - CreateIniFile(); - - if (!bSaveSettings && !bSaveSettingsNow) { - IniSetInt(L"Settings",L"SaveSettings",bSaveSettings); - return; - } - - pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - IniSectionSetInt(pIniSection,L"SaveSettings",bSaveSettings); - IniSectionSetInt(pIniSection,L"SaveRecentFiles",bSaveRecentFiles); - IniSectionSetInt(pIniSection,L"SaveFindReplace",bSaveFindReplace); - IniSectionSetInt(pIniSection,L"CloseFind",efrData.bFindClose); - IniSectionSetInt(pIniSection,L"CloseReplace",efrData.bReplaceClose); - IniSectionSetInt(pIniSection,L"NoFindWrap",efrData.bNoFindWrap); - PathRelativeToApp(tchOpenWithDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs); - IniSectionSetString(pIniSection,L"OpenWithDir",wchTmp); - PathRelativeToApp(tchFavoritesDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs); - IniSectionSetString(pIniSection,L"Favorites",wchTmp); - IniSectionSetInt(pIniSection,L"PathNameFormat",iPathNameFormat); - IniSectionSetInt(pIniSection,L"WordWrap",fWordWrapG); - IniSectionSetInt(pIniSection,L"WordWrapMode",iWordWrapMode); - IniSectionSetInt(pIniSection,L"WordWrapIndent",iWordWrapIndent); - IniSectionSetInt(pIniSection,L"WordWrapSymbols",iWordWrapSymbols); - IniSectionSetInt(pIniSection,L"ShowWordWrapSymbols",bShowWordWrapSymbols); - IniSectionSetInt(pIniSection,L"MatchBraces",bMatchBraces); - IniSectionSetInt(pIniSection,L"AutoCloseTags",bAutoCloseTags); - IniSectionSetInt(pIniSection,L"HighlightCurrentLine",bHiliteCurrentLine); - IniSectionSetInt(pIniSection,L"AutoIndent",bAutoIndent); - IniSectionSetInt(pIniSection,L"AutoCompleteWords",bAutoCompleteWords); - IniSectionSetInt(pIniSection,L"ShowIndentGuides",bShowIndentGuides); - IniSectionSetInt(pIniSection,L"TabsAsSpaces",bTabsAsSpacesG); - IniSectionSetInt(pIniSection,L"TabIndents",bTabIndentsG); - IniSectionSetInt(pIniSection,L"BackspaceUnindents",bBackspaceUnindents); - IniSectionSetInt(pIniSection,L"TabWidth",iTabWidthG); - IniSectionSetInt(pIniSection,L"IndentWidth",iIndentWidthG); - IniSectionSetInt(pIniSection,L"MarkLongLines",bMarkLongLines); - IniSectionSetInt(pIniSection,L"LongLinesLimit",iLongLinesLimitG); - IniSectionSetInt(pIniSection,L"LongLineMode",iLongLineMode); - IniSectionSetInt(pIniSection,L"ShowSelectionMargin",bShowSelectionMargin); - IniSectionSetInt(pIniSection,L"ShowLineNumbers",bShowLineNumbers); - IniSectionSetInt(pIniSection,L"ShowCodeFolding",bShowCodeFolding); - IniSectionSetInt(pIniSection,L"MarkOccurrences",iMarkOccurrences); - IniSectionSetInt(pIniSection,L"MarkOccurrencesMatchCase",bMarkOccurrencesMatchCase); - IniSectionSetInt(pIniSection,L"MarkOccurrencesMatchWholeWords",bMarkOccurrencesMatchWords); - IniSectionSetInt(pIniSection,L"ViewWhiteSpace",bViewWhiteSpace); - IniSectionSetInt(pIniSection,L"ViewEOLs",bViewEOLs); - IniSectionSetInt(pIniSection,L"DefaultEncoding",Encoding_MapIniSetting(FALSE,iDefaultEncoding)); - IniSectionSetInt(pIniSection,L"SkipUnicodeDetection",bSkipUnicodeDetection); - IniSectionSetInt(pIniSection,L"LoadASCIIasUTF8",bLoadASCIIasUTF8); - IniSectionSetInt(pIniSection,L"LoadNFOasOEM",bLoadNFOasOEM); - IniSectionSetInt(pIniSection,L"NoEncodingTags",bNoEncodingTags); - IniSectionSetInt(pIniSection,L"DefaultEOLMode",iDefaultEOLMode); - IniSectionSetInt(pIniSection,L"FixLineEndings",bFixLineEndings); - IniSectionSetInt(pIniSection,L"FixTrailingBlanks",bAutoStripBlanks); - IniSectionSetInt(pIniSection,L"PrintHeader",iPrintHeader); - IniSectionSetInt(pIniSection,L"PrintFooter",iPrintFooter); - IniSectionSetInt(pIniSection,L"PrintColorMode",iPrintColor); - IniSectionSetInt(pIniSection,L"PrintZoom",iPrintZoom+10); - IniSectionSetInt(pIniSection,L"PrintMarginLeft",pagesetupMargin.left); - IniSectionSetInt(pIniSection,L"PrintMarginTop",pagesetupMargin.top); - IniSectionSetInt(pIniSection,L"PrintMarginRight",pagesetupMargin.right); - IniSectionSetInt(pIniSection,L"PrintMarginBottom",pagesetupMargin.bottom); - IniSectionSetInt(pIniSection,L"SaveBeforeRunningTools",bSaveBeforeRunningTools); - IniSectionSetInt(pIniSection,L"FileWatchingMode",iFileWatchingMode); - IniSectionSetInt(pIniSection,L"ResetFileWatching",bResetFileWatching); - IniSectionSetInt(pIniSection,L"EscFunction",iEscFunction); - IniSectionSetInt(pIniSection,L"AlwaysOnTop",bAlwaysOnTop); - IniSectionSetInt(pIniSection,L"MinimizeToTray",bMinimizeToTray); - IniSectionSetInt(pIniSection,L"TransparentMode",bTransparentMode); - Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons)); - IniSectionSetString(pIniSection,L"ToolbarButtons",tchToolbarButtons); - IniSectionSetInt(pIniSection,L"ShowToolbar",bShowToolbar); - IniSectionSetInt(pIniSection,L"ShowStatusbar",bShowStatusbar); - IniSectionSetInt(pIniSection,L"EncodingDlgSizeX",cxEncodingDlg); - IniSectionSetInt(pIniSection,L"EncodingDlgSizeY",cyEncodingDlg); - IniSectionSetInt(pIniSection,L"RecodeDlgSizeX",cxRecodeDlg); - IniSectionSetInt(pIniSection,L"RecodeDlgSizeY",cyRecodeDlg); - IniSectionSetInt(pIniSection,L"FileMRUDlgSizeX",cxFileMRUDlg); - IniSectionSetInt(pIniSection,L"FileMRUDlgSizeY",cyFileMRUDlg); - IniSectionSetInt(pIniSection,L"OpenWithDlgSizeX",cxOpenWithDlg); - IniSectionSetInt(pIniSection,L"OpenWithDlgSizeY",cyOpenWithDlg); - IniSectionSetInt(pIniSection,L"FavoritesDlgSizeX",cxFavoritesDlg); - IniSectionSetInt(pIniSection,L"FavoritesDlgSizeY",cyFavoritesDlg); - IniSectionSetInt(pIniSection,L"FindReplaceDlgPosX",xFindReplaceDlg); - IniSectionSetInt(pIniSection,L"FindReplaceDlgPosY",yFindReplaceDlg); - - SaveIniSection(L"Settings",pIniSection); - LocalFree(pIniSection); - - /* - SaveSettingsNow(): query Window Dimensions - */ - - if (bSaveSettingsNow) - { - WINDOWPLACEMENT wndpl; - - // GetWindowPlacement - wndpl.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hwndMain,&wndpl); - - wi.x = wndpl.rcNormalPosition.left; - wi.y = wndpl.rcNormalPosition.top; - wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; - wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; - wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); - } - - if (!IniGetInt(L"Settings2",L"StickyWindowPosition",0)) { - - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; - - int ResX = GetSystemMetrics(SM_CXSCREEN); - int ResY = GetSystemMetrics(SM_CYSCREEN); - - wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); - wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); - wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); - wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); - wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); - - IniSetInt(L"Window",tchPosX,wi.x); - IniSetInt(L"Window",tchPosY,wi.y); - IniSetInt(L"Window",tchSizeX,wi.cx); - IniSetInt(L"Window",tchSizeY,wi.cy); - IniSetInt(L"Window",tchMaximized,wi.max); - } - - // Scintilla Styles - Style_Save(); - -} - - -//============================================================================= -// -// ParseCommandLine() -// -// -void ParseCommandLine() -{ - - LPWSTR lp1,lp2,lp3; - BOOL bContinue = TRUE; - BOOL bIsFileArg = FALSE; - BOOL bIsNotepadReplacement = FALSE; - - LPWSTR lpCmdLine = GetCommandLine(); - - if (lstrlen(lpCmdLine) == 0) - return; - - // Good old console can also send args separated by Tabs - StrTab2Space(lpCmdLine); - - lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - lp3 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - - // Start with 2nd argument - ExtractFirstArgument(lpCmdLine,lp1,lp3); - - while (bContinue && ExtractFirstArgument(lp3,lp1,lp2)) - { - - // options - if (!bIsFileArg && lstrcmp(lp1,L"+") == 0) { - flagMultiFileArg = 2; - bIsFileArg = TRUE; - } - - else if (!bIsFileArg && lstrcmp(lp1,L"-") == 0) { - flagMultiFileArg = 1; - bIsFileArg = TRUE; - } - - else if (!bIsFileArg && ((*lp1 == L'/') || (*lp1 == L'-'))) - { - - // LTrim - StrLTrim(lp1,L"-/"); - - // Encoding - if (lstrcmpi(lp1,L"ANSI") == 0 || lstrcmpi(lp1,L"A") == 0 || lstrcmpi(lp1,L"MBCS") == 0) - flagSetEncoding = IDM_ENCODING_ANSI-IDM_ENCODING_ANSI + 1; - else if (lstrcmpi(lp1,L"UNICODE") == 0 || lstrcmpi(lp1,L"W") == 0) - flagSetEncoding = IDM_ENCODING_UNICODE-IDM_ENCODING_ANSI + 1; - else if (lstrcmpi(lp1,L"UNICODEBE") == 0 || lstrcmpi(lp1,L"UNICODE-BE") == 0) - flagSetEncoding = IDM_ENCODING_UNICODEREV-IDM_ENCODING_ANSI + 1; - else if (lstrcmpi(lp1,L"UTF8") == 0 || lstrcmpi(lp1,L"UTF-8") == 0) - flagSetEncoding = IDM_ENCODING_UTF8-IDM_ENCODING_ANSI + 1; - else if (lstrcmpi(lp1,L"UTF8SIG") == 0 || lstrcmpi(lp1,L"UTF-8SIG") == 0 || - lstrcmpi(lp1,L"UTF8SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8SIGNATURE") == 0 || - lstrcmpi(lp1,L"UTF8-SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8-SIGNATURE") == 0) - flagSetEncoding = IDM_ENCODING_UTF8SIGN-IDM_ENCODING_ANSI + 1; - - // EOL Mode - else if (lstrcmpi(lp1,L"CRLF") == 0 || lstrcmpi(lp1,L"CR+LF") == 0) - flagSetEOLMode = IDM_LINEENDINGS_CRLF-IDM_LINEENDINGS_CRLF + 1; - else if (lstrcmpi(lp1,L"LF") == 0) - flagSetEOLMode = IDM_LINEENDINGS_LF-IDM_LINEENDINGS_CRLF + 1; - else if (lstrcmpi(lp1,L"CR") == 0) - flagSetEOLMode = IDM_LINEENDINGS_CR-IDM_LINEENDINGS_CRLF + 1; - - // Shell integration - else if (StrCmpNI(lp1,L"appid=",CSTRLEN(L"appid=")) == 0) { - StrCpyN(g_wchAppUserModelID,lp1+CSTRLEN(L"appid="),COUNTOF(g_wchAppUserModelID)); - StrTrim(g_wchAppUserModelID,L" "); - if (lstrlen(g_wchAppUserModelID) == 0) - lstrcpy(g_wchAppUserModelID,L"(default)"); - } - else if (StrCmpNI(lp1,L"sysmru=",CSTRLEN(L"sysmru=")) == 0) { - WCHAR wch[8]; - StrCpyN(wch,lp1+CSTRLEN(L"sysmru="),COUNTOF(wch)); - StrTrim(wch,L" "); - if (*wch == L'1') - flagUseSystemMRU = 2; - else - flagUseSystemMRU = 1; - } - - else switch (*CharUpper(lp1)) - { - - case L'N': - flagReuseWindow = 0; - flagNoReuseWindow = 1; - if (*CharUpper(lp1+1) == L'S') - flagSingleFileInstance = 1; - else - flagSingleFileInstance = 0; - break; - - case L'R': - flagReuseWindow = 1; - flagNoReuseWindow = 0; - if (*CharUpper(lp1+1) == L'S') - flagSingleFileInstance = 1; - else - flagSingleFileInstance = 0; - break; - - case L'F': - if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O') - lstrcpy(szIniFile,L"*?"); - else if (ExtractFirstArgument(lp2,lp1,lp2)) { - StrCpyN(szIniFile,lp1,COUNTOF(szIniFile)); - TrimString(szIniFile); - PathUnquoteSpaces(szIniFile); - } - break; - - case L'I': - flagStartAsTrayIcon = 1; - break; - - case L'O': - if (*(lp1+1) == L'0' || *(lp1+1) == L'-' || *CharUpper(lp1+1) == L'O') - flagAlwaysOnTop = 1; - else - flagAlwaysOnTop = 2; - break; - - case L'P': - { - WCHAR *lp = lp1; - if (StrCmpNI(lp1,L"POS:",CSTRLEN(L"POS:")) == 0) - lp += CSTRLEN(L"POS:") -1; - else if (StrCmpNI(lp1,L"POS",CSTRLEN(L"POS")) == 0) - lp += CSTRLEN(L"POS") -1; - else if (*(lp1+1) == L':') - lp += 1; - else if (bIsNotepadReplacement) { - if (*(lp1+1) == L'T') - ExtractFirstArgument(lp2,lp1,lp2); - break; - } - if (*(lp+1) == L'0' || *CharUpper(lp+1) == L'O') { - flagPosParam = 1; - flagDefaultPos = 1; - } - else if (*CharUpper(lp+1) == L'D' || *CharUpper(lp+1) == L'S') { - flagPosParam = 1; - flagDefaultPos = (StrChrI((lp+1),L'L')) ? 3 : 2; - } - else if (StrChrI(L"FLTRBM",*(lp+1))) { - WCHAR *p = (lp+1); - flagPosParam = 1; - flagDefaultPos = 0; - while (*p) { - switch (*CharUpper(p)) { - case L'F': - flagDefaultPos &= ~(4|8|16|32); - flagDefaultPos |= 64; - break; - case L'L': - flagDefaultPos &= ~(8|64); - flagDefaultPos |= 4; - break; - case L'R': - flagDefaultPos &= ~(4|64); - flagDefaultPos |= 8; - break; - case L'T': - flagDefaultPos &= ~(32|64); - flagDefaultPos |= 16; - break; - case L'B': - flagDefaultPos &= ~(16|64); - flagDefaultPos |= 32; - break; - case L'M': - if (flagDefaultPos == 0) - flagDefaultPos |= 64; - flagDefaultPos |= 128; - break; - } - p = CharNext(p); - } - } - else if (ExtractFirstArgument(lp2,lp1,lp2)) { - int itok = - swscanf(lp1,L"%i,%i,%i,%i,%i",&wi.x,&wi.y,&wi.cx,&wi.cy,&wi.max); - if (itok == 4 || itok == 5) { // scan successful - flagPosParam = 1; - flagDefaultPos = 0; - if (wi.cx < 1) wi.cx = CW_USEDEFAULT; - if (wi.cy < 1) wi.cy = CW_USEDEFAULT; - if (wi.max) wi.max = 1; - if (itok == 4) wi.max = 0; - } - } - } - break; - - case L'T': - if (ExtractFirstArgument(lp2,lp1,lp2)) { - StrCpyN(szTitleExcerpt,lp1,COUNTOF(szTitleExcerpt)); - fKeepTitleExcerpt = 1; - } - break; - - case L'C': - flagNewFromClipboard = 1; - break; - - case L'B': - flagPasteBoard = 1; - break; - - case L'E': - if (ExtractFirstArgument(lp2,lp1,lp2)) { - if (lpEncodingArg) - LocalFree(lpEncodingArg); - lpEncodingArg = StrDup(lp1); - } - break; - - case L'G': - if (ExtractFirstArgument(lp2,lp1,lp2)) { - int itok = - swscanf(lp1,L"%i,%i",&iInitialLine,&iInitialColumn); - if (itok == 1 || itok == 2) { // scan successful - flagJumpTo = 1; - } - } - break; - - case L'M': - { - BOOL bFindUp = FALSE; - BOOL bRegex = FALSE; - BOOL bTransBS = FALSE; - - if (StrChr(lp1,L'-')) - bFindUp = TRUE; - if (StrChr(lp1,L'R')) - bRegex = TRUE; - if (StrChr(lp1,L'B')) - bTransBS = TRUE; - - if (ExtractFirstArgument(lp2,lp1,lp2)) { - if (lpMatchArg) - GlobalFree(lpMatchArg); - lpMatchArg = StrDup(lp1); - flagMatchText = 1; - - if (bFindUp) - flagMatchText |= 2; - - if (bRegex) { - flagMatchText &= ~8; - flagMatchText |= 4; - } - - if (bTransBS) { - flagMatchText &= ~4; - flagMatchText |= 8; - } - } - } - break; - - case L'L': - if (*(lp1+1) == L'0' || *(lp1+1) == L'-' || *CharUpper(lp1+1) == L'O') - flagChangeNotify = 1; - else - flagChangeNotify = 2; - break; - - case L'Q': - flagQuietCreate = 1; - break; - - case L'S': - if (ExtractFirstArgument(lp2,lp1,lp2)) { - if (lpSchemeArg) - LocalFree(lpSchemeArg); - lpSchemeArg = StrDup(lp1); - flagLexerSpecified = 1; - } - break; - - case L'D': - if (lpSchemeArg) { - LocalFree(lpSchemeArg); - lpSchemeArg = NULL; - } - iInitialLexer = 0; - flagLexerSpecified = 1; - break; - - case L'H': - if (lpSchemeArg) { - LocalFree(lpSchemeArg); - lpSchemeArg = NULL; - } - iInitialLexer = 34; - flagLexerSpecified = 1; - break; - - case L'X': - if (lpSchemeArg) { - LocalFree(lpSchemeArg); - lpSchemeArg = NULL; - } - iInitialLexer = 35; - flagLexerSpecified = 1; - break; - - case L'U': - flagRelaunchElevated = 1; - break; - - case L'Z': - ExtractFirstArgument(lp2,lp1,lp2); - flagMultiFileArg = 1; - bIsNotepadReplacement = TRUE; - break; - - case L'?': - flagDisplayHelp = 1; - break; - - default: - break; - - } - - } - - // pathname - else - { - LPWSTR lpFileBuf = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - - cchiFileList = lstrlen(lpCmdLine) - lstrlen(lp3); - - if (lpFileArg) - GlobalFree(lpFileArg); - - lpFileArg = GlobalAlloc(GPTR,sizeof(WCHAR)*(MAX_PATH+2)); // changed for ActivatePrevInst() needs - StrCpyN(lpFileArg,lp3,MAX_PATH); - - PathFixBackslashes(lpFileArg); - - if (!PathIsRelative(lpFileArg) && !PathIsUNC(lpFileArg) && - PathGetDriveNumber(lpFileArg) == -1 /*&& PathGetDriveNumber(g_wchWorkingDirectory) != -1*/) { - - WCHAR wchPath[MAX_PATH]; - lstrcpy(wchPath,g_wchWorkingDirectory); - PathStripToRoot(wchPath); - PathAppend(wchPath,lpFileArg); - lstrcpy(lpFileArg,wchPath); - } - - StrTrim(lpFileArg,L" \""); - - while (cFileList < 32 && ExtractFirstArgument(lp3,lpFileBuf,lp3)) { - PathQuoteSpaces(lpFileBuf); - lpFileList[cFileList++] = StrDup(lpFileBuf); - } - - bContinue = FALSE; - LocalFree(lpFileBuf); - } - - // Continue with next argument - if (bContinue) - lstrcpy(lp3,lp2); - - } - - LocalFree(lp1); - LocalFree(lp2); - LocalFree(lp3); - -} - - -//============================================================================= -// -// LoadFlags() -// -// -void LoadFlags() -{ - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - LoadIniSection(L"Settings2",pIniSection,cchIniSection); - - if (!flagReuseWindow && !flagNoReuseWindow) { - - if (!IniSectionGetInt(pIniSection,L"ReuseWindow",0)) - flagNoReuseWindow = 1; - - if (IniSectionGetInt(pIniSection,L"SingleFileInstance",0)) - flagSingleFileInstance = 1; - } - - if (flagMultiFileArg == 0) { - if (IniSectionGetInt(pIniSection,L"MultiFileArg",0)) - flagMultiFileArg = 2; - } - - if (IniSectionGetInt(pIniSection,L"RelativeFileMRU",1)) - flagRelativeFileMRU = 1; - - if (IniSectionGetInt(pIniSection,L"PortableMyDocs",flagRelativeFileMRU)) - flagPortableMyDocs = 1; - - if (IniSectionGetInt(pIniSection,L"NoFadeHidden",0)) - flagNoFadeHidden = 1; - - flagToolbarLook = IniSectionGetInt(pIniSection,L"ToolbarLook",IsXP() ? 1 : 2); - flagToolbarLook = max(min(flagToolbarLook,2),0); - - if (IniSectionGetInt(pIniSection,L"SimpleIndentGuides",0)) - flagSimpleIndentGuides = 1; - - if (IniSectionGetInt(pIniSection,L"NoHTMLGuess",0)) - fNoHTMLGuess = 1; - - if (IniSectionGetInt(pIniSection,L"NoCGIGuess",0)) - fNoCGIGuess = 1; - - if (IniSectionGetInt(pIniSection,L"NoFileVariables",0)) - fNoFileVariables = 1; - - if (lstrlen(g_wchAppUserModelID) == 0) { - IniSectionGetString(pIniSection,L"ShellAppUserModelID",L"(default)", - g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID)); - } - - if (flagUseSystemMRU == 0) { - if (IniSectionGetInt(pIniSection,L"ShellUseSystemMRU",0)) - flagUseSystemMRU = 2; - } - - LocalFree(pIniSection); -} - - -//============================================================================= -// -// FindIniFile() -// -// -int CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule) -{ - WCHAR tchFileExpanded[MAX_PATH]; - WCHAR tchBuild[MAX_PATH]; - ExpandEnvironmentStrings(lpszFile,tchFileExpanded,COUNTOF(tchFileExpanded)); - - if (PathIsRelative(tchFileExpanded)) { - // program directory - lstrcpy(tchBuild,lpszModule); - lstrcpy(PathFindFileName(tchBuild),tchFileExpanded); - if (PathFileExists(tchBuild)) { - lstrcpy(lpszFile,tchBuild); - return(1); - } - // %appdata% - if (S_OK == SHGetFolderPath(NULL,CSIDL_APPDATA,NULL,SHGFP_TYPE_CURRENT,tchBuild)) { - PathAppend(tchBuild,tchFileExpanded); - if (PathFileExists(tchBuild)) { - lstrcpy(lpszFile,tchBuild); - return(1); - } - } - // general - if (SearchPath(NULL,tchFileExpanded,NULL,COUNTOF(tchBuild),tchBuild,NULL)) { - lstrcpy(lpszFile,tchBuild); - return(1); - } - } - - else if (PathFileExists(tchFileExpanded)) { - lstrcpy(lpszFile,tchFileExpanded); - return(1); - } - - return(0); -} - -int CheckIniFileRedirect(LPWSTR lpszFile,LPCWSTR lpszModule) -{ - WCHAR tch[MAX_PATH]; - if (GetPrivateProfileString(L"Notepad2",L"Notepad2.ini",L"",tch,COUNTOF(tch),lpszFile)) { - if (CheckIniFile(tch,lpszModule)) { - lstrcpy(lpszFile,tch); - return(1); - } - else { - WCHAR tchFileExpanded[MAX_PATH]; - ExpandEnvironmentStrings(tch,tchFileExpanded,COUNTOF(tchFileExpanded)); - if (PathIsRelative(tchFileExpanded)) { - lstrcpy(lpszFile,lpszModule); - lstrcpy(PathFindFileName(lpszFile),tchFileExpanded); - return(1); - } - else { - lstrcpy(lpszFile,tchFileExpanded); - return(1); - } - } - } - return(0); -} - -int FindIniFile() { - - int bFound = 0; - WCHAR tchTest[MAX_PATH]; - WCHAR tchModule[MAX_PATH]; - GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); - - if (lstrlen(szIniFile)) { - if (lstrcmpi(szIniFile,L"*?") == 0) - return(0); - else { - if (!CheckIniFile(szIniFile,tchModule)) { - ExpandEnvironmentStringsEx(szIniFile,COUNTOF(szIniFile)); - if (PathIsRelative(szIniFile)) { - lstrcpy(tchTest,tchModule); - PathRemoveFileSpec(tchTest); - PathAppend(tchTest,szIniFile); - lstrcpy(szIniFile,tchTest); - } - } - } - return(1); - } - - lstrcpy(tchTest,PathFindFileName(tchModule)); - PathRenameExtension(tchTest,L".ini"); - bFound = CheckIniFile(tchTest,tchModule); - - if (!bFound) { - lstrcpy(tchTest,L"Notepad2.ini"); - bFound = CheckIniFile(tchTest,tchModule); - } - - if (bFound) { - // allow two redirections: administrator -> user -> custom - if (CheckIniFileRedirect(tchTest,tchModule)) - CheckIniFileRedirect(tchTest,tchModule); - lstrcpy(szIniFile,tchTest); - } - - else { - lstrcpy(szIniFile,tchModule); - PathRenameExtension(szIniFile,L".ini"); - } - - return(1); -} - - -int TestIniFile() { - - if (lstrcmpi(szIniFile,L"*?") == 0) { - lstrcpy(szIniFile2,L""); - lstrcpy(szIniFile,L""); - return(0); - } - - if (PathIsDirectory(szIniFile) || *CharPrev(szIniFile,StrEnd(szIniFile)) == L'\\') { - WCHAR wchModule[MAX_PATH]; - GetModuleFileName(NULL,wchModule,COUNTOF(wchModule)); - PathAppend(szIniFile,PathFindFileName(wchModule)); - PathRenameExtension(szIniFile,L".ini"); - if (!PathFileExists(szIniFile)) { - lstrcpy(PathFindFileName(szIniFile),L"Notepad2.ini"); - if (!PathFileExists(szIniFile)) { - lstrcpy(PathFindFileName(szIniFile),PathFindFileName(wchModule)); - PathRenameExtension(szIniFile,L".ini"); - } - } - } - - if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) { - lstrcpy(szIniFile2,szIniFile); - lstrcpy(szIniFile,L""); - return(0); - } - else - return(1); -} - - -int CreateIniFile() { - - return(CreateIniFileEx(szIniFile)); -} - - -int CreateIniFileEx(LPCWSTR lpszIniFile) { - - if (*lpszIniFile) { - - HANDLE hFile; - WCHAR *pwchTail; - - if (pwchTail = StrRChrW(lpszIniFile,NULL,L'\\')) { - *pwchTail = 0; - SHCreateDirectoryEx(NULL,lpszIniFile,NULL); - *pwchTail = L'\\'; - } - - hFile = CreateFile(lpszIniFile, - GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - dwLastIOError = GetLastError(); - if (hFile != INVALID_HANDLE_VALUE) { - if (GetFileSize(hFile,NULL) == 0) { - DWORD dw; - WriteFile(hFile,(LPCVOID)L"\xFEFF[Notepad2]\r\n",26,&dw,NULL); - } - CloseHandle(hFile); - return(1); - } - else - return(0); - } - - else - return(0); -} - - -//============================================================================= -// -// UpdateToolbar() -// -// -#define EnableTool(id,b) SendMessage(hwndToolbar,TB_ENABLEBUTTON,id, \ - MAKELONG(((b) ? 1 : 0), 0)) - -#define CheckTool(id,b) SendMessage(hwndToolbar,TB_CHECKBUTTON,id, \ - MAKELONG(b,0)) - -void UpdateToolbar() -{ - - int i; - - if (!bShowToolbar) - return; - - EnableTool(IDT_FILE_ADDTOFAV,lstrlen(szCurFile)); - - EnableTool(IDT_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/); - EnableTool(IDT_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/); - - i = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - EnableTool(IDT_EDIT_CUT,i /*&& !bReadOnly*/); - EnableTool(IDT_EDIT_COPY,SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); - EnableTool(IDT_EDIT_PASTE,SendMessage(hwndEdit,SCI_CANPASTE,0,0) /*&& !bReadOnly*/); - - i = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); - EnableTool(IDT_EDIT_FIND,i); - //EnableTool(IDT_EDIT_FINDNEXT,i); - //EnableTool(IDT_EDIT_FINDPREV,i && lstrlen(efrData.szFind)); - EnableTool(IDT_EDIT_REPLACE,i /*&& !bReadOnly*/); - EnableTool(IDT_EDIT_CLEAR,i /*&& !bReadOnly*/); - - EnableTool(IDT_VIEW_TOGGLEFOLDS,i && bShowCodeFolding); - EnableTool(IDT_FILE_LAUNCH,i); - - CheckTool(IDT_VIEW_WORDWRAP,fWordWrap); - -} - - -//============================================================================= -// -// UpdateStatusbar() -// -// -void UpdateStatusbar() -{ - - int iPos; - int iLn; - int iLines; - int iCol; - int iSel; - WCHAR tchLn[32]; - WCHAR tchLines[32]; - WCHAR tchCol[32]; - WCHAR tchCols[32]; - WCHAR tchSel[32]; - WCHAR tchDocPos[256]; - - int iBytes; - WCHAR tchBytes[64]; - WCHAR tchDocSize[256]; - - WCHAR tchEOLMode[32]; - WCHAR tchOvrMode[32]; - WCHAR tchLexerName[128]; - -#ifdef BOOKMARK_EDITION - int iSelStart; - int iSelEnd; - int iLineStart; - int iLineEnd; - int iStartOfLinePos; - int iLinesSelected; - WCHAR tchLinesSelected[32]; -#endif - - if (!bShowStatusbar) - return; - - iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); - - iLn = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0) + 1; - wsprintf(tchLn,L"%i",iLn); - FormatNumberStr(tchLn); - - iLines = (int)SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0); - wsprintf(tchLines,L"%i",iLines); - FormatNumberStr(tchLines); - - iCol = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0) + 1; - wsprintf(tchCol,L"%i",iCol); - FormatNumberStr(tchCol); - - if (bMarkLongLines) { - wsprintf(tchCols,L"%i",iLongLinesLimit); - FormatNumberStr(tchCols); - } - - if (SC_SEL_RECTANGLE != SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0)) - { - iSel = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); - wsprintf(tchSel,L"%i",iSel); - FormatNumberStr(tchSel); - } - else - lstrcpy(tchSel,L"--"); - -#ifdef BOOKMARK_EDITION - // Print number of lines selected lines in statusbar - iSelStart = (int)SendMessage( hwndEdit , SCI_GETSELECTIONSTART , 0 , 0 ); - iSelEnd = (int)SendMessage( hwndEdit , SCI_GETSELECTIONEND , 0 , 0 ); - iLineStart = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iSelStart , 0 ); - iLineEnd = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iSelEnd , 0 ); - iStartOfLinePos = (int)SendMessage( hwndEdit , SCI_POSITIONFROMLINE , iLineEnd , 0 ); - iLinesSelected = iLineEnd - iLineStart; - if( iSelStart != iSelEnd && iStartOfLinePos != iSelEnd ) iLinesSelected += 1; - wsprintf(tchLinesSelected,L"%i",iLinesSelected); - FormatNumberStr(tchLinesSelected); - - if (!bMarkLongLines) - FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS,tchLn,tchLines,tchCol,tchSel,tchLinesSelected); - else - FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS2,tchLn,tchLines,tchCol,tchCols,tchSel,tchLinesSelected); - -#else - - if (!bMarkLongLines) - FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS,tchLn,tchLines,tchCol,tchSel); - else - FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS2,tchLn,tchLines,tchCol,tchCols,tchSel); -#endif - - iBytes = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); - StrFormatByteSize(iBytes,tchBytes,COUNTOF(tchBytes)); - - FormatString(tchDocSize,COUNTOF(tchDocSize),IDS_DOCSIZE,tchBytes); - - Encoding_GetLabel(iEncoding); - - if (iEOLMode == SC_EOL_CR) - lstrcpy(tchEOLMode,L"CR"); - else if (iEOLMode == SC_EOL_LF) - lstrcpy(tchEOLMode,L"LF"); - else - lstrcpy(tchEOLMode,L"CR+LF"); - - if (SendMessage(hwndEdit,SCI_GETOVERTYPE,0,0)) - lstrcpy(tchOvrMode,L"OVR"); - else - lstrcpy(tchOvrMode,L"INS"); - - Style_GetCurrentLexerName(tchLexerName,COUNTOF(tchLexerName)); - - StatusSetText(hwndStatus,STATUS_DOCPOS,tchDocPos); - StatusSetText(hwndStatus,STATUS_DOCSIZE,tchDocSize); - StatusSetText(hwndStatus,STATUS_CODEPAGE,mEncoding[iEncoding].wchLabel); - StatusSetText(hwndStatus,STATUS_EOLMODE,tchEOLMode); - StatusSetText(hwndStatus,STATUS_OVRMODE,tchOvrMode); - StatusSetText(hwndStatus,STATUS_LEXER,tchLexerName); - - //InvalidateRect(hwndStatus,NULL,TRUE); - -} - - -//============================================================================= -// -// UpdateLineNumberWidth() -// -// -void UpdateLineNumberWidth() -{ - char tchLines[32]; - int iLineMarginWidthNow; - int iLineMarginWidthFit; - - if (bShowLineNumbers) { - - wsprintfA(tchLines,"_%i_",SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0)); - - iLineMarginWidthNow = (int)SendMessage(hwndEdit,SCI_GETMARGINWIDTHN,0,0); - iLineMarginWidthFit = (int)SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)tchLines); - - if (iLineMarginWidthNow != iLineMarginWidthFit) { - //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0); - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,iLineMarginWidthFit); - } - } - - else - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0); -} - - -//============================================================================= -// -// FileIO() -// -// -BOOL FileIO(BOOL fLoad,LPCWSTR psz,BOOL bNoEncDetect,int *ienc,int *ieol, - BOOL *pbUnicodeErr,BOOL *pbFileTooBig, - BOOL *pbCancelDataLoss,BOOL bSaveCopy) -{ - WCHAR tch[MAX_PATH+40]; - BOOL fSuccess; - DWORD dwFileAttributes; - - BeginWaitCursor(); - - FormatString(tch,COUNTOF(tch),(fLoad) ? IDS_LOADFILE : IDS_SAVEFILE,PathFindFileName(psz)); - - StatusSetText(hwndStatus,STATUS_HELP,tch); - StatusSetSimple(hwndStatus,TRUE); - - InvalidateRect(hwndStatus,NULL,TRUE); - UpdateWindow(hwndStatus); - - if (fLoad) - fSuccess = EditLoadFile(hwndEdit,psz,bNoEncDetect,ienc,ieol,pbUnicodeErr,pbFileTooBig); - else - fSuccess = EditSaveFile(hwndEdit,psz,*ienc,pbCancelDataLoss,bSaveCopy); - - dwFileAttributes = GetFileAttributes(psz); - bReadOnly = (dwFileAttributes != INVALID_FILE_ATTRIBUTES && dwFileAttributes & FILE_ATTRIBUTE_READONLY); - - StatusSetSimple(hwndStatus,FALSE); - - EndWaitCursor(); - - return(fSuccess); -} - - -//============================================================================= -// -// FileLoad() -// -// -BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lpszFile) -{ - WCHAR tch[MAX_PATH] = L""; - WCHAR szFileName[MAX_PATH] = L""; - BOOL fSuccess; - BOOL bUnicodeErr = FALSE; - BOOL bFileTooBig = FALSE; - - if (!bDontSave) - { - if (!FileSave(FALSE,TRUE,FALSE,FALSE)) - return FALSE; - } - - if (bNew) { - lstrcpy(szCurFile,L""); - SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); - SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); - if (!fKeepTitleExcerpt) - lstrcpy(szTitleExcerpt,L""); - FileVars_Init(NULL,0,&fvCurFile); - EditSetNewText(hwndEdit,"",0); - Style_SetLexer(hwndEdit,NULL); - UpdateLineNumberWidth(); - bModified = FALSE; - bReadOnly = FALSE; - iEOLMode = iLineEndings[iDefaultEOLMode]; - SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); - iEncoding = iDefaultEncoding; - iOriginalEncoding = iDefaultEncoding; - SendMessage(hwndEdit,SCI_SETCODEPAGE,(iDefaultEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); - EditSetNewText(hwndEdit,"",0); - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - - // Terminate file watching - if (bResetFileWatching) - iFileWatchingMode = 0; - InstallFileWatching(NULL); - - return TRUE; - } - - if (!lpszFile || lstrlen(lpszFile) == 0) { - if (!OpenFileDlg(hwndMain,tch,COUNTOF(tch),NULL)) - return FALSE; - } - - else - lstrcpy(tch,lpszFile); - - ExpandEnvironmentStringsEx(tch,COUNTOF(tch)); - - if (PathIsRelative(tch)) { - StrCpyN(szFileName,g_wchWorkingDirectory,COUNTOF(szFileName)); - PathAppend(szFileName,tch); - if (!PathFileExists(szFileName)) { - WCHAR wchFullPath[MAX_PATH]; - if (SearchPath(NULL,tch,NULL,COUNTOF(wchFullPath),wchFullPath,NULL)) { - lstrcpy(szFileName,wchFullPath); - } - } - } - else - lstrcpy(szFileName,tch); - - PathCanonicalizeEx(szFileName); - GetLongPathNameEx(szFileName,COUNTOF(szFileName)); - - if (PathIsLnkFile(szFileName)) - PathGetLnkPath(szFileName,szFileName,COUNTOF(szFileName)); - - // Ask to create a new file... - if (!bReload && !PathFileExists(szFileName)) - { - if (flagQuietCreate || MsgBox(MBYESNO,IDS_ASK_CREATE,szFileName) == IDYES) { - HANDLE hFile = CreateFile(szFileName, - GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); - dwLastIOError = GetLastError(); - if (fSuccess = (hFile != INVALID_HANDLE_VALUE)) { - CloseHandle(hFile); - FileVars_Init(NULL,0,&fvCurFile); - EditSetNewText(hwndEdit,"",0); - Style_SetLexer(hwndEdit,NULL); - iEOLMode = iLineEndings[iDefaultEOLMode]; - SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); - if (iSrcEncoding != -1) { - iEncoding = iSrcEncoding; - iOriginalEncoding = iSrcEncoding; - } - else { - iEncoding = iDefaultEncoding; - iOriginalEncoding = iDefaultEncoding; - } - SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); - bReadOnly = FALSE; - EditSetNewText(hwndEdit,"",0); - } - } - else - return FALSE; - } - - else - fSuccess = FileIO(TRUE,szFileName,bNoEncDetect,&iEncoding,&iEOLMode,&bUnicodeErr,&bFileTooBig,NULL,FALSE); - - if (fSuccess) { - lstrcpy(szCurFile,szFileName); - SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); - SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); - if (!fKeepTitleExcerpt) - lstrcpy(szTitleExcerpt,L""); - if (!flagLexerSpecified) // flag will be cleared - Style_SetLexerFromFile(hwndEdit,szCurFile); - UpdateLineNumberWidth(); - iOriginalEncoding = iEncoding; - bModified = FALSE; - //bReadOnly = FALSE; - SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0); - MRU_AddFile(pFileMRU,szFileName,flagRelativeFileMRU,flagPortableMyDocs); - if (flagUseSystemMRU == 2) - SHAddToRecentDocs(SHARD_PATHW,szFileName); - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szFileName, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - - // Install watching of the current file - if (!bReload && bResetFileWatching) - iFileWatchingMode = 0; - InstallFileWatching(szCurFile); - - // the .LOG feature ... - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { - char tchLog[5] = ""; - SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog); - if (lstrcmpiA(tchLog,".LOG") == 0) { - EditJumpTo(hwndEdit,-1,0); - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0); - EditJumpTo(hwndEdit,-1,0); - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - EditJumpTo(hwndEdit,-1,0); - EditEnsureSelectionVisible(hwndEdit); - } - } - - // Show warning: Unicode file loaded as ANSI - if (bUnicodeErr) - MsgBox(MBWARN,IDS_ERR_UNICODE); - } - - else if (!bFileTooBig) - MsgBox(MBWARN,IDS_ERR_LOADFILE,szFileName); - - return(fSuccess); -} - - -//============================================================================= -// -// FileSave() -// -// -BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy) -{ - WCHAR tchFile[MAX_PATH]; - BOOL fSuccess = FALSE; - BOOL bCancelDataLoss = FALSE; - - BOOL bIsEmptyNewFile = FALSE; - if (lstrlen(szCurFile) == 0) { - int cchText = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); - if (cchText == 0) - bIsEmptyNewFile = TRUE; - else if (cchText < 1023) { - char tchText[2048]; - SendMessage(hwndEdit,SCI_GETTEXT,(WPARAM)2047,(LPARAM)tchText); - StrTrimA(tchText," \t\n\r"); - if (lstrlenA(tchText) == 0) - bIsEmptyNewFile = TRUE; - } - } - - if (!bSaveAlways && (!bModified && iEncoding == iOriginalEncoding || bIsEmptyNewFile) && !bSaveAs) - return TRUE; - - if (bAsk) - { - // File or "Untitled" ... - WCHAR tch[MAX_PATH]; - if (lstrlen(szCurFile)) - lstrcpy(tch,szCurFile); - else - GetString(IDS_UNTITLED,tch,COUNTOF(tch)); - - switch (MsgBox(MBYESNOCANCEL,IDS_ASK_SAVE,tch)) { - case IDCANCEL: - return FALSE; - case IDNO: - return TRUE; - } - } - - // Read only... - if (!bSaveAs && !bSaveCopy && lstrlen(szCurFile)) - { - DWORD dwFileAttributes = GetFileAttributes(szCurFile); - if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) - bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); - if (bReadOnly) { - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - if (MsgBox(MBYESNOWARN,IDS_READONLY_SAVE,szCurFile) == IDYES) - bSaveAs = TRUE; - else - return FALSE; - } - } - - // Save As... - if (bSaveAs || bSaveCopy || lstrlen(szCurFile) == 0) - { - WCHAR tchInitialDir[MAX_PATH] = L""; - if (bSaveCopy && lstrlen(tchLastSaveCopyDir)) { - lstrcpy(tchInitialDir,tchLastSaveCopyDir); - lstrcpy(tchFile,tchLastSaveCopyDir); - PathAppend(tchFile,PathFindFileName(szCurFile)); - } - else - lstrcpy(tchFile,szCurFile); - - if (SaveFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchInitialDir)) - { - if (fSuccess = FileIO(FALSE,tchFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,bSaveCopy)) - { - if (!bSaveCopy) - { - lstrcpy(szCurFile,tchFile); - SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); - SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); - if (!fKeepTitleExcerpt) - lstrcpy(szTitleExcerpt,L""); - Style_SetLexerFromFile(hwndEdit,szCurFile); - UpdateStatusbar(); - UpdateLineNumberWidth(); - } - else { - lstrcpy(tchLastSaveCopyDir,tchFile); - PathRemoveFileSpec(tchLastSaveCopyDir); - } - } - } - else - return FALSE; - } - - else - fSuccess = FileIO(FALSE,szCurFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,FALSE); - - if (fSuccess) - { - if (!bSaveCopy) - { - bModified = FALSE; - iOriginalEncoding = iEncoding; - MRU_AddFile(pFileMRU,szCurFile,flagRelativeFileMRU,flagPortableMyDocs); - if (flagUseSystemMRU == 2) - SHAddToRecentDocs(SHARD_PATHW,szCurFile); - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - - // Install watching of the current file - if (bSaveAs && bResetFileWatching) - iFileWatchingMode = 0; - InstallFileWatching(szCurFile); - } - } - - else if (!bCancelDataLoss) - { - if (lstrlen(szCurFile) != 0) - lstrcpy(tchFile,szCurFile); - - SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, - iPathNameFormat,bModified || iEncoding != iOriginalEncoding, - IDS_READONLY,bReadOnly,szTitleExcerpt); - - MsgBox(MBWARN,IDS_ERR_SAVEFILE,tchFile); - } - - return(fSuccess); -} - - -//============================================================================= -// -// OpenFileDlg() -// -// -BOOL OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) -{ - OPENFILENAME ofn; - WCHAR szFile[MAX_PATH]; - WCHAR szFilter[NUMLEXERS*1024]; - WCHAR tchInitialDir[MAX_PATH] = L""; - - lstrcpy(szFile,L""); - Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter)); - - if (!lpstrInitialDir) { - if (lstrlen(szCurFile)) { - lstrcpy(tchInitialDir,szCurFile); - PathRemoveFileSpec(tchInitialDir); - } - else if (lstrlen(tchDefaultDir)) { - ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); - if (PathIsRelative(tchInitialDir)) { - WCHAR tchModule[MAX_PATH]; - GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); - PathRemoveFileSpec(tchModule); - PathAppend(tchModule,tchInitialDir); - PathCanonicalize(tchInitialDir,tchModule); - } - } - else - lstrcpy(tchInitialDir,g_wchWorkingDirectory); - } - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile = szFile; - ofn.lpstrInitialDir = (lpstrInitialDir) ? lpstrInitialDir : tchInitialDir; - ofn.nMaxFile = COUNTOF(szFile); - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/ - OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST | - OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/; - ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL; - - if (GetOpenFileName(&ofn)) { - lstrcpyn(lpstrFile,szFile,cchFile); - return TRUE; - } - - else - return FALSE; -} - - -//============================================================================= -// -// SaveFileDlg() -// -// -BOOL SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) -{ - OPENFILENAME ofn; - WCHAR szNewFile[MAX_PATH]; - WCHAR szFilter[NUMLEXERS*1024]; - WCHAR tchInitialDir[MAX_PATH] = L""; - - lstrcpy(szNewFile,lpstrFile); - Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter)); - - if (lstrlen(lpstrInitialDir)) - lstrcpy(tchInitialDir,lpstrInitialDir); - else if (lstrlen(szCurFile)) { - lstrcpy(tchInitialDir,szCurFile); - PathRemoveFileSpec(tchInitialDir); - } - else if (lstrlen(tchDefaultDir)) { - ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); - if (PathIsRelative(tchInitialDir)) { - WCHAR tchModule[MAX_PATH]; - GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); - PathRemoveFileSpec(tchModule); - PathAppend(tchModule,tchInitialDir); - PathCanonicalize(tchInitialDir,tchModule); - } - } - else - lstrcpy(tchInitialDir,g_wchWorkingDirectory); - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile = szNewFile; - ofn.lpstrInitialDir = tchInitialDir; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ | - /*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT | - OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST; - ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL; - - if (GetSaveFileName(&ofn)) { - lstrcpyn(lpstrFile,szNewFile,cchFile); - return TRUE; - } - - else - return FALSE; -} - - -/****************************************************************************** -* -* ActivatePrevInst() -* -* Tries to find and activate an already open Notepad2 Window -* -* -******************************************************************************/ -BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam) -{ - BOOL bContinue = TRUE; - WCHAR szClassName[64]; - - if (GetClassName(hwnd,szClassName,COUNTOF(szClassName))) - - if (lstrcmpi(szClassName,wchWndClass) == 0) { - - DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE); - if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) { - - *(HWND*)lParam = hwnd; - - if (IsWindowEnabled(hwnd)) - bContinue = FALSE; - } - } - return(bContinue); -} - -BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam) -{ - BOOL bContinue = TRUE; - WCHAR szClassName[64]; - - if (GetClassName(hwnd,szClassName,COUNTOF(szClassName))) - - if (lstrcmpi(szClassName,wchWndClass) == 0) { - - DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE); - if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) { - - WCHAR tchFileName[MAX_PATH] = L""; - - if (IsWindowEnabled(hwnd)) - bContinue = FALSE; - - GetDlgItemText(hwnd,IDC_FILENAME,tchFileName,COUNTOF(tchFileName)); - if (lstrcmpi(tchFileName,lpFileArg) == 0) - *(HWND*)lParam = hwnd; - else - bContinue = TRUE; - } - } - return(bContinue); -} - -BOOL ActivatePrevInst() -{ - HWND hwnd = NULL; - COPYDATASTRUCT cds; - - if ((flagNoReuseWindow && !flagSingleFileInstance) || flagStartAsTrayIcon || flagNewFromClipboard || flagPasteBoard) - return(FALSE); - - if (flagSingleFileInstance && lpFileArg) { - - // Search working directory from second instance, first! - // lpFileArg is at least MAX_PATH+2 bytes - WCHAR tchTmp[MAX_PATH]; - - ExpandEnvironmentStringsEx(lpFileArg,(DWORD)GlobalSize(lpFileArg)/sizeof(WCHAR)); - - if (PathIsRelative(lpFileArg)) { - StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); - PathAppend(tchTmp,lpFileArg); - if (PathFileExists(tchTmp)) - lstrcpy(lpFileArg,tchTmp); - else { - if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - lstrcpy(lpFileArg,tchTmp); - else { - StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); - PathAppend(tchTmp,lpFileArg); - lstrcpy(lpFileArg,tchTmp); - } - } - } - - else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - lstrcpy(lpFileArg,tchTmp); - - GetLongPathNameEx(lpFileArg,MAX_PATH); - - EnumWindows(EnumWndProc2,(LPARAM)&hwnd); - - if (hwnd != NULL) - { - // Enabled - if (IsWindowEnabled(hwnd)) - { - LPNP2PARAMS params; - DWORD cb = sizeof(NP2PARAMS); - - // Make sure the previous window won't pop up a change notification message - //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0); - - if (IsIconic(hwnd)) - ShowWindowAsync(hwnd,SW_RESTORE); - - if (!IsWindowVisible(hwnd)) { - SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK); - SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP); - } - - SetForegroundWindow(hwnd); - - if (lpSchemeArg) - cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR); - - params = GlobalAlloc(GPTR,cb); - params->flagFileSpecified = FALSE; - params->flagChangeNotify = 0; - params->flagQuietCreate = FALSE; - params->flagLexerSpecified = flagLexerSpecified; - if (flagLexerSpecified && lpSchemeArg) { - lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg); - params->iInitialLexer = -1; - } - else - params->iInitialLexer = iInitialLexer; - params->flagJumpTo = flagJumpTo; - params->iInitialLine = iInitialLine; - params->iInitialColumn = iInitialColumn; - - params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1; - params->flagSetEncoding = flagSetEncoding; - params->flagSetEOLMode = flagSetEOLMode; - params->flagTitleExcerpt = 0; - - cds.dwData = DATA_NOTEPAD2_PARAMS; - cds.cbData = (DWORD)GlobalSize(params); - cds.lpData = params; - - SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds); - GlobalFree(params); - - return(TRUE); - } - - else // IsWindowEnabled() - { - // Ask... - if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED)) - return(FALSE); - else - return(TRUE); - } - } - } - - if (flagNoReuseWindow) - return(FALSE); - - hwnd = NULL; - EnumWindows(EnumWndProc,(LPARAM)&hwnd); - - // Found a window - if (hwnd != NULL) - { - // Enabled - if (IsWindowEnabled(hwnd)) - { - // Make sure the previous window won't pop up a change notification message - //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0); - - if (IsIconic(hwnd)) - ShowWindowAsync(hwnd,SW_RESTORE); - - if (!IsWindowVisible(hwnd)) { - SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK); - SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP); - } - - SetForegroundWindow(hwnd); - - if (lpFileArg) - { - // Search working directory from second instance, first! - // lpFileArg is at least MAX_PATH+2 bytes - WCHAR tchTmp[MAX_PATH]; - LPNP2PARAMS params; - DWORD cb = sizeof(NP2PARAMS); - int cchTitleExcerpt; - - ExpandEnvironmentStringsEx(lpFileArg,(DWORD)GlobalSize(lpFileArg)/sizeof(WCHAR)); - - if (PathIsRelative(lpFileArg)) { - StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); - PathAppend(tchTmp,lpFileArg); - if (PathFileExists(tchTmp)) - lstrcpy(lpFileArg,tchTmp); - else { - if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - lstrcpy(lpFileArg,tchTmp); - } - } - - else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - lstrcpy(lpFileArg,tchTmp); - - cb += (lstrlen(lpFileArg) + 1) * sizeof(WCHAR); - - if (lpSchemeArg) - cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR); - - cchTitleExcerpt = lstrlen(szTitleExcerpt); - if (cchTitleExcerpt) - cb += (cchTitleExcerpt + 1) * sizeof(WCHAR); - - params = GlobalAlloc(GPTR,cb); - params->flagFileSpecified = TRUE; - lstrcpy(¶ms->wchData,lpFileArg); - params->flagChangeNotify = flagChangeNotify; - params->flagQuietCreate = flagQuietCreate; - params->flagLexerSpecified = flagLexerSpecified; - if (flagLexerSpecified && lpSchemeArg) { - lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg); - params->iInitialLexer = -1; - } - else - params->iInitialLexer = iInitialLexer; - params->flagJumpTo = flagJumpTo; - params->iInitialLine = iInitialLine; - params->iInitialColumn = iInitialColumn; - - params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1; - params->flagSetEncoding = flagSetEncoding; - params->flagSetEOLMode = flagSetEOLMode; - - if (cchTitleExcerpt) { - lstrcpy(StrEnd(¶ms->wchData)+1,szTitleExcerpt); - params->flagTitleExcerpt = 1; - } - else - params->flagTitleExcerpt = 0; - - cds.dwData = DATA_NOTEPAD2_PARAMS; - cds.cbData = (DWORD)GlobalSize(params); - cds.lpData = params; - - SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds); - GlobalFree(params); - GlobalFree(lpFileArg); - } - return(TRUE); - } - else // IsWindowEnabled() - { - // Ask... - if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED)) - return(FALSE); - else - return(TRUE); - } - } - else - return(FALSE); -} - - -//============================================================================= -// -// RelaunchMultiInst() -// -// -BOOL RelaunchMultiInst() { - - if (flagMultiFileArg == 2 && cFileList > 1) { - - WCHAR *pwch; - int i = 0; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - LPWSTR lpCmdLineNew = StrDup(GetCommandLine()); - LPWSTR lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1)); - LPWSTR lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1)); - - StrTab2Space(lpCmdLineNew); - lstrcpy(lpCmdLineNew + cchiFileList,L""); - - pwch = CharPrev(lpCmdLineNew,StrEnd(lpCmdLineNew)); - while (*pwch == L' ' || *pwch == L'-' || *pwch == L'+') { - *pwch = L' '; - pwch = CharPrev(lpCmdLineNew,pwch); - if (i++ > 1) - cchiFileList--; - } - - for (i = 0; i < cFileList; i++) { - - lstrcpy(lpCmdLineNew + cchiFileList,L" /n - "); - lstrcat(lpCmdLineNew,lpFileList[i]); - LocalFree(lpFileList[i]); - - ZeroMemory(&si,sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); - ZeroMemory(&pi,sizeof(PROCESS_INFORMATION)); - - CreateProcess(NULL,lpCmdLineNew,NULL,NULL,FALSE,0,NULL,g_wchWorkingDirectory,&si,&pi); - } - LocalFree(lpCmdLineNew); - LocalFree(lp1); - LocalFree(lp2); - GlobalFree(lpFileArg); - - return TRUE; - } - - else { - int i; - for (i = 0; i < cFileList; i++) - LocalFree(lpFileList[i]); - return FALSE; - } -} - - -//============================================================================= -// -// RelaunchElevated() -// -// -BOOL RelaunchElevated() { - - if (!IsVista() || fIsElevated || !flagRelaunchElevated || flagDisplayHelp) - return(FALSE); - - else { - - LPWSTR lpCmdLine; - LPWSTR lpArg1, lpArg2; - STARTUPINFO si; - SHELLEXECUTEINFO sei; - - si.cb = sizeof(STARTUPINFO); - GetStartupInfo(&si); - - lpCmdLine = GetCommandLine(); - lpArg1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - lpArg2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); - ExtractFirstArgument(lpCmdLine,lpArg1,lpArg2); - - if (lstrlen(lpArg1)) { - - ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOASYNC*/0x00000100 | /*SEE_MASK_NOZONECHECKS*/0x00800000; - sei.hwnd = GetForegroundWindow(); - sei.lpVerb = L"runas"; - sei.lpFile = lpArg1; - sei.lpParameters = lpArg2; - sei.lpDirectory = g_wchWorkingDirectory; - sei.nShow = si.wShowWindow; - - ShellExecuteEx(&sei); - } - - LocalFree(lpArg1); - LocalFree(lpArg2); - - return(TRUE); - } -} - - -//============================================================================= -// -// SnapToDefaultPos() -// -// Aligns Notepad2 to the default window position on the current screen -// -// -void SnapToDefaultPos(HWND hwnd) -{ - WINDOWPLACEMENT wndpl; - HMONITOR hMonitor; - MONITORINFO mi; - int x,y,cx,cy; - RECT rcOld; - - GetWindowRect(hwnd,&rcOld); - - hMonitor = MonitorFromRect(&rcOld,MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor,&mi); - - y = mi.rcWork.top + 16; - cy = mi.rcWork.bottom - mi.rcWork.top - 32; - cx = min(mi.rcWork.right - mi.rcWork.left - 32,cy); - x = mi.rcWork.right - cx - 16; - - wndpl.length = sizeof(WINDOWPLACEMENT); - wndpl.flags = WPF_ASYNCWINDOWPLACEMENT; - wndpl.showCmd = SW_RESTORE; - - wndpl.rcNormalPosition.left = x; - wndpl.rcNormalPosition.top = y; - wndpl.rcNormalPosition.right = x + cx; - wndpl.rcNormalPosition.bottom = y + cy; - - if (EqualRect(&rcOld,&wndpl.rcNormalPosition)) { - x = mi.rcWork.left + 16; - wndpl.rcNormalPosition.left = x; - wndpl.rcNormalPosition.right = x + cx; - } - - if (GetDoAnimateMinimize()) { - DrawAnimatedRects(hwnd,IDANI_CAPTION,&rcOld,&wndpl.rcNormalPosition); - OffsetRect(&wndpl.rcNormalPosition,mi.rcMonitor.left - mi.rcWork.left,mi.rcMonitor.top - mi.rcWork.top); - } - - SetWindowPlacement(hwnd,&wndpl); -} - - -//============================================================================= -// -// ShowNotifyIcon() -// -// -void ShowNotifyIcon(HWND hwnd,BOOL bAdd) -{ - - static HICON hIcon; - NOTIFYICONDATA nid; - - if (!hIcon) - hIcon = LoadImage(g_hInstance,MAKEINTRESOURCE(IDR_MAINWND), - IMAGE_ICON,16,16,LR_DEFAULTCOLOR); - - ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = hwnd; - nid.uID = 0; - nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; - nid.uCallbackMessage = WM_TRAYMESSAGE; - nid.hIcon = hIcon; - lstrcpy(nid.szTip,L"Notepad2"); - - if(bAdd) - Shell_NotifyIcon(NIM_ADD,&nid); - else - Shell_NotifyIcon(NIM_DELETE,&nid); - -} - - -//============================================================================= -// -// SetNotifyIconTitle() -// -// -void SetNotifyIconTitle(HWND hwnd) -{ - - NOTIFYICONDATA nid; - SHFILEINFO shfi; - WCHAR tchTitle[128]; - WCHAR tchFormat[32]; - - ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = hwnd; - nid.uID = 0; - nid.uFlags = NIF_TIP; - - if (lstrlen(szTitleExcerpt)) { - GetString(IDS_TITLEEXCERPT,tchFormat,COUNTOF(tchFormat)); - wsprintf(tchTitle,tchFormat,szTitleExcerpt); - } - - else if (lstrlen(szCurFile)) { - SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); - PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0); - } - else - GetString(IDS_UNTITLED,tchTitle,COUNTOF(tchTitle)-4); - - if (bModified || iEncoding != iOriginalEncoding) - lstrcpy(nid.szTip,L"* "); - else - lstrcpy(nid.szTip,L""); - lstrcat(nid.szTip,tchTitle); - - Shell_NotifyIcon(NIM_MODIFY,&nid); - -} - - -//============================================================================= -// -// InstallFileWatching() -// -// -void InstallFileWatching(LPCWSTR lpszFile) -{ - - WCHAR tchDirectory[MAX_PATH]; - HANDLE hFind; - - // Terminate - if (!iFileWatchingMode || !lpszFile || lstrlen(lpszFile) == 0) - { - if (bRunningWatch) - { - if (hChangeHandle) { - FindCloseChangeNotification(hChangeHandle); - hChangeHandle = NULL; - } - KillTimer(NULL,ID_WATCHTIMER); - bRunningWatch = FALSE; - dwChangeNotifyTime = 0; - } - return; - } - - // Install - else - { - // Terminate previous watching - if (bRunningWatch) { - if (hChangeHandle) { - FindCloseChangeNotification(hChangeHandle); - hChangeHandle = NULL; - } - dwChangeNotifyTime = 0; - } - - // No previous watching installed, so launch the timer first - else - SetTimer(NULL,ID_WATCHTIMER,dwFileCheckInverval,WatchTimerProc); - - lstrcpy(tchDirectory,lpszFile); - PathRemoveFileSpec(tchDirectory); - - // Save data of current file - hFind = FindFirstFile(szCurFile,&fdCurFile); - if (hFind != INVALID_HANDLE_VALUE) - FindClose(hFind); - else - ZeroMemory(&fdCurFile,sizeof(WIN32_FIND_DATA)); - - hChangeHandle = FindFirstChangeNotification(tchDirectory,FALSE, - FILE_NOTIFY_CHANGE_FILE_NAME | \ - FILE_NOTIFY_CHANGE_DIR_NAME | \ - FILE_NOTIFY_CHANGE_ATTRIBUTES | \ - FILE_NOTIFY_CHANGE_SIZE | \ - FILE_NOTIFY_CHANGE_LAST_WRITE); - - bRunningWatch = TRUE; - dwChangeNotifyTime = 0; - } -} - - -//============================================================================= -// -// WatchTimerProc() -// -// -void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) -{ - if (bRunningWatch) - { - if (dwChangeNotifyTime > 0 && GetTickCount() - dwChangeNotifyTime > dwAutoReloadTimeout) - { - if (hChangeHandle) { - FindCloseChangeNotification(hChangeHandle); - hChangeHandle = NULL; - } - KillTimer(NULL,ID_WATCHTIMER); - bRunningWatch = FALSE; - dwChangeNotifyTime = 0; - SendMessage(hwndMain,WM_CHANGENOTIFY,0,0); - } - - // Check Change Notification Handle - else if (WAIT_OBJECT_0 == WaitForSingleObject(hChangeHandle,0)) - { - // Check if the changes affect the current file - WIN32_FIND_DATA fdUpdated; - HANDLE hFind = FindFirstFile(szCurFile,&fdUpdated); - if (INVALID_HANDLE_VALUE != hFind) - FindClose(hFind); - else - // The current file has been removed - ZeroMemory(&fdUpdated,sizeof(WIN32_FIND_DATA)); - - // Check if the file has been changed - if (CompareFileTime(&fdCurFile.ftLastWriteTime,&fdUpdated.ftLastWriteTime) != 0 || - fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow || - fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh) - { - // Shutdown current watching and give control to main window - if (hChangeHandle) { - FindCloseChangeNotification(hChangeHandle); - hChangeHandle = NULL; - } - if (iFileWatchingMode == 2) { - bRunningWatch = TRUE; /* ! */ - dwChangeNotifyTime = GetTickCount(); - } - else { - KillTimer(NULL,ID_WATCHTIMER); - bRunningWatch = FALSE; - dwChangeNotifyTime = 0; - SendMessage(hwndMain,WM_CHANGENOTIFY,0,0); - } - } - - else - FindNextChangeNotification(hChangeHandle); - } - } -} - - -//============================================================================= -// -// PasteBoardTimer() -// -// -void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) -{ - if (dwLastCopyTime > 0 && GetTickCount() - dwLastCopyTime > 200) { - - if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) { - - BOOL bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; - EditJumpTo(hwndEdit,-1,0); - SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0) - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndEdit,SCI_PASTE,0,0); - SendMessage(hwndEdit,SCI_NEWLINE,0,0); - SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); - EditEnsureSelectionVisible(hwndEdit); - bAutoIndent = bAutoIndent2; - } - - dwLastCopyTime = 0; - } -} - - - -/// End of Notepad2.c \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Notepad2.c +* Main application window functionality +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "scintilla.h" +#include "scilexer.h" +#include "notepad2.h" +#include "edit.h" +#include "styles.h" +#include "dialogs.h" +#include "helpers.h" +#include "SciCall.h" +#include "resource.h" + + + +/****************************************************************************** +* +* Local and global Variables for Notepad2.c +* +*/ +HWND hwndStatus; +HWND hwndToolbar; +HWND hwndReBar; +HWND hwndEdit; +HWND hwndEditFrame; +HWND hwndMain; +HWND hwndNextCBChain = NULL; +HWND hDlgFindReplace = NULL; + +#define NUMTOOLBITMAPS 25 +#define NUMINITIALTOOLS 24 +#define MARGIN_FOLD_INDEX 2 + +TBBUTTON tbbMainWnd[] = { {0,IDT_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {1,IDT_FILE_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {2,IDT_FILE_BROWSE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {3,IDT_FILE_SAVE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {4,IDT_EDIT_UNDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {5,IDT_EDIT_REDO,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {6,IDT_EDIT_CUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {7,IDT_EDIT_COPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {8,IDT_EDIT_PASTE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {9,IDT_EDIT_FIND,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {10,IDT_EDIT_REPLACE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {11,IDT_VIEW_WORDWRAP,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {12,IDT_VIEW_ZOOMIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {13,IDT_VIEW_ZOOMOUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {14,IDT_VIEW_SCHEME,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {15,IDT_VIEW_SCHEMECONFIG,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {0,0,0,TBSTYLE_SEP,0,0}, + {16,IDT_FILE_EXIT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {17,IDT_FILE_SAVEAS,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {18,IDT_FILE_SAVECOPY,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {19,IDT_EDIT_CLEAR,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {20,IDT_FILE_PRINT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {21,IDT_FILE_OPENFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {22,IDT_FILE_ADDTOFAV,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {23,IDT_VIEW_TOGGLEFOLDS,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0}, + {24,IDT_FILE_LAUNCH,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0} }; + +WCHAR szIniFile[MAX_PATH] = L""; +WCHAR szIniFile2[MAX_PATH] = L""; +BOOL bSaveSettings; +BOOL bSaveRecentFiles; +BOOL bSaveFindReplace; +WCHAR tchLastSaveCopyDir[MAX_PATH] = L""; +WCHAR tchOpenWithDir[MAX_PATH]; +WCHAR tchFavoritesDir[MAX_PATH]; +WCHAR tchDefaultDir[MAX_PATH]; +WCHAR tchDefaultExtension[64]; +WCHAR tchFileDlgFilters[5*1024]; +WCHAR tchToolbarButtons[512]; +WCHAR tchToolbarBitmap[MAX_PATH]; +WCHAR tchToolbarBitmapHot[MAX_PATH]; +WCHAR tchToolbarBitmapDisabled[MAX_PATH]; +int iPathNameFormat; +BOOL fWordWrap; +BOOL fWordWrapG; +int iWordWrapMode; +int iWordWrapIndent; +int iWordWrapSymbols; +BOOL bShowWordWrapSymbols; +BOOL bMatchBraces; +BOOL bAutoIndent; +BOOL bAutoCloseTags; +BOOL bShowIndentGuides; +BOOL bHiliteCurrentLine; +BOOL bTabsAsSpaces; +BOOL bTabsAsSpacesG; +BOOL bTabIndents; +BOOL bTabIndentsG; +BOOL bBackspaceUnindents; +int iTabWidth; +int iTabWidthG; +int iIndentWidth; +int iIndentWidthG; +BOOL bMarkLongLines; +int iLongLinesLimit; +int iLongLinesLimitG; +int iLongLineMode; +int iWrapCol = 0; +BOOL bShowSelectionMargin; +BOOL bShowLineNumbers; +int iMarkOccurrences; +BOOL bMarkOccurrencesMatchCase; +BOOL bMarkOccurrencesMatchWords; +BOOL bAutoCompleteWords; +BOOL bShowCodeFolding; +BOOL bViewWhiteSpace; +BOOL bViewEOLs; +int iDefaultEncoding; +BOOL bSkipUnicodeDetection; +BOOL bLoadASCIIasUTF8; +BOOL bLoadNFOasOEM; +BOOL bNoEncodingTags; +int iSrcEncoding = -1; +int iWeakSrcEncoding = -1; +int iDefaultEOLMode; +BOOL bFixLineEndings; +BOOL bAutoStripBlanks; +int iPrintHeader; +int iPrintFooter; +int iPrintColor; +int iPrintZoom; +RECT pagesetupMargin; +BOOL bSaveBeforeRunningTools; +int iFileWatchingMode; +BOOL bResetFileWatching; +DWORD dwFileCheckInverval; +DWORD dwAutoReloadTimeout; +int iEscFunction; +BOOL bAlwaysOnTop; +BOOL bMinimizeToTray; +BOOL bTransparentMode; +BOOL bTransparentModeAvailable; +BOOL bShowToolbar; +BOOL bShowStatusbar; + +typedef struct _wi +{ + int x; + int y; + int cx; + int cy; + int max; +} WININFO; + +WININFO wi; +BOOL bStickyWinPos; + +BOOL bIsAppThemed; +int cyReBar; +int cyReBarFrame; +int cxEditFrame; +int cyEditFrame; + +int cxEncodingDlg; +int cyEncodingDlg; +int cxRecodeDlg; +int cyRecodeDlg; +int cxFileMRUDlg; +int cyFileMRUDlg; +int cxOpenWithDlg; +int cyOpenWithDlg; +int cxFavoritesDlg; +int cyFavoritesDlg; +int xFindReplaceDlg; +int yFindReplaceDlg; + +LPWSTR lpFileList[32]; +int cFileList = 0; +int cchiFileList = 0; +LPWSTR lpFileArg = NULL; +LPWSTR lpSchemeArg = NULL; +LPWSTR lpMatchArg = NULL; +LPWSTR lpEncodingArg = NULL; +LPMRULIST pFileMRU; +LPMRULIST mruFind; +LPMRULIST mruReplace; + +DWORD dwLastIOError; +WCHAR szCurFile[MAX_PATH+40]; +FILEVARS fvCurFile; +BOOL bModified; +BOOL bReadOnly = FALSE; +int iEncoding; +int iOriginalEncoding; +int iEOLMode; + +int iDefaultCodePage; +int iDefaultCharSet; + +int iInitialLine; +int iInitialColumn; + +int iInitialLexer; + +BOOL bLastCopyFromMe = FALSE; +DWORD dwLastCopyTime; + +UINT uidsAppTitle = IDS_APPTITLE; +WCHAR szTitleExcerpt[128] = L""; +int fKeepTitleExcerpt = 0; + +HANDLE hChangeHandle = NULL; +BOOL bRunningWatch = FALSE; +BOOL dwChangeNotifyTime = 0; +WIN32_FIND_DATA fdCurFile; + +UINT msgTaskbarCreated = 0; + +HMODULE hModUxTheme = NULL; + +EDITFINDREPLACE efrData = { "", "", "", "", 0, 0, 0, 0, 0, 0, NULL }; +UINT cpLastFind = 0; +BOOL bReplaceInitialized = FALSE; + +extern NP2ENCODING mEncoding[]; + +int iLineEndings[3] = { + SC_EOL_CRLF, + SC_EOL_LF, + SC_EOL_CR +}; + +WCHAR wchPrefixSelection[256] = L""; +WCHAR wchAppendSelection[256] = L""; + +WCHAR wchPrefixLines[256] = L""; +WCHAR wchAppendLines[256] = L""; + +int iSortOptions = 0; +int iAlignMode = 0; + +BOOL fIsElevated = FALSE; +WCHAR wchWndClass[16] = WC_NOTEPAD2; + +HINSTANCE g_hInstance; +HANDLE g_hScintilla; +UINT16 g_uWinVer; +WCHAR g_wchAppUserModelID[32] = L""; +WCHAR g_wchWorkingDirectory[MAX_PATH] = L""; + + + +#ifdef BOOKMARK_EDITION + //Graphics for bookmark indicator + /* XPM */ + static char * bookmark_pixmap[] = { + "11 11 44 1", + " c #EBE9ED", + ". c #E5E3E7", + "+ c #767C6D", + "@ c #2A3120", + "# c #1B2312", + "$ c #333B28", + "% c #E3E1E5", + "& c #D8D6DA", + "* c #444D38", + "= c #3F5C19", + "- c #63AD00", + "; c #73C900", + "> c #64AF00", + ", c #3D5718", + "' c #3E4634", + ") c #7B8172", + "! c #42601A", + "~ c #74CB00", + "{ c #71C600", + "] c #3A5317", + "^ c #707668", + "/ c #3F4931", + "( c #262C1D", + "_ c #2F3A1E", + ": c #72C700", + "< c #74CA00", + "[ c #0E1109", + "} c #3C462F", + "| c #62AC00", + "1 c #21271A", + "2 c #7A8071", + "3 c #405D19", + "4 c #3D5A18", + "5 c #D9D7DB", + "6 c #4E5841", + "7 c #72C800", + "8 c #63AC00", + "9 c #3F5B19", + "0 c #3D4533", + "a c #DFDDE0", + "b c #353E29", + "c c #29331B", + "d c #7B8272", + "e c #DDDBDF", + " ", + " .+@#$+% ", + " &*=-;>,' ", + " )!~~~~{]^ ", + " /-~~~~~>( ", + " _:~~~~~<[ ", + " }|~~~~~|1 ", + " 23~~~~;4+ ", + " 56=|7890 ", + " a2bc}de ", + " "}; +#endif + + + +//============================================================================= +// +// Flags +// +int flagNoReuseWindow = 0; +int flagReuseWindow = 0; +int flagMultiFileArg = 0; +int flagSingleFileInstance = 0; +int flagStartAsTrayIcon = 0; +int flagAlwaysOnTop = 0; +int flagRelativeFileMRU = 0; +int flagPortableMyDocs = 0; +int flagNoFadeHidden = 0; +int flagToolbarLook = 0; +int flagSimpleIndentGuides = 0; +int fNoHTMLGuess = 0; +int fNoCGIGuess = 0; +int fNoFileVariables = 0; +int flagPosParam = 0; +int flagDefaultPos = 0; +int flagNewFromClipboard = 0; +int flagPasteBoard = 0; +int flagSetEncoding = 0; +int flagSetEOLMode = 0; +int flagJumpTo = 0; +int flagMatchText = 0; +int flagChangeNotify = 0; +int flagLexerSpecified = 0; +int flagQuietCreate = 0; +int flagUseSystemMRU = 0; +int flagRelaunchElevated = 0; +int flagDisplayHelp = 0; + + + +//============================================================================== +// +// Folding Functions +// +// +typedef enum { + EXPAND = 1, + SNIFF = 0, + FOLD = -1 +} FOLD_ACTION; + +#define FOLD_CHILDREN SCMOD_CTRL +#define FOLD_SIBLINGS SCMOD_SHIFT + +BOOL __stdcall FoldToggleNode( int ln, FOLD_ACTION action ) +{ + BOOL fExpanded = SciCall_GetFoldExpanded(ln); + + if ((action == FOLD && fExpanded) || (action == EXPAND && !fExpanded)) + { + SciCall_ToggleFold(ln); + return(TRUE); + } + + return(FALSE); +} + +void __stdcall FoldToggleAll( FOLD_ACTION action ) +{ + BOOL fToggled = FALSE; + int lnTotal = SciCall_GetLineCount(); + int ln; + + for (ln = 0; ln < lnTotal; ++ln) + { + if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + { + if (action == SNIFF) + action = SciCall_GetFoldExpanded(ln) ? FOLD : EXPAND; + + if (FoldToggleNode(ln, action)) + fToggled = TRUE; + } + } + + if (fToggled) + { + SciCall_SetXCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,50); + SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,5); + SciCall_ScrollCaret(); + SciCall_SetXCaretPolicy(CARET_SLOP|CARET_EVEN,50); + SciCall_SetYCaretPolicy(CARET_EVEN,0); + } +} + +void __stdcall FoldPerformAction( int ln, int mode, FOLD_ACTION action ) +{ + if (action == SNIFF) + action = SciCall_GetFoldExpanded(ln) ? FOLD : EXPAND; + + if (mode & (FOLD_CHILDREN | FOLD_SIBLINGS)) + { + // ln/lvNode: line and level of the source of this fold action + int lnNode = ln; + int lvNode = SciCall_GetFoldLevel(lnNode) & SC_FOLDLEVELNUMBERMASK; + int lnTotal = SciCall_GetLineCount(); + + // lvStop: the level over which we should not cross + int lvStop = lvNode; + + if (mode & FOLD_SIBLINGS) + { + ln = SciCall_GetFoldParent(lnNode) + 1; // -1 + 1 = 0 if no parent + --lvStop; + } + + for ( ; ln < lnTotal; ++ln) + { + int lv = SciCall_GetFoldLevel(ln); + BOOL fHeader = lv & SC_FOLDLEVELHEADERFLAG; + lv &= SC_FOLDLEVELNUMBERMASK; + + if (lv < lvStop || (lv == lvStop && fHeader && ln != lnNode)) + return; + else if (fHeader && (lv == lvNode || (lv > lvNode && mode & FOLD_CHILDREN))) + FoldToggleNode(ln, action); + } + } + else + { + FoldToggleNode(ln, action); + } +} + +void __stdcall FoldClick( int ln, int mode ) +{ + static struct { + int ln; + int mode; + DWORD dwTickCount; + } prev; + + BOOL fGotoFoldPoint = mode & FOLD_SIBLINGS; + + if (!(SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG)) + { + // Not a fold point: need to look for a double-click + + if ( prev.ln == ln && prev.mode == mode && + GetTickCount() - prev.dwTickCount <= GetDoubleClickTime() ) + { + prev.ln = -1; // Prevent re-triggering on a triple-click + + ln = SciCall_GetFoldParent(ln); + + if (ln >= 0 && SciCall_GetFoldExpanded(ln)) + fGotoFoldPoint = TRUE; + else + return; + } + else + { + // Save the info needed to match this click with the next click + prev.ln = ln; + prev.mode = mode; + prev.dwTickCount = GetTickCount(); + return; + } + } + + FoldPerformAction(ln, mode, SNIFF); + + if (fGotoFoldPoint) + EditJumpTo(hwndEdit, ln + 1, 0); +} + +void __stdcall FoldAltArrow( int key, int mode ) +{ + // Because Alt-Shift is already in use (and because the sibling fold feature + // is not as useful from the keyboard), only the Ctrl modifier is supported + + if (bShowCodeFolding && (mode & (SCMOD_ALT | SCMOD_SHIFT)) == SCMOD_ALT) + { + int ln = SciCall_LineFromPosition(SciCall_GetCurrentPos()); + + // Jump to the next visible fold point + if (key == SCK_DOWN && !(mode & SCMOD_CTRL)) + { + int lnTotal = SciCall_GetLineCount(); + for (ln = ln + 1; ln < lnTotal; ++ln) + { + if ( SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG && + SciCall_GetLineVisible(ln) ) + { + EditJumpTo(hwndEdit, ln + 1, 0); + return; + } + } + } + + // Jump to the previous visible fold point + else if (key == SCK_UP && !(mode & SCMOD_CTRL)) + { + for (ln = ln - 1; ln >= 0; --ln) + { + if ( SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG && + SciCall_GetLineVisible(ln) ) + { + EditJumpTo(hwndEdit, ln + 1, 0); + return; + } + } + } + + // Perform a fold/unfold operation + else if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + { + if (key == SCK_LEFT ) FoldPerformAction(ln, mode, FOLD); + if (key == SCK_RIGHT) FoldPerformAction(ln, mode, EXPAND); + } + } +} + + + +//============================================================================= +// +// WinMain() +// +// +int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow) +{ + + MSG msg; + HWND hwnd; + HACCEL hAccMain; + HACCEL hAccFindReplace; + INITCOMMONCONTROLSEX icex; + //HMODULE hSciLexer; + WCHAR wchWorkingDirectory[MAX_PATH]; + + // Set global variable g_hInstance + g_hInstance = hInstance; + + // Set the Windows version global variable + g_uWinVer = LOWORD(GetVersion()); + g_uWinVer = MAKEWORD(HIBYTE(g_uWinVer),LOBYTE(g_uWinVer)); + + // Don't keep working directory locked + GetCurrentDirectory(COUNTOF(g_wchWorkingDirectory),g_wchWorkingDirectory); + GetModuleFileName(NULL,wchWorkingDirectory,COUNTOF(wchWorkingDirectory)); + PathRemoveFileSpec(wchWorkingDirectory); + SetCurrentDirectory(wchWorkingDirectory); + + SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); + + // check if running at least on Windows 2000 + if (!Is2k()) { + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER| + FORMAT_MESSAGE_FROM_SYSTEM| + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ERROR_OLD_WIN_VERSION, + MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Default language + (LPWSTR)&lpMsgBuf, + 0, + NULL); + MessageBox(NULL,(LPCWSTR)lpMsgBuf,L"Notepad2-mod",MB_OK|MB_ICONEXCLAMATION); + LocalFree(lpMsgBuf); + return(0); + } + + // Check if running with elevated privileges + fIsElevated = IsElevated(); + + // Default Encodings (may already be used for command line parsing) + Encoding_InitDefaults(); + + // Command Line, Ini File and Flags + ParseCommandLine(); + FindIniFile(); + TestIniFile(); + CreateIniFile(); + LoadFlags(); + + // set AppUserModelID + PrivateSetCurrentProcessExplicitAppUserModelID(g_wchAppUserModelID); + + // Command Line Help Dialog + if (flagDisplayHelp) { + DisplayCmdLineHelp(NULL); + return(0); + } + + // Adapt window class name + if (fIsElevated) + StrCat(wchWndClass,L"U"); + if (flagPasteBoard) + StrCat(wchWndClass,L"B"); + + // Relaunch with elevated privileges + if (RelaunchElevated()) + return(0); + + // Try to run multiple instances + if (RelaunchMultiInst()) + return(0); + + // Try to activate another window + if (ActivatePrevInst()) + return(0); + + // Init OLE and Common Controls + OleInitialize(NULL); + + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES; + InitCommonControlsEx(&icex); + + msgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); + + hModUxTheme = LoadLibrary(L"uxtheme.dll"); + + Scintilla_RegisterClasses(hInstance); + + // Load Settings + LoadSettings(); + + if (!InitApplication(hInstance)) + return FALSE; + + if (!(hwnd = InitInstance(hInstance,lpCmdLine,nCmdShow))) + return FALSE; + + hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); + hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE)); + + while (GetMessage(&msg,NULL,0,0)) + { + if (IsWindow(hDlgFindReplace) && (msg.hwnd == hDlgFindReplace || IsChild(hDlgFindReplace,msg.hwnd))) + if (TranslateAccelerator(hDlgFindReplace,hAccFindReplace,&msg) || IsDialogMessage(hDlgFindReplace,&msg)) + continue; + + if (!TranslateAccelerator(hwnd,hAccMain,&msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + // Save Settings is done elsewhere + + Scintilla_ReleaseResources(); + UnregisterClass(wchWndClass,hInstance); + + if (hModUxTheme) + FreeLibrary(hModUxTheme); + + OleUninitialize(); + + return(int)(msg.wParam); + + hPrevInst; + +} + + +//============================================================================= +// +// InitApplication() +// +// +BOOL InitApplication(HINSTANCE hInstance) +{ + + WNDCLASS wc; + + wc.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS; + wc.lpfnWndProc = (WNDPROC)MainWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); + wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINWND); + wc.lpszClassName = wchWndClass; + + return RegisterClass(&wc); + +} + + +//============================================================================= +// +// InitInstance() +// +// +HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) +{ + + RECT rc = { wi.x, wi.y, wi.x+wi.cx, wi.y+wi.cy }; + RECT rc2; + MONITORINFO mi; + + HMONITOR hMonitor = MonitorFromRect(&rc,MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor,&mi); + + if (flagDefaultPos == 1) { + wi.x = wi.y = wi.cx = wi.cy = CW_USEDEFAULT; + wi.max = 0; + } + + else if (flagDefaultPos >= 4) { + SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0); + if (flagDefaultPos & 8) + wi.x = (rc.right - rc.left) / 2; + else + wi.x = rc.left; + wi.cx = rc.right - rc.left; + if (flagDefaultPos & (4|8)) + wi.cx /= 2; + if (flagDefaultPos & 32) + wi.y = (rc.bottom - rc.top) / 2; + else + wi.y = rc.top; + wi.cy = rc.bottom - rc.top; + if (flagDefaultPos & (16|32)) + wi.cy /= 2; + if (flagDefaultPos & 64) { + wi.x = rc.left; + wi.y = rc.top; + wi.cx = rc.right - rc.left; + wi.cy = rc.bottom - rc.top; + } + if (flagDefaultPos & 128) { + wi.x += (flagDefaultPos & 8) ? 4 : 8; + wi.cx -= (flagDefaultPos & (4|8)) ? 12 : 16; + wi.y += (flagDefaultPos & 32) ? 4 : 8; + wi.cy -= (flagDefaultPos & (16|32)) ? 12 : 16; + } + } + + else if (flagDefaultPos == 2 || flagDefaultPos == 3 || + wi.x == CW_USEDEFAULT || wi.y == CW_USEDEFAULT || + wi.cx == CW_USEDEFAULT || wi.cy == CW_USEDEFAULT) { + + // default window position + SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0); + wi.y = rc.top + 16; + wi.cy = rc.bottom - rc.top - 32; + wi.cx = min(rc.right - rc.left - 32,wi.cy); + wi.x = (flagDefaultPos == 3) ? rc.left + 16 : rc.right - wi.cx - 16; + } + + else { + + // fit window into working area of current monitor + wi.x += (mi.rcWork.left - mi.rcMonitor.left); + wi.y += (mi.rcWork.top - mi.rcMonitor.top); + if (wi.x < mi.rcWork.left) + wi.x = mi.rcWork.left; + if (wi.y < mi.rcWork.top) + wi.y = mi.rcWork.top; + if (wi.x + wi.cx > mi.rcWork.right) { + wi.x -= (wi.x + wi.cx - mi.rcWork.right); + if (wi.x < mi.rcWork.left) + wi.x = mi.rcWork.left; + if (wi.x + wi.cx > mi.rcWork.right) + wi.cx = mi.rcWork.right - wi.x; + } + if (wi.y + wi.cy > mi.rcWork.bottom) { + wi.y -= (wi.y + wi.cy - mi.rcWork.bottom); + if (wi.y < mi.rcWork.top) + wi.y = mi.rcWork.top; + if (wi.y + wi.cy > mi.rcWork.bottom) + wi.cy = mi.rcWork.bottom - wi.y; + } + SetRect(&rc,wi.x,wi.y,wi.x+wi.cx,wi.y+wi.cy); + if (!IntersectRect(&rc2,&rc,&mi.rcWork)) { + wi.y = mi.rcWork.top + 16; + wi.cy = mi.rcWork.bottom - mi.rcWork.top - 32; + wi.cx = min(mi.rcWork.right - mi.rcWork.left - 32,wi.cy); + wi.x = mi.rcWork.right - wi.cx - 16; + } + } + + hwndMain = CreateWindowEx( + 0, + wchWndClass, + L"Notepad2", + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, + wi.x, + wi.y, + wi.cx, + wi.cy, + NULL, + NULL, + hInstance, + NULL); + + if (wi.max) + nCmdShow = SW_SHOWMAXIMIZED; + + if ((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1) + SetWindowPos(hwndMain,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + + if (bTransparentMode) + SetWindowTransparentMode(hwndMain,TRUE); + + // Current file information -- moved in front of ShowWindow() + FileLoad(TRUE,TRUE,FALSE,FALSE,L""); + + if (!flagStartAsTrayIcon) { + ShowWindow(hwndMain,nCmdShow); + UpdateWindow(hwndMain); + } + else { + ShowWindow(hwndMain,SW_HIDE); // trick ShowWindow() + ShowNotifyIcon(hwndMain,TRUE); + } + + // Source Encoding + if (lpEncodingArg) + iSrcEncoding = Encoding_MatchW(lpEncodingArg); + + // Pathname parameter + if (lpFileArg /*&& !flagNewFromClipboard*/) + { + BOOL bOpened = FALSE; + + // Open from Directory + if (PathIsDirectory(lpFileArg)) { + WCHAR tchFile[MAX_PATH]; + if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),lpFileArg)) + bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); + } + else { + if (bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,lpFileArg)) { + if (flagJumpTo) { // Jump to position + EditJumpTo(hwndEdit,iInitialLine,iInitialColumn); + EditEnsureSelectionVisible(hwndEdit); + } + } + } + GlobalFree(lpFileArg); + + if (bOpened) { + if (flagChangeNotify == 1) { + iFileWatchingMode = 0; + bResetFileWatching = TRUE; + InstallFileWatching(szCurFile); + } + else if (flagChangeNotify == 2) { + iFileWatchingMode = 2; + bResetFileWatching = TRUE; + InstallFileWatching(szCurFile); + } + } + } + + else { + if (iSrcEncoding != -1) { + iEncoding = iSrcEncoding; + iOriginalEncoding = iSrcEncoding; + SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); + } + } + + // reset + iSrcEncoding = -1; + flagQuietCreate = 0; + fKeepTitleExcerpt = 0; + + // Check for /c [if no file is specified] -- even if a file is specified + /*else */if (flagNewFromClipboard) { + if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) { + BOOL bAutoIndent2 = bAutoIndent; + bAutoIndent = 0; + EditJumpTo(hwndEdit,-1,0); + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0) + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndEdit,SCI_PASTE,0,0); + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + bAutoIndent = bAutoIndent2; + if (flagJumpTo) + EditJumpTo(hwndEdit,iInitialLine,iInitialColumn); + EditEnsureSelectionVisible(hwndEdit); + } + } + + // Encoding + if (0 != flagSetEncoding) { + SendMessage( + hwndMain, + WM_COMMAND, + MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1), + 0); + flagSetEncoding = 0; + } + + // EOL mode + if (0 != flagSetEOLMode) { + SendMessage( + hwndMain, + WM_COMMAND, + MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1), + 0); + flagSetEOLMode = 0; + } + + // Match Text + if (flagMatchText && lpMatchArg) { + if (lstrlen(lpMatchArg) && SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) { + + UINT cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); + WideCharToMultiByte(cp,0,lpMatchArg,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL); + WideCharToMultiByte(CP_UTF8,0,lpMatchArg,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL); + cpLastFind = cp; + + if (flagMatchText & 4) + efrData.fuFlags |= SCFIND_REGEXP | SCFIND_POSIX; + else if (flagMatchText & 8) + efrData.bTransformBS = TRUE; + + if (flagMatchText & 2) { + if (!flagJumpTo) + EditJumpTo(hwndEdit,-1,0); + EditFindPrev(hwndEdit,&efrData,FALSE); + EditEnsureSelectionVisible(hwndEdit); + } + else { + if (!flagJumpTo) + SendMessage(hwndEdit,SCI_DOCUMENTSTART,0,0); + EditFindNext(hwndEdit,&efrData,FALSE); + EditEnsureSelectionVisible(hwndEdit); + } + } + GlobalFree(lpMatchArg); + } + + // Check for Paste Board option -- after loading files + if (flagPasteBoard) { + bLastCopyFromMe = TRUE; + hwndNextCBChain = SetClipboardViewer(hwndMain); + uidsAppTitle = IDS_APPTITLE_PASTEBOARD; + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + bLastCopyFromMe = FALSE; + + dwLastCopyTime = 0; + SetTimer(hwndMain,ID_PASTEBOARDTIMER,100,PasteBoardTimer); + } + + // check if a lexer was specified from the command line + if (flagLexerSpecified) { + if (lpSchemeArg) { + Style_SetLexerFromName(hwndEdit,szCurFile,lpSchemeArg); + LocalFree(lpSchemeArg); + } + else if (iInitialLexer >=0 && iInitialLexer < NUMLEXERS) + Style_SetLexerFromID(hwndEdit,iInitialLexer); + flagLexerSpecified = 0; + } + + // If start as tray icon, set current filename as tooltip + if (flagStartAsTrayIcon) + SetNotifyIconTitle(hwndMain); + + UpdateToolbar(); + UpdateStatusbar(); + + return(hwndMain); + +} + + +//============================================================================= +// +// MainWndProc() +// +// Messages are distributed to the MsgXXX-handlers +// +// +LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + static BOOL bShutdownOK; + + switch(umsg) + { + + // Quickly handle painting and sizing messages, found in ScintillaWin.cxx + // Cool idea, don't know if this has any effect... ;-) + case WM_MOVE: + case WM_MOUSEACTIVATE: + case WM_NCHITTEST: + case WM_NCCALCSIZE: + case WM_NCPAINT: + case WM_PAINT: + case WM_ERASEBKGND: + case WM_NCMOUSEMOVE: + case WM_NCLBUTTONDOWN: + case WM_WINDOWPOSCHANGING: + case WM_WINDOWPOSCHANGED: + return DefWindowProc(hwnd,umsg,wParam,lParam); + + case WM_CREATE: + return MsgCreate(hwnd,wParam,lParam); + + + case WM_DESTROY: + case WM_ENDSESSION: + if (!bShutdownOK) { + + WINDOWPLACEMENT wndpl; + + // Terminate file watching + InstallFileWatching(NULL); + + // GetWindowPlacement + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hwnd,&wndpl); + + wi.x = wndpl.rcNormalPosition.left; + wi.y = wndpl.rcNormalPosition.top; + wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; + wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; + wi.max = (IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); + + DragAcceptFiles(hwnd,FALSE); + + // Terminate clipboard watching + if (flagPasteBoard) { + KillTimer(hwnd,ID_PASTEBOARDTIMER); + ChangeClipboardChain(hwnd,hwndNextCBChain); + } + + // Destroy find / replace dialog + if (IsWindow(hDlgFindReplace)) + DestroyWindow(hDlgFindReplace); + + // call SaveSettings() when hwndToolbar is still valid + SaveSettings(FALSE); + + if (lstrlen(szIniFile) != 0) { + + // Cleanup unwanted MRU's + if (!bSaveRecentFiles) { + MRU_Empty(pFileMRU); + MRU_Save(pFileMRU); + } + else + MRU_MergeSave(pFileMRU,TRUE,flagRelativeFileMRU,flagPortableMyDocs); + MRU_Destroy(pFileMRU); + + if (!bSaveFindReplace) { + MRU_Empty(mruFind); + MRU_Empty(mruReplace); + MRU_Save(mruFind); + MRU_Save(mruReplace); + } + else { + MRU_MergeSave(mruFind,FALSE,FALSE,FALSE); + MRU_MergeSave(mruReplace,FALSE,FALSE,FALSE); + } + MRU_Destroy(mruFind); + MRU_Destroy(mruReplace); + } + + // Remove tray icon if necessary + ShowNotifyIcon(hwnd,FALSE); + + bShutdownOK = TRUE; + } + if (umsg == WM_DESTROY) + PostQuitMessage(0); + break; + + + case WM_CLOSE: + if (FileSave(FALSE,TRUE,FALSE,FALSE)) + DestroyWindow(hwnd); + break; + + + case WM_QUERYENDSESSION: + if (FileSave(FALSE,TRUE,FALSE,FALSE)) + return TRUE; + else + return FALSE; + + + // Reinitialize theme-dependent values and resize windows + case WM_THEMECHANGED: + MsgThemeChanged(hwnd,wParam,lParam); + break; + + + // update Scintilla colors + case WM_SYSCOLORCHANGE: + { + extern PEDITLEXER pLexCurrent; + Style_SetLexer(hwndEdit,pLexCurrent); + return DefWindowProc(hwnd,umsg,wParam,lParam); + } + + + //case WM_TIMER: + // break; + + + case WM_SIZE: + MsgSize(hwnd,wParam,lParam); + break; + + + case WM_SETFOCUS: + SetFocus(hwndEdit); + + UpdateToolbar(); + UpdateStatusbar(); + + //if (bPendingChangeNotify) + // PostMessage(hwnd,WM_CHANGENOTIFY,0,0); + break; + + + case WM_DROPFILES: + { + WCHAR szBuf[MAX_PATH+40]; + HDROP hDrop = (HDROP)wParam; + + // Reset Change Notify + //bPendingChangeNotify = FALSE; + + if (IsIconic(hwnd)) + ShowWindow(hwnd,SW_RESTORE); + + //SetForegroundWindow(hwnd); + + DragQueryFile(hDrop,0,szBuf,COUNTOF(szBuf)); + + if (PathIsDirectory(szBuf)) { + WCHAR tchFile[MAX_PATH]; + if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),szBuf)) + FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); + } + + else + FileLoad(FALSE,FALSE,FALSE,FALSE,szBuf); + + if (DragQueryFile(hDrop,(UINT)(-1),NULL,0) > 1) + MsgBox(MBWARN,IDS_ERR_DROP); + + DragFinish(hDrop); + } + break; + + + case WM_COPYDATA: + { + PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT)lParam; + + // Reset Change Notify + //bPendingChangeNotify = FALSE; + + SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE); + + if (pcds->dwData == DATA_NOTEPAD2_PARAMS) { + LPNP2PARAMS params = LocalAlloc(LPTR,pcds->cbData); + CopyMemory(params,pcds->lpData,pcds->cbData); + + if (params->flagLexerSpecified) + flagLexerSpecified = 1; + + if (params->flagQuietCreate) + flagQuietCreate = 1; + + if (params->flagFileSpecified) { + + BOOL bOpened = FALSE; + iSrcEncoding = params->iSrcEncoding; + + if (PathIsDirectory(¶ms->wchData)) { + WCHAR tchFile[MAX_PATH]; + if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),¶ms->wchData)) + bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,tchFile); + } + + else + bOpened = FileLoad(FALSE,FALSE,FALSE,FALSE,¶ms->wchData); + + if (bOpened) { + + if (params->flagChangeNotify == 1) { + iFileWatchingMode = 0; + bResetFileWatching = TRUE; + InstallFileWatching(szCurFile); + } + else if (params->flagChangeNotify == 2) { + iFileWatchingMode = 2; + bResetFileWatching = TRUE; + InstallFileWatching(szCurFile); + } + + if (0 != params->flagSetEncoding) { + flagSetEncoding = params->flagSetEncoding; + SendMessage( + hwnd, + WM_COMMAND, + MAKELONG(IDM_ENCODING_ANSI + flagSetEncoding -1,1), + 0); + flagSetEncoding = 0; + } + + if (0 != params->flagSetEOLMode) { + flagSetEOLMode = params->flagSetEOLMode; + SendMessage( + hwndMain, + WM_COMMAND, + MAKELONG(IDM_LINEENDINGS_CRLF + flagSetEOLMode -1,1), + 0); + flagSetEOLMode = 0; + } + + if (params->flagLexerSpecified) { + if (params->iInitialLexer < 0) { + WCHAR wchExt[32] = L"."; + lstrcpyn(CharNext(wchExt),StrEnd(¶ms->wchData)+1,30); + Style_SetLexerFromName(hwndEdit,¶ms->wchData,wchExt); + } + else if (params->iInitialLexer >=0 && params->iInitialLexer < NUMLEXERS) + Style_SetLexerFromID(hwndEdit,params->iInitialLexer); + } + + if (params->flagTitleExcerpt) { + lstrcpyn(szTitleExcerpt,StrEnd(¶ms->wchData)+1,COUNTOF(szTitleExcerpt)); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + } + } + // reset + iSrcEncoding = -1; + } + + if (params->flagJumpTo) { + if (params->iInitialLine == 0) + params->iInitialLine = 1; + EditJumpTo(hwndEdit,params->iInitialLine,params->iInitialColumn); + EditEnsureSelectionVisible(hwndEdit); + } + + flagLexerSpecified = 0; + flagQuietCreate = 0; + + LocalFree(params); + + UpdateStatusbar(); + } + } + return TRUE; + + + case WM_CONTEXTMENU: + { + HMENU hmenu; + int imenu = 0; + POINT pt; + int nID = GetDlgCtrlID((HWND)wParam); + + if ((nID != IDC_EDIT) && (nID != IDC_STATUSBAR) && + (nID != IDC_REBAR) && (nID != IDC_TOOLBAR)) + return DefWindowProc(hwnd,umsg,wParam,lParam); + + hmenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU)); + //SetMenuDefaultItem(GetSubMenu(hmenu,1),0,FALSE); + + pt.x = (int)(short)LOWORD(lParam); + pt.y = (int)(short)HIWORD(lParam); + + switch(nID) + { + case IDC_EDIT: + { + int iSelStart = (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0); + + if (iSelStart == iSelEnd && pt.x != -1 && pt.y != -1) + { + int iNewPos; + POINT ptc = { pt.x, pt.y }; + ScreenToClient(hwndEdit,&ptc); + iNewPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMPOINT,(WPARAM)ptc.x,(LPARAM)ptc.y); + SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iNewPos,0); + } + + if (pt.x == -1 && pt.y == -1) + { + int iCurrentPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + pt.x = (int)SendMessage(hwndEdit,SCI_POINTXFROMPOSITION,0,(LPARAM)iCurrentPos); + pt.y = (int)SendMessage(hwndEdit,SCI_POINTYFROMPOSITION,0,(LPARAM)iCurrentPos); + ClientToScreen(hwndEdit,&pt); + } + imenu = 0; + } + break; + + case IDC_TOOLBAR: + case IDC_STATUSBAR: + case IDC_REBAR: + if (pt.x == -1 && pt.y == -1) + GetCursorPos(&pt); + imenu = 1; + break; + } + + TrackPopupMenuEx(GetSubMenu(hmenu,imenu), + TPM_LEFTBUTTON | TPM_RIGHTBUTTON,pt.x+1,pt.y+1,hwnd,NULL); + + DestroyMenu(hmenu); + } + break; + + + case WM_INITMENU: + MsgInitMenu(hwnd,wParam,lParam); + break; + + + case WM_NOTIFY: + return MsgNotify(hwnd,wParam,lParam); + + + case WM_COMMAND: + return MsgCommand(hwnd,wParam,lParam); + + + case WM_SYSCOMMAND: + switch (wParam) + { + case SC_MINIMIZE: + ShowOwnedPopups(hwnd,FALSE); + if (bMinimizeToTray) { + MinimizeWndToTray(hwnd); + ShowNotifyIcon(hwnd,TRUE); + SetNotifyIconTitle(hwnd); + return(0); + } + else + return DefWindowProc(hwnd,umsg,wParam,lParam); + + case SC_RESTORE: { + LRESULT lrv = DefWindowProc(hwnd,umsg,wParam,lParam); + ShowOwnedPopups(hwnd,TRUE); + return(lrv); + } + } + return DefWindowProc(hwnd,umsg,wParam,lParam); + + + case WM_CHANGENOTIFY: + if (iFileWatchingMode == 1 || bModified || iEncoding != iOriginalEncoding) + SetForegroundWindow(hwnd); + + if (PathFileExists(szCurFile)) { + + if ((iFileWatchingMode == 2 && !bModified && iEncoding == iOriginalEncoding) || + MsgBox(MBYESNO,IDS_FILECHANGENOTIFY) == IDYES) { + + int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iVisTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); + int iDocTopLine = (int)SendMessage(hwndEdit,SCI_DOCLINEFROMVISIBLE,(WPARAM)iVisTopLine,0); + int iXOffset = (int)SendMessage(hwndEdit,SCI_GETXOFFSET,0,0); + BOOL bIsTail = (iCurPos == iAnchorPos) && (iCurPos == SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); + + iWeakSrcEncoding = iEncoding; + if (FileLoad(TRUE,FALSE,TRUE,FALSE,szCurFile)) { + + if (bIsTail && iFileWatchingMode == 2) { + EditJumpTo(hwndEdit,-1,0); + EditEnsureSelectionVisible(hwndEdit); + } + + else if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { + char tch[5] = ""; + SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch); + if (lstrcmpiA(tch,".LOG") != 0) { + int iNewTopLine; + SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos); + SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0); + iNewTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); + SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)iVisTopLine - iNewTopLine); + SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0); + } + } + } + } + } + else { + + if (MsgBox(MBYESNO,IDS_FILECHANGENOTIFY2) == IDYES) + FileSave(TRUE,FALSE,FALSE,FALSE); + } + + if (!bRunningWatch) + InstallFileWatching(szCurFile); + break; + + + //// This message is posted before Notepad2 reactivates itself + //case WM_CHANGENOTIFYCLEAR: + // bPendingChangeNotify = FALSE; + // break; + + + case WM_DRAWCLIPBOARD: + if (!bLastCopyFromMe) + dwLastCopyTime = GetTickCount(); + else + bLastCopyFromMe = FALSE; + if (hwndNextCBChain) + SendMessage(hwndNextCBChain,WM_DRAWCLIPBOARD,wParam,lParam); + break; + + + case WM_CHANGECBCHAIN: + if ((HWND)wParam == hwndNextCBChain) + hwndNextCBChain = (HWND)lParam; + if (hwndNextCBChain) + SendMessage(hwndNextCBChain,WM_CHANGECBCHAIN,lParam,wParam); + break; + + + case WM_TRAYMESSAGE: + switch(lParam) + { + case WM_RBUTTONUP: { + + HMENU hMenu = LoadMenu(g_hInstance,MAKEINTRESOURCE(IDR_POPUPMENU)); + HMENU hMenuPopup = GetSubMenu(hMenu,2); + + POINT pt; + int iCmd; + + SetForegroundWindow(hwnd); + + GetCursorPos(&pt); + SetMenuDefaultItem(hMenuPopup,IDM_TRAY_RESTORE,FALSE); + iCmd = TrackPopupMenu(hMenuPopup, + TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, + pt.x,pt.y,0,hwnd,NULL); + + PostMessage(hwnd,WM_NULL,0,0); + + DestroyMenu(hMenu); + + if (iCmd == IDM_TRAY_RESTORE) { + ShowNotifyIcon(hwnd,FALSE); + RestoreWndFromTray(hwnd); + ShowOwnedPopups(hwnd,TRUE); + } + + else if (iCmd == IDM_TRAY_EXIT) { + //ShowNotifyIcon(hwnd,FALSE); + SendMessage(hwnd,WM_CLOSE,0,0); + } + } + return TRUE; + + case WM_LBUTTONUP: + ShowNotifyIcon(hwnd,FALSE); + RestoreWndFromTray(hwnd); + ShowOwnedPopups(hwnd,TRUE); + return TRUE; + } + break; + + + default: + + if (umsg == msgTaskbarCreated) { + if (!IsWindowVisible(hwnd)) + ShowNotifyIcon(hwnd,TRUE); + SetNotifyIconTitle(hwnd); + return(0); + } + + return DefWindowProc(hwnd,umsg,wParam,lParam); + + } + + return(0); + +} + + +//============================================================================= +// +// MsgCreate() - Handles WM_CREATE +// +// +LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + + HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance; + + // Setup edit control + hwndEdit = EditCreate(hwnd); + InitScintillaHandle(hwndEdit); + + // Tabs + SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + SendMessage(hwndEdit,SCI_SETBACKSPACEUNINDENTS,bBackspaceUnindents,0); + SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0); + SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0); + + // Indent Guides + Style_SetIndentGuides(hwndEdit,bShowIndentGuides); + + // Word wrap + if (!fWordWrap) + SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); + else + SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); + if (iWordWrapIndent == 5) + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0); + else if (iWordWrapIndent == 6) + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0); + else { + int i = 0; + switch (iWordWrapIndent) { + case 1: i = 1; break; + case 2: i = 2; break; + case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; + case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; + } + SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0); + } + if (bShowWordWrapSymbols) { + int wrapVisualFlags = 0; + int wrapVisualFlagsLocation = 0; + if (iWordWrapSymbols == 0) + iWordWrapSymbols = 22; + switch (iWordWrapSymbols%10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; + } + switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; + } + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); + } + else { + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); + } + + // Long Lines + if (bMarkLongLines) + SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); + else + SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); + SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); + + // Margins + SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,2,0); + SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0); + UpdateLineNumberWidth(); + //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0, + // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)L"_999999_"):0); + + // Code folding + SciCall_SetMarginType(MARGIN_FOLD_INDEX, SC_MARGIN_SYMBOL); + SciCall_SetMarginMask(MARGIN_FOLD_INDEX, SC_MASK_FOLDERS); + SciCall_SetMarginWidth(MARGIN_FOLD_INDEX, (bShowCodeFolding) ? 11 : 0); + SciCall_SetMarginSensitive(MARGIN_FOLD_INDEX, TRUE); + SciCall_MarkerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS); + SciCall_MarkerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS); + SciCall_MarkerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE); + SciCall_MarkerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER); + SciCall_MarkerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED); + SciCall_MarkerDefine(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED); + SciCall_MarkerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER); + SciCall_SetFoldFlags(16); + + // Nonprinting characters + SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); + SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); + + hwndEditFrame = CreateWindowEx( + WS_EX_CLIENTEDGE, + WC_LISTVIEW, + NULL, + WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, + 0,0,100,100, + hwnd, + (HMENU)IDC_EDITFRAME, + hInstance, + NULL); + + if (PrivateIsAppThemed()) { + + RECT rc, rc2; + + bIsAppThemed = TRUE; + + SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); + SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + + if (IsVista()) { + cxEditFrame = 0; + cyEditFrame = 0; + } + + else { + GetClientRect(hwndEditFrame,&rc); + GetWindowRect(hwndEditFrame,&rc2); + + cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; + cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; + } + } + else { + bIsAppThemed = FALSE; + + cxEditFrame = 0; + cyEditFrame = 0; + } + + // Create Toolbar and Statusbar + CreateBars(hwnd,hInstance); + + // Window Initialization + + CreateWindow( + WC_STATIC, + NULL, + WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, + 0,0,10,10, + hwnd, + (HMENU)IDC_FILENAME, + hInstance, + NULL); + + SetDlgItemText(hwnd,IDC_FILENAME,szCurFile); + + CreateWindow( + WC_STATIC, + NULL, + WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, + 10,10,10,10, + hwnd, + (HMENU)IDC_REUSELOCK, + hInstance, + NULL); + + SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE); + + // Menu + //SetMenuDefaultItem(GetSubMenu(GetMenu(hwnd),0),0); + + // Drag & Drop + DragAcceptFiles(hwnd,TRUE); + + // File MRU + pFileMRU = MRU_Create(L"Recent Files",MRU_NOCASE,32); + MRU_Load(pFileMRU); + + mruFind = MRU_Create(L"Recent Find",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16); + MRU_Load(mruFind); + + mruReplace = MRU_Create(L"Recent Replace",(/*IsWindowsNT()*/1) ? MRU_UTF8 : 0,16); + MRU_Load(mruReplace); + + if (hwndEdit == NULL || hwndEditFrame == NULL || + hwndStatus == NULL || hwndToolbar == NULL || hwndReBar == NULL) + return(-1); + + return(0); + +} + + +//============================================================================= +// +// CreateBars() - Create Toolbar and Statusbar +// +// +void CreateBars(HWND hwnd,HINSTANCE hInstance) +{ + RECT rc; + + REBARINFO rbi; + REBARBANDINFO rbBand; + + BITMAP bmp; + HBITMAP hbmp, hbmpCopy = NULL; + HIMAGELIST himl; + WCHAR szTmp[MAX_PATH]; + BOOL bExternalBitmap = FALSE; + + DWORD dwToolbarStyle = WS_TOOLBAR; + DWORD dwStatusbarStyle = WS_CHILD | WS_CLIPSIBLINGS; + DWORD dwReBarStyle = WS_REBAR; + + BOOL bIsAppThemed = PrivateIsAppThemed(); + + int i,n; + WCHAR tchDesc[256]; + WCHAR tchIndex[256]; + + WCHAR *pIniSection = NULL; + int cchIniSection = 0; + + if (bShowToolbar) + dwReBarStyle |= WS_VISIBLE; + + hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle, + 0,0,0,0,hwnd,(HMENU)IDC_TOOLBAR,hInstance,NULL); + + SendMessage(hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0); + + // Add normal Toolbar Bitmap + hbmp = NULL; + if (lstrlen(tchToolbarBitmap)) + { + if (!SearchPath(NULL,tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL)) + lstrcpy(szTmp,tchToolbarBitmap); + hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); + } + if (hbmp) + bExternalBitmap = TRUE; + else { + hbmp = LoadImage(hInstance,MAKEINTRESOURCE(IDR_MAINWND),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + hbmpCopy = CopyImage(hbmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + } + GetObject(hbmp,sizeof(BITMAP),&bmp); + if (!IsXP()) + BitmapMergeAlpha(hbmp,GetSysColor(COLOR_3DFACE)); + himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); + DeleteObject(hbmp); + SendMessage(hwndToolbar,TB_SETIMAGELIST,0,(LPARAM)himl); + + // Optionally add hot Toolbar Bitmap + hbmp = NULL; + if (lstrlen(tchToolbarBitmapHot)) + { + if (!SearchPath(NULL,tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL)) + lstrcpy(szTmp,tchToolbarBitmapHot); + if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE)) + { + GetObject(hbmp,sizeof(BITMAP),&bmp); + himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); + DeleteObject(hbmp); + SendMessage(hwndToolbar,TB_SETHOTIMAGELIST,0,(LPARAM)himl); + } + } + + // Optionally add disabled Toolbar Bitmap + hbmp = NULL; + if (lstrlen(tchToolbarBitmapDisabled)) + { + if (!SearchPath(NULL,tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL)) + lstrcpy(szTmp,tchToolbarBitmapDisabled); + if (hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE)) + { + GetObject(hbmp,sizeof(BITMAP),&bmp); + himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); + DeleteObject(hbmp); + SendMessage(hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); + bExternalBitmap = TRUE; + } + } + + if (!bExternalBitmap) { + BOOL fProcessed = FALSE; + if (flagToolbarLook == 1) + fProcessed = BitmapAlphaBlend(hbmpCopy,GetSysColor(COLOR_3DFACE),0x60); + else if (flagToolbarLook == 2 || (!IsXP() && flagToolbarLook == 0)) + fProcessed = BitmapGrayScale(hbmpCopy); + if (fProcessed && !IsXP()) + BitmapMergeAlpha(hbmpCopy,GetSysColor(COLOR_3DFACE)); + if (fProcessed) { + himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); + ImageList_AddMasked(himl,hbmpCopy,CLR_DEFAULT); + SendMessage(hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); + } + } + if (hbmpCopy) + DeleteObject(hbmpCopy); + + // Load toolbar labels + pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + LoadIniSection(L"Toolbar Labels",pIniSection,cchIniSection); + n = 1; + for (i = 0; i < COUNTOF(tbbMainWnd); i++) { + + if (tbbMainWnd[i].fsStyle == TBSTYLE_SEP) + continue; + + wsprintf(tchIndex,L"%02i",n++); + + if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) { + tbbMainWnd[i].iString = SendMessage(hwndToolbar,TB_ADDSTRING,0,(LPARAM)tchDesc); + tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT; + } + + else + tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT); + } + LocalFree(pIniSection); + + SendMessage(hwndToolbar,TB_SETEXTENDEDSTYLE,0, + SendMessage(hwndToolbar,TB_GETEXTENDEDSTYLE,0,0) | TBSTYLE_EX_MIXEDBUTTONS); + + SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); + if (Toolbar_SetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,tbbMainWnd,COUNTOF(tbbMainWnd)) == 0) + SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); + SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); + //SendMessage(hwndToolbar,TB_SETINDENT,2,0); + + if (bShowStatusbar) + dwStatusbarStyle |= WS_VISIBLE; + + hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR); + + // Create ReBar and add Toolbar + hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle, + 0,0,0,0,hwnd,(HMENU)IDC_REBAR,hInstance,NULL); + + rbi.cbSize = sizeof(REBARINFO); + rbi.fMask = 0; + rbi.himl = (HIMAGELIST)NULL; + SendMessage(hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi); + + rbBand.cbSize = sizeof(REBARBANDINFO); + rbBand.fMask = /*RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | */ + RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE /*| RBBIM_SIZE*/; + rbBand.fStyle = /*RBBS_CHILDEDGE |*//* RBBS_BREAK |*/ RBBS_FIXEDSIZE /*| RBBS_GRIPPERALWAYS*/; + if (bIsAppThemed) + rbBand.fStyle |= RBBS_CHILDEDGE; + rbBand.hbmBack = NULL; + rbBand.lpText = L"Toolbar"; + rbBand.hwndChild = hwndToolbar; + rbBand.cxMinChild = (rc.right - rc.left) * COUNTOF(tbbMainWnd); + rbBand.cyMinChild = (rc.bottom - rc.top) + 2 * rc.top; + rbBand.cx = 0; + SendMessage(hwndReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbBand); + + SetWindowPos(hwndReBar,NULL,0,0,0,0,SWP_NOZORDER); + GetWindowRect(hwndReBar,&rc); + cyReBar = rc.bottom - rc.top; + + cyReBarFrame = bIsAppThemed ? 0 : 2; +} + + +//============================================================================= +// +// MsgThemeChanged() - Handle WM_THEMECHANGED +// +// +void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + RECT rc, rc2; + HINSTANCE hInstance = (HINSTANCE)(INT_PTR)GetWindowLongPtr(hwnd,GWLP_HINSTANCE); + + // reinitialize edit frame + + if (PrivateIsAppThemed()) { + bIsAppThemed = TRUE; + + SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); + SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE); + + if (IsVista()) { + cxEditFrame = 0; + cyEditFrame = 0; + } + + else { + SetWindowPos(hwndEditFrame,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + GetClientRect(hwndEditFrame,&rc); + GetWindowRect(hwndEditFrame,&rc2); + + cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; + cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; + } + } + + else { + bIsAppThemed = FALSE; + + SetWindowLongPtr(hwndEdit,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(hwndEdit,GWL_EXSTYLE)); + SetWindowPos(hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + + cxEditFrame = 0; + cyEditFrame = 0; + } + + // recreate toolbar and statusbar + Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons)); + + DestroyWindow(hwndToolbar); + DestroyWindow(hwndReBar); + DestroyWindow(hwndStatus); + CreateBars(hwnd,hInstance); + UpdateToolbar(); + + GetClientRect(hwnd,&rc); + SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,MAKELONG(rc.right,rc.bottom)); + UpdateStatusbar(); +} + + +//============================================================================= +// +// MsgSize() - Handles WM_SIZE +// +// +void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + + RECT rc; + int x,y,cx,cy; + HDWP hdwp; + + // Statusbar + int aWidth[6]; + + if (wParam == SIZE_MINIMIZED) + return; + + x = 0; + y = 0; + + cx = LOWORD(lParam); + cy = HIWORD(lParam); + + if (bShowToolbar) + { +/* SendMessage(hwndToolbar,WM_SIZE,0,0); + GetWindowRect(hwndToolbar,&rc); + y = (rc.bottom - rc.top); + cy -= (rc.bottom - rc.top);*/ + + //SendMessage(hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); + SetWindowPos(hwndReBar,NULL,0,0,LOWORD(lParam),cyReBar,SWP_NOZORDER); + // the ReBar automatically sets the correct height + // calling SetWindowPos() with the height of one toolbar button + // causes the control not to temporarily use the whole client area + // and prevents flickering + + //GetWindowRect(hwndReBar,&rc); + y = cyReBar + cyReBarFrame; // define + cy -= cyReBar + cyReBarFrame; // border + } + + if (bShowStatusbar) + { + SendMessage(hwndStatus,WM_SIZE,0,0); + GetWindowRect(hwndStatus,&rc); + cy -= (rc.bottom - rc.top); + } + + hdwp = BeginDeferWindowPos(2); + + DeferWindowPos(hdwp,hwndEditFrame,NULL,x,y,cx,cy, + SWP_NOZORDER | SWP_NOACTIVATE); + + DeferWindowPos(hdwp,hwndEdit,NULL,x+cxEditFrame,y+cyEditFrame, + cx-2*cxEditFrame,cy-2*cyEditFrame, + SWP_NOZORDER | SWP_NOACTIVATE); + + EndDeferWindowPos(hdwp); + + // Statusbar width + aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L"Ln 9'999'999 : 9'999'999 Col 9'999'999 : 999 Sel 9'999'999"))); + aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes"); + aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM"); + aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"CR+LF"); + aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"OVR"); + aWidth[5] = -1; + + SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth); + + //UpdateStatusbar(); + +} + + +//============================================================================= +// +// MsgInitMenu() - Handles WM_INITMENU +// +// +void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + + int i,i2; + HMENU hmenu = (HMENU)wParam; + + i = lstrlen(szCurFile); + EnableCmd(hmenu,IDM_FILE_REVERT,i); + EnableCmd(hmenu, CMD_RELOADASCIIASUTF8, i); + EnableCmd(hmenu, CMD_RELOADANSI, i); + EnableCmd(hmenu, CMD_RELOADOEM, i); + EnableCmd(hmenu, CMD_RELOADNOFILEVARS, i); + EnableCmd(hmenu, CMD_RECODEDEFAULT, i); + EnableCmd(hmenu,IDM_FILE_LAUNCH,i); + EnableCmd(hmenu,IDM_FILE_PROPERTIES,i); + EnableCmd(hmenu,IDM_FILE_CREATELINK,i); + EnableCmd(hmenu,IDM_FILE_ADDTOFAV,i); + + EnableCmd(hmenu,IDM_FILE_READONLY,i); + CheckCmd(hmenu,IDM_FILE_READONLY,bReadOnly); + + //EnableCmd(hmenu,IDM_ENCODING_UNICODEREV,!bReadOnly); + //EnableCmd(hmenu,IDM_ENCODING_UNICODE,!bReadOnly); + //EnableCmd(hmenu,IDM_ENCODING_UTF8SIGN,!bReadOnly); + //EnableCmd(hmenu,IDM_ENCODING_UTF8,!bReadOnly); + //EnableCmd(hmenu,IDM_ENCODING_ANSI,!bReadOnly); + //EnableCmd(hmenu,IDM_LINEENDINGS_CRLF,!bReadOnly); + //EnableCmd(hmenu,IDM_LINEENDINGS_LF,!bReadOnly); + //EnableCmd(hmenu,IDM_LINEENDINGS_CR,!bReadOnly); + + EnableCmd(hmenu,IDM_ENCODING_RECODE,i); + + if (mEncoding[iEncoding].uFlags & NCP_UNICODE_REVERSE) + i = IDM_ENCODING_UNICODEREV; + else if (mEncoding[iEncoding].uFlags & NCP_UNICODE) + i = IDM_ENCODING_UNICODE; + else if (mEncoding[iEncoding].uFlags & NCP_UTF8_SIGN) + i = IDM_ENCODING_UTF8SIGN; + else if (mEncoding[iEncoding].uFlags & NCP_UTF8) + i = IDM_ENCODING_UTF8; + else if (mEncoding[iEncoding].uFlags & NCP_DEFAULT) + i = IDM_ENCODING_ANSI; + else + i = -1; + CheckMenuRadioItem(hmenu,IDM_ENCODING_ANSI,IDM_ENCODING_UTF8SIGN,i,MF_BYCOMMAND); + + if (iEOLMode == SC_EOL_CRLF) + i = IDM_LINEENDINGS_CRLF; + else if (iEOLMode == SC_EOL_LF) + i = IDM_LINEENDINGS_LF; + else + i = IDM_LINEENDINGS_CR; + CheckMenuRadioItem(hmenu,IDM_LINEENDINGS_CRLF,IDM_LINEENDINGS_CR,i,MF_BYCOMMAND); + + EnableCmd(hmenu,IDM_FILE_RECENT,(MRU_Enum(pFileMRU,0,NULL,0) > 0)); + + EnableCmd(hmenu,IDM_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/); + + i = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + i2 = (int)SendMessage(hwndEdit,SCI_CANPASTE,0,0); + + EnableCmd(hmenu,IDM_EDIT_CUT,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_COPY,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_COPYALL,SendMessage(hwndEdit,SCI_GETLENGTH,0,0) /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_COPYADD,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_PASTE,i2 /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_SWAP,i || i2 /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_CLEAR,i /*&& !bReadOnly*/); + + OpenClipboard(hwnd); + EnableCmd(hmenu,IDM_EDIT_CLEARCLIPBOARD,CountClipboardFormats()); + CloseClipboard(); + + //EnableCmd(hmenu,IDM_EDIT_MOVELINEUP,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_MOVELINEDOWN,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_DUPLICATELINE,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_CUTLINE,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_COPYLINE,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_DELETELINE,!bReadOnly); + + //EnableCmd(hmenu,IDM_EDIT_INDENT,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_UNINDENT,!bReadOnly); + + //EnableCmd(hmenu,IDM_EDIT_PADWITHSPACES,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_STRIP1STCHAR,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_STRIPLASTCHAR,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_TRIMLINES,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_MERGEBLANKLINES,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_REMOVEBLANKLINES,!bReadOnly); + + EnableCmd(hmenu,IDM_EDIT_SORTLINES, + SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0) - + SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0) >= 1); + + EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/); + EnableCmd(hmenu,IDM_EDIT_SPLITLINES,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_JOINLINES,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_JOINLINESEX,i /*&& !bReadOnly*/); + + EnableCmd(hmenu,IDM_EDIT_CONVERTUPPERCASE,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_CONVERTLOWERCASE,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_INVERTCASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); + EnableCmd(hmenu,IDM_EDIT_TITLECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); + EnableCmd(hmenu,IDM_EDIT_SENTENCECASE,i /*&& !bReadOnly*/ /*&& IsWindowsNT()*/); + + EnableCmd(hmenu,IDM_EDIT_CONVERTTABS,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_CONVERTTABS2,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_CONVERTSPACES2,i /*&& !bReadOnly*/); + + EnableCmd(hmenu,IDM_EDIT_URLENCODE,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_URLDECODE,i /*&& !bReadOnly*/); + + EnableCmd(hmenu,IDM_EDIT_ESCAPECCHARS,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_UNESCAPECCHARS,i /*&& !bReadOnly*/); + + EnableCmd(hmenu,IDM_EDIT_CHAR2HEX,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_HEX2CHAR,i /*&& !bReadOnly*/); + + //EnableCmd(hmenu,IDM_EDIT_INCREASENUM,i /*&& !bReadOnly*/); + //EnableCmd(hmenu,IDM_EDIT_DECREASENUM,i /*&& !bReadOnly*/); + + EnableCmd(hmenu,IDM_VIEW_SHOWEXCERPT,i); + + i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); + EnableCmd(hmenu,IDM_EDIT_LINECOMMENT, + !(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF)); + EnableCmd(hmenu,IDM_EDIT_STREAMCOMMENT, + !(i == SCLEX_NULL || i == SCLEX_VBSCRIPT || i == SCLEX_MAKEFILE || i == SCLEX_VB || i == SCLEX_ASM || + i == SCLEX_SQL || i == SCLEX_PERL || i == SCLEX_PYTHON || i == SCLEX_PROPERTIES ||i == SCLEX_CONF || + i == SCLEX_POWERSHELL || i == SCLEX_BATCH || i == SCLEX_DIFF || i == SCLEX_BASH || i == SCLEX_TCL || + i == SCLEX_AU3 || i == SCLEX_LATEX || i == SCLEX_AHK || i == SCLEX_RUBY || i == SCLEX_CMAKE || i == SCLEX_MARKDOWN || + i == SCLEX_YAML)); + + EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING,*mEncoding[iEncoding].pszParseNames); + + //EnableCmd(hmenu,IDM_EDIT_INSERT_SHORTDATE,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_INSERT_LONGDATE,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_INSERT_FILENAME,!bReadOnly); + //EnableCmd(hmenu,IDM_EDIT_INSERT_PATHNAME,!bReadOnly); + + i = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); + EnableCmd(hmenu,IDM_EDIT_FIND,i); + EnableCmd(hmenu,IDM_EDIT_SAVEFIND,i); + EnableCmd(hmenu,IDM_EDIT_FINDNEXT,i); + EnableCmd(hmenu,IDM_EDIT_FINDPREV,i && lstrlenA(efrData.szFind)); + EnableCmd(hmenu,IDM_EDIT_REPLACE,i /*&& !bReadOnly*/); + EnableCmd(hmenu,IDM_EDIT_REPLACENEXT,i); + EnableCmd(hmenu,IDM_EDIT_SELTONEXT,i && lstrlenA(efrData.szFind)); + EnableCmd(hmenu,IDM_EDIT_SELTOPREV,i && lstrlenA(efrData.szFind)); + EnableCmd(hmenu,IDM_EDIT_FINDMATCHINGBRACE,i); + EnableCmd(hmenu,IDM_EDIT_SELTOMATCHINGBRACE,i); +#ifdef BOOKMARK_EDITION + EnableCmd(hmenu,BME_EDIT_BOOKMARKPREV,i); + EnableCmd(hmenu,BME_EDIT_BOOKMARKNEXT,i); + EnableCmd(hmenu,BME_EDIT_BOOKMARKTOGGLE,i); + EnableCmd(hmenu,BME_EDIT_BOOKMARKCLEAR,i); +#endif + EnableCmd(hmenu, IDM_EDIT_DELETELINELEFT, i); + EnableCmd(hmenu, IDM_EDIT_DELETELINERIGHT, i); + EnableCmd(hmenu, CMD_CTRLBACK, i); + EnableCmd(hmenu, CMD_CTRLDEL, i); + EnableCmd(hmenu, CMD_TIMESTAMPS, i); + EnableCmd(hmenu,IDM_VIEW_TOGGLEFOLDS,i && bShowCodeFolding); + CheckCmd(hmenu,IDM_VIEW_FOLDING,bShowCodeFolding); + + CheckCmd(hmenu,IDM_VIEW_USE2NDDEFAULT,Style_GetUse2ndDefault(hwndEdit)); + CheckMenuRadioItem(hmenu,IDM_VIEW_THEME_ORIGINAL,IDM_VIEW_THEME_DARK, + Style_IsDarkTheme() ? IDM_VIEW_THEME_DARK : IDM_VIEW_THEME_ORIGINAL,MF_BYCOMMAND); + + CheckCmd(hmenu,IDM_VIEW_WORDWRAP,fWordWrap); + CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,bMarkLongLines); + CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,bTabsAsSpaces); + CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,bShowIndentGuides); + CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,bAutoIndent); + CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,bShowLineNumbers); + CheckCmd(hmenu,IDM_VIEW_MARGIN,bShowSelectionMargin); + + EnableCmd(hmenu,IDM_EDIT_COMPLETEWORD,i); + CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,bAutoCompleteWords); + + switch (iMarkOccurrences) + { + case 0: i = IDM_VIEW_MARKOCCURRENCES_OFF; break; + case 3: i = IDM_VIEW_MARKOCCURRENCES_BLUE; break; + case 2: i = IDM_VIEW_MARKOCCURRENCES_GREEN; break; + case 1: i = IDM_VIEW_MARKOCCURRENCES_RED; break; + } + CheckMenuRadioItem(hmenu,IDM_VIEW_MARKOCCURRENCES_OFF,IDM_VIEW_MARKOCCURRENCES_RED,i,MF_BYCOMMAND); + CheckCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_CASE,bMarkOccurrencesMatchCase); + CheckCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_WORD,bMarkOccurrencesMatchWords); + EnableCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_CASE,iMarkOccurrences != 0); + EnableCmd(hmenu,IDM_VIEW_MARKOCCURRENCES_WORD,iMarkOccurrences != 0); + + CheckCmd(hmenu,IDM_VIEW_SHOWWHITESPACE,bViewWhiteSpace); + CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,bViewEOLs); + CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,bShowWordWrapSymbols); + CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,bMatchBraces); + CheckCmd(hmenu,IDM_VIEW_TOOLBAR,bShowToolbar); + EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB,bShowToolbar); + CheckCmd(hmenu,IDM_VIEW_STATUSBAR,bShowStatusbar); + + i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); + //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML)); + CheckCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); + CheckCmd(hmenu,IDM_VIEW_HILITECURRENTLINE,bHiliteCurrentLine); + + i = IniGetInt(L"Settings2",L"ReuseWindow",0); + CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); + i = IniGetInt(L"Settings2",L"SingleFileInstance",0); + CheckCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); + bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",0); + CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,bStickyWinPos); + CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1)); + CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,bMinimizeToTray); + CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentMode && bTransparentModeAvailable); + EnableCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentModeAvailable); + + CheckCmd(hmenu,IDM_VIEW_NOSAVERECENT,bSaveRecentFiles); + CheckCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,bSaveFindReplace); + CheckCmd(hmenu,IDM_VIEW_SAVEBEFORERUNNINGTOOLS,bSaveBeforeRunningTools); + + CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,iFileWatchingMode); + + if (lstrlen(szTitleExcerpt)) + i = IDM_VIEW_SHOWEXCERPT; + else if (iPathNameFormat == 0) + i = IDM_VIEW_SHOWFILENAMEONLY; + else if (iPathNameFormat == 1) + i = IDM_VIEW_SHOWFILENAMEFIRST; + else + i = IDM_VIEW_SHOWFULLPATH; + CheckMenuRadioItem(hmenu,IDM_VIEW_SHOWFILENAMEONLY,IDM_VIEW_SHOWEXCERPT,i,MF_BYCOMMAND); + + if (iEscFunction == 1) + i = IDM_VIEW_ESCMINIMIZE; + else if (iEscFunction == 2) + i = IDM_VIEW_ESCEXIT; + else + i = IDM_VIEW_NOESCFUNC; + CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND); + + i = lstrlen(szIniFile); + CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,bSaveSettings && i); + + EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); + EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i); + EnableCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); + EnableCmd(hmenu,IDM_VIEW_NOSAVERECENT,i); + EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i); + EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,i); + + i = (lstrlen(szIniFile) > 0 || lstrlen(szIniFile2) > 0); + EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,i); + +} + + +//============================================================================= +// +// MsgCommand() - Handles WM_COMMAND +// +// +LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + + switch(LOWORD(wParam)) + { + + case IDM_FILE_NEW: + FileLoad(FALSE,TRUE,FALSE,FALSE,L""); + break; + + + case IDM_FILE_OPEN: + FileLoad(FALSE,FALSE,FALSE,FALSE,L""); + break; + + + case IDM_FILE_REVERT: + { + if (lstrlen(szCurFile)) { + + WCHAR tchCurFile2[MAX_PATH]; + + int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iVisTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); + int iDocTopLine = (int)SendMessage(hwndEdit,SCI_DOCLINEFROMVISIBLE,(WPARAM)iVisTopLine,0); + int iXOffset = (int)SendMessage(hwndEdit,SCI_GETXOFFSET,0,0); + + if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_REVERT) != IDOK) + return(0); + + lstrcpy(tchCurFile2,szCurFile); + + iWeakSrcEncoding = iEncoding; + if (FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2)) + { + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { + char tch[5] = ""; + SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tch); + if (lstrcmpiA(tch,".LOG") != 0) { + int iNewTopLine; + SendMessage(hwndEdit,SCI_SETSEL,iAnchorPos,iCurPos); + SendMessage(hwndEdit,SCI_ENSUREVISIBLE,(WPARAM)iDocTopLine,0); + iNewTopLine = (int)SendMessage(hwndEdit,SCI_GETFIRSTVISIBLELINE,0,0); + SendMessage(hwndEdit,SCI_LINESCROLL,0,(LPARAM)iVisTopLine - iNewTopLine); + SendMessage(hwndEdit,SCI_SETXOFFSET,(WPARAM)iXOffset,0); + } + } + } + } + } + break; + + + case IDM_FILE_SAVE: + FileSave(TRUE,FALSE,FALSE,FALSE); + break; + + + case IDM_FILE_SAVEAS: + FileSave(TRUE,FALSE,TRUE,FALSE); + break; + + + case IDM_FILE_SAVECOPY: + FileSave(TRUE,FALSE,TRUE,TRUE); + break; + + + case IDM_FILE_READONLY: + //bReadOnly = (bReadOnly) ? FALSE : TRUE; + //SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0); + //UpdateToolbar(); + //UpdateStatusbar(); + if (lstrlen(szCurFile)) + { + DWORD dwFileAttributes = GetFileAttributes(szCurFile); + if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) { + if (bReadOnly) + dwFileAttributes = (dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); + else + dwFileAttributes |= FILE_ATTRIBUTE_READONLY; + if (!SetFileAttributes(szCurFile,dwFileAttributes)) + MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile); + } + else + MsgBox(MBWARN,IDS_READONLY_MODIFY,szCurFile); + + dwFileAttributes = GetFileAttributes(szCurFile); + if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) + bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); + + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + } + break; + + + case IDM_FILE_BROWSE: + { + SHELLEXECUTEINFO sei; + WCHAR tchParam[MAX_PATH+4] = L""; + WCHAR tchExeFile[MAX_PATH+4]; + WCHAR tchTemp[MAX_PATH+4]; + + if (!IniGetString(L"Settings2",L"filebrowser.exe",L"",tchTemp,COUNTOF(tchTemp))) { + if (!SearchPath(NULL,L"metapath.exe",NULL,COUNTOF(tchExeFile),tchExeFile,NULL)) { + GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile)); + PathRemoveFileSpec(tchExeFile); + PathAppend(tchExeFile,L"metapath.exe"); + } + } + + else { + ExtractFirstArgument(tchTemp,tchExeFile,tchParam); + if (PathIsRelative(tchExeFile)) { + if (!SearchPath(NULL,tchExeFile,NULL,COUNTOF(tchTemp),tchTemp,NULL)) { + GetModuleFileName(NULL,tchTemp,COUNTOF(tchTemp)); + PathRemoveFileSpec(tchTemp); + PathAppend(tchTemp,tchExeFile); + lstrcpy(tchExeFile,tchTemp); + } + } + } + + if (lstrlen(tchParam) && lstrlen(szCurFile)) + StrCatBuff(tchParam,L" ",COUNTOF(tchParam)); + + if (lstrlen(szCurFile)) { + lstrcpy(tchTemp,szCurFile); + PathQuoteSpaces(tchTemp); + StrCatBuff(tchParam,tchTemp,COUNTOF(tchParam)); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOZONECHECKS*/0x00800000; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = tchExeFile; + sei.lpParameters = tchParam; + sei.lpDirectory = NULL; + sei.nShow = SW_SHOWNORMAL; + + ShellExecuteEx(&sei); + + if ((INT_PTR)sei.hInstApp < 32) + MsgBox(MBWARN,IDS_ERR_BROWSE); + } + break; + + + case IDM_FILE_NEWWINDOW: + case IDM_FILE_NEWWINDOW2: + { + SHELLEXECUTEINFO sei; + WCHAR szModuleName[MAX_PATH]; + WCHAR szFileName[MAX_PATH]; + WCHAR szParameters[2*MAX_PATH+64]; + + MONITORINFO mi; + HMONITOR hMonitor; + WINDOWPLACEMENT wndpl; + int x,y,cx,cy,imax; + WCHAR tch[64]; + + if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) + break; + + GetModuleFileName(NULL,szModuleName,COUNTOF(szModuleName)); + + wsprintf(tch,L"\"-appid=%s\"",g_wchAppUserModelID); + lstrcpy(szParameters,tch); + + wsprintf(tch,L" \"-sysmru=%i\"",(flagUseSystemMRU == 2) ? 1 : 0); + lstrcat(szParameters,tch); + + lstrcat(szParameters,L" -f"); + if (lstrlen(szIniFile)) { + lstrcat(szParameters,L" \""); + lstrcat(szParameters,szIniFile); + lstrcat(szParameters,L"\""); + } + else + lstrcat(szParameters,L"0"); + + lstrcat(szParameters,L" -n"); + + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hwnd,&wndpl); + + hMonitor = MonitorFromRect(&wndpl.rcNormalPosition,MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor,&mi); + + // offset new window position +10/+10 + x = wndpl.rcNormalPosition.left + 10; + y = wndpl.rcNormalPosition.top + 10; + cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; + cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; + + // check if window fits monitor + if ((x + cx) > mi.rcWork.right || (y + cy) > mi.rcWork.bottom) { + x = mi.rcMonitor.left; + y = mi.rcMonitor.top; + } + + imax = IsZoomed(hwnd); + + wsprintf(tch,L" -pos %i,%i,%i,%i,%i",x,y,cx,cy,imax); + lstrcat(szParameters,tch); + + if (LOWORD(wParam) != IDM_FILE_NEWWINDOW2 && lstrlen(szCurFile)) { + lstrcpy(szFileName,szCurFile); + PathQuoteSpaces(szFileName); + lstrcat(szParameters,L" "); + lstrcat(szParameters,szFileName); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = szModuleName; + sei.lpParameters = szParameters; + sei.lpDirectory = g_wchWorkingDirectory; + sei.nShow = SW_SHOWNORMAL; + + ShellExecuteEx(&sei); + } + break; + + + case IDM_FILE_LAUNCH: + { + SHELLEXECUTEINFO sei; + WCHAR wchDirectory[MAX_PATH] = L""; + + if (!lstrlen(szCurFile)) + break; + + if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) + break; + + if (lstrlen(szCurFile)) { + lstrcpy(wchDirectory,szCurFile); + PathRemoveFileSpec(wchDirectory); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = 0; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = szCurFile; + sei.lpParameters = NULL; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + + ShellExecuteEx(&sei); + } + break; + + + case IDM_FILE_RUN: + { + WCHAR tchCmdLine[MAX_PATH+4]; + + if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) + break; + + lstrcpy(tchCmdLine,szCurFile); + PathQuoteSpaces(tchCmdLine); + + RunDlg(hwnd,tchCmdLine); + } + break; + + + case IDM_FILE_OPENWITH: + if (bSaveBeforeRunningTools && !FileSave(FALSE,TRUE,FALSE,FALSE)) + break; + OpenWithDlg(hwnd,szCurFile); + break; + + + case IDM_FILE_PAGESETUP: + EditPrintSetup(hwndEdit); + break; + + case IDM_FILE_PRINT: + { + SHFILEINFO shfi; + WCHAR *pszTitle; + WCHAR tchUntitled[32]; + WCHAR tchPageFmt[32]; + + if (lstrlen(szCurFile)) { + SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + pszTitle = shfi.szDisplayName; + } + else { + GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); + pszTitle = tchUntitled; + } + + GetString(IDS_PRINT_PAGENUM,tchPageFmt,COUNTOF(tchPageFmt)); + + if (!EditPrint(hwndEdit,pszTitle,tchPageFmt)) + MsgBox(MBWARN,IDS_PRINT_ERROR,pszTitle); + } + break; + + + case IDM_FILE_PROPERTIES: + { + SHELLEXECUTEINFO sei; + + if (lstrlen(szCurFile) == 0) + break; + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = SEE_MASK_INVOKEIDLIST; + sei.hwnd = hwnd; + sei.lpVerb = L"properties"; + sei.lpFile = szCurFile; + sei.nShow = SW_SHOWNORMAL; + + ShellExecuteEx(&sei); + } + break; + + case IDM_FILE_CREATELINK: + { + if (!lstrlen(szCurFile)) + break; + + if (!PathCreateDeskLnk(szCurFile)) + MsgBox(MBWARN,IDS_ERR_CREATELINK); + } + break; + + + case IDM_FILE_OPENFAV: + if (FileSave(FALSE,TRUE,FALSE,FALSE)) { + + WCHAR tchSelItem[MAX_PATH]; + + if (FavoritesDlg(hwnd,tchSelItem)) + { + if (PathIsLnkToDirectory(tchSelItem,NULL,0)) + PathGetLnkPath(tchSelItem,tchSelItem,COUNTOF(tchSelItem)); + + if (PathIsDirectory(tchSelItem)) + { + WCHAR tchFile[MAX_PATH]; + + if (OpenFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchSelItem)) + FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile); + } + else + FileLoad(TRUE,FALSE,FALSE,FALSE,tchSelItem); + } + } + break; + + + case IDM_FILE_ADDTOFAV: + if (lstrlen(szCurFile)) { + SHFILEINFO shfi; + SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + AddToFavDlg(hwnd,shfi.szDisplayName,szCurFile); + } + break; + + + case IDM_FILE_MANAGEFAV: + { + SHELLEXECUTEINFO sei; + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = 0; + sei.hwnd = hwnd; + sei.lpVerb = NULL; + sei.lpFile = tchFavoritesDir; + sei.lpParameters = NULL; + sei.lpDirectory = NULL; + sei.nShow = SW_SHOWNORMAL; + + // Run favorites directory + ShellExecuteEx(&sei); + } + break; + + + case IDM_FILE_RECENT: + if (MRU_Enum(pFileMRU,0,NULL,0) > 0) { + if (FileSave(FALSE,TRUE,FALSE,FALSE)) { + WCHAR tchFile[MAX_PATH]; + if (FileMRUDlg(hwnd,tchFile)) + FileLoad(TRUE,FALSE,FALSE,FALSE,tchFile); + } + } + break; + + + case IDM_FILE_EXIT: + SendMessage(hwnd,WM_CLOSE,0,0); + break; + + + case IDM_ENCODING_ANSI: + case IDM_ENCODING_UNICODE: + case IDM_ENCODING_UNICODEREV: + case IDM_ENCODING_UTF8: + case IDM_ENCODING_UTF8SIGN: + case IDM_ENCODING_SELECT: + { + int iNewEncoding = iEncoding; + if (LOWORD(wParam) == IDM_ENCODING_SELECT && !SelectEncodingDlg(hwnd,&iNewEncoding)) + break; + else { + switch (LOWORD(wParam)) { + case IDM_ENCODING_UNICODE: iNewEncoding = CPI_UNICODEBOM; break; + case IDM_ENCODING_UNICODEREV: iNewEncoding = CPI_UNICODEBEBOM; break; + case IDM_ENCODING_UTF8: iNewEncoding = CPI_UTF8; break; + case IDM_ENCODING_UTF8SIGN: iNewEncoding = CPI_UTF8SIGN; break; + case IDM_ENCODING_ANSI: iNewEncoding = CPI_DEFAULT; break; + } + } + + if (EditSetNewEncoding(hwndEdit, + iEncoding,iNewEncoding, + (flagSetEncoding),lstrlen(szCurFile) == 0)) { + + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) { + iEncoding = iNewEncoding; + iOriginalEncoding = iNewEncoding; + } + else { + if (iEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) + iOriginalEncoding = -1; + iEncoding = iNewEncoding; + } + + UpdateToolbar(); + UpdateStatusbar(); + + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + } + } + break; + + + case IDM_ENCODING_RECODE: + { + if (lstrlen(szCurFile)) { + + WCHAR tchCurFile2[MAX_PATH]; + + int iNewEncoding = -1; + if (iEncoding != CPI_DEFAULT) + iNewEncoding = iEncoding; + if (iEncoding == CPI_UTF8SIGN) + iNewEncoding = CPI_UTF8; + if (iEncoding == CPI_UNICODEBOM) + iNewEncoding = CPI_UNICODE; + if (iEncoding == CPI_UNICODEBEBOM) + iNewEncoding = CPI_UNICODEBE; + + if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_RECODE) != IDOK) + return(0); + + if (RecodeDlg(hwnd,&iNewEncoding)) { + + lstrcpy(tchCurFile2,szCurFile); + iSrcEncoding = iNewEncoding; + FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2); + } + } + } + break; + + + case IDM_ENCODING_SETDEFAULT: + SelectDefEncodingDlg(hwnd,&iDefaultEncoding); + break; + + + case IDM_LINEENDINGS_CRLF: + case IDM_LINEENDINGS_LF: + case IDM_LINEENDINGS_CR: + { + int iNewEOLMode = iLineEndings[LOWORD(wParam)-IDM_LINEENDINGS_CRLF]; + iEOLMode = iNewEOLMode; + SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0); + SendMessage(hwndEdit,SCI_CONVERTEOLS,iEOLMode,0); + EditFixPositions(hwndEdit); + UpdateToolbar(); + UpdateStatusbar(); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + } + break; + + + case IDM_LINEENDINGS_SETDEFAULT: + SelectDefLineEndingDlg(hwnd,&iDefaultEOLMode); + break; + + + case IDM_EDIT_UNDO: + SendMessage(hwndEdit,SCI_UNDO,0,0); + break; + + + case IDM_EDIT_REDO: + SendMessage(hwndEdit,SCI_REDO,0,0); + break; + + + case IDM_EDIT_CUT: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_CUT,0,0); + break; + + + case IDM_EDIT_COPY: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_COPY,0,0); + UpdateToolbar(); + break; + + + case IDM_EDIT_COPYALL: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_COPYRANGE,0,SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); + UpdateToolbar(); + break; + + + case IDM_EDIT_COPYADD: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + EditCopyAppend(hwndEdit); + UpdateToolbar(); + break; + + + case IDM_EDIT_PASTE: + SendMessage(hwndEdit,SCI_PASTE,0,0); + break; + + + case IDM_EDIT_SWAP: + if (SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) == 0) { + int iNewPos; + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + SendMessage(hwndEdit,SCI_PASTE,0,0); + iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + SendMessage(hwndEdit,SCI_SETSEL,iPos,iNewPos); + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEARCLIPBOARD,1),0); + } + else { + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + char *pClip = EditGetClipboardText(hwndEdit); + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwndEdit,SCI_CUT,0,0); + SendMessage(hwndEdit,SCI_REPLACESEL,(WPARAM)0,(LPARAM)pClip); + if (iPos > iAnchor) + SendMessage(hwndEdit,SCI_SETSEL,iAnchor,iAnchor + lstrlenA(pClip)); + else + SendMessage(hwndEdit,SCI_SETSEL,iPos + lstrlenA(pClip),iPos); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + LocalFree(pClip); + } + break; + + + case IDM_EDIT_CLEAR: + SendMessage(hwndEdit,SCI_CLEAR,0,0); + break; + + + case IDM_EDIT_CLEARCLIPBOARD: + if (OpenClipboard(hwnd)) { + if (CountClipboardFormats() > 0) { + EmptyClipboard(); + UpdateToolbar(); + UpdateStatusbar(); + } + CloseClipboard(); + } + break; + + + case IDM_EDIT_SELECTALL: + SendMessage(hwndEdit,SCI_SELECTALL,0,0); + //SendMessage(hwndEdit,SCI_SETSEL,0,(LPARAM)-1); + break; + + + case IDM_EDIT_SELECTWORD: + { + int iSel = + (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + + if (iSel == 0) { + + int iWordStart = (int)SendMessage(hwndEdit,SCI_WORDSTARTPOSITION,iPos,TRUE); + int iWordEnd = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,TRUE); + + if (iWordStart == iWordEnd) // we are in whitespace salad... + { + iWordStart = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iPos,FALSE); + iWordEnd = (int)SendMessage(hwndEdit,SCI_WORDENDPOSITION,iWordStart,TRUE); + if (iWordStart != iWordEnd) { + //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) && + // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) && + // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0)) + // iWordStart--; + SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd); + } + } + else { + //if (SCLEX_HTML == SendMessage(hwndEdit,SCI_GETLEXER,0,0) && + // SCE_HPHP_VARIABLE == SendMessage(hwndEdit,SCI_GETSTYLEAT,(WPARAM)iWordStart,0) && + // '$' == (char)SendMessage(hwndEdit,SCI_GETCHARAT,(WPARAM)iWordStart-1,0)) + // iWordStart--; + SendMessage(hwndEdit,SCI_SETSEL,iWordStart,iWordEnd); + } + + iSel = + (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + + if (iSel == 0) { + int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0); + int iLineStart = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0); + int iLineEnd = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0); + SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd); + } + } + else { + int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0); + int iLineStart = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,iLine,0); + int iLineEnd = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iLine,0); + SendMessage(hwndEdit,SCI_SETSEL,iLineStart,iLineEnd); + } + } + + break; + + + case IDM_EDIT_SELECTLINE: + { + int iSelStart = (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + int iSelEnd = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0); + int iLineStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelStart,0); + int iLineEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iSelEnd,0); + iSelStart = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineStart,0); + iSelEnd = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLineEnd+1,0); + SendMessage(hwndEdit,SCI_SETSEL,iSelStart,iSelEnd); + SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); + } + break; + + + case IDM_EDIT_MOVELINEUP: + EditMoveUp(hwndEdit); + break; + + + case IDM_EDIT_MOVELINEDOWN: + EditMoveDown(hwndEdit); + break; + + + case IDM_EDIT_DUPLICATELINE: + SendMessage(hwndEdit,SCI_LINEDUPLICATE,0,0); + break; + + + case IDM_EDIT_CUTLINE: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_LINECUT,0,0); + break; + + + case IDM_EDIT_COPYLINE: + if (flagPasteBoard) + bLastCopyFromMe = TRUE; + SendMessage(hwndEdit,SCI_LINECOPY,0,0); + UpdateToolbar(); + break; + + + case IDM_EDIT_DELETELINE: + SendMessage(hwndEdit,SCI_LINEDELETE,0,0); + break; + + + case IDM_EDIT_DELETELINELEFT: + SendMessage(hwndEdit,SCI_DELLINELEFT,0,0); + break; + + + case IDM_EDIT_DELETELINERIGHT: + SendMessage(hwndEdit,SCI_DELLINERIGHT,0,0); + break; + + + case IDM_EDIT_INDENT: + { + int iLineSelStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0); + int iLineSelEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, + (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0); + + SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0); + if (iLineSelStart == iLineSelEnd) { + SendMessage(hwndEdit,SCI_VCHOME,0,0); + SendMessage(hwndEdit,SCI_TAB,0,0); + } + else + SendMessage(hwndEdit,SCI_TAB,0,0); + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + } + break; + + + case IDM_EDIT_UNINDENT: + { + int iLineSelStart = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0),0); + int iLineSelEnd = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION, + (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0),0); + + SendMessage(hwndEdit,SCI_SETTABINDENTS,TRUE,0); + if (iLineSelStart == iLineSelEnd) { + SendMessage(hwndEdit,SCI_VCHOME,0,0); + SendMessage(hwndEdit,SCI_BACKTAB,0,0); + } + else + SendMessage(hwndEdit,SCI_BACKTAB,0,0); + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + } + break; + + + case IDM_EDIT_ENCLOSESELECTION: + if (EditEncloseSelectionDlg(hwnd,wchPrefixSelection,wchAppendSelection)) { + BeginWaitCursor(); + EditEncloseSelection(hwndEdit,wchPrefixSelection,wchAppendSelection); + EndWaitCursor(); + } + break; + + + case IDM_EDIT_SELECTIONDUPLICATE: + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwndEdit,SCI_SELECTIONDUPLICATE,0,0); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + break; + + + case IDM_EDIT_PADWITHSPACES: + BeginWaitCursor(); + EditPadWithSpaces(hwndEdit,FALSE,FALSE); + EndWaitCursor(); + break; + + + case IDM_EDIT_STRIP1STCHAR: + BeginWaitCursor(); + EditStripFirstCharacter(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_STRIPLASTCHAR: + BeginWaitCursor(); + EditStripLastCharacter(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_TRIMLINES: + BeginWaitCursor(); + EditStripTrailingBlanks(hwndEdit,FALSE); + EndWaitCursor(); + break; + + + case IDM_EDIT_COMPRESSWS: + BeginWaitCursor(); + EditCompressSpaces(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_MERGEBLANKLINES: + BeginWaitCursor(); + EditRemoveBlankLines(hwndEdit,TRUE); + EndWaitCursor(); + break; + + + case IDM_EDIT_REMOVEBLANKLINES: + BeginWaitCursor(); + EditRemoveBlankLines(hwndEdit,FALSE); + EndWaitCursor(); + break; + + + case IDM_EDIT_MODIFYLINES: + if (EditModifyLinesDlg(hwnd,wchPrefixLines,wchAppendLines)) { + BeginWaitCursor(); + EditModifyLines(hwndEdit,wchPrefixLines,wchAppendLines); + EndWaitCursor(); + } + break; + + + case IDM_EDIT_ALIGN: + if (EditAlignDlg(hwnd,&iAlignMode)) { + BeginWaitCursor(); + EditAlignText(hwndEdit,iAlignMode); + EndWaitCursor(); + } + break; + + + case IDM_EDIT_SORTLINES: + if (EditSortDlg(hwnd,&iSortOptions)) { + BeginWaitCursor(); + StatusSetText(hwndStatus,255,L"..."); + StatusSetSimple(hwndStatus,TRUE); + InvalidateRect(hwndStatus,NULL,TRUE); + UpdateWindow(hwndStatus); + EditSortLines(hwndEdit,iSortOptions); + StatusSetSimple(hwndStatus,FALSE); + EndWaitCursor(); + } + break; + + + case IDM_EDIT_COLUMNWRAP: + { + if (iWrapCol == 0) + iWrapCol = iLongLinesLimit; + + if (ColumnWrapDlg(hwnd,IDD_COLUMNWRAP,&iWrapCol)) + { + iWrapCol = max(min(iWrapCol,512),1); + BeginWaitCursor(); + EditWrapToColumn(hwndEdit,iWrapCol); + EndWaitCursor(); + } + } + break; + + + case IDM_EDIT_SPLITLINES: + BeginWaitCursor(); + SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0); + SendMessage(hwndEdit,SCI_LINESSPLIT,0,0); + EndWaitCursor(); + break; + + + case IDM_EDIT_JOINLINES: + BeginWaitCursor(); + SendMessage(hwndEdit,SCI_TARGETFROMSELECTION,0,0); + SendMessage(hwndEdit,SCI_LINESJOIN,0,0); + EditJoinLinesEx(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_JOINLINESEX: + BeginWaitCursor(); + EditJoinLinesEx(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTUPPERCASE: + BeginWaitCursor(); + SendMessage(hwndEdit,SCI_UPPERCASE,0,0); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTLOWERCASE: + BeginWaitCursor(); + SendMessage(hwndEdit,SCI_LOWERCASE,0,0); + EndWaitCursor(); + break; + + + case IDM_EDIT_INVERTCASE: + BeginWaitCursor(); + EditInvertCase(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_TITLECASE: + BeginWaitCursor(); + EditTitleCase(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_SENTENCECASE: + BeginWaitCursor(); + EditSentenceCase(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTTABS: + BeginWaitCursor(); + EditTabsToSpaces(hwndEdit,iTabWidth,FALSE); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTSPACES: + BeginWaitCursor(); + EditSpacesToTabs(hwndEdit,iTabWidth,FALSE); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTTABS2: + BeginWaitCursor(); + EditTabsToSpaces(hwndEdit,iTabWidth,TRUE); + EndWaitCursor(); + break; + + + case IDM_EDIT_CONVERTSPACES2: + BeginWaitCursor(); + EditSpacesToTabs(hwndEdit,iTabWidth,TRUE); + EndWaitCursor(); + break; + + + case IDM_EDIT_INSERT_TAG: + { + WCHAR wszOpen[256] = L""; + WCHAR wszClose[256] = L""; + if (EditInsertTagDlg(hwnd,wszOpen,wszClose)) + EditEncloseSelection(hwndEdit,wszOpen,wszClose); + } + break; + + + case IDM_EDIT_INSERT_ENCODING: + { + if (*mEncoding[iEncoding].pszParseNames) { + char msz[32]; + char *p; + //int iSelStart; + lstrcpynA(msz,mEncoding[iEncoding].pszParseNames,COUNTOF(msz)); + if (p = StrChrA(msz,',')) + *p = 0; + //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz); + //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); + } + } + break; + + + case IDM_EDIT_INSERT_SHORTDATE: + case IDM_EDIT_INSERT_LONGDATE: + { + WCHAR tchDate[128]; + WCHAR tchTime[128]; + WCHAR tchDateTime[256]; + WCHAR tchTemplate[256]; + SYSTEMTIME st; + char mszBuf[MAX_PATH*3]; + UINT uCP; + //int iSelStart; + + GetLocalTime(&st); + + if (IniGetString(L"Settings2", + (LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? L"DateTimeShort" : L"DateTimeLong", + L"",tchTemplate,COUNTOF(tchTemplate))) { + struct tm sst; + sst.tm_isdst = -1; + sst.tm_sec = (int)st.wSecond; + sst.tm_min = (int)st.wMinute; + sst.tm_hour = (int)st.wHour; + sst.tm_mday = (int)st.wDay; + sst.tm_mon = (int)st.wMonth - 1; + sst.tm_year = (int)st.wYear - 1900; + sst.tm_wday = (int)st.wDayOfWeek; + mktime(&sst); + wcsftime(tchDateTime,COUNTOF(tchDateTime),tchTemplate,&sst); + } + else { + GetDateFormat(LOCALE_USER_DEFAULT,( + LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? DATE_SHORTDATE : DATE_LONGDATE, + &st,NULL,tchDate,COUNTOF(tchDate)); + GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,tchTime,COUNTOF(tchTime)); + + wsprintf(tchDateTime,L"%s %s",tchTime,tchDate); + } + + uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; + WideCharToMultiByte(uCP,0,tchDateTime,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL); + //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); + //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); + } + break; + + + case IDM_EDIT_INSERT_FILENAME: + case IDM_EDIT_INSERT_PATHNAME: + { + SHFILEINFO shfi; + WCHAR *pszInsert; + WCHAR tchUntitled[32]; + char mszBuf[MAX_PATH*3]; + UINT uCP; + //int iSelStart; + + if (lstrlen(szCurFile)) { + if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) { + SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + pszInsert = shfi.szDisplayName; + } + else + pszInsert = szCurFile; + } + + else { + GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); + pszInsert = tchUntitled; + } + + uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; + WideCharToMultiByte(uCP,0,pszInsert,-1,mszBuf,COUNTOF(mszBuf),NULL,NULL); + //iSelStart = SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); + //SendMessage(hwndEdit,SCI_SETANCHOR,(WPARAM)iSelStart,0); + } + break; + + + case IDM_EDIT_LINECOMMENT: + switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) { + case SCLEX_NULL: + case SCLEX_CSS: + case SCLEX_DIFF: + case SCLEX_MARKDOWN: + break; + case SCLEX_HTML: + case SCLEX_XML: + case SCLEX_CPP: + case SCLEX_PASCAL: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"//",FALSE); + EndWaitCursor(); + break; + case SCLEX_VBSCRIPT: + case SCLEX_VB: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"'",FALSE); + EndWaitCursor(); + break; + case SCLEX_MAKEFILE: + case SCLEX_PERL: + case SCLEX_PYTHON: + case SCLEX_CONF: + case SCLEX_BASH: + case SCLEX_TCL: + case SCLEX_RUBY: + case SCLEX_POWERSHELL: + case SCLEX_CMAKE: + case SCLEX_AVS: + case SCLEX_YAML: + case SCLEX_COFFEESCRIPT: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"#",TRUE); + EndWaitCursor(); + break; + case SCLEX_ASM: + case SCLEX_PROPERTIES: + case SCLEX_AU3: + case SCLEX_AHK: + case SCLEX_NSIS: // # could also be used instead + case SCLEX_INNOSETUP: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L";",TRUE); + EndWaitCursor(); + break; + case SCLEX_SQL: + case SCLEX_LUA: + case SCLEX_VHDL: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"--",TRUE); + EndWaitCursor(); + break; + case SCLEX_BATCH: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"rem ",TRUE); + EndWaitCursor(); + break; + case SCLEX_LATEX: + BeginWaitCursor(); + EditToggleLineComments(hwndEdit,L"%",TRUE); + EndWaitCursor(); + break; + } + break; + + + case IDM_EDIT_STREAMCOMMENT: + switch (SendMessage(hwndEdit,SCI_GETLEXER,0,0)) { + case SCLEX_NULL: + case SCLEX_VBSCRIPT: + case SCLEX_MAKEFILE: + case SCLEX_VB: + case SCLEX_ASM: + case SCLEX_SQL: + case SCLEX_PERL: + case SCLEX_PYTHON: + case SCLEX_PROPERTIES: + case SCLEX_CONF: + case SCLEX_POWERSHELL: + case SCLEX_BATCH: + case SCLEX_DIFF: + case SCLEX_BASH: + case SCLEX_TCL: + case SCLEX_AU3: + case SCLEX_LATEX: + case SCLEX_AHK: + case SCLEX_RUBY: + case SCLEX_CMAKE: + case SCLEX_MARKDOWN: + case SCLEX_YAML: + break; + case SCLEX_HTML: + case SCLEX_XML: + case SCLEX_CSS: + case SCLEX_CPP: + case SCLEX_NSIS: + case SCLEX_AVS: + case SCLEX_VHDL: + EditEncloseSelection(hwndEdit,L"/*",L"*/"); + break; + case SCLEX_PASCAL: + case SCLEX_INNOSETUP: + EditEncloseSelection(hwndEdit,L"{",L"}"); + break; + case SCLEX_LUA: + EditEncloseSelection(hwndEdit,L"--[[",L"]]"); + break; + case SCLEX_COFFEESCRIPT: + EditEncloseSelection(hwndEdit,L"###",L"###"); + } + break; + + + case IDM_EDIT_URLENCODE: + BeginWaitCursor(); + EditURLEncode(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_URLDECODE: + BeginWaitCursor(); + EditURLDecode(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_ESCAPECCHARS: + BeginWaitCursor(); + EditEscapeCChars(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_UNESCAPECCHARS: + BeginWaitCursor(); + EditUnescapeCChars(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_CHAR2HEX: + BeginWaitCursor(); + EditChar2Hex(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_HEX2CHAR: + BeginWaitCursor(); + EditHex2Char(hwndEdit); + EndWaitCursor(); + break; + + + case IDM_EDIT_FINDMATCHINGBRACE: + { + int iBrace2 = -1; + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) + iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + // Try one before + else { + iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); + c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) + iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + } + if (iBrace2 != -1) + SendMessage(hwndEdit,SCI_GOTOPOS,(WPARAM)iBrace2,0); + } + break; + + + case IDM_EDIT_SELTOMATCHINGBRACE: + { + int iBrace2 = -1; + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + char c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) + iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + // Try one before + else { + iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); + c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) + iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + } + if (iBrace2 != -1) { + if (iBrace2 > iPos) + SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iBrace2+1); + else + SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos+1,(LPARAM)iBrace2); + } + } + break; + + + case IDM_EDIT_FIND: + if (!IsWindow(hDlgFindReplace)) + hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE); + else { + if (GetDlgItem(hDlgFindReplace,IDC_REPLACE)) { + SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOFIND,1),0); + DestroyWindow(hDlgFindReplace); + hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,FALSE); + } + else { + SetForegroundWindow(hDlgFindReplace); + PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1); + } + } + break; + + +#ifdef BOOKMARK_EDITION + // Main Bookmark Functions + //case IDM_EDIT_BOOKMARKNEXT: + case BME_EDIT_BOOKMARKNEXT: + { + int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); + int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); + + int bitmask = 1; + int iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERNEXT , iLine+1 , bitmask ); + if( iNextLine == -1 ) + { + iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERNEXT , 0 , bitmask ); + } + + if( iNextLine != -1 ) + { + SciCall_EnsureVisible(iNextLine); + SendMessage( hwndEdit , SCI_GOTOLINE , iNextLine , 0 ); + SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,10); + SciCall_ScrollCaret(); + SciCall_SetYCaretPolicy(CARET_EVEN,0); + } + break; + } + + //case IMD_EDIT_BOOKMARKPREV: + case BME_EDIT_BOOKMARKPREV: + { + int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); + int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); + + int bitmask = 1; + int iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); + if( iNextLine == -1 ) + { + int nLines = (int)SendMessage( hwndEdit , SCI_GETLINECOUNT , 0 , 0 ); + iNextLine = (int)SendMessage( hwndEdit , SCI_MARKERPREVIOUS , nLines , bitmask ); + } + + if( iNextLine != -1 ) + { + SciCall_EnsureVisible(iNextLine); + SendMessage( hwndEdit , SCI_GOTOLINE , iNextLine , 0 ); + SciCall_SetYCaretPolicy(CARET_SLOP|CARET_STRICT|CARET_EVEN,10); + SciCall_ScrollCaret(); + SciCall_SetYCaretPolicy(CARET_EVEN,0); + } + + break; + } + + //case IDM_EDIT_BOOKMARKTOGGLE: + case BME_EDIT_BOOKMARKTOGGLE: + { + int iPos = (int)SendMessage( hwndEdit , SCI_GETCURRENTPOS , 0 , 0); + int iLine = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iPos , 0 ); + + int bitmask = (int)SendMessage( hwndEdit , SCI_MARKERGET , iLine , 0 ); + if( bitmask & 1 ) + { + // unset + SendMessage( hwndEdit , SCI_MARKERDELETE , iLine , 0 ); + } + else + { + + if( bShowSelectionMargin ) + { + SendMessage( hwndEdit , SCI_MARKERDEFINEPIXMAP , 0 , (LPARAM)bookmark_pixmap ); + } + else + { + SendMessage( hwndEdit , SCI_MARKERSETBACK , 0 , Style_GetBookmarkColor() ); + SendMessage( hwndEdit , SCI_MARKERSETALPHA , 0 , Style_IsDarkTheme() ? 60 : 20); + SendMessage( hwndEdit , SCI_MARKERDEFINE , 0 , SC_MARK_BACKGROUND ); + } + + // set + SendMessage( hwndEdit , SCI_MARKERADD , iLine , 0 ); + } + + break; + } + + //case IDM_EDIT_BOOKMARKCLEAR: + case BME_EDIT_BOOKMARKCLEAR: + { + SendMessage( hwndEdit , SCI_MARKERDELETEALL , -1 , 0 ); + + break; + } +#endif + + + case IDM_EDIT_FINDNEXT: + case IDM_EDIT_FINDPREV: + case IDM_EDIT_REPLACENEXT: + case IDM_EDIT_SELTONEXT: + case IDM_EDIT_SELTOPREV: + + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) == 0) + break; + + if (!lstrlenA(efrData.szFind)) { + if (LOWORD(wParam) != IDM_EDIT_REPLACENEXT) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); + else + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); + } + + else { + + UINT cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); + if (cpLastFind != cp) { + if (cp != SC_CP_UTF8) { + + WCHAR wch[512]; + + MultiByteToWideChar(CP_UTF8,0,efrData.szFindUTF8,-1,wch,COUNTOF(wch)); + WideCharToMultiByte(cp,0,wch,-1,efrData.szFind,COUNTOF(efrData.szFind),NULL,NULL); + + MultiByteToWideChar(CP_UTF8,0,efrData.szReplaceUTF8,-1,wch,COUNTOF(wch)); + WideCharToMultiByte(cp,0,wch,-1,efrData.szReplace,COUNTOF(efrData.szReplace),NULL,NULL); + } + else { + + lstrcpyA(efrData.szFind,efrData.szFindUTF8); + lstrcpyA(efrData.szReplace,efrData.szReplaceUTF8); + } + } + cpLastFind = cp; + switch (LOWORD(wParam)) { + + case IDM_EDIT_FINDNEXT: + EditFindNext(hwndEdit,&efrData,FALSE); + break; + + case IDM_EDIT_FINDPREV: + EditFindPrev(hwndEdit,&efrData,FALSE); + break; + + case IDM_EDIT_REPLACENEXT: + if (bReplaceInitialized) + EditReplace(hwndEdit,&efrData); + else + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); + break; + + case IDM_EDIT_SELTONEXT: + EditFindNext(hwndEdit,&efrData,TRUE); + break; + + case IDM_EDIT_SELTOPREV: + EditFindPrev(hwndEdit,&efrData,TRUE); + break; + } + } + break; + + case IDM_EDIT_COMPLETEWORD: + CompleteWord(hwndEdit, TRUE); + break; + + + case IDM_EDIT_REPLACE: + if (!IsWindow(hDlgFindReplace)) + hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE); + else { + if (!GetDlgItem(hDlgFindReplace,IDC_REPLACE)) { + SendMessage(hDlgFindReplace,WM_COMMAND,MAKELONG(IDMSG_SWITCHTOREPLACE,1),0); + DestroyWindow(hDlgFindReplace); + hDlgFindReplace = EditFindReplaceDlg(hwndEdit,&efrData,TRUE); + } + else { + SetForegroundWindow(hDlgFindReplace); + PostMessage(hDlgFindReplace,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hDlgFindReplace,IDC_FINDTEXT)),1); + } + } + break; + + + case IDM_EDIT_GOTOLINE: + EditLinenumDlg(hwndEdit); + break; + + + case IDM_VIEW_SCHEME: + Style_SelectLexerDlg(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_USE2NDDEFAULT: + Style_ToggleUse2ndDefault(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + case IDM_VIEW_THEME_ORIGINAL: + case IDM_VIEW_THEME_DARK: + Style_SetTheme(hwndEdit,LOWORD(wParam) == IDM_VIEW_THEME_DARK); + UpdateLineNumberWidth(); + UpdateStatusbar(); + break; + + + case IDM_VIEW_SCHEMECONFIG: + Style_ConfigDlg(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_FONT: + Style_SetDefaultFont(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_WORDWRAP: + fWordWrap = (fWordWrap) ? FALSE : TRUE; + if (!fWordWrap) + SendMessage(hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); + else + SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); + fWordWrapG = fWordWrap; + UpdateToolbar(); + break; + + + case IDM_VIEW_WORDWRAPSETTINGS: + if (WordWrapSettingsDlg(hwnd,IDD_WORDWRAP,&iWordWrapIndent)) + { + if (fWordWrap) + SendMessage(hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WORD : SC_WRAP_CHAR,0); + if (iWordWrapIndent == 5) + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_SAME,0); + else if (iWordWrapIndent == 6) + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_INDENT,0); + else { + int i = 0; + switch (iWordWrapIndent) { + case 1: i = 1; break; + case 2: i = 2; break; + case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; + case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; + } + SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); + SendMessage(hwndEdit,SCI_SETWRAPINDENTMODE,SC_WRAPINDENT_FIXED,0); + } + if (bShowWordWrapSymbols) { + int wrapVisualFlags = 0; + int wrapVisualFlagsLocation = 0; + if (iWordWrapSymbols == 0) + iWordWrapSymbols = 22; + switch (iWordWrapSymbols%10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; + } + switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; + } + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); + } + else { + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); + } + } + break; + + + case IDM_VIEW_LONGLINEMARKER: + bMarkLongLines = (bMarkLongLines) ? FALSE: TRUE; + if (bMarkLongLines) { + SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); + Style_SetLongLineColors(hwndEdit); + } + else + SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); + UpdateStatusbar(); + break; + + + case IDM_VIEW_LONGLINESETTINGS: + if (LongLineSettingsDlg(hwnd,IDD_LONGLINES,&iLongLinesLimit)) { + bMarkLongLines = TRUE; + SendMessage(hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); + Style_SetLongLineColors(hwndEdit); + iLongLinesLimit = max(min(iLongLinesLimit,4096),0); + SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); + UpdateStatusbar(); + iLongLinesLimitG = iLongLinesLimit; + } + break; + + + case IDM_VIEW_TABSASSPACES: + bTabsAsSpaces = (bTabsAsSpaces) ? FALSE : TRUE; + SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); + bTabsAsSpacesG = bTabsAsSpaces; + break; + + + case IDM_VIEW_TABSETTINGS: + if (TabSettingsDlg(hwnd,IDD_TABSETTINGS,NULL)) + { + SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + SendMessage(hwndEdit,SCI_SETBACKSPACEUNINDENTS,bBackspaceUnindents,0); + iTabWidth = max(min(iTabWidth,256),1); + iIndentWidth = max(min(iIndentWidth,256),0); + SendMessage(hwndEdit,SCI_SETTABWIDTH,iTabWidth,0); + SendMessage(hwndEdit,SCI_SETINDENT,iIndentWidth,0); + bTabsAsSpacesG = bTabsAsSpaces; + bTabIndentsG = bTabIndents; + iTabWidthG = iTabWidth; + iIndentWidthG = iIndentWidth; + if (SendMessage(hwndEdit,SCI_GETWRAPINDENTMODE,0,0) == SC_WRAPINDENT_FIXED) { + int i = 0; + switch (iWordWrapIndent) { + case 1: i = 1; break; + case 2: i = 2; break; + case 3: i = (iIndentWidth) ? 1 * iIndentWidth : 1 * iTabWidth; break; + case 4: i = (iIndentWidth) ? 2 * iIndentWidth : 2 * iTabWidth; break; + } + SendMessage(hwndEdit,SCI_SETWRAPSTARTINDENT,i,0); + } + } + break; + + + case IDM_VIEW_SHOWINDENTGUIDES: + bShowIndentGuides = (bShowIndentGuides) ? FALSE : TRUE; + Style_SetIndentGuides(hwndEdit,bShowIndentGuides); + break; + + + case IDM_VIEW_AUTOINDENTTEXT: + bAutoIndent = (bAutoIndent) ? FALSE : TRUE; + break; + + + case IDM_VIEW_LINENUMBERS: + bShowLineNumbers = (bShowLineNumbers) ? FALSE : TRUE; + UpdateLineNumberWidth(); + //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0, + // (bShowLineNumbers)?SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)"_999999_"):0); + break; + + + case IDM_VIEW_MARGIN: + bShowSelectionMargin = (bShowSelectionMargin) ? FALSE : TRUE; + SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,1,(bShowSelectionMargin)?16:0); + +#ifdef BOOKMARK_EDITION + //Depending on if the margin is visible or not, choose different bookmark indication + if( bShowSelectionMargin ) + { + SendMessage( hwndEdit , SCI_MARKERDEFINEPIXMAP , 0 , (LPARAM)bookmark_pixmap ); + } + else + { + SendMessage( hwndEdit , SCI_MARKERSETBACK , 0 , Style_GetBookmarkColor() ); + SendMessage( hwndEdit , SCI_MARKERSETALPHA , 0 , Style_IsDarkTheme() ? 60 : 20); + SendMessage( hwndEdit , SCI_MARKERDEFINE , 0 , SC_MARK_BACKGROUND ); + } +#endif + + break; + + case IDM_VIEW_AUTOCOMPLETEWORDS: + if (bAutoCompleteWords) { + // close the autocompletion list + SendMessage(hwndEdit, SCI_AUTOCCANCEL, 0, 0); + bAutoCompleteWords = FALSE; + } + else { + bAutoCompleteWords = TRUE; + } + break; + + case IDM_VIEW_MARKOCCURRENCES_OFF: + iMarkOccurrences = 0; + // clear all marks + SendMessage(hwndEdit, SCI_SETINDICATORCURRENT, 1, 0); + SendMessage(hwndEdit, SCI_INDICATORCLEARRANGE, 0, (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); + break; + + case IDM_VIEW_MARKOCCURRENCES_RED: + iMarkOccurrences = 1; + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + break; + + case IDM_VIEW_MARKOCCURRENCES_GREEN: + iMarkOccurrences = 2; + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + break; + + case IDM_VIEW_MARKOCCURRENCES_BLUE: + iMarkOccurrences = 3; + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + break; + + case IDM_VIEW_MARKOCCURRENCES_CASE: + bMarkOccurrencesMatchCase = (bMarkOccurrencesMatchCase) ? FALSE : TRUE; + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + break; + + case IDM_VIEW_MARKOCCURRENCES_WORD: + bMarkOccurrencesMatchWords = (bMarkOccurrencesMatchWords) ? FALSE : TRUE; + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + break; + + case IDM_VIEW_FOLDING: + bShowCodeFolding = (bShowCodeFolding) ? FALSE : TRUE; + SciCall_SetMarginWidth(MARGIN_FOLD_INDEX, (bShowCodeFolding) ? 11 : 0); + UpdateToolbar(); + if (!bShowCodeFolding) + FoldToggleAll(EXPAND); + break; + + + case IDM_VIEW_TOGGLEFOLDS: + FoldToggleAll(SNIFF); + break; + + + case IDM_VIEW_SHOWWHITESPACE: + bViewWhiteSpace = (bViewWhiteSpace) ? FALSE : TRUE; + SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); + break; + + + case IDM_VIEW_SHOWEOLS: + bViewEOLs = (bViewEOLs) ? FALSE : TRUE; + SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); + break; + + + case IDM_VIEW_WORDWRAPSYMBOLS: + bShowWordWrapSymbols = (bShowWordWrapSymbols) ? 0 : 1; + if (bShowWordWrapSymbols) { + int wrapVisualFlags = 0; + int wrapVisualFlagsLocation = 0; + if (iWordWrapSymbols == 0) + iWordWrapSymbols = 22; + switch (iWordWrapSymbols%10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; + } + switch (((iWordWrapSymbols%100)-(iWordWrapSymbols%10))/10) { + case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; break; + case 2: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; break; + } + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGSLOCATION,wrapVisualFlagsLocation,0); + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,wrapVisualFlags,0); + } + else { + SendMessage(hwndEdit,SCI_SETWRAPVISUALFLAGS,0,0); + } + break; + + + case IDM_VIEW_MATCHBRACES: + bMatchBraces = (bMatchBraces) ? FALSE : TRUE; + if (bMatchBraces) { + struct SCNotification scn; + scn.nmhdr.hwndFrom = hwndEdit; + scn.nmhdr.idFrom = IDC_EDIT; + scn.nmhdr.code = SCN_UPDATEUI; + scn.updated = SC_UPDATE_CONTENT; + SendMessage(hwnd,WM_NOTIFY,IDC_EDIT,(LPARAM)&scn); + } + else + SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1); + break; + + + case IDM_VIEW_AUTOCLOSETAGS: + bAutoCloseTags = (bAutoCloseTags) ? FALSE : TRUE; + break; + + + case IDM_VIEW_HILITECURRENTLINE: + bHiliteCurrentLine = (bHiliteCurrentLine) ? FALSE : TRUE; + Style_SetCurrentLineBackground(hwndEdit); + break; + + + case IDM_VIEW_ZOOMIN: + SendMessage(hwndEdit,SCI_ZOOMIN,0,0); + //UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_ZOOMOUT: + SendMessage(hwndEdit,SCI_ZOOMOUT,0,0); + //UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_RESETZOOM: + SendMessage(hwndEdit,SCI_SETZOOM,0,0); + //UpdateLineNumberWidth(); + break; + + + case IDM_VIEW_TOOLBAR: + if (bShowToolbar) { + bShowToolbar = 0; + ShowWindow(hwndReBar,SW_HIDE); + } + else { + bShowToolbar = 1; + UpdateToolbar(); + ShowWindow(hwndReBar,SW_SHOW); + } + SendWMSize(hwnd); + break; + + + case IDM_VIEW_CUSTOMIZETB: + SendMessage(hwndToolbar,TB_CUSTOMIZE,0,0); + break; + + + case IDM_VIEW_STATUSBAR: + if (bShowStatusbar) { + bShowStatusbar = 0; + ShowWindow(hwndStatus,SW_HIDE); + } + else { + bShowStatusbar = 1; + UpdateStatusbar(); + ShowWindow(hwndStatus,SW_SHOW); + } + SendWMSize(hwnd); + break; + + + case IDM_VIEW_STICKYWINPOS: + bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",bStickyWinPos); + if (!bStickyWinPos) { + WINDOWPLACEMENT wndpl; + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + + int ResX = GetSystemMetrics(SM_CXSCREEN); + int ResY = GetSystemMetrics(SM_CYSCREEN); + + // GetWindowPlacement + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hwndMain,&wndpl); + + wi.x = wndpl.rcNormalPosition.left; + wi.y = wndpl.rcNormalPosition.top; + wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; + wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; + wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); + + wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); + wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); + wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); + wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); + wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); + + bStickyWinPos = 1; + IniSetInt(L"Settings2",L"StickyWindowPosition",1); + + IniSetInt(L"Window",tchPosX,wi.x); + IniSetInt(L"Window",tchPosY,wi.y); + IniSetInt(L"Window",tchSizeX,wi.cx); + IniSetInt(L"Window",tchSizeY,wi.cy); + IniSetInt(L"Window",tchMaximized,wi.max); + + InfoBox(0,L"MsgStickyWinPos",IDS_STICKYWINPOS); + } + else { + bStickyWinPos = 0; + IniSetInt(L"Settings2",L"StickyWindowPosition",0); + } + break; + + + case IDM_VIEW_REUSEWINDOW: + if (IniGetInt(L"Settings2",L"ReuseWindow",0)) + IniSetInt(L"Settings2",L"ReuseWindow",0); + else + IniSetInt(L"Settings2",L"ReuseWindow",1); + break; + + + case IDM_VIEW_SINGLEFILEINSTANCE: + if (IniGetInt(L"Settings2",L"SingleFileInstance",0)) + IniSetInt(L"Settings2",L"SingleFileInstance",0); + else + IniSetInt(L"Settings2",L"SingleFileInstance",1); + break; + + + case IDM_VIEW_ALWAYSONTOP: + if ((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1) { + bAlwaysOnTop = 0; + flagAlwaysOnTop = 0; + SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + else { + bAlwaysOnTop = 1; + flagAlwaysOnTop = 0; + SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + } + break; + + + case IDM_VIEW_MINTOTRAY: + bMinimizeToTray =(bMinimizeToTray) ? FALSE : TRUE; + break; + + + case IDM_VIEW_TRANSPARENT: + bTransparentMode =(bTransparentMode) ? FALSE : TRUE; + SetWindowTransparentMode(hwnd,bTransparentMode); + break; + + + case IDM_VIEW_SHOWFILENAMEONLY: + iPathNameFormat = 0; + lstrcpy(szTitleExcerpt,L""); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + + case IDM_VIEW_SHOWFILENAMEFIRST: + iPathNameFormat = 1; + lstrcpy(szTitleExcerpt,L""); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + + case IDM_VIEW_SHOWFULLPATH: + iPathNameFormat = 2; + lstrcpy(szTitleExcerpt,L""); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + + case IDM_VIEW_SHOWEXCERPT: + EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + + case IDM_VIEW_NOSAVERECENT: + bSaveRecentFiles = (bSaveRecentFiles) ? FALSE : TRUE; + break; + + + case IDM_VIEW_NOSAVEFINDREPL: + bSaveFindReplace = (bSaveFindReplace) ? FALSE : TRUE; + break; + + + case IDM_VIEW_SAVEBEFORERUNNINGTOOLS: + bSaveBeforeRunningTools = (bSaveBeforeRunningTools) ? FALSE : TRUE; + break; + + + case IDM_VIEW_CHANGENOTIFY: + if (ChangeNotifyDlg(hwnd)) + InstallFileWatching(szCurFile); + break; + + + case IDM_VIEW_NOESCFUNC: + iEscFunction = 0; + break; + + + case IDM_VIEW_ESCMINIMIZE: + iEscFunction = 1; + break; + + + case IDM_VIEW_ESCEXIT: + iEscFunction = 2; + break; + + + case IDM_VIEW_SAVESETTINGS: + bSaveSettings = (bSaveSettings) ? FALSE : TRUE; + break; + + + case IDM_VIEW_SAVESETTINGSNOW: + { + BOOL bCreateFailure = FALSE; + + if (lstrlen(szIniFile) == 0) { + + if (lstrlen(szIniFile2) > 0) { + if (CreateIniFileEx(szIniFile2)) { + lstrcpy(szIniFile,szIniFile2); + lstrcpy(szIniFile2,L""); + } + else + bCreateFailure = TRUE; + } + + else + break; + } + + if (!bCreateFailure) { + + if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",szIniFile)) { + + BeginWaitCursor(); + StatusSetTextID(hwndStatus,STATUS_HELP,IDS_SAVINGSETTINGS); + StatusSetSimple(hwndStatus,TRUE); + InvalidateRect(hwndStatus,NULL,TRUE); + UpdateWindow(hwndStatus); + SaveSettings(TRUE); + StatusSetSimple(hwndStatus,FALSE); + EndWaitCursor(); + MsgBox(MBINFO,IDS_SAVEDSETTINGS); + } + else { + dwLastIOError = GetLastError(); + MsgBox(MBWARN,IDS_WRITEINI_FAIL); + } + } + else + MsgBox(MBWARN,IDS_CREATEINI_FAIL); + } + break; + + + case IDM_HELP_ABOUT: + ThemedDialogBox(g_hInstance,MAKEINTRESOURCE(IDD_ABOUT), + hwnd,AboutDlgProc); + break; + + + case IDM_CMDLINE_HELP: + DisplayCmdLineHelp(hwnd); + break; + + + case CMD_ESCAPE: + //close the autocomplete box + SendMessage(hwndEdit,SCI_AUTOCCANCEL,0, 0); + + if (iEscFunction == 1) + SendMessage(hwnd,WM_SYSCOMMAND,SC_MINIMIZE,0); + else if (iEscFunction == 2) + SendMessage(hwnd,WM_CLOSE,0,0); + break; + + + case CMD_SHIFTESC: + if (FileSave(TRUE,FALSE,FALSE,FALSE)) + SendMessage(hwnd,WM_CLOSE,0,0); + break; + + + // Newline with toggled auto indent setting + case CMD_CTRLENTER: + bAutoIndent = (bAutoIndent) ? 0 : 1; + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + bAutoIndent = (bAutoIndent) ? 0 : 1; + break; + + + case CMD_CTRLBACK: + { + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0); + int iStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + int iIndentPos = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iLine,0); + + if (iPos != iAnchor) + SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos); + else { + if (iPos == iStartPos) + SendMessage(hwndEdit,SCI_DELETEBACK,0,0); + else if (iPos <= iIndentPos) + SendMessage(hwndEdit,SCI_DELLINELEFT,0,0); + else + SendMessage(hwndEdit,SCI_DELWORDLEFT,0,0); + } + } + break; + + + case CMD_CTRLDEL: + { + int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iAnchor = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iPos,0); + int iStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iLine,0); + int iEndPos = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0); + + if (iPos != iAnchor) + SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iPos,(LPARAM)iPos); + else { + if (iStartPos != iEndPos) + SendMessage(hwndEdit,SCI_DELWORDRIGHT,0,0); + else // iStartPos == iEndPos + SendMessage(hwndEdit,SCI_LINEDELETE,0,0); + } + } + break; + + + case CMD_CTRLTAB: + SendMessage(hwndEdit,SCI_SETTABINDENTS,FALSE,0); + SendMessage(hwndEdit,SCI_SETUSETABS,TRUE,0); + SendMessage(hwndEdit,SCI_TAB,0,0); + SendMessage(hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0); + SendMessage(hwndEdit,SCI_SETTABINDENTS,bTabIndents,0); + break; + + + case CMD_RECODEDEFAULT: + { + WCHAR tchCurFile2[MAX_PATH]; + if (lstrlen(szCurFile)) { + if (iDefaultEncoding == CPI_UNICODEBOM) + iSrcEncoding = CPI_UNICODE; + else if (iDefaultEncoding == CPI_UNICODEBEBOM) + iSrcEncoding = CPI_UNICODEBE; + else if (iDefaultEncoding == CPI_UTF8SIGN) + iSrcEncoding = CPI_UTF8; + else + iSrcEncoding = iDefaultEncoding; + lstrcpy(tchCurFile2,szCurFile); + FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); + } + } + break; + + + case CMD_RELOADANSI: + { + WCHAR tchCurFile2[MAX_PATH]; + if (lstrlen(szCurFile)) { + iSrcEncoding = CPI_DEFAULT; + lstrcpy(tchCurFile2,szCurFile); + FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); + } + } + break; + + + case CMD_RELOADOEM: + { + WCHAR tchCurFile2[MAX_PATH]; + if (lstrlen(szCurFile)) { + iSrcEncoding = CPI_OEM; + lstrcpy(tchCurFile2,szCurFile); + FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); + } + } + break; + + + case CMD_RELOADASCIIASUTF8: + { + WCHAR tchCurFile2[MAX_PATH]; + BOOL _bLoadASCIIasUTF8 = bLoadASCIIasUTF8; + if (lstrlen(szCurFile)) { + bLoadASCIIasUTF8 = 1; + lstrcpy(tchCurFile2,szCurFile); + FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); + bLoadASCIIasUTF8 = _bLoadASCIIasUTF8; + } + } + break; + + + case CMD_RELOADNOFILEVARS: + { + WCHAR tchCurFile2[MAX_PATH]; + if (lstrlen(szCurFile)) { + int _fNoFileVariables = fNoFileVariables; + BOOL _bNoEncodingTags = bNoEncodingTags; + fNoFileVariables = 1; + bNoEncodingTags = 1; + lstrcpy(tchCurFile2,szCurFile); + FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2); + fNoFileVariables = _fNoFileVariables; + bNoEncodingTags = _bNoEncodingTags; + } + } + break; + + + case CMD_LEXDEFAULT: + Style_SetDefaultLexer(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case CMD_LEXHTML: + Style_SetHTMLLexer(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case CMD_LEXXML: + Style_SetXMLLexer(hwndEdit); + UpdateStatusbar(); + UpdateLineNumberWidth(); + break; + + + case CMD_TIMESTAMPS: + { + WCHAR wchFind[256] = {0}; + WCHAR wchTemplate[256] = {0}; + WCHAR *pwchSep; + WCHAR wchReplace[256]; + + SYSTEMTIME st; + struct tm sst; + + UINT cp; + EDITFINDREPLACE efrTS = { "", "", "", "", SCFIND_REGEXP, 0, 0, 0, 0, 0, hwndEdit }; + + IniGetString(L"Settings2",L"TimeStamp",L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $",wchFind,COUNTOF(wchFind)); + + if (pwchSep = StrChr(wchFind,L'|')) { + lstrcpy(wchTemplate,pwchSep+1); + *pwchSep = 0; + } + + StrTrim(wchFind,L" "); + StrTrim(wchTemplate,L" "); + + if (lstrlen(wchFind) == 0 || lstrlen(wchTemplate) == 0) + break; + + GetLocalTime(&st); + sst.tm_isdst = -1; + sst.tm_sec = (int)st.wSecond; + sst.tm_min = (int)st.wMinute; + sst.tm_hour = (int)st.wHour; + sst.tm_mday = (int)st.wDay; + sst.tm_mon = (int)st.wMonth - 1; + sst.tm_year = (int)st.wYear - 1900; + sst.tm_wday = (int)st.wDayOfWeek; + mktime(&sst); + wcsftime(wchReplace,COUNTOF(wchReplace),wchTemplate,&sst); + + cp = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); + WideCharToMultiByte(cp,0,wchFind,-1,efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL); + WideCharToMultiByte(cp,0,wchReplace,-1,efrTS.szReplace,COUNTOF(efrTS.szReplace),NULL,NULL); + + if (SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) != + SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0)) + EditReplaceAllInSelection(hwndEdit,&efrTS,TRUE); + else + EditReplaceAll(hwndEdit,&efrTS,TRUE); + } + break; + + + case CMD_WEBACTION1: + case CMD_WEBACTION2: + { + BOOL bCmdEnabled; + LPWSTR lpszTemplateName; + WCHAR szCmdTemplate[256]; + char mszSelection[512] = { 0 }; + DWORD cchSelection; + char *lpsz; + LPWSTR lpszCommand; + LPWSTR lpszArgs; + SHELLEXECUTEINFO sei; + WCHAR wchDirectory[MAX_PATH] = L""; + + lpszTemplateName = (LOWORD(wParam) == CMD_WEBACTION1) ? L"WebTemplate1" : L"WebTemplate2"; + + bCmdEnabled = IniGetString(L"Settings2",lpszTemplateName,L"",szCmdTemplate,COUNTOF(szCmdTemplate)); + + if (bCmdEnabled) { + + cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + + if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < COUNTOF(mszSelection)) + { + SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection); + mszSelection[cchSelection] = 0; // zero terminate + + // Check lpszSelection and truncate bad WCHARs + lpsz = StrChrA(mszSelection,13); + if (lpsz) *lpsz = '\0'; + + lpsz = StrChrA(mszSelection,10); + if (lpsz) *lpsz = '\0'; + + lpsz = StrChrA(mszSelection,9); + if (lpsz) *lpsz = '\0'; + + if (lstrlenA(mszSelection)) { + + WCHAR wszSelection[512]; + UINT uCP = (SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0) == SC_CP_UTF8) ? CP_UTF8 : CP_ACP; + MultiByteToWideChar(uCP,0,mszSelection,-1,wszSelection,COUNTOF(wszSelection)); + + lpszCommand = GlobalAlloc(GPTR,sizeof(WCHAR)*(512+COUNTOF(szCmdTemplate)+MAX_PATH+32)); + wsprintf(lpszCommand,szCmdTemplate,wszSelection); + ExpandEnvironmentStringsEx(lpszCommand,(DWORD)GlobalSize(lpszCommand)/sizeof(WCHAR)); + + lpszArgs = GlobalAlloc(GPTR,GlobalSize(lpszCommand)); + ExtractFirstArgument(lpszCommand,lpszCommand,lpszArgs); + + if (lstrlen(szCurFile)) { + lstrcpy(wchDirectory,szCurFile); + PathRemoveFileSpec(wchDirectory); + } + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = /*SEE_MASK_NOZONECHECKS*/0x00800000; + sei.hwnd = NULL; + sei.lpVerb = NULL; + sei.lpFile = lpszCommand; + sei.lpParameters = lpszArgs; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + + ShellExecuteEx(&sei); + + GlobalFree(lpszCommand); + GlobalFree(lpszArgs); + } + } + } + } + break; + + + case CMD_FINDNEXTSEL: + case CMD_FINDPREVSEL: + case IDM_EDIT_SAVEFIND: + { + int cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + + if (cchSelection == 0) + { + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_SELECTWORD,1),0); + cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - + (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + } + + if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < 512) + { + char mszSelection[512]; + char *lpsz; + + SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection); + mszSelection[cchSelection] = 0; // zero terminate + + // Check lpszSelection and truncate newlines + lpsz = StrChrA(mszSelection,'\n'); + if (lpsz) *lpsz = '\0'; + + lpsz = StrChrA(mszSelection,'\r'); + if (lpsz) *lpsz = '\0'; + + cpLastFind = (UINT)SendMessage(hwndEdit,SCI_GETCODEPAGE,0,0); + lstrcpyA(efrData.szFind,mszSelection); + + if (cpLastFind != SC_CP_UTF8) + { + WCHAR wszBuf[512]; + + MultiByteToWideChar(cpLastFind,0,mszSelection,-1,wszBuf,COUNTOF(wszBuf)); + WideCharToMultiByte(CP_UTF8,0,wszBuf,-1,efrData.szFindUTF8,COUNTOF(efrData.szFindUTF8),NULL,NULL); + } + else + lstrcpyA(efrData.szFindUTF8,mszSelection); + + efrData.fuFlags &= (~(SCFIND_REGEXP|SCFIND_POSIX)); + efrData.bTransformBS = FALSE; + + switch (LOWORD(wParam)) { + + case IDM_EDIT_SAVEFIND: + break; + + case CMD_FINDNEXTSEL: + EditFindNext(hwndEdit,&efrData,FALSE); + break; + + case CMD_FINDPREVSEL: + EditFindPrev(hwndEdit,&efrData,FALSE); + break; + } + } + } + break; + + + case CMD_INCLINELIMIT: + case CMD_DECLINELIMIT: + if (!bMarkLongLines) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_LONGLINEMARKER,1),0); + else { + if (LOWORD(wParam) == CMD_INCLINELIMIT) + iLongLinesLimit++; + else + iLongLinesLimit--; + iLongLinesLimit = max(min(iLongLinesLimit,4096),0); + SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); + UpdateStatusbar(); + iLongLinesLimitG = iLongLinesLimit; + } + break; + + + case CMD_STRINGIFY: + EditEncloseSelection(hwndEdit,L"'",L"'"); + break; + + + case CMD_STRINGIFY2: + EditEncloseSelection(hwndEdit,L"\"",L"\""); + break; + + + case CMD_EMBRACE: + EditEncloseSelection(hwndEdit,L"(",L")"); + break; + + + case CMD_EMBRACE2: + EditEncloseSelection(hwndEdit,L"[",L"]"); + break; + + + case CMD_EMBRACE3: + EditEncloseSelection(hwndEdit,L"{",L"}"); + break; + + + case CMD_EMBRACE4: + EditEncloseSelection(hwndEdit,L"`",L"`"); + break; + + + case CMD_INCREASENUM: + EditModifyNumber(hwndEdit,TRUE); + break; + + + case CMD_DECREASENUM: + EditModifyNumber(hwndEdit,FALSE); + break; + + + case CMD_TOGGLETITLE: + EditGetExcerpt(hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + + case CMD_JUMP2SELSTART: + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iCursorPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + if (iCursorPos > iAnchorPos) { + SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos); + SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); + } + } + break; + + + case CMD_JUMP2SELEND: + if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { + int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iCursorPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + if (iCursorPos < iAnchorPos) { + SendMessage(hwndEdit,SCI_SETSEL,iCursorPos,iAnchorPos); + SendMessage(hwndEdit,SCI_CHOOSECARETX,0,0); + } + } + break; + + + case CMD_COPYPATHNAME: { + + WCHAR *pszCopy; + WCHAR tchUntitled[32]; + if (lstrlen(szCurFile)) + pszCopy = szCurFile; + else { + GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); + pszCopy = tchUntitled; + } + + if (OpenClipboard(hwnd)) { + HANDLE hData; + WCHAR *pData; + EmptyClipboard(); + hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (lstrlen(pszCopy) + 1)); + pData = GlobalLock(hData); + StrCpyN(pData,pszCopy,(int)GlobalSize(hData) / sizeof(WCHAR)); + GlobalUnlock(hData); + SetClipboardData(CF_UNICODETEXT,hData); + CloseClipboard(); + } + } + break; + + + case CMD_COPYWINPOS: { + + WCHAR wszWinPos[256]; + WINDOWPLACEMENT wndpl; + int x, y, cx, cy, max; + + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hwndMain,&wndpl); + + x = wndpl.rcNormalPosition.left; + y = wndpl.rcNormalPosition.top; + cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; + cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; + max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); + + wsprintf(wszWinPos,L"/pos %i,%i,%i,%i,%i",x,y,cx,cy,max); + + if (OpenClipboard(hwnd)) { + HANDLE hData; + WCHAR *pData; + EmptyClipboard(); + hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(WCHAR) * (lstrlen(wszWinPos) + 1)); + pData = GlobalLock(hData); + StrCpyN(pData,wszWinPos,(int)GlobalSize(hData) / sizeof(WCHAR)); + GlobalUnlock(hData); + SetClipboardData(CF_UNICODETEXT,hData); + CloseClipboard(); + } + + UpdateToolbar(); + } + break; + + + case CMD_DEFAULTWINPOS: + SnapToDefaultPos(hwnd); + break; + + + case CMD_OPENINIFILE: + if (lstrlen(szIniFile)) { + CreateIniFile(); + FileLoad(FALSE,FALSE,FALSE,FALSE,szIniFile); + } + break; + + + case IDT_FILE_NEW: + if (IsCmdEnabled(hwnd,IDM_FILE_NEW)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_NEW,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_OPEN: + if (IsCmdEnabled(hwnd,IDM_FILE_OPEN)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPEN,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_BROWSE: + if (IsCmdEnabled(hwnd,IDM_FILE_BROWSE)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_BROWSE,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_SAVE: + if (IsCmdEnabled(hwnd,IDM_FILE_SAVE)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVE,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_UNDO: + if (IsCmdEnabled(hwnd,IDM_EDIT_UNDO)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_UNDO,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_REDO: + if (IsCmdEnabled(hwnd,IDM_EDIT_REDO)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REDO,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_CUT: + if (IsCmdEnabled(hwnd,IDM_EDIT_CUT)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUT,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_COPY: + if (IsCmdEnabled(hwnd,IDM_EDIT_COPY)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPY,1),0); + else + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPYALL,1),0); + break; + + + case IDT_EDIT_PASTE: + if (IsCmdEnabled(hwnd,IDM_EDIT_PASTE)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_PASTE,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_FIND: + if (IsCmdEnabled(hwnd,IDM_EDIT_FIND)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_REPLACE: + if (IsCmdEnabled(hwnd,IDM_EDIT_REPLACE)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_WORDWRAP: + if (IsCmdEnabled(hwnd,IDM_VIEW_WORDWRAP)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_WORDWRAP,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_ZOOMIN: + if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMIN)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMIN,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_ZOOMOUT: + if (IsCmdEnabled(hwnd,IDM_VIEW_ZOOMOUT)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_ZOOMOUT,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_SCHEME: + if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEME)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_SCHEMECONFIG: + if (IsCmdEnabled(hwnd,IDM_VIEW_SCHEMECONFIG)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEMECONFIG,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_EXIT: + SendMessage(hwnd,WM_CLOSE,0,0); + break; + + + case IDT_FILE_SAVEAS: + if (IsCmdEnabled(hwnd,IDM_FILE_SAVEAS)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVEAS,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_SAVECOPY: + if (IsCmdEnabled(hwnd,IDM_FILE_SAVECOPY)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_SAVECOPY,1),0); + else + MessageBeep(0); + break; + + + case IDT_EDIT_CLEAR: + if (IsCmdEnabled(hwnd,IDM_EDIT_CLEAR)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEAR,1),0); + else + SendMessage(hwndEdit,SCI_CLEARALL,0,0); + break; + + + case IDT_FILE_PRINT: + if (IsCmdEnabled(hwnd,IDM_FILE_PRINT)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_PRINT,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_OPENFAV: + if (IsCmdEnabled(hwnd,IDM_FILE_OPENFAV)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_OPENFAV,1),0); + else + MessageBeep(0); + break; + + + case IDT_FILE_ADDTOFAV: + if (IsCmdEnabled(hwnd,IDM_FILE_ADDTOFAV)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_ADDTOFAV,1),0); + else + MessageBeep(0); + break; + + + case IDT_VIEW_TOGGLEFOLDS: + if (IsCmdEnabled(hwnd,IDM_VIEW_TOGGLEFOLDS)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_TOGGLEFOLDS,1),0); + else + MessageBeep(0); + break; + + case IDT_FILE_LAUNCH: + if (IsCmdEnabled(hwnd,IDM_FILE_LAUNCH)) + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_LAUNCH,1),0); + else + MessageBeep(0); + break; + + } + + return(0); + +} + + +//============================================================================= +// +// MsgNotify() - Handles WM_NOTIFY +// +// +LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) +{ + + LPNMHDR pnmh = (LPNMHDR)lParam; + struct SCNotification* scn = (struct SCNotification*)lParam; + + switch(pnmh->idFrom) + { + + case IDC_EDIT: + + switch(pnmh->code) + { + case SCN_UPDATEUI: + + if (scn->updated & ~(SC_UPDATE_V_SCROLL | SC_UPDATE_H_SCROLL)) { + + UpdateToolbar(); + UpdateStatusbar(); + + // Invalidate invalid selections + // #pragma message("TODO: Remove check for invalid selections once fixed in Scintilla") + if (SendMessage(hwndEdit,SCI_GETSELECTIONS,0,0) > 1 && + SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0) != SC_SEL_RECTANGLE) { + int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + SendMessage(hwndEdit,WM_CANCELMODE,0,0); + SendMessage(hwndEdit,SCI_CLEARSELECTIONS,0,0); + SendMessage(hwndEdit,SCI_SETSELECTION,(WPARAM)iCurPos,(LPARAM)iCurPos); + } + + // mark occurrences of text currently selected + EditMarkAll(hwndEdit, iMarkOccurrences, bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords); + + // Brace Match + if (bMatchBraces) + { + int iPos; + char c; + + int iEndStyled = (int)SendMessage(hwndEdit,SCI_GETENDSTYLED,0,0); + if (iEndStyled < (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0)) { + int iLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iEndStyled,0); + int iEndStyled = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iLine,0); + SendMessage(hwndEdit,SCI_COLOURISE,iEndStyled,-1); + } + + iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) { + int iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + if (iBrace2 != -1) { + int col1 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0); + int col2 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0); + SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2); + SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0); + } + else { + SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0); + SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); + } + } + // Try one before + else + { + iPos = (int)SendMessage(hwndEdit,SCI_POSITIONBEFORE,iPos,0); + c = (char)SendMessage(hwndEdit,SCI_GETCHARAT,iPos,0); + if (StrChrA("()[]{}",c)) { + int iBrace2 = (int)SendMessage(hwndEdit,SCI_BRACEMATCH,iPos,0); + if (iBrace2 != -1) { + int col1 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0); + int col2 = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iBrace2,0); + SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,iPos,iBrace2); + SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,min(col1,col2),0); + } + else { + SendMessage(hwndEdit,SCI_BRACEBADLIGHT,iPos,0); + SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); + } + } + else { + SendMessage(hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1); + SendMessage(hwndEdit,SCI_SETHIGHLIGHTGUIDE,0,0); + } + } + } + } + break; + + case SCN_CHARADDED: + // Auto indent + if (bAutoIndent && (scn->ch == '\x0D' || scn->ch == '\x0A')) + { + // in CRLF mode handle LF only... + if ((SC_EOL_CRLF == iEOLMode && scn->ch != '\x0A') || SC_EOL_CRLF != iEOLMode) + { + char *pLineBuf; + char *pPos; + //int iIndentLen; + + int iCurPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + //int iAnchorPos = (int)SendMessage(hwndEdit,SCI_GETANCHOR,0,0); + int iCurLine = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,(WPARAM)iCurPos,0); + //int iLineLength = (int)SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine,0); + //int iIndentBefore = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine-1,0); + +#ifdef BOOKMARK_EDITION + // Move bookmark along with line if inserting lines (pressing return at beginning of line) because Scintilla does not do this for us + if( iCurLine > 0 ) + { + int iPrevLineLength = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,iCurLine-1,0) - (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,iCurLine-1,0) ; + if( iPrevLineLength == 0 ) + { + int bitmask = (int)SendMessage( hwndEdit , SCI_MARKERGET , iCurLine-1 , 0 ); + if( bitmask & 1 ) + { + SendMessage( hwndEdit , SCI_MARKERDELETE , iCurLine-1 , 0 ); + SendMessage( hwndEdit , SCI_MARKERADD , iCurLine , 0 ); + } + } + } +#endif + + if (iCurLine > 0/* && iLineLength <= 2*/) + { + int iPrevLineLength = (int)SendMessage(hwndEdit,SCI_LINELENGTH,iCurLine-1,0); + if (pLineBuf = GlobalAlloc(GPTR,iPrevLineLength+1)) + { + SendMessage(hwndEdit,SCI_GETLINE,iCurLine-1,(LPARAM)pLineBuf); + *(pLineBuf+iPrevLineLength) = '\0'; + for (pPos = pLineBuf; *pPos; pPos++) { + if (*pPos != ' ' && *pPos != '\t') + *pPos = '\0'; + } + if (*pLineBuf) { + //int iPrevLineStartPos; + //int iPrevLineEndPos; + //int iPrevLineIndentPos; + + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwndEdit,SCI_ADDTEXT,lstrlenA(pLineBuf),(LPARAM)pLineBuf); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + + //iPrevLineStartPos = (int)SendMessage(hwndEdit,SCI_POSITIONFROMLINE,(WPARAM)iCurLine-1,0); + //iPrevLineEndPos = (int)SendMessage(hwndEdit,SCI_GETLINEENDPOSITION,(WPARAM)iCurLine-1,0); + //iPrevLineIndentPos = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTPOSITION,(WPARAM)iCurLine-1,0); + + //if (iPrevLineEndPos == iPrevLineIndentPos) { + // SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + // SendMessage(hwndEdit,SCI_SETTARGETSTART,(WPARAM)iPrevLineStartPos,0); + // SendMessage(hwndEdit,SCI_SETTARGETEND,(WPARAM)iPrevLineEndPos,0); + // SendMessage(hwndEdit,SCI_REPLACETARGET,0,(LPARAM)""); + // SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + //} + } + GlobalFree(pLineBuf); + //int iIndent = (int)SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0); + //SendMessage(hwndEdit,SCI_SETLINEINDENTATION,(WPARAM)iCurLine,(LPARAM)iIndentBefore); + //iIndentLen = /*- iIndent +*/ SendMessage(hwndEdit,SCI_GETLINEINDENTATION,(WPARAM)iCurLine,0); + //if (iIndentLen > 0) + // SendMessage(hwndEdit,SCI_SETSEL,(WPARAM)iAnchorPos+iIndentLen,(LPARAM)iCurPos+iIndentLen); + } + } + } + } + // Auto close tags + else if (bAutoCloseTags && scn->ch == '>') + { + //int iLexer = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); + if (/*iLexer == SCLEX_HTML || iLexer == SCLEX_XML*/ 1) + { + char tchBuf[512] = { 0 }; + char tchIns[516] = "= 3) { + + struct Sci_TextRange tr = { { iStartPos, iCurPos }, tchBuf }; + SendMessage(hwndEdit,SCI_GETTEXTRANGE,0,(LPARAM)&tr); + + if (tchBuf[iSize - 2] != '/') { + + const char* pBegin = &tchBuf[0]; + const char* pCur = &tchBuf[iSize - 2]; + + while (pCur > pBegin && *pCur != '<' && *pCur != '>') + --pCur; + + if (*pCur == '<') { + pCur++; + while (StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) { + tchIns[cchIns++] = *pCur; + pCur++; + } + } + + tchIns[cchIns++] = '>'; + tchIns[cchIns] = 0; + + if (cchIns > 3 && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"
") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"") && + lstrcmpiA(tchIns,"")) + { + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)tchIns); + SendMessage(hwndEdit,SCI_SETSEL,iCurPos,iCurPos); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + } + } + } + } + } + else if (bAutoCompleteWords && !SendMessage(hwndEdit, SCI_AUTOCACTIVE, 0, 0)) + CompleteWord(hwndEdit, FALSE); + break; + + case SCN_MODIFIED: + case SCN_ZOOM: + UpdateLineNumberWidth(); + break; + + case SCN_SAVEPOINTREACHED: + bModified = FALSE; + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + + case SCN_MARGINCLICK: + if (scn->margin == MARGIN_FOLD_INDEX) + FoldClick(SciCall_LineFromPosition(scn->position), scn->modifiers); + break; + + case SCN_KEY: + // Also see the corresponding patch in scintilla\src\Editor.cxx + FoldAltArrow(scn->ch, scn->modifiers); + break; + + case SCN_SAVEPOINTLEFT: + bModified = TRUE; + SetWindowTitle(hwnd,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + break; + } + break; + + + case IDC_TOOLBAR: + + switch(pnmh->code) + { + + case TBN_ENDADJUST: + UpdateToolbar(); + break; + + case TBN_QUERYDELETE: + case TBN_QUERYINSERT: + return TRUE; + + case TBN_GETBUTTONINFO: + { + if (((LPTBNOTIFY)lParam)->iItem < COUNTOF(tbbMainWnd)) + { + WCHAR tch[256]; + GetString(tbbMainWnd[((LPTBNOTIFY)lParam)->iItem].idCommand,tch,COUNTOF(tch)); + lstrcpyn(((LPTBNOTIFY)lParam)->pszText,/*StrChr(tch,L'\n')+1*/tch,((LPTBNOTIFY)lParam)->cchText); + CopyMemory(&((LPTBNOTIFY)lParam)->tbButton,&tbbMainWnd[((LPTBNOTIFY)lParam)->iItem],sizeof(TBBUTTON)); + return TRUE; + } + } + return FALSE; + + case TBN_RESET: + { + int i; int c = (int)SendMessage(hwndToolbar,TB_BUTTONCOUNT,0,0); + for (i = 0; i < c; i++) + SendMessage(hwndToolbar,TB_DELETEBUTTON,0,0); + SendMessage(hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); + return(0); + } + + } + break; + + + case IDC_STATUSBAR: + + switch(pnmh->code) + { + + case NM_CLICK: + { + LPNMMOUSE pnmm = (LPNMMOUSE)lParam; + + switch (pnmm->dwItemSpec) + { + case STATUS_EOLMODE: + SendMessage(hwndEdit,SCI_CONVERTEOLS,SendMessage(hwndEdit,SCI_GETEOLMODE,0,0),0); + EditFixPositions(hwndEdit); + return TRUE; + + default: + return FALSE; + } + } + + case NM_DBLCLK: + { + int i; + LPNMMOUSE pnmm = (LPNMMOUSE)lParam; + + switch (pnmm->dwItemSpec) + { + case STATUS_CODEPAGE: + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_ENCODING_SELECT,1),0); + return TRUE; + + case STATUS_EOLMODE: + if (iEOLMode == SC_EOL_CRLF) + i = IDM_LINEENDINGS_CRLF; + else if (iEOLMode == SC_EOL_LF) + i = IDM_LINEENDINGS_LF; + else + i = IDM_LINEENDINGS_CR; + i++; + if (i > IDM_LINEENDINGS_CR) + i = IDM_LINEENDINGS_CRLF; + SendMessage(hwnd,WM_COMMAND,MAKELONG(i,1),0); + return TRUE; + + case STATUS_LEXER: + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_SCHEME,1),0); + return TRUE; + + case STATUS_OVRMODE: + SendMessage(hwndEdit,SCI_EDITTOGGLEOVERTYPE,0,0); + return TRUE; + + default: + return FALSE; + } + } + break; + + } + break; + + + default: + + switch(pnmh->code) + { + + case TTN_NEEDTEXT: + { + WCHAR tch[256]; + + if (((LPTOOLTIPTEXT)lParam)->uFlags & TTF_IDISHWND) + { + ; + } + + else + { + GetString((UINT)pnmh->idFrom,tch,COUNTOF(tch)); + lstrcpyn(((LPTOOLTIPTEXT)lParam)->szText,/*StrChr(tch,L'\n')+1*/tch,80); + } + } + break; + + } + break; + + } + + + return(0); + +} + + +//============================================================================= +// +// LoadSettings() +// +// +void LoadSettings() +{ + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + LoadIniSection(L"Settings",pIniSection,cchIniSection); + + bSaveSettings = + IniSectionGetInt(pIniSection,L"SaveSettings",1); + if (bSaveSettings) bSaveSettings = 1; + + bSaveRecentFiles = + IniSectionGetInt(pIniSection,L"SaveRecentFiles",0); + if (bSaveRecentFiles) bSaveRecentFiles = 1; + + bSaveFindReplace = + IniSectionGetInt(pIniSection,L"SaveFindReplace",0); + if (bSaveFindReplace) bSaveFindReplace = 1; + + efrData.bFindClose = IniSectionGetInt(pIniSection,L"CloseFind",0); + if (efrData.bFindClose) efrData.bReplaceClose = TRUE; + + efrData.bReplaceClose = IniSectionGetInt(pIniSection,L"CloseReplace",0); + if (efrData.bReplaceClose) efrData.bReplaceClose = TRUE; + + efrData.bNoFindWrap = IniSectionGetInt(pIniSection,L"NoFindWrap",0); + if (efrData.bNoFindWrap) efrData.bNoFindWrap = TRUE; + + if (!IniSectionGetString(pIniSection,L"OpenWithDir",L"", + tchOpenWithDir,COUNTOF(tchOpenWithDir))) + SHGetSpecialFolderPath(NULL,tchOpenWithDir,CSIDL_DESKTOPDIRECTORY,TRUE); + else + PathAbsoluteFromApp(tchOpenWithDir,NULL,COUNTOF(tchOpenWithDir),TRUE); + + if (!IniSectionGetString(pIniSection,L"Favorites",L"", + tchFavoritesDir,COUNTOF(tchFavoritesDir))) + SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,tchFavoritesDir); + else + PathAbsoluteFromApp(tchFavoritesDir,NULL,COUNTOF(tchFavoritesDir),TRUE); + + iPathNameFormat = IniSectionGetInt(pIniSection,L"PathNameFormat",0); + iPathNameFormat = max(min(iPathNameFormat,2),0); + + fWordWrap = IniSectionGetInt(pIniSection,L"WordWrap",0); + if (fWordWrap) fWordWrap = 1; + fWordWrapG = fWordWrap; + + iWordWrapMode = IniSectionGetInt(pIniSection,L"WordWrapMode",0); + iWordWrapMode = max(min(iWordWrapMode,1),0); + + iWordWrapIndent = IniSectionGetInt(pIniSection,L"WordWrapIndent",0); + iWordWrapIndent = max(min(iWordWrapIndent,6),0); + + iWordWrapSymbols = IniSectionGetInt(pIniSection,L"WordWrapSymbols",22); + iWordWrapSymbols = max(min(iWordWrapSymbols%10,2),0)+max(min((iWordWrapSymbols%100-iWordWrapSymbols%10)/10,2),0)*10; + + bShowWordWrapSymbols = IniSectionGetInt(pIniSection,L"ShowWordWrapSymbols",0); + if (bShowWordWrapSymbols) bShowWordWrapSymbols = 1; + + bMatchBraces = IniSectionGetInt(pIniSection,L"MatchBraces",1); + if (bMatchBraces) bMatchBraces = 1; + + bAutoCloseTags = IniSectionGetInt(pIniSection,L"AutoCloseTags",0); + if (bAutoCloseTags) bAutoCloseTags = 1; + + bHiliteCurrentLine = IniSectionGetInt(pIniSection,L"HighlightCurrentLine",0); + if (bHiliteCurrentLine) bHiliteCurrentLine = 1; + + bAutoIndent = IniSectionGetInt(pIniSection,L"AutoIndent",1); + if (bAutoIndent) bAutoIndent = 1; + + bAutoCompleteWords = IniSectionGetInt(pIniSection,L"AutoCompleteWords",0); + if (bAutoCompleteWords) bAutoCompleteWords = 1; + + bShowIndentGuides = IniSectionGetInt(pIniSection,L"ShowIndentGuides",0); + if (bShowIndentGuides) bShowIndentGuides = 1; + + bTabsAsSpaces = IniSectionGetInt(pIniSection,L"TabsAsSpaces",1); + if (bTabsAsSpaces) bTabsAsSpaces = 1; + bTabsAsSpacesG = bTabsAsSpaces; + + bTabIndents = IniSectionGetInt(pIniSection,L"TabIndents",1); + if (bTabIndents) bTabIndents = 1; + bTabIndentsG = bTabIndents; + + bBackspaceUnindents = IniSectionGetInt(pIniSection,L"BackspaceUnindents",0); + if (bBackspaceUnindents) bBackspaceUnindents = 1; + + iTabWidth = IniSectionGetInt(pIniSection,L"TabWidth",2); + iTabWidth = max(min(iTabWidth,256),1); + iTabWidthG = iTabWidth; + + iIndentWidth = IniSectionGetInt(pIniSection,L"IndentWidth",0); + iIndentWidth = max(min(iIndentWidth,256),0); + iIndentWidthG = iIndentWidth; + + bMarkLongLines = IniSectionGetInt(pIniSection,L"MarkLongLines",0); + if (bMarkLongLines) bMarkLongLines = 1; + + iLongLinesLimit = IniSectionGetInt(pIniSection,L"LongLinesLimit",72); + iLongLinesLimit = max(min(iLongLinesLimit,4096),0); + iLongLinesLimitG = iLongLinesLimit; + + iLongLineMode = IniSectionGetInt(pIniSection,L"LongLineMode",EDGE_LINE); + iLongLineMode = max(min(iLongLineMode,EDGE_BACKGROUND),EDGE_LINE); + + bShowSelectionMargin = IniSectionGetInt(pIniSection,L"ShowSelectionMargin",0); + if (bShowSelectionMargin) bShowSelectionMargin = 1; + + bShowLineNumbers = IniSectionGetInt(pIniSection,L"ShowLineNumbers",1); + if (bShowLineNumbers) bShowLineNumbers = 1; + + bShowCodeFolding = IniSectionGetInt(pIniSection,L"ShowCodeFolding",1); + if (bShowCodeFolding) bShowCodeFolding = 1; + + iMarkOccurrences = IniSectionGetInt(pIniSection,L"MarkOccurrences",3); + bMarkOccurrencesMatchCase = IniSectionGetInt(pIniSection,L"MarkOccurrencesMatchCase",0); + bMarkOccurrencesMatchWords = IniSectionGetInt(pIniSection,L"MarkOccurrencesMatchWholeWords",1); + + bViewWhiteSpace = IniSectionGetInt(pIniSection,L"ViewWhiteSpace",0); + if (bViewWhiteSpace) bViewWhiteSpace = 1; + + bViewEOLs = IniSectionGetInt(pIniSection,L"ViewEOLs",0); + if (bViewEOLs) bViewEOLs = 1; + + iDefaultEncoding = IniSectionGetInt(pIniSection,L"DefaultEncoding",0); + iDefaultEncoding = Encoding_MapIniSetting(TRUE,iDefaultEncoding); + if (!Encoding_IsValid(iDefaultEncoding)) iDefaultEncoding = CPI_UTF8; + + bSkipUnicodeDetection = IniSectionGetInt(pIniSection,L"SkipUnicodeDetection",0); + if (bSkipUnicodeDetection) bSkipUnicodeDetection = 1; + + bLoadASCIIasUTF8 = IniSectionGetInt(pIniSection,L"LoadASCIIasUTF8",0); + if (bLoadASCIIasUTF8) bLoadASCIIasUTF8 = 1; + + bLoadNFOasOEM = IniSectionGetInt(pIniSection,L"LoadNFOasOEM",1); + if (bLoadNFOasOEM) bLoadNFOasOEM = 1; + + bNoEncodingTags = IniSectionGetInt(pIniSection,L"NoEncodingTags",0); + if (bNoEncodingTags) bNoEncodingTags = 1; + + iDefaultEOLMode = IniSectionGetInt(pIniSection,L"DefaultEOLMode",0); + iDefaultEOLMode = max(min(iDefaultEOLMode,2),0); + + bFixLineEndings = IniSectionGetInt(pIniSection,L"FixLineEndings",1); + if (bFixLineEndings) bFixLineEndings = 1; + + bAutoStripBlanks = IniSectionGetInt(pIniSection,L"FixTrailingBlanks",0); + if (bAutoStripBlanks) bAutoStripBlanks = 1; + + iPrintHeader = IniSectionGetInt(pIniSection,L"PrintHeader",1); + iPrintHeader = max(min(iPrintHeader,3),0); + + iPrintFooter = IniSectionGetInt(pIniSection,L"PrintFooter",0); + iPrintFooter = max(min(iPrintFooter,1),0); + + iPrintColor = IniSectionGetInt(pIniSection,L"PrintColorMode",3); + iPrintColor = max(min(iPrintColor,4),0); + + iPrintZoom = IniSectionGetInt(pIniSection,L"PrintZoom",10)-10; + iPrintZoom = max(min(iPrintZoom,20),-10); + + pagesetupMargin.left = IniSectionGetInt(pIniSection,L"PrintMarginLeft",-1); + pagesetupMargin.left = max(pagesetupMargin.left,-1); + + pagesetupMargin.top = IniSectionGetInt(pIniSection,L"PrintMarginTop",-1); + pagesetupMargin.top = max(pagesetupMargin.top,-1); + + pagesetupMargin.right = IniSectionGetInt(pIniSection,L"PrintMarginRight",-1); + pagesetupMargin.right = max(pagesetupMargin.right,-1); + + pagesetupMargin.bottom = IniSectionGetInt(pIniSection,L"PrintMarginBottom",-1); + pagesetupMargin.bottom = max(pagesetupMargin.bottom,-1); + + bSaveBeforeRunningTools = IniSectionGetInt(pIniSection,L"SaveBeforeRunningTools",0); + if (bSaveBeforeRunningTools) bSaveBeforeRunningTools = 1; + + iFileWatchingMode = IniSectionGetInt(pIniSection,L"FileWatchingMode",0); + iFileWatchingMode = max(min(iFileWatchingMode,2),0); + + bResetFileWatching = IniSectionGetInt(pIniSection,L"ResetFileWatching",1); + if (bResetFileWatching) bResetFileWatching = 1; + + iEscFunction = IniSectionGetInt(pIniSection,L"EscFunction",0); + iEscFunction = max(min(iEscFunction,2),0); + + bAlwaysOnTop = IniSectionGetInt(pIniSection,L"AlwaysOnTop",0); + if (bAlwaysOnTop) bAlwaysOnTop = 1; + + bMinimizeToTray = IniSectionGetInt(pIniSection,L"MinimizeToTray",0); + if (bMinimizeToTray) bMinimizeToTray = 1; + + bTransparentMode = IniSectionGetInt(pIniSection,L"TransparentMode",0); + if (bTransparentMode) bTransparentMode = 1; + + // Check if SetLayeredWindowAttributes() is available + bTransparentModeAvailable = + (GetProcAddress(GetModuleHandle(L"User32"),"SetLayeredWindowAttributes") != NULL); + + IniSectionGetString(pIniSection,L"ToolbarButtons",L"", + tchToolbarButtons,COUNTOF(tchToolbarButtons)); + + bShowToolbar = IniSectionGetInt(pIniSection,L"ShowToolbar",1); + if (bShowToolbar) bShowToolbar = 1; + + bShowStatusbar = IniSectionGetInt(pIniSection,L"ShowStatusbar",1); + if (bShowStatusbar) bShowStatusbar = 1; + + cxEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeX",256); + cxEncodingDlg = max(cxEncodingDlg,0); + + cyEncodingDlg = IniSectionGetInt(pIniSection,L"EncodingDlgSizeY",262); + cyEncodingDlg = max(cyEncodingDlg,0); + + cxRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeX",256); + cxRecodeDlg = max(cxRecodeDlg,0); + + cyRecodeDlg = IniSectionGetInt(pIniSection,L"RecodeDlgSizeY",262); + cyRecodeDlg = max(cyRecodeDlg,0); + + cxFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeX",412); + cxFileMRUDlg = max(cxFileMRUDlg,0); + + cyFileMRUDlg = IniSectionGetInt(pIniSection,L"FileMRUDlgSizeY",376); + cyFileMRUDlg = max(cyFileMRUDlg,0); + + cxOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeX",384); + cxOpenWithDlg = max(cxOpenWithDlg,0); + + cyOpenWithDlg = IniSectionGetInt(pIniSection,L"OpenWithDlgSizeY",386); + cyOpenWithDlg = max(cyOpenWithDlg,0); + + cxFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeX",334); + cxFavoritesDlg = max(cxFavoritesDlg,0); + + cyFavoritesDlg = IniSectionGetInt(pIniSection,L"FavoritesDlgSizeY",316); + cyFavoritesDlg = max(cyFavoritesDlg,0); + + xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0); + yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0); + + LoadIniSection(L"Settings2",pIniSection,cchIniSection); + + bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0); + if (bStickyWinPos) bStickyWinPos = 1; + + IniSectionGetString(pIniSection,L"DefaultExtension",L"txt", + tchDefaultExtension,COUNTOF(tchDefaultExtension)); + StrTrim(tchDefaultExtension,L" \t.\""); + + IniSectionGetString(pIniSection,L"DefaultDirectory",L"", + tchDefaultDir,COUNTOF(tchDefaultDir)); + + ZeroMemory(tchFileDlgFilters,sizeof(WCHAR)*COUNTOF(tchFileDlgFilters)); + IniSectionGetString(pIniSection,L"FileDlgFilters",L"", + tchFileDlgFilters,COUNTOF(tchFileDlgFilters)-2); + + dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000); + dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000); + + LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection); + IniSectionGetString(pIniSection,L"BitmapDefault",L"", + tchToolbarBitmap,COUNTOF(tchToolbarBitmap)); + IniSectionGetString(pIniSection,L"BitmapHot",L"", + tchToolbarBitmapHot,COUNTOF(tchToolbarBitmap)); + IniSectionGetString(pIniSection,L"BitmapDisabled",L"", + tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmap)); + + if (!flagPosParam /*|| bStickyWinPos*/) { // ignore window position if /p was specified + + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + + int ResX = GetSystemMetrics(SM_CXSCREEN); + int ResY = GetSystemMetrics(SM_CYSCREEN); + + wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); + wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); + wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); + wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); + wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); + + LoadIniSection(L"Window",pIniSection,cchIniSection); + + wi.x = IniSectionGetInt(pIniSection,tchPosX,CW_USEDEFAULT); + wi.y = IniSectionGetInt(pIniSection,tchPosY,CW_USEDEFAULT); + wi.cx = IniSectionGetInt(pIniSection,tchSizeX,CW_USEDEFAULT); + wi.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT); + wi.max = IniSectionGetInt(pIniSection,tchMaximized,0); + if (wi.max) wi.max = 1; + } + + LocalFree(pIniSection); + + iDefaultCodePage = 0; { + int acp = GetACP(); + if (acp == 932 || acp == 936 || acp == 949 || acp == 950 || acp == 1361) + iDefaultCodePage = acp; + } + + { + CHARSETINFO ci; + if (TranslateCharsetInfo((DWORD*)(UINT_PTR)iDefaultCodePage,&ci,TCI_SRCCODEPAGE)) + iDefaultCharSet = ci.ciCharset; + else + iDefaultCharSet = ANSI_CHARSET; + } + + // Scintilla Styles + Style_Load(); + +} + + +//============================================================================= +// +// SaveSettings() +// +// +void SaveSettings(BOOL bSaveSettingsNow) +{ + WCHAR *pIniSection = NULL; + int cchIniSection = 0; + + WCHAR wchTmp[MAX_PATH]; + + if (lstrlen(szIniFile) == 0) + return; + + CreateIniFile(); + + if (!bSaveSettings && !bSaveSettingsNow) { + IniSetInt(L"Settings",L"SaveSettings",bSaveSettings); + return; + } + + pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + IniSectionSetInt(pIniSection,L"SaveSettings",bSaveSettings); + IniSectionSetInt(pIniSection,L"SaveRecentFiles",bSaveRecentFiles); + IniSectionSetInt(pIniSection,L"SaveFindReplace",bSaveFindReplace); + IniSectionSetInt(pIniSection,L"CloseFind",efrData.bFindClose); + IniSectionSetInt(pIniSection,L"CloseReplace",efrData.bReplaceClose); + IniSectionSetInt(pIniSection,L"NoFindWrap",efrData.bNoFindWrap); + PathRelativeToApp(tchOpenWithDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs); + IniSectionSetString(pIniSection,L"OpenWithDir",wchTmp); + PathRelativeToApp(tchFavoritesDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs); + IniSectionSetString(pIniSection,L"Favorites",wchTmp); + IniSectionSetInt(pIniSection,L"PathNameFormat",iPathNameFormat); + IniSectionSetInt(pIniSection,L"WordWrap",fWordWrapG); + IniSectionSetInt(pIniSection,L"WordWrapMode",iWordWrapMode); + IniSectionSetInt(pIniSection,L"WordWrapIndent",iWordWrapIndent); + IniSectionSetInt(pIniSection,L"WordWrapSymbols",iWordWrapSymbols); + IniSectionSetInt(pIniSection,L"ShowWordWrapSymbols",bShowWordWrapSymbols); + IniSectionSetInt(pIniSection,L"MatchBraces",bMatchBraces); + IniSectionSetInt(pIniSection,L"AutoCloseTags",bAutoCloseTags); + IniSectionSetInt(pIniSection,L"HighlightCurrentLine",bHiliteCurrentLine); + IniSectionSetInt(pIniSection,L"AutoIndent",bAutoIndent); + IniSectionSetInt(pIniSection,L"AutoCompleteWords",bAutoCompleteWords); + IniSectionSetInt(pIniSection,L"ShowIndentGuides",bShowIndentGuides); + IniSectionSetInt(pIniSection,L"TabsAsSpaces",bTabsAsSpacesG); + IniSectionSetInt(pIniSection,L"TabIndents",bTabIndentsG); + IniSectionSetInt(pIniSection,L"BackspaceUnindents",bBackspaceUnindents); + IniSectionSetInt(pIniSection,L"TabWidth",iTabWidthG); + IniSectionSetInt(pIniSection,L"IndentWidth",iIndentWidthG); + IniSectionSetInt(pIniSection,L"MarkLongLines",bMarkLongLines); + IniSectionSetInt(pIniSection,L"LongLinesLimit",iLongLinesLimitG); + IniSectionSetInt(pIniSection,L"LongLineMode",iLongLineMode); + IniSectionSetInt(pIniSection,L"ShowSelectionMargin",bShowSelectionMargin); + IniSectionSetInt(pIniSection,L"ShowLineNumbers",bShowLineNumbers); + IniSectionSetInt(pIniSection,L"ShowCodeFolding",bShowCodeFolding); + IniSectionSetInt(pIniSection,L"MarkOccurrences",iMarkOccurrences); + IniSectionSetInt(pIniSection,L"MarkOccurrencesMatchCase",bMarkOccurrencesMatchCase); + IniSectionSetInt(pIniSection,L"MarkOccurrencesMatchWholeWords",bMarkOccurrencesMatchWords); + IniSectionSetInt(pIniSection,L"ViewWhiteSpace",bViewWhiteSpace); + IniSectionSetInt(pIniSection,L"ViewEOLs",bViewEOLs); + IniSectionSetInt(pIniSection,L"DefaultEncoding",Encoding_MapIniSetting(FALSE,iDefaultEncoding)); + IniSectionSetInt(pIniSection,L"SkipUnicodeDetection",bSkipUnicodeDetection); + IniSectionSetInt(pIniSection,L"LoadASCIIasUTF8",bLoadASCIIasUTF8); + IniSectionSetInt(pIniSection,L"LoadNFOasOEM",bLoadNFOasOEM); + IniSectionSetInt(pIniSection,L"NoEncodingTags",bNoEncodingTags); + IniSectionSetInt(pIniSection,L"DefaultEOLMode",iDefaultEOLMode); + IniSectionSetInt(pIniSection,L"FixLineEndings",bFixLineEndings); + IniSectionSetInt(pIniSection,L"FixTrailingBlanks",bAutoStripBlanks); + IniSectionSetInt(pIniSection,L"PrintHeader",iPrintHeader); + IniSectionSetInt(pIniSection,L"PrintFooter",iPrintFooter); + IniSectionSetInt(pIniSection,L"PrintColorMode",iPrintColor); + IniSectionSetInt(pIniSection,L"PrintZoom",iPrintZoom+10); + IniSectionSetInt(pIniSection,L"PrintMarginLeft",pagesetupMargin.left); + IniSectionSetInt(pIniSection,L"PrintMarginTop",pagesetupMargin.top); + IniSectionSetInt(pIniSection,L"PrintMarginRight",pagesetupMargin.right); + IniSectionSetInt(pIniSection,L"PrintMarginBottom",pagesetupMargin.bottom); + IniSectionSetInt(pIniSection,L"SaveBeforeRunningTools",bSaveBeforeRunningTools); + IniSectionSetInt(pIniSection,L"FileWatchingMode",iFileWatchingMode); + IniSectionSetInt(pIniSection,L"ResetFileWatching",bResetFileWatching); + IniSectionSetInt(pIniSection,L"EscFunction",iEscFunction); + IniSectionSetInt(pIniSection,L"AlwaysOnTop",bAlwaysOnTop); + IniSectionSetInt(pIniSection,L"MinimizeToTray",bMinimizeToTray); + IniSectionSetInt(pIniSection,L"TransparentMode",bTransparentMode); + Toolbar_GetButtons(hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons)); + IniSectionSetString(pIniSection,L"ToolbarButtons",tchToolbarButtons); + IniSectionSetInt(pIniSection,L"ShowToolbar",bShowToolbar); + IniSectionSetInt(pIniSection,L"ShowStatusbar",bShowStatusbar); + IniSectionSetInt(pIniSection,L"EncodingDlgSizeX",cxEncodingDlg); + IniSectionSetInt(pIniSection,L"EncodingDlgSizeY",cyEncodingDlg); + IniSectionSetInt(pIniSection,L"RecodeDlgSizeX",cxRecodeDlg); + IniSectionSetInt(pIniSection,L"RecodeDlgSizeY",cyRecodeDlg); + IniSectionSetInt(pIniSection,L"FileMRUDlgSizeX",cxFileMRUDlg); + IniSectionSetInt(pIniSection,L"FileMRUDlgSizeY",cyFileMRUDlg); + IniSectionSetInt(pIniSection,L"OpenWithDlgSizeX",cxOpenWithDlg); + IniSectionSetInt(pIniSection,L"OpenWithDlgSizeY",cyOpenWithDlg); + IniSectionSetInt(pIniSection,L"FavoritesDlgSizeX",cxFavoritesDlg); + IniSectionSetInt(pIniSection,L"FavoritesDlgSizeY",cyFavoritesDlg); + IniSectionSetInt(pIniSection,L"FindReplaceDlgPosX",xFindReplaceDlg); + IniSectionSetInt(pIniSection,L"FindReplaceDlgPosY",yFindReplaceDlg); + + SaveIniSection(L"Settings",pIniSection); + LocalFree(pIniSection); + + /* + SaveSettingsNow(): query Window Dimensions + */ + + if (bSaveSettingsNow) + { + WINDOWPLACEMENT wndpl; + + // GetWindowPlacement + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hwndMain,&wndpl); + + wi.x = wndpl.rcNormalPosition.left; + wi.y = wndpl.rcNormalPosition.top; + wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; + wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; + wi.max = (IsZoomed(hwndMain) || (wndpl.flags & WPF_RESTORETOMAXIMIZED)); + } + + if (!IniGetInt(L"Settings2",L"StickyWindowPosition",0)) { + + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + + int ResX = GetSystemMetrics(SM_CXSCREEN); + int ResY = GetSystemMetrics(SM_CYSCREEN); + + wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); + wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); + wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); + wsprintf(tchSizeY,L"%ix%i SizeY",ResX,ResY); + wsprintf(tchMaximized,L"%ix%i Maximized",ResX,ResY); + + IniSetInt(L"Window",tchPosX,wi.x); + IniSetInt(L"Window",tchPosY,wi.y); + IniSetInt(L"Window",tchSizeX,wi.cx); + IniSetInt(L"Window",tchSizeY,wi.cy); + IniSetInt(L"Window",tchMaximized,wi.max); + } + + // Scintilla Styles + Style_Save(); + +} + + +//============================================================================= +// +// ParseCommandLine() +// +// +void ParseCommandLine() +{ + + LPWSTR lp1,lp2,lp3; + BOOL bContinue = TRUE; + BOOL bIsFileArg = FALSE; + BOOL bIsNotepadReplacement = FALSE; + + LPWSTR lpCmdLine = GetCommandLine(); + + if (lstrlen(lpCmdLine) == 0) + return; + + // Good old console can also send args separated by Tabs + StrTab2Space(lpCmdLine); + + lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + lp3 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + + // Start with 2nd argument + ExtractFirstArgument(lpCmdLine,lp1,lp3); + + while (bContinue && ExtractFirstArgument(lp3,lp1,lp2)) + { + + // options + if (!bIsFileArg && lstrcmp(lp1,L"+") == 0) { + flagMultiFileArg = 2; + bIsFileArg = TRUE; + } + + else if (!bIsFileArg && lstrcmp(lp1,L"-") == 0) { + flagMultiFileArg = 1; + bIsFileArg = TRUE; + } + + else if (!bIsFileArg && ((*lp1 == L'/') || (*lp1 == L'-'))) + { + + // LTrim + StrLTrim(lp1,L"-/"); + + // Encoding + if (lstrcmpi(lp1,L"ANSI") == 0 || lstrcmpi(lp1,L"A") == 0 || lstrcmpi(lp1,L"MBCS") == 0) + flagSetEncoding = IDM_ENCODING_ANSI-IDM_ENCODING_ANSI + 1; + else if (lstrcmpi(lp1,L"UNICODE") == 0 || lstrcmpi(lp1,L"W") == 0) + flagSetEncoding = IDM_ENCODING_UNICODE-IDM_ENCODING_ANSI + 1; + else if (lstrcmpi(lp1,L"UNICODEBE") == 0 || lstrcmpi(lp1,L"UNICODE-BE") == 0) + flagSetEncoding = IDM_ENCODING_UNICODEREV-IDM_ENCODING_ANSI + 1; + else if (lstrcmpi(lp1,L"UTF8") == 0 || lstrcmpi(lp1,L"UTF-8") == 0) + flagSetEncoding = IDM_ENCODING_UTF8-IDM_ENCODING_ANSI + 1; + else if (lstrcmpi(lp1,L"UTF8SIG") == 0 || lstrcmpi(lp1,L"UTF-8SIG") == 0 || + lstrcmpi(lp1,L"UTF8SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8SIGNATURE") == 0 || + lstrcmpi(lp1,L"UTF8-SIGNATURE") == 0 || lstrcmpi(lp1,L"UTF-8-SIGNATURE") == 0) + flagSetEncoding = IDM_ENCODING_UTF8SIGN-IDM_ENCODING_ANSI + 1; + + // EOL Mode + else if (lstrcmpi(lp1,L"CRLF") == 0 || lstrcmpi(lp1,L"CR+LF") == 0) + flagSetEOLMode = IDM_LINEENDINGS_CRLF-IDM_LINEENDINGS_CRLF + 1; + else if (lstrcmpi(lp1,L"LF") == 0) + flagSetEOLMode = IDM_LINEENDINGS_LF-IDM_LINEENDINGS_CRLF + 1; + else if (lstrcmpi(lp1,L"CR") == 0) + flagSetEOLMode = IDM_LINEENDINGS_CR-IDM_LINEENDINGS_CRLF + 1; + + // Shell integration + else if (StrCmpNI(lp1,L"appid=",CSTRLEN(L"appid=")) == 0) { + StrCpyN(g_wchAppUserModelID,lp1+CSTRLEN(L"appid="),COUNTOF(g_wchAppUserModelID)); + StrTrim(g_wchAppUserModelID,L" "); + if (lstrlen(g_wchAppUserModelID) == 0) + lstrcpy(g_wchAppUserModelID,L"(default)"); + } + else if (StrCmpNI(lp1,L"sysmru=",CSTRLEN(L"sysmru=")) == 0) { + WCHAR wch[8]; + StrCpyN(wch,lp1+CSTRLEN(L"sysmru="),COUNTOF(wch)); + StrTrim(wch,L" "); + if (*wch == L'1') + flagUseSystemMRU = 2; + else + flagUseSystemMRU = 1; + } + + else switch (*CharUpper(lp1)) + { + + case L'N': + flagReuseWindow = 0; + flagNoReuseWindow = 1; + if (*CharUpper(lp1+1) == L'S') + flagSingleFileInstance = 1; + else + flagSingleFileInstance = 0; + break; + + case L'R': + flagReuseWindow = 1; + flagNoReuseWindow = 0; + if (*CharUpper(lp1+1) == L'S') + flagSingleFileInstance = 1; + else + flagSingleFileInstance = 0; + break; + + case L'F': + if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O') + lstrcpy(szIniFile,L"*?"); + else if (ExtractFirstArgument(lp2,lp1,lp2)) { + StrCpyN(szIniFile,lp1,COUNTOF(szIniFile)); + TrimString(szIniFile); + PathUnquoteSpaces(szIniFile); + } + break; + + case L'I': + flagStartAsTrayIcon = 1; + break; + + case L'O': + if (*(lp1+1) == L'0' || *(lp1+1) == L'-' || *CharUpper(lp1+1) == L'O') + flagAlwaysOnTop = 1; + else + flagAlwaysOnTop = 2; + break; + + case L'P': + { + WCHAR *lp = lp1; + if (StrCmpNI(lp1,L"POS:",CSTRLEN(L"POS:")) == 0) + lp += CSTRLEN(L"POS:") -1; + else if (StrCmpNI(lp1,L"POS",CSTRLEN(L"POS")) == 0) + lp += CSTRLEN(L"POS") -1; + else if (*(lp1+1) == L':') + lp += 1; + else if (bIsNotepadReplacement) { + if (*(lp1+1) == L'T') + ExtractFirstArgument(lp2,lp1,lp2); + break; + } + if (*(lp+1) == L'0' || *CharUpper(lp+1) == L'O') { + flagPosParam = 1; + flagDefaultPos = 1; + } + else if (*CharUpper(lp+1) == L'D' || *CharUpper(lp+1) == L'S') { + flagPosParam = 1; + flagDefaultPos = (StrChrI((lp+1),L'L')) ? 3 : 2; + } + else if (StrChrI(L"FLTRBM",*(lp+1))) { + WCHAR *p = (lp+1); + flagPosParam = 1; + flagDefaultPos = 0; + while (*p) { + switch (*CharUpper(p)) { + case L'F': + flagDefaultPos &= ~(4|8|16|32); + flagDefaultPos |= 64; + break; + case L'L': + flagDefaultPos &= ~(8|64); + flagDefaultPos |= 4; + break; + case L'R': + flagDefaultPos &= ~(4|64); + flagDefaultPos |= 8; + break; + case L'T': + flagDefaultPos &= ~(32|64); + flagDefaultPos |= 16; + break; + case L'B': + flagDefaultPos &= ~(16|64); + flagDefaultPos |= 32; + break; + case L'M': + if (flagDefaultPos == 0) + flagDefaultPos |= 64; + flagDefaultPos |= 128; + break; + } + p = CharNext(p); + } + } + else if (ExtractFirstArgument(lp2,lp1,lp2)) { + int itok = + swscanf(lp1,L"%i,%i,%i,%i,%i",&wi.x,&wi.y,&wi.cx,&wi.cy,&wi.max); + if (itok == 4 || itok == 5) { // scan successful + flagPosParam = 1; + flagDefaultPos = 0; + if (wi.cx < 1) wi.cx = CW_USEDEFAULT; + if (wi.cy < 1) wi.cy = CW_USEDEFAULT; + if (wi.max) wi.max = 1; + if (itok == 4) wi.max = 0; + } + } + } + break; + + case L'T': + if (ExtractFirstArgument(lp2,lp1,lp2)) { + StrCpyN(szTitleExcerpt,lp1,COUNTOF(szTitleExcerpt)); + fKeepTitleExcerpt = 1; + } + break; + + case L'C': + flagNewFromClipboard = 1; + break; + + case L'B': + flagPasteBoard = 1; + break; + + case L'E': + if (ExtractFirstArgument(lp2,lp1,lp2)) { + if (lpEncodingArg) + LocalFree(lpEncodingArg); + lpEncodingArg = StrDup(lp1); + } + break; + + case L'G': + if (ExtractFirstArgument(lp2,lp1,lp2)) { + int itok = + swscanf(lp1,L"%i,%i",&iInitialLine,&iInitialColumn); + if (itok == 1 || itok == 2) { // scan successful + flagJumpTo = 1; + } + } + break; + + case L'M': + { + BOOL bFindUp = FALSE; + BOOL bRegex = FALSE; + BOOL bTransBS = FALSE; + + if (StrChr(lp1,L'-')) + bFindUp = TRUE; + if (StrChr(lp1,L'R')) + bRegex = TRUE; + if (StrChr(lp1,L'B')) + bTransBS = TRUE; + + if (ExtractFirstArgument(lp2,lp1,lp2)) { + if (lpMatchArg) + GlobalFree(lpMatchArg); + lpMatchArg = StrDup(lp1); + flagMatchText = 1; + + if (bFindUp) + flagMatchText |= 2; + + if (bRegex) { + flagMatchText &= ~8; + flagMatchText |= 4; + } + + if (bTransBS) { + flagMatchText &= ~4; + flagMatchText |= 8; + } + } + } + break; + + case L'L': + if (*(lp1+1) == L'0' || *(lp1+1) == L'-' || *CharUpper(lp1+1) == L'O') + flagChangeNotify = 1; + else + flagChangeNotify = 2; + break; + + case L'Q': + flagQuietCreate = 1; + break; + + case L'S': + if (ExtractFirstArgument(lp2,lp1,lp2)) { + if (lpSchemeArg) + LocalFree(lpSchemeArg); + lpSchemeArg = StrDup(lp1); + flagLexerSpecified = 1; + } + break; + + case L'D': + if (lpSchemeArg) { + LocalFree(lpSchemeArg); + lpSchemeArg = NULL; + } + iInitialLexer = 0; + flagLexerSpecified = 1; + break; + + case L'H': + if (lpSchemeArg) { + LocalFree(lpSchemeArg); + lpSchemeArg = NULL; + } + iInitialLexer = 34; + flagLexerSpecified = 1; + break; + + case L'X': + if (lpSchemeArg) { + LocalFree(lpSchemeArg); + lpSchemeArg = NULL; + } + iInitialLexer = 35; + flagLexerSpecified = 1; + break; + + case L'U': + flagRelaunchElevated = 1; + break; + + case L'Z': + ExtractFirstArgument(lp2,lp1,lp2); + flagMultiFileArg = 1; + bIsNotepadReplacement = TRUE; + break; + + case L'?': + flagDisplayHelp = 1; + break; + + default: + break; + + } + + } + + // pathname + else + { + LPWSTR lpFileBuf = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + + cchiFileList = lstrlen(lpCmdLine) - lstrlen(lp3); + + if (lpFileArg) + GlobalFree(lpFileArg); + + lpFileArg = GlobalAlloc(GPTR,sizeof(WCHAR)*(MAX_PATH+2)); // changed for ActivatePrevInst() needs + StrCpyN(lpFileArg,lp3,MAX_PATH); + + PathFixBackslashes(lpFileArg); + + if (!PathIsRelative(lpFileArg) && !PathIsUNC(lpFileArg) && + PathGetDriveNumber(lpFileArg) == -1 /*&& PathGetDriveNumber(g_wchWorkingDirectory) != -1*/) { + + WCHAR wchPath[MAX_PATH]; + lstrcpy(wchPath,g_wchWorkingDirectory); + PathStripToRoot(wchPath); + PathAppend(wchPath,lpFileArg); + lstrcpy(lpFileArg,wchPath); + } + + StrTrim(lpFileArg,L" \""); + + while (cFileList < 32 && ExtractFirstArgument(lp3,lpFileBuf,lp3)) { + PathQuoteSpaces(lpFileBuf); + lpFileList[cFileList++] = StrDup(lpFileBuf); + } + + bContinue = FALSE; + LocalFree(lpFileBuf); + } + + // Continue with next argument + if (bContinue) + lstrcpy(lp3,lp2); + + } + + LocalFree(lp1); + LocalFree(lp2); + LocalFree(lp3); + +} + + +//============================================================================= +// +// LoadFlags() +// +// +void LoadFlags() +{ + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + LoadIniSection(L"Settings2",pIniSection,cchIniSection); + + if (!flagReuseWindow && !flagNoReuseWindow) { + + if (!IniSectionGetInt(pIniSection,L"ReuseWindow",0)) + flagNoReuseWindow = 1; + + if (IniSectionGetInt(pIniSection,L"SingleFileInstance",0)) + flagSingleFileInstance = 1; + } + + if (flagMultiFileArg == 0) { + if (IniSectionGetInt(pIniSection,L"MultiFileArg",0)) + flagMultiFileArg = 2; + } + + if (IniSectionGetInt(pIniSection,L"RelativeFileMRU",1)) + flagRelativeFileMRU = 1; + + if (IniSectionGetInt(pIniSection,L"PortableMyDocs",flagRelativeFileMRU)) + flagPortableMyDocs = 1; + + if (IniSectionGetInt(pIniSection,L"NoFadeHidden",0)) + flagNoFadeHidden = 1; + + flagToolbarLook = IniSectionGetInt(pIniSection,L"ToolbarLook",IsXP() ? 1 : 2); + flagToolbarLook = max(min(flagToolbarLook,2),0); + + if (IniSectionGetInt(pIniSection,L"SimpleIndentGuides",0)) + flagSimpleIndentGuides = 1; + + if (IniSectionGetInt(pIniSection,L"NoHTMLGuess",0)) + fNoHTMLGuess = 1; + + if (IniSectionGetInt(pIniSection,L"NoCGIGuess",0)) + fNoCGIGuess = 1; + + if (IniSectionGetInt(pIniSection,L"NoFileVariables",0)) + fNoFileVariables = 1; + + if (lstrlen(g_wchAppUserModelID) == 0) { + IniSectionGetString(pIniSection,L"ShellAppUserModelID",L"(default)", + g_wchAppUserModelID,COUNTOF(g_wchAppUserModelID)); + } + + if (flagUseSystemMRU == 0) { + if (IniSectionGetInt(pIniSection,L"ShellUseSystemMRU",0)) + flagUseSystemMRU = 2; + } + + LocalFree(pIniSection); +} + + +//============================================================================= +// +// FindIniFile() +// +// +int CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule) +{ + WCHAR tchFileExpanded[MAX_PATH]; + WCHAR tchBuild[MAX_PATH]; + ExpandEnvironmentStrings(lpszFile,tchFileExpanded,COUNTOF(tchFileExpanded)); + + if (PathIsRelative(tchFileExpanded)) { + // program directory + lstrcpy(tchBuild,lpszModule); + lstrcpy(PathFindFileName(tchBuild),tchFileExpanded); + if (PathFileExists(tchBuild)) { + lstrcpy(lpszFile,tchBuild); + return(1); + } + // %appdata% + if (S_OK == SHGetFolderPath(NULL,CSIDL_APPDATA,NULL,SHGFP_TYPE_CURRENT,tchBuild)) { + PathAppend(tchBuild,tchFileExpanded); + if (PathFileExists(tchBuild)) { + lstrcpy(lpszFile,tchBuild); + return(1); + } + } + // general + if (SearchPath(NULL,tchFileExpanded,NULL,COUNTOF(tchBuild),tchBuild,NULL)) { + lstrcpy(lpszFile,tchBuild); + return(1); + } + } + + else if (PathFileExists(tchFileExpanded)) { + lstrcpy(lpszFile,tchFileExpanded); + return(1); + } + + return(0); +} + +int CheckIniFileRedirect(LPWSTR lpszFile,LPCWSTR lpszModule) +{ + WCHAR tch[MAX_PATH]; + if (GetPrivateProfileString(L"Notepad2",L"Notepad2.ini",L"",tch,COUNTOF(tch),lpszFile)) { + if (CheckIniFile(tch,lpszModule)) { + lstrcpy(lpszFile,tch); + return(1); + } + else { + WCHAR tchFileExpanded[MAX_PATH]; + ExpandEnvironmentStrings(tch,tchFileExpanded,COUNTOF(tchFileExpanded)); + if (PathIsRelative(tchFileExpanded)) { + lstrcpy(lpszFile,lpszModule); + lstrcpy(PathFindFileName(lpszFile),tchFileExpanded); + return(1); + } + else { + lstrcpy(lpszFile,tchFileExpanded); + return(1); + } + } + } + return(0); +} + +int FindIniFile() { + + int bFound = 0; + WCHAR tchTest[MAX_PATH]; + WCHAR tchModule[MAX_PATH]; + GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); + + if (lstrlen(szIniFile)) { + if (lstrcmpi(szIniFile,L"*?") == 0) + return(0); + else { + if (!CheckIniFile(szIniFile,tchModule)) { + ExpandEnvironmentStringsEx(szIniFile,COUNTOF(szIniFile)); + if (PathIsRelative(szIniFile)) { + lstrcpy(tchTest,tchModule); + PathRemoveFileSpec(tchTest); + PathAppend(tchTest,szIniFile); + lstrcpy(szIniFile,tchTest); + } + } + } + return(1); + } + + lstrcpy(tchTest,PathFindFileName(tchModule)); + PathRenameExtension(tchTest,L".ini"); + bFound = CheckIniFile(tchTest,tchModule); + + if (!bFound) { + lstrcpy(tchTest,L"Notepad2.ini"); + bFound = CheckIniFile(tchTest,tchModule); + } + + if (bFound) { + // allow two redirections: administrator -> user -> custom + if (CheckIniFileRedirect(tchTest,tchModule)) + CheckIniFileRedirect(tchTest,tchModule); + lstrcpy(szIniFile,tchTest); + } + + else { + lstrcpy(szIniFile,tchModule); + PathRenameExtension(szIniFile,L".ini"); + } + + return(1); +} + + +int TestIniFile() { + + if (lstrcmpi(szIniFile,L"*?") == 0) { + lstrcpy(szIniFile2,L""); + lstrcpy(szIniFile,L""); + return(0); + } + + if (PathIsDirectory(szIniFile) || *CharPrev(szIniFile,StrEnd(szIniFile)) == L'\\') { + WCHAR wchModule[MAX_PATH]; + GetModuleFileName(NULL,wchModule,COUNTOF(wchModule)); + PathAppend(szIniFile,PathFindFileName(wchModule)); + PathRenameExtension(szIniFile,L".ini"); + if (!PathFileExists(szIniFile)) { + lstrcpy(PathFindFileName(szIniFile),L"Notepad2.ini"); + if (!PathFileExists(szIniFile)) { + lstrcpy(PathFindFileName(szIniFile),PathFindFileName(wchModule)); + PathRenameExtension(szIniFile,L".ini"); + } + } + } + + if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) { + lstrcpy(szIniFile2,szIniFile); + lstrcpy(szIniFile,L""); + return(0); + } + else + return(1); +} + + +int CreateIniFile() { + + return(CreateIniFileEx(szIniFile)); +} + + +int CreateIniFileEx(LPCWSTR lpszIniFile) { + + if (*lpszIniFile) { + + HANDLE hFile; + WCHAR *pwchTail; + + if (pwchTail = StrRChrW(lpszIniFile,NULL,L'\\')) { + *pwchTail = 0; + SHCreateDirectoryEx(NULL,lpszIniFile,NULL); + *pwchTail = L'\\'; + } + + hFile = CreateFile(lpszIniFile, + GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); + dwLastIOError = GetLastError(); + if (hFile != INVALID_HANDLE_VALUE) { + if (GetFileSize(hFile,NULL) == 0) { + DWORD dw; + WriteFile(hFile,(LPCVOID)L"\xFEFF[Notepad2]\r\n",26,&dw,NULL); + } + CloseHandle(hFile); + return(1); + } + else + return(0); + } + + else + return(0); +} + + +//============================================================================= +// +// UpdateToolbar() +// +// +#define EnableTool(id,b) SendMessage(hwndToolbar,TB_ENABLEBUTTON,id, \ + MAKELONG(((b) ? 1 : 0), 0)) + +#define CheckTool(id,b) SendMessage(hwndToolbar,TB_CHECKBUTTON,id, \ + MAKELONG(b,0)) + +void UpdateToolbar() +{ + + int i; + + if (!bShowToolbar) + return; + + EnableTool(IDT_FILE_ADDTOFAV,lstrlen(szCurFile)); + + EnableTool(IDT_EDIT_UNDO,SendMessage(hwndEdit,SCI_CANUNDO,0,0) /*&& !bReadOnly*/); + EnableTool(IDT_EDIT_REDO,SendMessage(hwndEdit,SCI_CANREDO,0,0) /*&& !bReadOnly*/); + + i = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + EnableTool(IDT_EDIT_CUT,i /*&& !bReadOnly*/); + EnableTool(IDT_EDIT_COPY,SendMessage(hwndEdit,SCI_GETLENGTH,0,0)); + EnableTool(IDT_EDIT_PASTE,SendMessage(hwndEdit,SCI_CANPASTE,0,0) /*&& !bReadOnly*/); + + i = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); + EnableTool(IDT_EDIT_FIND,i); + //EnableTool(IDT_EDIT_FINDNEXT,i); + //EnableTool(IDT_EDIT_FINDPREV,i && lstrlen(efrData.szFind)); + EnableTool(IDT_EDIT_REPLACE,i /*&& !bReadOnly*/); + EnableTool(IDT_EDIT_CLEAR,i /*&& !bReadOnly*/); + + EnableTool(IDT_VIEW_TOGGLEFOLDS,i && bShowCodeFolding); + EnableTool(IDT_FILE_LAUNCH,i); + + CheckTool(IDT_VIEW_WORDWRAP,fWordWrap); + +} + + +//============================================================================= +// +// UpdateStatusbar() +// +// +void UpdateStatusbar() +{ + + int iPos; + int iLn; + int iLines; + int iCol; + int iSel; + WCHAR tchLn[32]; + WCHAR tchLines[32]; + WCHAR tchCol[32]; + WCHAR tchCols[32]; + WCHAR tchSel[32]; + WCHAR tchDocPos[256]; + + int iBytes; + WCHAR tchBytes[64]; + WCHAR tchDocSize[256]; + + WCHAR tchEOLMode[32]; + WCHAR tchOvrMode[32]; + WCHAR tchLexerName[128]; + +#ifdef BOOKMARK_EDITION + int iSelStart; + int iSelEnd; + int iLineStart; + int iLineEnd; + int iStartOfLinePos; + int iLinesSelected; + WCHAR tchLinesSelected[32]; +#endif + + if (!bShowStatusbar) + return; + + iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + + iLn = (int)SendMessage(hwndEdit,SCI_LINEFROMPOSITION,iPos,0) + 1; + wsprintf(tchLn,L"%i",iLn); + FormatNumberStr(tchLn); + + iLines = (int)SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0); + wsprintf(tchLines,L"%i",iLines); + FormatNumberStr(tchLines); + + iCol = (int)SendMessage(hwndEdit,SCI_GETCOLUMN,iPos,0) + 1; + wsprintf(tchCol,L"%i",iCol); + FormatNumberStr(tchCol); + + if (bMarkLongLines) { + wsprintf(tchCols,L"%i",iLongLinesLimit); + FormatNumberStr(tchCols); + } + + if (SC_SEL_RECTANGLE != SendMessage(hwndEdit,SCI_GETSELECTIONMODE,0,0)) + { + iSel = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0); + wsprintf(tchSel,L"%i",iSel); + FormatNumberStr(tchSel); + } + else + lstrcpy(tchSel,L"--"); + +#ifdef BOOKMARK_EDITION + // Print number of lines selected lines in statusbar + iSelStart = (int)SendMessage( hwndEdit , SCI_GETSELECTIONSTART , 0 , 0 ); + iSelEnd = (int)SendMessage( hwndEdit , SCI_GETSELECTIONEND , 0 , 0 ); + iLineStart = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iSelStart , 0 ); + iLineEnd = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iSelEnd , 0 ); + iStartOfLinePos = (int)SendMessage( hwndEdit , SCI_POSITIONFROMLINE , iLineEnd , 0 ); + iLinesSelected = iLineEnd - iLineStart; + if( iSelStart != iSelEnd && iStartOfLinePos != iSelEnd ) iLinesSelected += 1; + wsprintf(tchLinesSelected,L"%i",iLinesSelected); + FormatNumberStr(tchLinesSelected); + + if (!bMarkLongLines) + FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS,tchLn,tchLines,tchCol,tchSel,tchLinesSelected); + else + FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS2,tchLn,tchLines,tchCol,tchCols,tchSel,tchLinesSelected); + +#else + + if (!bMarkLongLines) + FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS,tchLn,tchLines,tchCol,tchSel); + else + FormatString(tchDocPos,COUNTOF(tchDocPos),IDS_DOCPOS2,tchLn,tchLines,tchCol,tchCols,tchSel); +#endif + + iBytes = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); + StrFormatByteSize(iBytes,tchBytes,COUNTOF(tchBytes)); + + FormatString(tchDocSize,COUNTOF(tchDocSize),IDS_DOCSIZE,tchBytes); + + Encoding_GetLabel(iEncoding); + + if (iEOLMode == SC_EOL_CR) + lstrcpy(tchEOLMode,L"CR"); + else if (iEOLMode == SC_EOL_LF) + lstrcpy(tchEOLMode,L"LF"); + else + lstrcpy(tchEOLMode,L"CR+LF"); + + if (SendMessage(hwndEdit,SCI_GETOVERTYPE,0,0)) + lstrcpy(tchOvrMode,L"OVR"); + else + lstrcpy(tchOvrMode,L"INS"); + + Style_GetCurrentLexerName(tchLexerName,COUNTOF(tchLexerName)); + + StatusSetText(hwndStatus,STATUS_DOCPOS,tchDocPos); + StatusSetText(hwndStatus,STATUS_DOCSIZE,tchDocSize); + StatusSetText(hwndStatus,STATUS_CODEPAGE,mEncoding[iEncoding].wchLabel); + StatusSetText(hwndStatus,STATUS_EOLMODE,tchEOLMode); + StatusSetText(hwndStatus,STATUS_OVRMODE,tchOvrMode); + StatusSetText(hwndStatus,STATUS_LEXER,tchLexerName); + + //InvalidateRect(hwndStatus,NULL,TRUE); + +} + + +//============================================================================= +// +// UpdateLineNumberWidth() +// +// +void UpdateLineNumberWidth() +{ + char tchLines[32]; + int iLineMarginWidthNow; + int iLineMarginWidthFit; + + if (bShowLineNumbers) { + + wsprintfA(tchLines,"_%i_",SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0)); + + iLineMarginWidthNow = (int)SendMessage(hwndEdit,SCI_GETMARGINWIDTHN,0,0); + iLineMarginWidthFit = (int)SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)tchLines); + + if (iLineMarginWidthNow != iLineMarginWidthFit) { + //SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0); + SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,iLineMarginWidthFit); + } + } + + else + SendMessage(hwndEdit,SCI_SETMARGINWIDTHN,0,0); +} + + +//============================================================================= +// +// FileIO() +// +// +BOOL FileIO(BOOL fLoad,LPCWSTR psz,BOOL bNoEncDetect,int *ienc,int *ieol, + BOOL *pbUnicodeErr,BOOL *pbFileTooBig, + BOOL *pbCancelDataLoss,BOOL bSaveCopy) +{ + WCHAR tch[MAX_PATH+40]; + BOOL fSuccess; + DWORD dwFileAttributes; + + BeginWaitCursor(); + + FormatString(tch,COUNTOF(tch),(fLoad) ? IDS_LOADFILE : IDS_SAVEFILE,PathFindFileName(psz)); + + StatusSetText(hwndStatus,STATUS_HELP,tch); + StatusSetSimple(hwndStatus,TRUE); + + InvalidateRect(hwndStatus,NULL,TRUE); + UpdateWindow(hwndStatus); + + if (fLoad) + fSuccess = EditLoadFile(hwndEdit,psz,bNoEncDetect,ienc,ieol,pbUnicodeErr,pbFileTooBig); + else + fSuccess = EditSaveFile(hwndEdit,psz,*ienc,pbCancelDataLoss,bSaveCopy); + + dwFileAttributes = GetFileAttributes(psz); + bReadOnly = (dwFileAttributes != INVALID_FILE_ATTRIBUTES && dwFileAttributes & FILE_ATTRIBUTE_READONLY); + + StatusSetSimple(hwndStatus,FALSE); + + EndWaitCursor(); + + return(fSuccess); +} + + +//============================================================================= +// +// FileLoad() +// +// +BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lpszFile) +{ + WCHAR tch[MAX_PATH] = L""; + WCHAR szFileName[MAX_PATH] = L""; + BOOL fSuccess; + BOOL bUnicodeErr = FALSE; + BOOL bFileTooBig = FALSE; + + if (!bDontSave) + { + if (!FileSave(FALSE,TRUE,FALSE,FALSE)) + return FALSE; + } + + if (bNew) { + lstrcpy(szCurFile,L""); + SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); + SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); + if (!fKeepTitleExcerpt) + lstrcpy(szTitleExcerpt,L""); + FileVars_Init(NULL,0,&fvCurFile); + EditSetNewText(hwndEdit,"",0); + Style_SetLexer(hwndEdit,NULL); + UpdateLineNumberWidth(); + bModified = FALSE; + bReadOnly = FALSE; + iEOLMode = iLineEndings[iDefaultEOLMode]; + SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); + iEncoding = iDefaultEncoding; + iOriginalEncoding = iDefaultEncoding; + SendMessage(hwndEdit,SCI_SETCODEPAGE,(iDefaultEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); + EditSetNewText(hwndEdit,"",0); + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + + // Terminate file watching + if (bResetFileWatching) + iFileWatchingMode = 0; + InstallFileWatching(NULL); + + return TRUE; + } + + if (!lpszFile || lstrlen(lpszFile) == 0) { + if (!OpenFileDlg(hwndMain,tch,COUNTOF(tch),NULL)) + return FALSE; + } + + else + lstrcpy(tch,lpszFile); + + ExpandEnvironmentStringsEx(tch,COUNTOF(tch)); + + if (PathIsRelative(tch)) { + StrCpyN(szFileName,g_wchWorkingDirectory,COUNTOF(szFileName)); + PathAppend(szFileName,tch); + if (!PathFileExists(szFileName)) { + WCHAR wchFullPath[MAX_PATH]; + if (SearchPath(NULL,tch,NULL,COUNTOF(wchFullPath),wchFullPath,NULL)) { + lstrcpy(szFileName,wchFullPath); + } + } + } + else + lstrcpy(szFileName,tch); + + PathCanonicalizeEx(szFileName); + GetLongPathNameEx(szFileName,COUNTOF(szFileName)); + + if (PathIsLnkFile(szFileName)) + PathGetLnkPath(szFileName,szFileName,COUNTOF(szFileName)); + + // Ask to create a new file... + if (!bReload && !PathFileExists(szFileName)) + { + if (flagQuietCreate || MsgBox(MBYESNO,IDS_ASK_CREATE,szFileName) == IDYES) { + HANDLE hFile = CreateFile(szFileName, + GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); + dwLastIOError = GetLastError(); + if (fSuccess = (hFile != INVALID_HANDLE_VALUE)) { + CloseHandle(hFile); + FileVars_Init(NULL,0,&fvCurFile); + EditSetNewText(hwndEdit,"",0); + Style_SetLexer(hwndEdit,NULL); + iEOLMode = iLineEndings[iDefaultEOLMode]; + SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0); + if (iSrcEncoding != -1) { + iEncoding = iSrcEncoding; + iOriginalEncoding = iSrcEncoding; + } + else { + iEncoding = iDefaultEncoding; + iOriginalEncoding = iDefaultEncoding; + } + SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0); + bReadOnly = FALSE; + EditSetNewText(hwndEdit,"",0); + } + } + else + return FALSE; + } + + else + fSuccess = FileIO(TRUE,szFileName,bNoEncDetect,&iEncoding,&iEOLMode,&bUnicodeErr,&bFileTooBig,NULL,FALSE); + + if (fSuccess) { + lstrcpy(szCurFile,szFileName); + SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); + SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); + if (!fKeepTitleExcerpt) + lstrcpy(szTitleExcerpt,L""); + if (!flagLexerSpecified) // flag will be cleared + Style_SetLexerFromFile(hwndEdit,szCurFile); + UpdateLineNumberWidth(); + iOriginalEncoding = iEncoding; + bModified = FALSE; + //bReadOnly = FALSE; + SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0); + MRU_AddFile(pFileMRU,szFileName,flagRelativeFileMRU,flagPortableMyDocs); + if (flagUseSystemMRU == 2) + SHAddToRecentDocs(SHARD_PATHW,szFileName); + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szFileName, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + + // Install watching of the current file + if (!bReload && bResetFileWatching) + iFileWatchingMode = 0; + InstallFileWatching(szCurFile); + + // the .LOG feature ... + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { + char tchLog[5] = ""; + SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog); + if (lstrcmpiA(tchLog,".LOG") == 0) { + EditJumpTo(hwndEdit,-1,0); + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0); + EditJumpTo(hwndEdit,-1,0); + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + EditJumpTo(hwndEdit,-1,0); + EditEnsureSelectionVisible(hwndEdit); + } + } + + // Show warning: Unicode file loaded as ANSI + if (bUnicodeErr) + MsgBox(MBWARN,IDS_ERR_UNICODE); + } + + else if (!bFileTooBig) + MsgBox(MBWARN,IDS_ERR_LOADFILE,szFileName); + + return(fSuccess); +} + + +//============================================================================= +// +// FileSave() +// +// +BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy) +{ + WCHAR tchFile[MAX_PATH]; + BOOL fSuccess = FALSE; + BOOL bCancelDataLoss = FALSE; + + BOOL bIsEmptyNewFile = FALSE; + if (lstrlen(szCurFile) == 0) { + int cchText = (int)SendMessage(hwndEdit,SCI_GETLENGTH,0,0); + if (cchText == 0) + bIsEmptyNewFile = TRUE; + else if (cchText < 1023) { + char tchText[2048]; + SendMessage(hwndEdit,SCI_GETTEXT,(WPARAM)2047,(LPARAM)tchText); + StrTrimA(tchText," \t\n\r"); + if (lstrlenA(tchText) == 0) + bIsEmptyNewFile = TRUE; + } + } + + if (!bSaveAlways && (!bModified && iEncoding == iOriginalEncoding || bIsEmptyNewFile) && !bSaveAs) + return TRUE; + + if (bAsk) + { + // File or "Untitled" ... + WCHAR tch[MAX_PATH]; + if (lstrlen(szCurFile)) + lstrcpy(tch,szCurFile); + else + GetString(IDS_UNTITLED,tch,COUNTOF(tch)); + + switch (MsgBox(MBYESNOCANCEL,IDS_ASK_SAVE,tch)) { + case IDCANCEL: + return FALSE; + case IDNO: + return TRUE; + } + } + + // Read only... + if (!bSaveAs && !bSaveCopy && lstrlen(szCurFile)) + { + DWORD dwFileAttributes = GetFileAttributes(szCurFile); + if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) + bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); + if (bReadOnly) { + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + if (MsgBox(MBYESNOWARN,IDS_READONLY_SAVE,szCurFile) == IDYES) + bSaveAs = TRUE; + else + return FALSE; + } + } + + // Save As... + if (bSaveAs || bSaveCopy || lstrlen(szCurFile) == 0) + { + WCHAR tchInitialDir[MAX_PATH] = L""; + if (bSaveCopy && lstrlen(tchLastSaveCopyDir)) { + lstrcpy(tchInitialDir,tchLastSaveCopyDir); + lstrcpy(tchFile,tchLastSaveCopyDir); + PathAppend(tchFile,PathFindFileName(szCurFile)); + } + else + lstrcpy(tchFile,szCurFile); + + if (SaveFileDlg(hwndMain,tchFile,COUNTOF(tchFile),tchInitialDir)) + { + if (fSuccess = FileIO(FALSE,tchFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,bSaveCopy)) + { + if (!bSaveCopy) + { + lstrcpy(szCurFile,tchFile); + SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); + SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); + if (!fKeepTitleExcerpt) + lstrcpy(szTitleExcerpt,L""); + Style_SetLexerFromFile(hwndEdit,szCurFile); + UpdateStatusbar(); + UpdateLineNumberWidth(); + } + else { + lstrcpy(tchLastSaveCopyDir,tchFile); + PathRemoveFileSpec(tchLastSaveCopyDir); + } + } + } + else + return FALSE; + } + + else + fSuccess = FileIO(FALSE,szCurFile,FALSE,&iEncoding,&iEOLMode,NULL,NULL,&bCancelDataLoss,FALSE); + + if (fSuccess) + { + if (!bSaveCopy) + { + bModified = FALSE; + iOriginalEncoding = iEncoding; + MRU_AddFile(pFileMRU,szCurFile,flagRelativeFileMRU,flagPortableMyDocs); + if (flagUseSystemMRU == 2) + SHAddToRecentDocs(SHARD_PATHW,szCurFile); + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + + // Install watching of the current file + if (bSaveAs && bResetFileWatching) + iFileWatchingMode = 0; + InstallFileWatching(szCurFile); + } + } + + else if (!bCancelDataLoss) + { + if (lstrlen(szCurFile) != 0) + lstrcpy(tchFile,szCurFile); + + SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile, + iPathNameFormat,bModified || iEncoding != iOriginalEncoding, + IDS_READONLY,bReadOnly,szTitleExcerpt); + + MsgBox(MBWARN,IDS_ERR_SAVEFILE,tchFile); + } + + return(fSuccess); +} + + +//============================================================================= +// +// OpenFileDlg() +// +// +BOOL OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) +{ + OPENFILENAME ofn; + WCHAR szFile[MAX_PATH]; + WCHAR szFilter[NUMLEXERS*1024]; + WCHAR tchInitialDir[MAX_PATH] = L""; + + lstrcpy(szFile,L""); + Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter)); + + if (!lpstrInitialDir) { + if (lstrlen(szCurFile)) { + lstrcpy(tchInitialDir,szCurFile); + PathRemoveFileSpec(tchInitialDir); + } + else if (lstrlen(tchDefaultDir)) { + ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); + if (PathIsRelative(tchInitialDir)) { + WCHAR tchModule[MAX_PATH]; + GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); + PathRemoveFileSpec(tchModule); + PathAppend(tchModule,tchInitialDir); + PathCanonicalize(tchInitialDir,tchModule); + } + } + else + lstrcpy(tchInitialDir,g_wchWorkingDirectory); + } + + ZeroMemory(&ofn,sizeof(OPENFILENAME)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = szFilter; + ofn.lpstrFile = szFile; + ofn.lpstrInitialDir = (lpstrInitialDir) ? lpstrInitialDir : tchInitialDir; + ofn.nMaxFile = COUNTOF(szFile); + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/ + OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST | + OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/; + ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL; + + if (GetOpenFileName(&ofn)) { + lstrcpyn(lpstrFile,szFile,cchFile); + return TRUE; + } + + else + return FALSE; +} + + +//============================================================================= +// +// SaveFileDlg() +// +// +BOOL SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) +{ + OPENFILENAME ofn; + WCHAR szNewFile[MAX_PATH]; + WCHAR szFilter[NUMLEXERS*1024]; + WCHAR tchInitialDir[MAX_PATH] = L""; + + lstrcpy(szNewFile,lpstrFile); + Style_GetOpenDlgFilterStr(szFilter,COUNTOF(szFilter)); + + if (lstrlen(lpstrInitialDir)) + lstrcpy(tchInitialDir,lpstrInitialDir); + else if (lstrlen(szCurFile)) { + lstrcpy(tchInitialDir,szCurFile); + PathRemoveFileSpec(tchInitialDir); + } + else if (lstrlen(tchDefaultDir)) { + ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); + if (PathIsRelative(tchInitialDir)) { + WCHAR tchModule[MAX_PATH]; + GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); + PathRemoveFileSpec(tchModule); + PathAppend(tchModule,tchInitialDir); + PathCanonicalize(tchInitialDir,tchModule); + } + } + else + lstrcpy(tchInitialDir,g_wchWorkingDirectory); + + ZeroMemory(&ofn,sizeof(OPENFILENAME)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = szFilter; + ofn.lpstrFile = szNewFile; + ofn.lpstrInitialDir = tchInitialDir; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ | + /*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT | + OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST; + ofn.lpstrDefExt = (lstrlen(tchDefaultExtension)) ? tchDefaultExtension : NULL; + + if (GetSaveFileName(&ofn)) { + lstrcpyn(lpstrFile,szNewFile,cchFile); + return TRUE; + } + + else + return FALSE; +} + + +/****************************************************************************** +* +* ActivatePrevInst() +* +* Tries to find and activate an already open Notepad2 Window +* +* +******************************************************************************/ +BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam) +{ + BOOL bContinue = TRUE; + WCHAR szClassName[64]; + + if (GetClassName(hwnd,szClassName,COUNTOF(szClassName))) + + if (lstrcmpi(szClassName,wchWndClass) == 0) { + + DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE); + if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) { + + *(HWND*)lParam = hwnd; + + if (IsWindowEnabled(hwnd)) + bContinue = FALSE; + } + } + return(bContinue); +} + +BOOL CALLBACK EnumWndProc2(HWND hwnd,LPARAM lParam) +{ + BOOL bContinue = TRUE; + WCHAR szClassName[64]; + + if (GetClassName(hwnd,szClassName,COUNTOF(szClassName))) + + if (lstrcmpi(szClassName,wchWndClass) == 0) { + + DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE); + if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) { + + WCHAR tchFileName[MAX_PATH] = L""; + + if (IsWindowEnabled(hwnd)) + bContinue = FALSE; + + GetDlgItemText(hwnd,IDC_FILENAME,tchFileName,COUNTOF(tchFileName)); + if (lstrcmpi(tchFileName,lpFileArg) == 0) + *(HWND*)lParam = hwnd; + else + bContinue = TRUE; + } + } + return(bContinue); +} + +BOOL ActivatePrevInst() +{ + HWND hwnd = NULL; + COPYDATASTRUCT cds; + + if ((flagNoReuseWindow && !flagSingleFileInstance) || flagStartAsTrayIcon || flagNewFromClipboard || flagPasteBoard) + return(FALSE); + + if (flagSingleFileInstance && lpFileArg) { + + // Search working directory from second instance, first! + // lpFileArg is at least MAX_PATH+2 bytes + WCHAR tchTmp[MAX_PATH]; + + ExpandEnvironmentStringsEx(lpFileArg,(DWORD)GlobalSize(lpFileArg)/sizeof(WCHAR)); + + if (PathIsRelative(lpFileArg)) { + StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); + PathAppend(tchTmp,lpFileArg); + if (PathFileExists(tchTmp)) + lstrcpy(lpFileArg,tchTmp); + else { + if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) + lstrcpy(lpFileArg,tchTmp); + else { + StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); + PathAppend(tchTmp,lpFileArg); + lstrcpy(lpFileArg,tchTmp); + } + } + } + + else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) + lstrcpy(lpFileArg,tchTmp); + + GetLongPathNameEx(lpFileArg,MAX_PATH); + + EnumWindows(EnumWndProc2,(LPARAM)&hwnd); + + if (hwnd != NULL) + { + // Enabled + if (IsWindowEnabled(hwnd)) + { + LPNP2PARAMS params; + DWORD cb = sizeof(NP2PARAMS); + + // Make sure the previous window won't pop up a change notification message + //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0); + + if (IsIconic(hwnd)) + ShowWindowAsync(hwnd,SW_RESTORE); + + if (!IsWindowVisible(hwnd)) { + SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK); + SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP); + } + + SetForegroundWindow(hwnd); + + if (lpSchemeArg) + cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR); + + params = GlobalAlloc(GPTR,cb); + params->flagFileSpecified = FALSE; + params->flagChangeNotify = 0; + params->flagQuietCreate = FALSE; + params->flagLexerSpecified = flagLexerSpecified; + if (flagLexerSpecified && lpSchemeArg) { + lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg); + params->iInitialLexer = -1; + } + else + params->iInitialLexer = iInitialLexer; + params->flagJumpTo = flagJumpTo; + params->iInitialLine = iInitialLine; + params->iInitialColumn = iInitialColumn; + + params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1; + params->flagSetEncoding = flagSetEncoding; + params->flagSetEOLMode = flagSetEOLMode; + params->flagTitleExcerpt = 0; + + cds.dwData = DATA_NOTEPAD2_PARAMS; + cds.cbData = (DWORD)GlobalSize(params); + cds.lpData = params; + + SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds); + GlobalFree(params); + + return(TRUE); + } + + else // IsWindowEnabled() + { + // Ask... + if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED)) + return(FALSE); + else + return(TRUE); + } + } + } + + if (flagNoReuseWindow) + return(FALSE); + + hwnd = NULL; + EnumWindows(EnumWndProc,(LPARAM)&hwnd); + + // Found a window + if (hwnd != NULL) + { + // Enabled + if (IsWindowEnabled(hwnd)) + { + // Make sure the previous window won't pop up a change notification message + //SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0); + + if (IsIconic(hwnd)) + ShowWindowAsync(hwnd,SW_RESTORE); + + if (!IsWindowVisible(hwnd)) { + SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK); + SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP); + } + + SetForegroundWindow(hwnd); + + if (lpFileArg) + { + // Search working directory from second instance, first! + // lpFileArg is at least MAX_PATH+2 bytes + WCHAR tchTmp[MAX_PATH]; + LPNP2PARAMS params; + DWORD cb = sizeof(NP2PARAMS); + int cchTitleExcerpt; + + ExpandEnvironmentStringsEx(lpFileArg,(DWORD)GlobalSize(lpFileArg)/sizeof(WCHAR)); + + if (PathIsRelative(lpFileArg)) { + StrCpyN(tchTmp,g_wchWorkingDirectory,COUNTOF(tchTmp)); + PathAppend(tchTmp,lpFileArg); + if (PathFileExists(tchTmp)) + lstrcpy(lpFileArg,tchTmp); + else { + if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) + lstrcpy(lpFileArg,tchTmp); + } + } + + else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) + lstrcpy(lpFileArg,tchTmp); + + cb += (lstrlen(lpFileArg) + 1) * sizeof(WCHAR); + + if (lpSchemeArg) + cb += (lstrlen(lpSchemeArg) + 1) * sizeof(WCHAR); + + cchTitleExcerpt = lstrlen(szTitleExcerpt); + if (cchTitleExcerpt) + cb += (cchTitleExcerpt + 1) * sizeof(WCHAR); + + params = GlobalAlloc(GPTR,cb); + params->flagFileSpecified = TRUE; + lstrcpy(¶ms->wchData,lpFileArg); + params->flagChangeNotify = flagChangeNotify; + params->flagQuietCreate = flagQuietCreate; + params->flagLexerSpecified = flagLexerSpecified; + if (flagLexerSpecified && lpSchemeArg) { + lstrcpy(StrEnd(¶ms->wchData)+1,lpSchemeArg); + params->iInitialLexer = -1; + } + else + params->iInitialLexer = iInitialLexer; + params->flagJumpTo = flagJumpTo; + params->iInitialLine = iInitialLine; + params->iInitialColumn = iInitialColumn; + + params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : -1; + params->flagSetEncoding = flagSetEncoding; + params->flagSetEOLMode = flagSetEOLMode; + + if (cchTitleExcerpt) { + lstrcpy(StrEnd(¶ms->wchData)+1,szTitleExcerpt); + params->flagTitleExcerpt = 1; + } + else + params->flagTitleExcerpt = 0; + + cds.dwData = DATA_NOTEPAD2_PARAMS; + cds.cbData = (DWORD)GlobalSize(params); + cds.lpData = params; + + SendMessage(hwnd,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds); + GlobalFree(params); + GlobalFree(lpFileArg); + } + return(TRUE); + } + else // IsWindowEnabled() + { + // Ask... + if (IDYES == MsgBox(MBYESNO,IDS_ERR_PREVWINDISABLED)) + return(FALSE); + else + return(TRUE); + } + } + else + return(FALSE); +} + + +//============================================================================= +// +// RelaunchMultiInst() +// +// +BOOL RelaunchMultiInst() { + + if (flagMultiFileArg == 2 && cFileList > 1) { + + WCHAR *pwch; + int i = 0; + STARTUPINFO si; + PROCESS_INFORMATION pi; + + LPWSTR lpCmdLineNew = StrDup(GetCommandLine()); + LPWSTR lp1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1)); + LPWSTR lp2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLineNew) + 1)); + + StrTab2Space(lpCmdLineNew); + lstrcpy(lpCmdLineNew + cchiFileList,L""); + + pwch = CharPrev(lpCmdLineNew,StrEnd(lpCmdLineNew)); + while (*pwch == L' ' || *pwch == L'-' || *pwch == L'+') { + *pwch = L' '; + pwch = CharPrev(lpCmdLineNew,pwch); + if (i++ > 1) + cchiFileList--; + } + + for (i = 0; i < cFileList; i++) { + + lstrcpy(lpCmdLineNew + cchiFileList,L" /n - "); + lstrcat(lpCmdLineNew,lpFileList[i]); + LocalFree(lpFileList[i]); + + ZeroMemory(&si,sizeof(STARTUPINFO)); + si.cb = sizeof(STARTUPINFO); + ZeroMemory(&pi,sizeof(PROCESS_INFORMATION)); + + CreateProcess(NULL,lpCmdLineNew,NULL,NULL,FALSE,0,NULL,g_wchWorkingDirectory,&si,&pi); + } + LocalFree(lpCmdLineNew); + LocalFree(lp1); + LocalFree(lp2); + GlobalFree(lpFileArg); + + return TRUE; + } + + else { + int i; + for (i = 0; i < cFileList; i++) + LocalFree(lpFileList[i]); + return FALSE; + } +} + + +//============================================================================= +// +// RelaunchElevated() +// +// +BOOL RelaunchElevated() { + + if (!IsVista() || fIsElevated || !flagRelaunchElevated || flagDisplayHelp) + return(FALSE); + + else { + + LPWSTR lpCmdLine; + LPWSTR lpArg1, lpArg2; + STARTUPINFO si; + SHELLEXECUTEINFO sei; + + si.cb = sizeof(STARTUPINFO); + GetStartupInfo(&si); + + lpCmdLine = GetCommandLine(); + lpArg1 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + lpArg2 = LocalAlloc(LPTR,sizeof(WCHAR)*(lstrlen(lpCmdLine) + 1)); + ExtractFirstArgument(lpCmdLine,lpArg1,lpArg2); + + if (lstrlen(lpArg1)) { + + ZeroMemory(&sei,sizeof(SHELLEXECUTEINFO)); + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = SEE_MASK_FLAG_NO_UI | /*SEE_MASK_NOASYNC*/0x00000100 | /*SEE_MASK_NOZONECHECKS*/0x00800000; + sei.hwnd = GetForegroundWindow(); + sei.lpVerb = L"runas"; + sei.lpFile = lpArg1; + sei.lpParameters = lpArg2; + sei.lpDirectory = g_wchWorkingDirectory; + sei.nShow = si.wShowWindow; + + ShellExecuteEx(&sei); + } + + LocalFree(lpArg1); + LocalFree(lpArg2); + + return(TRUE); + } +} + + +//============================================================================= +// +// SnapToDefaultPos() +// +// Aligns Notepad2 to the default window position on the current screen +// +// +void SnapToDefaultPos(HWND hwnd) +{ + WINDOWPLACEMENT wndpl; + HMONITOR hMonitor; + MONITORINFO mi; + int x,y,cx,cy; + RECT rcOld; + + GetWindowRect(hwnd,&rcOld); + + hMonitor = MonitorFromRect(&rcOld,MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor,&mi); + + y = mi.rcWork.top + 16; + cy = mi.rcWork.bottom - mi.rcWork.top - 32; + cx = min(mi.rcWork.right - mi.rcWork.left - 32,cy); + x = mi.rcWork.right - cx - 16; + + wndpl.length = sizeof(WINDOWPLACEMENT); + wndpl.flags = WPF_ASYNCWINDOWPLACEMENT; + wndpl.showCmd = SW_RESTORE; + + wndpl.rcNormalPosition.left = x; + wndpl.rcNormalPosition.top = y; + wndpl.rcNormalPosition.right = x + cx; + wndpl.rcNormalPosition.bottom = y + cy; + + if (EqualRect(&rcOld,&wndpl.rcNormalPosition)) { + x = mi.rcWork.left + 16; + wndpl.rcNormalPosition.left = x; + wndpl.rcNormalPosition.right = x + cx; + } + + if (GetDoAnimateMinimize()) { + DrawAnimatedRects(hwnd,IDANI_CAPTION,&rcOld,&wndpl.rcNormalPosition); + OffsetRect(&wndpl.rcNormalPosition,mi.rcMonitor.left - mi.rcWork.left,mi.rcMonitor.top - mi.rcWork.top); + } + + SetWindowPlacement(hwnd,&wndpl); +} + + +//============================================================================= +// +// ShowNotifyIcon() +// +// +void ShowNotifyIcon(HWND hwnd,BOOL bAdd) +{ + + static HICON hIcon; + NOTIFYICONDATA nid; + + if (!hIcon) + hIcon = LoadImage(g_hInstance,MAKEINTRESOURCE(IDR_MAINWND), + IMAGE_ICON,16,16,LR_DEFAULTCOLOR); + + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hwnd; + nid.uID = 0; + nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nid.uCallbackMessage = WM_TRAYMESSAGE; + nid.hIcon = hIcon; + lstrcpy(nid.szTip,L"Notepad2"); + + if(bAdd) + Shell_NotifyIcon(NIM_ADD,&nid); + else + Shell_NotifyIcon(NIM_DELETE,&nid); + +} + + +//============================================================================= +// +// SetNotifyIconTitle() +// +// +void SetNotifyIconTitle(HWND hwnd) +{ + + NOTIFYICONDATA nid; + SHFILEINFO shfi; + WCHAR tchTitle[128]; + WCHAR tchFormat[32]; + + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hwnd; + nid.uID = 0; + nid.uFlags = NIF_TIP; + + if (lstrlen(szTitleExcerpt)) { + GetString(IDS_TITLEEXCERPT,tchFormat,COUNTOF(tchFormat)); + wsprintf(tchTitle,tchFormat,szTitleExcerpt); + } + + else if (lstrlen(szCurFile)) { + SHGetFileInfo2(szCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0); + } + else + GetString(IDS_UNTITLED,tchTitle,COUNTOF(tchTitle)-4); + + if (bModified || iEncoding != iOriginalEncoding) + lstrcpy(nid.szTip,L"* "); + else + lstrcpy(nid.szTip,L""); + lstrcat(nid.szTip,tchTitle); + + Shell_NotifyIcon(NIM_MODIFY,&nid); + +} + + +//============================================================================= +// +// InstallFileWatching() +// +// +void InstallFileWatching(LPCWSTR lpszFile) +{ + + WCHAR tchDirectory[MAX_PATH]; + HANDLE hFind; + + // Terminate + if (!iFileWatchingMode || !lpszFile || lstrlen(lpszFile) == 0) + { + if (bRunningWatch) + { + if (hChangeHandle) { + FindCloseChangeNotification(hChangeHandle); + hChangeHandle = NULL; + } + KillTimer(NULL,ID_WATCHTIMER); + bRunningWatch = FALSE; + dwChangeNotifyTime = 0; + } + return; + } + + // Install + else + { + // Terminate previous watching + if (bRunningWatch) { + if (hChangeHandle) { + FindCloseChangeNotification(hChangeHandle); + hChangeHandle = NULL; + } + dwChangeNotifyTime = 0; + } + + // No previous watching installed, so launch the timer first + else + SetTimer(NULL,ID_WATCHTIMER,dwFileCheckInverval,WatchTimerProc); + + lstrcpy(tchDirectory,lpszFile); + PathRemoveFileSpec(tchDirectory); + + // Save data of current file + hFind = FindFirstFile(szCurFile,&fdCurFile); + if (hFind != INVALID_HANDLE_VALUE) + FindClose(hFind); + else + ZeroMemory(&fdCurFile,sizeof(WIN32_FIND_DATA)); + + hChangeHandle = FindFirstChangeNotification(tchDirectory,FALSE, + FILE_NOTIFY_CHANGE_FILE_NAME | \ + FILE_NOTIFY_CHANGE_DIR_NAME | \ + FILE_NOTIFY_CHANGE_ATTRIBUTES | \ + FILE_NOTIFY_CHANGE_SIZE | \ + FILE_NOTIFY_CHANGE_LAST_WRITE); + + bRunningWatch = TRUE; + dwChangeNotifyTime = 0; + } +} + + +//============================================================================= +// +// WatchTimerProc() +// +// +void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) +{ + if (bRunningWatch) + { + if (dwChangeNotifyTime > 0 && GetTickCount() - dwChangeNotifyTime > dwAutoReloadTimeout) + { + if (hChangeHandle) { + FindCloseChangeNotification(hChangeHandle); + hChangeHandle = NULL; + } + KillTimer(NULL,ID_WATCHTIMER); + bRunningWatch = FALSE; + dwChangeNotifyTime = 0; + SendMessage(hwndMain,WM_CHANGENOTIFY,0,0); + } + + // Check Change Notification Handle + else if (WAIT_OBJECT_0 == WaitForSingleObject(hChangeHandle,0)) + { + // Check if the changes affect the current file + WIN32_FIND_DATA fdUpdated; + HANDLE hFind = FindFirstFile(szCurFile,&fdUpdated); + if (INVALID_HANDLE_VALUE != hFind) + FindClose(hFind); + else + // The current file has been removed + ZeroMemory(&fdUpdated,sizeof(WIN32_FIND_DATA)); + + // Check if the file has been changed + if (CompareFileTime(&fdCurFile.ftLastWriteTime,&fdUpdated.ftLastWriteTime) != 0 || + fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow || + fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh) + { + // Shutdown current watching and give control to main window + if (hChangeHandle) { + FindCloseChangeNotification(hChangeHandle); + hChangeHandle = NULL; + } + if (iFileWatchingMode == 2) { + bRunningWatch = TRUE; /* ! */ + dwChangeNotifyTime = GetTickCount(); + } + else { + KillTimer(NULL,ID_WATCHTIMER); + bRunningWatch = FALSE; + dwChangeNotifyTime = 0; + SendMessage(hwndMain,WM_CHANGENOTIFY,0,0); + } + } + + else + FindNextChangeNotification(hChangeHandle); + } + } +} + + +//============================================================================= +// +// PasteBoardTimer() +// +// +void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) +{ + if (dwLastCopyTime > 0 && GetTickCount() - dwLastCopyTime > 200) { + + if (SendMessage(hwndEdit,SCI_CANPASTE,0,0)) { + + BOOL bAutoIndent2 = bAutoIndent; + bAutoIndent = 0; + EditJumpTo(hwndEdit,-1,0); + SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0); + if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) > 0) + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndEdit,SCI_PASTE,0,0); + SendMessage(hwndEdit,SCI_NEWLINE,0,0); + SendMessage(hwndEdit,SCI_ENDUNDOACTION,0,0); + EditEnsureSelectionVisible(hwndEdit); + bAutoIndent = bAutoIndent2; + } + + dwLastCopyTime = 0; + } +} + + + +/// End of Notepad2.c \\\ diff --git a/src/Notepad2.h b/src/Notepad2.h index a4c71df2..7903296b 100644 --- a/src/Notepad2.h +++ b/src/Notepad2.h @@ -1,147 +1,147 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Notepad2.h -* Global definitions and declarations -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - - - -//==== Main Window ============================================================ -#define WC_NOTEPAD2 L"Notepad2" - - -//==== Data Type for WM_COPYDATA ============================================== -#define DATA_NOTEPAD2_PARAMS 0xFB10 -typedef struct np2params { - - int flagFileSpecified; - int flagChangeNotify; - int flagLexerSpecified; - int iInitialLexer; - int flagQuietCreate; - int flagJumpTo; - int iInitialLine; - int iInitialColumn; - int iSrcEncoding; - int flagSetEncoding; - int flagSetEOLMode; - int flagTitleExcerpt; - WCHAR wchData; - -} NP2PARAMS, *LPNP2PARAMS; - - -//==== Toolbar Style ========================================================== -#define WS_TOOLBAR (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | \ - TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_ALTDRAG | \ - TBSTYLE_LIST | CCS_NODIVIDER | CCS_NOPARENTALIGN | \ - CCS_ADJUSTABLE) - - -//==== ReBar Style ============================================================ -#define WS_REBAR (WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | RBS_VARHEIGHT | \ - RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN) - - -//==== Ids ==================================================================== -#define IDC_STATUSBAR 0xFB00 -#define IDC_TOOLBAR 0xFB01 -#define IDC_REBAR 0xFB02 -#define IDC_EDIT 0xFB03 -#define IDC_EDITFRAME 0xFB04 -#define IDC_FILENAME 0xFB05 -#define IDC_REUSELOCK 0xFB06 - - -//==== Statusbar ============================================================== -#define STATUS_DOCPOS 0 -#define STATUS_DOCSIZE 1 -#define STATUS_CODEPAGE 2 -#define STATUS_EOLMODE 3 -#define STATUS_OVRMODE 4 -#define STATUS_LEXER 5 -#define STATUS_HELP 255 - - -//==== Change Notifications =================================================== -#define ID_WATCHTIMER 0xA000 -#define WM_CHANGENOTIFY WM_USER+1 -//#define WM_CHANGENOTIFYCLEAR WM_USER+2 - - -//==== Callback Message from System Tray ====================================== -#define WM_TRAYMESSAGE WM_USER - - -//==== Paste Board Timer ====================================================== -#define ID_PASTEBOARDTIMER 0xA001 - - -//==== Reuse Window Lock Timeout ============================================== -#define REUSEWINDOWLOCKTIMEOUT 1000 - - -//==== Function Declarations ================================================== -BOOL InitApplication(HINSTANCE); -HWND InitInstance(HINSTANCE,LPSTR,int); -BOOL ActivatePrevInst(); -BOOL RelaunchMultiInst(); -BOOL RelaunchElevated(); -void SnapToDefaultPos(HWND); -void ShowNotifyIcon(HWND,BOOL); -void SetNotifyIconTitle(HWND); -void InstallFileWatching(LPCWSTR); -void CALLBACK WatchTimerProc(HWND,UINT,UINT_PTR,DWORD); -void CALLBACK PasteBoardTimer(HWND,UINT,UINT_PTR,DWORD); - - -void LoadSettings(); -void SaveSettings(BOOL); -void ParseCommandLine(); -void LoadFlags(); -int CheckIniFile(LPWSTR,LPCWSTR); -int CheckIniFileRedirect(LPWSTR,LPCWSTR); -int FindIniFile(); -int TestIniFile(); -int CreateIniFile(); -int CreateIniFileEx(LPCWSTR); - - -void UpdateStatusbar(); -void UpdateToolbar(); -void UpdateLineNumberWidth(); - - -BOOL FileIO(BOOL,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*,BOOL*,BOOL); -BOOL FileLoad(BOOL,BOOL,BOOL,BOOL,LPCWSTR); -BOOL FileSave(BOOL,BOOL,BOOL,BOOL); -BOOL OpenFileDlg(HWND,LPWSTR,int,LPCWSTR); -BOOL SaveFileDlg(HWND,LPWSTR,int,LPCWSTR); - - -LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM); -LRESULT MsgCreate(HWND,WPARAM,LPARAM); -void CreateBars(HWND,HINSTANCE); -void MsgThemeChanged(HWND,WPARAM,LPARAM); -void MsgSize(HWND,WPARAM,LPARAM); -void MsgInitMenu(HWND,WPARAM,LPARAM); -LRESULT MsgCommand(HWND,WPARAM,LPARAM); -LRESULT MsgNotify(HWND,WPARAM,LPARAM); - - - -/// End of Notepad2.h \\\ +/****************************************************************************** +* +* +* Notepad2 +* +* Notepad2.h +* Global definitions and declarations +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + + + +//==== Main Window ============================================================ +#define WC_NOTEPAD2 L"Notepad2" + + +//==== Data Type for WM_COPYDATA ============================================== +#define DATA_NOTEPAD2_PARAMS 0xFB10 +typedef struct np2params { + + int flagFileSpecified; + int flagChangeNotify; + int flagLexerSpecified; + int iInitialLexer; + int flagQuietCreate; + int flagJumpTo; + int iInitialLine; + int iInitialColumn; + int iSrcEncoding; + int flagSetEncoding; + int flagSetEOLMode; + int flagTitleExcerpt; + WCHAR wchData; + +} NP2PARAMS, *LPNP2PARAMS; + + +//==== Toolbar Style ========================================================== +#define WS_TOOLBAR (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | \ + TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_ALTDRAG | \ + TBSTYLE_LIST | CCS_NODIVIDER | CCS_NOPARENTALIGN | \ + CCS_ADJUSTABLE) + + +//==== ReBar Style ============================================================ +#define WS_REBAR (WS_CHILD | WS_CLIPCHILDREN | WS_BORDER | RBS_VARHEIGHT | \ + RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NOPARENTALIGN) + + +//==== Ids ==================================================================== +#define IDC_STATUSBAR 0xFB00 +#define IDC_TOOLBAR 0xFB01 +#define IDC_REBAR 0xFB02 +#define IDC_EDIT 0xFB03 +#define IDC_EDITFRAME 0xFB04 +#define IDC_FILENAME 0xFB05 +#define IDC_REUSELOCK 0xFB06 + + +//==== Statusbar ============================================================== +#define STATUS_DOCPOS 0 +#define STATUS_DOCSIZE 1 +#define STATUS_CODEPAGE 2 +#define STATUS_EOLMODE 3 +#define STATUS_OVRMODE 4 +#define STATUS_LEXER 5 +#define STATUS_HELP 255 + + +//==== Change Notifications =================================================== +#define ID_WATCHTIMER 0xA000 +#define WM_CHANGENOTIFY WM_USER+1 +//#define WM_CHANGENOTIFYCLEAR WM_USER+2 + + +//==== Callback Message from System Tray ====================================== +#define WM_TRAYMESSAGE WM_USER + + +//==== Paste Board Timer ====================================================== +#define ID_PASTEBOARDTIMER 0xA001 + + +//==== Reuse Window Lock Timeout ============================================== +#define REUSEWINDOWLOCKTIMEOUT 1000 + + +//==== Function Declarations ================================================== +BOOL InitApplication(HINSTANCE); +HWND InitInstance(HINSTANCE,LPSTR,int); +BOOL ActivatePrevInst(); +BOOL RelaunchMultiInst(); +BOOL RelaunchElevated(); +void SnapToDefaultPos(HWND); +void ShowNotifyIcon(HWND,BOOL); +void SetNotifyIconTitle(HWND); +void InstallFileWatching(LPCWSTR); +void CALLBACK WatchTimerProc(HWND,UINT,UINT_PTR,DWORD); +void CALLBACK PasteBoardTimer(HWND,UINT,UINT_PTR,DWORD); + + +void LoadSettings(); +void SaveSettings(BOOL); +void ParseCommandLine(); +void LoadFlags(); +int CheckIniFile(LPWSTR,LPCWSTR); +int CheckIniFileRedirect(LPWSTR,LPCWSTR); +int FindIniFile(); +int TestIniFile(); +int CreateIniFile(); +int CreateIniFileEx(LPCWSTR); + + +void UpdateStatusbar(); +void UpdateToolbar(); +void UpdateLineNumberWidth(); + + +BOOL FileIO(BOOL,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*,BOOL*,BOOL); +BOOL FileLoad(BOOL,BOOL,BOOL,BOOL,LPCWSTR); +BOOL FileSave(BOOL,BOOL,BOOL,BOOL); +BOOL OpenFileDlg(HWND,LPWSTR,int,LPCWSTR); +BOOL SaveFileDlg(HWND,LPWSTR,int,LPCWSTR); + + +LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM); +LRESULT MsgCreate(HWND,WPARAM,LPARAM); +void CreateBars(HWND,HINSTANCE); +void MsgThemeChanged(HWND,WPARAM,LPARAM); +void MsgSize(HWND,WPARAM,LPARAM); +void MsgInitMenu(HWND,WPARAM,LPARAM); +LRESULT MsgCommand(HWND,WPARAM,LPARAM); +LRESULT MsgNotify(HWND,WPARAM,LPARAM); + + + +/// End of Notepad2.h \\\ diff --git a/src/Notepad2.rc b/src/Notepad2.rc index 7459b772..73d65ece 100644 Binary files a/src/Notepad2.rc and b/src/Notepad2.rc differ diff --git a/src/Notepad2.vcxproj b/src/Notepad2.vcxproj index 8f954098..ccd68ebd 100644 --- a/src/Notepad2.vcxproj +++ b/src/Notepad2.vcxproj @@ -1,244 +1,245 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Win32Proj - {BAAD32AB-CD47-12FD-873C-0BBC204B7641} - Notepad2 - - - - Unicode - Application - v141_xp - true - - - Unicode - Application - v141_xp - false - true - - - Unicode - Application - v141_xp - true - - - Unicode - Application - v141_xp - false - true - - - - - - - - - - - - - - - - - - - false - ..\bin\VS2017\$(Configuration)_x86\obj\ - true - ..\bin\VS2017\$(Configuration)_x86\ - - - false - ..\bin\VS2017\$(Configuration)_x86\obj\ - false - ..\bin\VS2017\$(Configuration)_x86\ - - - false - ..\bin\VS2017\$(Configuration)_x64\obj\ - true - ..\bin\VS2017\$(Configuration)_x64\ - - - false - ..\bin\VS2017\$(Configuration)_x64\obj\ - false - ..\bin\VS2017\$(Configuration)_x64\ - - - - ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) - EnableFastChecks - EditAndContinue - false - true - Disabled - WIN32;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - Level3 - - - comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - true - Windows - MachineX86 - - - ..\update_rev.bat - Generating revision number... - - - WIN32;BOOKMARK_EDITION;%(PreprocessorDefinitions) - - - - - ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) - EnableFastChecks - ProgramDatabase - false - true - Disabled - _WIN64;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - Level3 - - - comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - true - Windows - MachineX64 - - - ..\update_rev.bat - Generating revision number... - - - _WIN64;BOOKMARK_EDITION;%(PreprocessorDefinitions) - - - - - ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) - StreamingSIMDExtensions2 - true - MaxSpeed - WIN32;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - Level3 - - - comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - true - true - .rdata=.text - true - true - Windows - MachineX86 - - - ..\update_rev.bat - Generating revision number... - - - WIN32;BOOKMARK_EDITION;%(PreprocessorDefinitions) - - - - - ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) - true - MaxSpeed - _WIN64;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - Level3 - - - comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - true - true - .rdata=.text - true - true - Windows - MachineX64 - - - ..\update_rev.bat - Generating revision number... - - - _WIN64;BOOKMARK_EDITION;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {5877b917-512b-49f5-b514-1b4159e7a9ca} - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Win32Proj + 10.0 + {BAAD32AB-CD47-12FD-873C-0BBC204B7641} + Notepad2 + + + + Unicode + Application + v143 + true + + + Unicode + Application + v143 + false + true + + + Unicode + Application + v143 + true + + + Unicode + Application + v143 + false + true + + + + + + + + + + + + + + + + + + + false + ..\bin\VS2022\$(Configuration)_x86\obj\ + true + ..\bin\VS2022\$(Configuration)_x86\ + + + false + ..\bin\VS2022\$(Configuration)_x86\obj\ + false + ..\bin\VS2022\$(Configuration)_x86\ + + + false + ..\bin\VS2022\$(Configuration)_x64\obj\ + true + ..\bin\VS2022\$(Configuration)_x64\ + + + false + ..\bin\VS2022\$(Configuration)_x64\obj\ + false + ..\bin\VS2022\$(Configuration)_x64\ + + + + ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) + EnableFastChecks + EditAndContinue + false + true + Disabled + WIN32;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebug + Level3 + + + comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) + true + Windows + MachineX86 + + + ..\update_rev.bat + Generating revision number... + + + WIN32;BOOKMARK_EDITION;%(PreprocessorDefinitions) + + + + + ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) + EnableFastChecks + ProgramDatabase + false + true + Disabled + _WIN64;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDebug + Level3 + + + comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) + true + Windows + MachineX64 + + + ..\update_rev.bat + Generating revision number... + + + _WIN64;BOOKMARK_EDITION;%(PreprocessorDefinitions) + + + + + ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) + StreamingSIMDExtensions2 + true + MaxSpeed + WIN32;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreaded + Level3 + + + comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) + true + true + .rdata=.text + true + true + Windows + MachineX86 + + + ..\update_rev.bat + Generating revision number... + + + WIN32;BOOKMARK_EDITION;%(PreprocessorDefinitions) + + + + + ..\scintilla\include;..\scintilla\lexlib;..\scintilla\src;%(AdditionalIncludeDirectories) + true + MaxSpeed + _WIN64;STATIC_BUILD;SCI_LEXER;BOOKMARK_EDITION;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreaded + Level3 + + + comctl32.lib;imm32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) + true + true + .rdata=.text + true + true + Windows + MachineX64 + + + ..\update_rev.bat + Generating revision number... + + + _WIN64;BOOKMARK_EDITION;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {5877b917-512b-49f5-b514-1b4159e7a9ca} + + + + + \ No newline at end of file diff --git a/src/Notepad2.vcxproj.filters b/src/Notepad2.vcxproj.filters index 886955ae..6b8b665d 100644 --- a/src/Notepad2.vcxproj.filters +++ b/src/Notepad2.vcxproj.filters @@ -1,109 +1,109 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + \ No newline at end of file diff --git a/src/Print.cpp b/src/Print.cpp index 40f49775..19a23707 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -1,606 +1,606 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Print.cpp -* Scintilla Printing Functionality -* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include "platform.h" -#include "scintilla.h" -#include "scilexer.h" -extern "C" { -#include "dialogs.h" -#include "helpers.h" -} -#include "resource.h" - - -extern "C" HINSTANCE g_hInstance; - - -// Global settings... -extern "C" int iPrintHeader; -extern "C" int iPrintFooter; -extern "C" int iPrintColor; -extern "C" int iPrintZoom; -extern "C" RECT pagesetupMargin; - - -// Stored objects... -HGLOBAL hDevMode = NULL; -HGLOBAL hDevNames = NULL; - - -//============================================================================= -// -// EditPrint() - Code from SciTE -// -extern "C" HWND hwndStatus; - -void StatusUpdatePrintPage(int iPageNum) -{ - WCHAR tch[32]; - - FormatString(tch,COUNTOF(tch),IDS_PRINTFILE,iPageNum); - - StatusSetText(hwndStatus,255,tch); - StatusSetSimple(hwndStatus,TRUE); - - InvalidateRect(hwndStatus,NULL,TRUE); - UpdateWindow(hwndStatus); -} - - -extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) -{ - - // Don't print empty documents - if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) { - MsgBox(MBWARN,IDS_PRINT_EMPTY); - return TRUE; - } - - int startPos; - int endPos; - - HDC hdc; - - RECT rectMargins; - RECT rectPhysMargins; - RECT rectSetup; - POINT ptPage; - POINT ptDpi; - - //RECT rectSetup; - - TEXTMETRIC tm; - - int headerLineHeight; - HFONT fontHeader; - - int footerLineHeight; - HFONT fontFooter; - - WCHAR dateString[256]; - - DOCINFO di = {sizeof(DOCINFO), 0, 0, 0, 0}; - - int lengthDoc; - int lengthDocMax; - int lengthPrinted; - - struct Sci_RangeToFormat frPrint; - - int pageNum; - BOOL printPage; - - WCHAR pageString[32]; - - HPEN pen; - HPEN penOld; - - PRINTDLG pdlg = { sizeof(PRINTDLG), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - pdlg.hwndOwner = GetParent(hwnd); - pdlg.hInstance = g_hInstance; - pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC; - pdlg.nFromPage = 1; - pdlg.nToPage = 1; - pdlg.nMinPage = 1; - pdlg.nMaxPage = 0xffffU; - pdlg.nCopies = 1; - pdlg.hDC = 0; - pdlg.hDevMode = hDevMode; - pdlg.hDevNames = hDevNames; - - startPos = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); - endPos = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); - - if (startPos == endPos) { - pdlg.Flags |= PD_NOSELECTION; - } else { - pdlg.Flags |= PD_SELECTION; - } - if (0) { - // Don't display dialog box, just use the default printer and options - pdlg.Flags |= PD_RETURNDEFAULT; - } - if (!PrintDlg(&pdlg)) { - return TRUE; // False means error... - } - - hDevMode = pdlg.hDevMode; - hDevNames = pdlg.hDevNames; - - hdc = pdlg.hDC; - - // Get printer resolution - ptDpi.x = GetDeviceCaps(hdc, LOGPIXELSX); // dpi in X direction - ptDpi.y = GetDeviceCaps(hdc, LOGPIXELSY); // dpi in Y direction - - // Start by getting the physical page size (in device units). - ptPage.x = GetDeviceCaps(hdc, PHYSICALWIDTH); // device units - ptPage.y = GetDeviceCaps(hdc, PHYSICALHEIGHT); // device units - - // Get the dimensions of the unprintable - // part of the page (in device units). - rectPhysMargins.left = GetDeviceCaps(hdc, PHYSICALOFFSETX); - rectPhysMargins.top = GetDeviceCaps(hdc, PHYSICALOFFSETY); - - // To get the right and lower unprintable area, - // we take the entire width and height of the paper and - // subtract everything else. - rectPhysMargins.right = ptPage.x // total paper width - - GetDeviceCaps(hdc, HORZRES) // printable width - - rectPhysMargins.left; // left unprintable margin - - rectPhysMargins.bottom = ptPage.y // total paper height - - GetDeviceCaps(hdc, VERTRES) // printable height - - rectPhysMargins.top; // right unprintable margin - - // At this point, rectPhysMargins contains the widths of the - // unprintable regions on all four sides of the page in device units. - - // Take in account the page setup given by the user (if one value is not null) - if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || - pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { - - // Convert the hundredths of millimeters (HiMetric) or - // thousandths of inches (HiEnglish) margin values - // from the Page Setup dialog to device units. - // (There are 2540 hundredths of a mm in an inch.) - - WCHAR localeInfo[3]; - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); - - if (localeInfo[0] == L'0') { // Metric system. L'1' is US System - rectSetup.left = MulDiv (pagesetupMargin.left, ptDpi.x, 2540); - rectSetup.top = MulDiv (pagesetupMargin.top, ptDpi.y, 2540); - rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 2540); - rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540); - } else { - rectSetup.left = MulDiv(pagesetupMargin.left, ptDpi.x, 1000); - rectSetup.top = MulDiv(pagesetupMargin.top, ptDpi.y, 1000); - rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 1000); - rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000); - } - - // Dont reduce margins below the minimum printable area - rectMargins.left = max(rectPhysMargins.left, rectSetup.left); - rectMargins.top = max(rectPhysMargins.top, rectSetup.top); - rectMargins.right = max(rectPhysMargins.right, rectSetup.right); - rectMargins.bottom = max(rectPhysMargins.bottom, rectSetup.bottom); - } else { - rectMargins.left = rectPhysMargins.left; - rectMargins.top = rectPhysMargins.top; - rectMargins.right = rectPhysMargins.right; - rectMargins.bottom = rectPhysMargins.bottom; - } - - // rectMargins now contains the values used to shrink the printable - // area of the page. - - // Convert device coordinates into logical coordinates - DPtoLP(hdc, (LPPOINT)&rectMargins, 2); - DPtoLP(hdc, (LPPOINT)&rectPhysMargins, 2); - - // Convert page size to logical units and we're done! - DPtoLP(hdc, (LPPOINT) &ptPage, 1); - - headerLineHeight = MulDiv(8,ptDpi.y, 72); - fontHeader = CreateFont(headerLineHeight, - 0, 0, 0, - FW_BOLD, - 0, - 0, - 0, 0, 0, - 0, 0, 0, - L"Arial"); - SelectObject(hdc, fontHeader); - GetTextMetrics(hdc, &tm); - headerLineHeight = tm.tmHeight + tm.tmExternalLeading; - - if (iPrintHeader == 3) - headerLineHeight = 0; - - footerLineHeight = MulDiv(7,ptDpi.y, 72); - fontFooter = CreateFont(footerLineHeight, - 0, 0, 0, - FW_NORMAL, - 0, - 0, - 0, 0, 0, - 0, 0, 0, - L"Arial"); - SelectObject(hdc, fontFooter); - GetTextMetrics(hdc, &tm); - footerLineHeight = tm.tmHeight + tm.tmExternalLeading; - - if (iPrintFooter == 1) - footerLineHeight = 0; - - di.lpszDocName = pszDocTitle; - di.lpszOutput = 0; - di.lpszDatatype = 0; - di.fwType = 0; - if (StartDoc(hdc, &di) < 0) { - DeleteDC(hdc); - if (fontHeader) - DeleteObject(fontHeader); - if (fontFooter) - DeleteObject(fontFooter); - return FALSE; - } - - // Get current date... - SYSTEMTIME st; - GetLocalTime(&st); - GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateString,256); - - // Get current time... - if (iPrintHeader == 0) - { - WCHAR timeString[128]; - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,timeString,128); - lstrcat(dateString,L" "); - lstrcat(dateString,timeString); - } - - // Set print color mode - int printColorModes[5] = { - SC_PRINT_NORMAL, - SC_PRINT_INVERTLIGHT, - SC_PRINT_BLACKONWHITE, - SC_PRINT_COLOURONWHITE, - SC_PRINT_COLOURONWHITEDEFAULTBG }; - SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[iPrintColor],0); - - // Set print zoom... - SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)iPrintZoom,0); - - lengthDoc = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); - lengthDocMax = lengthDoc; - lengthPrinted = 0; - - // Requested to print selection - if (pdlg.Flags & PD_SELECTION) { - if (startPos > endPos) { - lengthPrinted = endPos; - lengthDoc = startPos; - } else { - lengthPrinted = startPos; - lengthDoc = endPos; - } - - if (lengthPrinted < 0) - lengthPrinted = 0; - if (lengthDoc > lengthDocMax) - lengthDoc = lengthDocMax; - } - - // We must substract the physical margins from the printable area - frPrint.hdc = hdc; - frPrint.hdcTarget = hdc; - frPrint.rc.left = rectMargins.left - rectPhysMargins.left; - frPrint.rc.top = rectMargins.top - rectPhysMargins.top; - frPrint.rc.right = ptPage.x - rectMargins.right - rectPhysMargins.left; - frPrint.rc.bottom = ptPage.y - rectMargins.bottom - rectPhysMargins.top; - frPrint.rcPage.left = 0; - frPrint.rcPage.top = 0; - frPrint.rcPage.right = ptPage.x - rectPhysMargins.left - rectPhysMargins.right - 1; - frPrint.rcPage.bottom = ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1; - frPrint.rc.top += headerLineHeight + headerLineHeight / 2; - frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2; - // Print each page - pageNum = 1; - - while (lengthPrinted < lengthDoc) { - printPage = (!(pdlg.Flags & PD_PAGENUMS) || - (pageNum >= pdlg.nFromPage) && (pageNum <= pdlg.nToPage)); - - wsprintf(pageString, pszPageFormat, pageNum); - - if (printPage) { - - // Show wait cursor... - BeginWaitCursor(); - - // Display current page number in Statusbar - StatusUpdatePrintPage(pageNum); - - StartPage(hdc); - - SetTextColor(hdc, RGB(0,0,0)); - SetBkColor(hdc, RGB(255,255,255)); - SelectObject(hdc, fontHeader); - UINT ta = SetTextAlign(hdc, TA_BOTTOM); - RECT rcw = {frPrint.rc.left, frPrint.rc.top - headerLineHeight - headerLineHeight / 2, - frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2}; - rcw.bottom = rcw.top + headerLineHeight; - - if (iPrintHeader < 3) - { - ExtTextOut(hdc, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, - /*ETO_OPAQUE*/0, &rcw, pszDocTitle, - lstrlen(pszDocTitle), NULL); - } - - // Print date in header - if (iPrintHeader == 0 || iPrintHeader == 1) - { - SIZE sizeInfo; - SelectObject(hdc,fontFooter); - GetTextExtentPoint32(hdc,dateString,lstrlen(dateString),&sizeInfo); - ExtTextOut(hdc, frPrint.rc.right - 5 - sizeInfo.cx, frPrint.rc.top - headerLineHeight / 2, - /*ETO_OPAQUE*/0, &rcw, dateString, - lstrlen(dateString), NULL); - } - - if (iPrintHeader < 3) - { - SetTextAlign(hdc, ta); - pen = CreatePen(0, 1, RGB(0,0,0)); - penOld = (HPEN)SelectObject(hdc, pen); - MoveToEx(hdc, frPrint.rc.left, frPrint.rc.top - headerLineHeight / 4, NULL); - LineTo(hdc, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 4); - SelectObject(hdc, penOld); - DeleteObject(pen); - } - } - - frPrint.chrg.cpMin = lengthPrinted; - frPrint.chrg.cpMax = lengthDoc; - - lengthPrinted = (int)SendMessage(hwnd, SCI_FORMATRANGE, printPage, (LPARAM)&frPrint); - - if (printPage) { - SetTextColor(hdc, RGB(0,0,0)); - SetBkColor(hdc, RGB(255,255,255)); - SelectObject(hdc, fontFooter); - UINT ta = SetTextAlign(hdc, TA_TOP); - RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2, - frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2}; - - if (iPrintFooter == 0) - { - SIZE sizeFooter; - GetTextExtentPoint32(hdc,pageString,lstrlen(pageString),&sizeFooter); - ExtTextOut(hdc, frPrint.rc.right - 5 - sizeFooter.cx, frPrint.rc.bottom + footerLineHeight / 2, - /*ETO_OPAQUE*/0, &rcw, pageString, - lstrlen(pageString), NULL); - - SetTextAlign(hdc, ta); - pen = ::CreatePen(0, 1, RGB(0,0,0)); - penOld = (HPEN)SelectObject(hdc, pen); - SetBkColor(hdc, RGB(0,0,0)); - MoveToEx(hdc, frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 4, NULL); - LineTo(hdc, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight / 4); - SelectObject(hdc, penOld); - DeleteObject(pen); - } - - EndPage(hdc); - } - pageNum++; - - if ((pdlg.Flags & PD_PAGENUMS) && (pageNum > pdlg.nToPage)) - break; - } - - SendMessage(hwnd,SCI_FORMATRANGE, FALSE, 0); - - EndDoc(hdc); - DeleteDC(hdc); - if (fontHeader) - DeleteObject(fontHeader); - if (fontFooter) - DeleteObject(fontFooter); - - // Reset Statusbar to default mode - StatusSetSimple(hwndStatus,FALSE); - - // Remove wait cursor... - EndWaitCursor(); - - return TRUE; -} - - -//============================================================================= -// -// EditPrintSetup() - Code from SciTE -// -// Custom controls: 30 Zoom -// 31 Spin -// 32 Header -// 33 Footer -// 34 Colors -// -extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uiMsg) - { - case WM_INITDIALOG: - { - WCHAR tch[512]; - WCHAR *p1,*p2; - - SendDlgItemMessage(hwnd,30,EM_LIMITTEXT,32,0); - - SendDlgItemMessage(hwnd,31,UDM_SETRANGE,0,MAKELONG((short)20,(short)-10)); - SendDlgItemMessage(hwnd,31,UDM_SETPOS,0,MAKELONG((short)iPrintZoom,0)); - - // Set header options - GetString(IDS_PRINT_HEADER,tch,COUNTOF(tch)); - lstrcat(tch,L"|"); - p1 = tch; - while (p2 = StrChr(p1,L'|')) { - *p2++ = L'\0'; - if (*p1) - SendDlgItemMessage(hwnd,32,CB_ADDSTRING,0,(LPARAM)p1); - p1 = p2; } - SendDlgItemMessage(hwnd,32,CB_SETCURSEL,(WPARAM)iPrintHeader,0); - - // Set footer options - GetString(IDS_PRINT_FOOTER,tch,COUNTOF(tch)); - lstrcat(tch,L"|"); - p1 = tch; - while (p2 = StrChr(p1,L'|')) { - *p2++ = L'\0'; - if (*p1) - SendDlgItemMessage(hwnd,33,CB_ADDSTRING,0,(LPARAM)p1); - p1 = p2; } - SendDlgItemMessage(hwnd,33,CB_SETCURSEL,(WPARAM)iPrintFooter,0); - - // Set color options - GetString(IDS_PRINT_COLOR,tch,COUNTOF(tch)); - lstrcat(tch,L"|"); - p1 = tch; - while (p2 = StrChr(p1,L'|')) { - *p2++ = L'\0'; - if (*p1) - SendDlgItemMessage(hwnd,34,CB_ADDSTRING,0,(LPARAM)p1); - p1 = p2; } - SendDlgItemMessage(hwnd,34,CB_SETCURSEL,(WPARAM)iPrintColor,0); - - // Make combos handier - SendDlgItemMessage(hwnd,32,CB_SETEXTENDEDUI,TRUE,0); - SendDlgItemMessage(hwnd,33,CB_SETEXTENDEDUI,TRUE,0); - SendDlgItemMessage(hwnd,34,CB_SETEXTENDEDUI,TRUE,0); - SendDlgItemMessage(hwnd,1137,CB_SETEXTENDEDUI,TRUE,0); - SendDlgItemMessage(hwnd,1138,CB_SETEXTENDEDUI,TRUE,0); - } - break; - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK) - { - int iPos = (int)SendDlgItemMessage(hwnd,31,UDM_GETPOS,0,0); - if (HIWORD(iPos) == 0) - iPrintZoom = (int)(short)LOWORD(iPos); - else - iPrintZoom = 0; - - iPrintHeader = (int)SendDlgItemMessage(hwnd, 32, CB_GETCURSEL, 0, 0); - iPrintFooter = (int)SendDlgItemMessage(hwnd, 33, CB_GETCURSEL, 0, 0); - iPrintColor = (int)SendDlgItemMessage(hwnd, 34, CB_GETCURSEL, 0, 0); - } - break; - - default: - break; - } - return(0); -} - - -extern "C" void EditPrintSetup(HWND hwnd) -{ - DLGTEMPLATE* pDlgTemplate = - LoadThemedDialogTemplate(MAKEINTRESOURCE(IDD_PAGESETUP),g_hInstance); - - PAGESETUPDLG pdlg; - ZeroMemory(&pdlg,sizeof(PAGESETUPDLG)); - pdlg.lStructSize = sizeof(PAGESETUPDLG); - pdlg.Flags = PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGESETUPTEMPLATEHANDLE; - pdlg.lpfnPageSetupHook = PageSetupHook; - pdlg.hPageSetupTemplate = pDlgTemplate; - pdlg.hwndOwner = GetParent(hwnd); - pdlg.hInstance = g_hInstance; - - if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || - pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { - pdlg.Flags |= PSD_MARGINS; - - pdlg.rtMargin.left = pagesetupMargin.left; - pdlg.rtMargin.top = pagesetupMargin.top; - pdlg.rtMargin.right = pagesetupMargin.right; - pdlg.rtMargin.bottom = pagesetupMargin.bottom; - } - - pdlg.hDevMode = hDevMode; - pdlg.hDevNames = hDevNames; - - if (PageSetupDlg(&pdlg)) { - - pagesetupMargin.left = pdlg.rtMargin.left; - pagesetupMargin.top = pdlg.rtMargin.top; - pagesetupMargin.right = pdlg.rtMargin.right; - pagesetupMargin.bottom = pdlg.rtMargin.bottom; - - hDevMode = pdlg.hDevMode; - hDevNames = pdlg.hDevNames; - } - - LocalFree(pDlgTemplate); -} - - -//============================================================================= -// -// EditPrintInit() - Setup default page margin if no values from registry -// -extern "C" void EditPrintInit() -{ - if (pagesetupMargin.left == -1 || pagesetupMargin.top == -1 || - pagesetupMargin.right == -1 || pagesetupMargin.bottom == -1) - { - WCHAR localeInfo[3]; - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); - - if (localeInfo[0] == L'0') { // Metric system. L'1' is US System - pagesetupMargin.left = 2000; - pagesetupMargin.top = 2000; - pagesetupMargin.right = 2000; - pagesetupMargin.bottom = 2000; } - - else { - pagesetupMargin.left = 1000; - pagesetupMargin.top = 1000; - pagesetupMargin.right = 1000; - pagesetupMargin.bottom = 1000; } - } -} - - -// End of Print.cpp +/****************************************************************************** +* +* +* Notepad2 +* +* Print.cpp +* Scintilla Printing Functionality +* Mostly taken from SciTE, (c) Neil Hodgson, http://www.scintilla.org +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include "platform.h" +#include "scintilla.h" +#include "scilexer.h" +extern "C" { +#include "dialogs.h" +#include "helpers.h" +} +#include "resource.h" + + +extern "C" HINSTANCE g_hInstance; + + +// Global settings... +extern "C" int iPrintHeader; +extern "C" int iPrintFooter; +extern "C" int iPrintColor; +extern "C" int iPrintZoom; +extern "C" RECT pagesetupMargin; + + +// Stored objects... +HGLOBAL hDevMode = NULL; +HGLOBAL hDevNames = NULL; + + +//============================================================================= +// +// EditPrint() - Code from SciTE +// +extern "C" HWND hwndStatus; + +void StatusUpdatePrintPage(int iPageNum) +{ + WCHAR tch[32]; + + FormatString(tch,COUNTOF(tch),IDS_PRINTFILE,iPageNum); + + StatusSetText(hwndStatus,255,tch); + StatusSetSimple(hwndStatus,TRUE); + + InvalidateRect(hwndStatus,NULL,TRUE); + UpdateWindow(hwndStatus); +} + + +extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) +{ + + // Don't print empty documents + if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) { + MsgBox(MBWARN,IDS_PRINT_EMPTY); + return TRUE; + } + + int startPos; + int endPos; + + HDC hdc; + + RECT rectMargins; + RECT rectPhysMargins; + RECT rectSetup; + POINT ptPage; + POINT ptDpi; + + //RECT rectSetup; + + TEXTMETRIC tm; + + int headerLineHeight; + HFONT fontHeader; + + int footerLineHeight; + HFONT fontFooter; + + WCHAR dateString[256]; + + DOCINFO di = {sizeof(DOCINFO), 0, 0, 0, 0}; + + int lengthDoc; + int lengthDocMax; + int lengthPrinted; + + struct Sci_RangeToFormat frPrint; + + int pageNum; + BOOL printPage; + + WCHAR pageString[32]; + + HPEN pen; + HPEN penOld; + + PRINTDLG pdlg = { sizeof(PRINTDLG), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + pdlg.hwndOwner = GetParent(hwnd); + pdlg.hInstance = g_hInstance; + pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC; + pdlg.nFromPage = 1; + pdlg.nToPage = 1; + pdlg.nMinPage = 1; + pdlg.nMaxPage = 0xffffU; + pdlg.nCopies = 1; + pdlg.hDC = 0; + pdlg.hDevMode = hDevMode; + pdlg.hDevNames = hDevNames; + + startPos = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); + endPos = (int)SendMessage(hwnd,SCI_GETSELECTIONEND,0,0); + + if (startPos == endPos) { + pdlg.Flags |= PD_NOSELECTION; + } else { + pdlg.Flags |= PD_SELECTION; + } + if (0) { + // Don't display dialog box, just use the default printer and options + pdlg.Flags |= PD_RETURNDEFAULT; + } + if (!PrintDlg(&pdlg)) { + return TRUE; // False means error... + } + + hDevMode = pdlg.hDevMode; + hDevNames = pdlg.hDevNames; + + hdc = pdlg.hDC; + + // Get printer resolution + ptDpi.x = GetDeviceCaps(hdc, LOGPIXELSX); // dpi in X direction + ptDpi.y = GetDeviceCaps(hdc, LOGPIXELSY); // dpi in Y direction + + // Start by getting the physical page size (in device units). + ptPage.x = GetDeviceCaps(hdc, PHYSICALWIDTH); // device units + ptPage.y = GetDeviceCaps(hdc, PHYSICALHEIGHT); // device units + + // Get the dimensions of the unprintable + // part of the page (in device units). + rectPhysMargins.left = GetDeviceCaps(hdc, PHYSICALOFFSETX); + rectPhysMargins.top = GetDeviceCaps(hdc, PHYSICALOFFSETY); + + // To get the right and lower unprintable area, + // we take the entire width and height of the paper and + // subtract everything else. + rectPhysMargins.right = ptPage.x // total paper width + - GetDeviceCaps(hdc, HORZRES) // printable width + - rectPhysMargins.left; // left unprintable margin + + rectPhysMargins.bottom = ptPage.y // total paper height + - GetDeviceCaps(hdc, VERTRES) // printable height + - rectPhysMargins.top; // right unprintable margin + + // At this point, rectPhysMargins contains the widths of the + // unprintable regions on all four sides of the page in device units. + + // Take in account the page setup given by the user (if one value is not null) + if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || + pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { + + // Convert the hundredths of millimeters (HiMetric) or + // thousandths of inches (HiEnglish) margin values + // from the Page Setup dialog to device units. + // (There are 2540 hundredths of a mm in an inch.) + + WCHAR localeInfo[3]; + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); + + if (localeInfo[0] == L'0') { // Metric system. L'1' is US System + rectSetup.left = MulDiv (pagesetupMargin.left, ptDpi.x, 2540); + rectSetup.top = MulDiv (pagesetupMargin.top, ptDpi.y, 2540); + rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 2540); + rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540); + } else { + rectSetup.left = MulDiv(pagesetupMargin.left, ptDpi.x, 1000); + rectSetup.top = MulDiv(pagesetupMargin.top, ptDpi.y, 1000); + rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 1000); + rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000); + } + + // Dont reduce margins below the minimum printable area + rectMargins.left = max(rectPhysMargins.left, rectSetup.left); + rectMargins.top = max(rectPhysMargins.top, rectSetup.top); + rectMargins.right = max(rectPhysMargins.right, rectSetup.right); + rectMargins.bottom = max(rectPhysMargins.bottom, rectSetup.bottom); + } else { + rectMargins.left = rectPhysMargins.left; + rectMargins.top = rectPhysMargins.top; + rectMargins.right = rectPhysMargins.right; + rectMargins.bottom = rectPhysMargins.bottom; + } + + // rectMargins now contains the values used to shrink the printable + // area of the page. + + // Convert device coordinates into logical coordinates + DPtoLP(hdc, (LPPOINT)&rectMargins, 2); + DPtoLP(hdc, (LPPOINT)&rectPhysMargins, 2); + + // Convert page size to logical units and we're done! + DPtoLP(hdc, (LPPOINT) &ptPage, 1); + + headerLineHeight = MulDiv(8,ptDpi.y, 72); + fontHeader = CreateFont(headerLineHeight, + 0, 0, 0, + FW_BOLD, + 0, + 0, + 0, 0, 0, + 0, 0, 0, + L"Arial"); + SelectObject(hdc, fontHeader); + GetTextMetrics(hdc, &tm); + headerLineHeight = tm.tmHeight + tm.tmExternalLeading; + + if (iPrintHeader == 3) + headerLineHeight = 0; + + footerLineHeight = MulDiv(7,ptDpi.y, 72); + fontFooter = CreateFont(footerLineHeight, + 0, 0, 0, + FW_NORMAL, + 0, + 0, + 0, 0, 0, + 0, 0, 0, + L"Arial"); + SelectObject(hdc, fontFooter); + GetTextMetrics(hdc, &tm); + footerLineHeight = tm.tmHeight + tm.tmExternalLeading; + + if (iPrintFooter == 1) + footerLineHeight = 0; + + di.lpszDocName = pszDocTitle; + di.lpszOutput = 0; + di.lpszDatatype = 0; + di.fwType = 0; + if (StartDoc(hdc, &di) < 0) { + DeleteDC(hdc); + if (fontHeader) + DeleteObject(fontHeader); + if (fontFooter) + DeleteObject(fontFooter); + return FALSE; + } + + // Get current date... + SYSTEMTIME st; + GetLocalTime(&st); + GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateString,256); + + // Get current time... + if (iPrintHeader == 0) + { + WCHAR timeString[128]; + GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,timeString,128); + lstrcat(dateString,L" "); + lstrcat(dateString,timeString); + } + + // Set print color mode + int printColorModes[5] = { + SC_PRINT_NORMAL, + SC_PRINT_INVERTLIGHT, + SC_PRINT_BLACKONWHITE, + SC_PRINT_COLOURONWHITE, + SC_PRINT_COLOURONWHITEDEFAULTBG }; + SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[iPrintColor],0); + + // Set print zoom... + SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)iPrintZoom,0); + + lengthDoc = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); + lengthDocMax = lengthDoc; + lengthPrinted = 0; + + // Requested to print selection + if (pdlg.Flags & PD_SELECTION) { + if (startPos > endPos) { + lengthPrinted = endPos; + lengthDoc = startPos; + } else { + lengthPrinted = startPos; + lengthDoc = endPos; + } + + if (lengthPrinted < 0) + lengthPrinted = 0; + if (lengthDoc > lengthDocMax) + lengthDoc = lengthDocMax; + } + + // We must substract the physical margins from the printable area + frPrint.hdc = hdc; + frPrint.hdcTarget = hdc; + frPrint.rc.left = rectMargins.left - rectPhysMargins.left; + frPrint.rc.top = rectMargins.top - rectPhysMargins.top; + frPrint.rc.right = ptPage.x - rectMargins.right - rectPhysMargins.left; + frPrint.rc.bottom = ptPage.y - rectMargins.bottom - rectPhysMargins.top; + frPrint.rcPage.left = 0; + frPrint.rcPage.top = 0; + frPrint.rcPage.right = ptPage.x - rectPhysMargins.left - rectPhysMargins.right - 1; + frPrint.rcPage.bottom = ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1; + frPrint.rc.top += headerLineHeight + headerLineHeight / 2; + frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2; + // Print each page + pageNum = 1; + + while (lengthPrinted < lengthDoc) { + printPage = (!(pdlg.Flags & PD_PAGENUMS) || + (pageNum >= pdlg.nFromPage) && (pageNum <= pdlg.nToPage)); + + wsprintf(pageString, pszPageFormat, pageNum); + + if (printPage) { + + // Show wait cursor... + BeginWaitCursor(); + + // Display current page number in Statusbar + StatusUpdatePrintPage(pageNum); + + StartPage(hdc); + + SetTextColor(hdc, RGB(0,0,0)); + SetBkColor(hdc, RGB(255,255,255)); + SelectObject(hdc, fontHeader); + UINT ta = SetTextAlign(hdc, TA_BOTTOM); + RECT rcw = {frPrint.rc.left, frPrint.rc.top - headerLineHeight - headerLineHeight / 2, + frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2}; + rcw.bottom = rcw.top + headerLineHeight; + + if (iPrintHeader < 3) + { + ExtTextOut(hdc, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, + /*ETO_OPAQUE*/0, &rcw, pszDocTitle, + lstrlen(pszDocTitle), NULL); + } + + // Print date in header + if (iPrintHeader == 0 || iPrintHeader == 1) + { + SIZE sizeInfo; + SelectObject(hdc,fontFooter); + GetTextExtentPoint32(hdc,dateString,lstrlen(dateString),&sizeInfo); + ExtTextOut(hdc, frPrint.rc.right - 5 - sizeInfo.cx, frPrint.rc.top - headerLineHeight / 2, + /*ETO_OPAQUE*/0, &rcw, dateString, + lstrlen(dateString), NULL); + } + + if (iPrintHeader < 3) + { + SetTextAlign(hdc, ta); + pen = CreatePen(0, 1, RGB(0,0,0)); + penOld = (HPEN)SelectObject(hdc, pen); + MoveToEx(hdc, frPrint.rc.left, frPrint.rc.top - headerLineHeight / 4, NULL); + LineTo(hdc, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 4); + SelectObject(hdc, penOld); + DeleteObject(pen); + } + } + + frPrint.chrg.cpMin = lengthPrinted; + frPrint.chrg.cpMax = lengthDoc; + + lengthPrinted = (int)SendMessage(hwnd, SCI_FORMATRANGE, printPage, (LPARAM)&frPrint); + + if (printPage) { + SetTextColor(hdc, RGB(0,0,0)); + SetBkColor(hdc, RGB(255,255,255)); + SelectObject(hdc, fontFooter); + UINT ta = SetTextAlign(hdc, TA_TOP); + RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2, + frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2}; + + if (iPrintFooter == 0) + { + SIZE sizeFooter; + GetTextExtentPoint32(hdc,pageString,lstrlen(pageString),&sizeFooter); + ExtTextOut(hdc, frPrint.rc.right - 5 - sizeFooter.cx, frPrint.rc.bottom + footerLineHeight / 2, + /*ETO_OPAQUE*/0, &rcw, pageString, + lstrlen(pageString), NULL); + + SetTextAlign(hdc, ta); + pen = ::CreatePen(0, 1, RGB(0,0,0)); + penOld = (HPEN)SelectObject(hdc, pen); + SetBkColor(hdc, RGB(0,0,0)); + MoveToEx(hdc, frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 4, NULL); + LineTo(hdc, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight / 4); + SelectObject(hdc, penOld); + DeleteObject(pen); + } + + EndPage(hdc); + } + pageNum++; + + if ((pdlg.Flags & PD_PAGENUMS) && (pageNum > pdlg.nToPage)) + break; + } + + SendMessage(hwnd,SCI_FORMATRANGE, FALSE, 0); + + EndDoc(hdc); + DeleteDC(hdc); + if (fontHeader) + DeleteObject(fontHeader); + if (fontFooter) + DeleteObject(fontFooter); + + // Reset Statusbar to default mode + StatusSetSimple(hwndStatus,FALSE); + + // Remove wait cursor... + EndWaitCursor(); + + return TRUE; +} + + +//============================================================================= +// +// EditPrintSetup() - Code from SciTE +// +// Custom controls: 30 Zoom +// 31 Spin +// 32 Header +// 33 Footer +// 34 Colors +// +extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uiMsg) + { + case WM_INITDIALOG: + { + WCHAR tch[512]; + WCHAR *p1,*p2; + + SendDlgItemMessage(hwnd,30,EM_LIMITTEXT,32,0); + + SendDlgItemMessage(hwnd,31,UDM_SETRANGE,0,MAKELONG((short)20,(short)-10)); + SendDlgItemMessage(hwnd,31,UDM_SETPOS,0,MAKELONG((short)iPrintZoom,0)); + + // Set header options + GetString(IDS_PRINT_HEADER,tch,COUNTOF(tch)); + lstrcat(tch,L"|"); + p1 = tch; + while (p2 = StrChr(p1,L'|')) { + *p2++ = L'\0'; + if (*p1) + SendDlgItemMessage(hwnd,32,CB_ADDSTRING,0,(LPARAM)p1); + p1 = p2; } + SendDlgItemMessage(hwnd,32,CB_SETCURSEL,(WPARAM)iPrintHeader,0); + + // Set footer options + GetString(IDS_PRINT_FOOTER,tch,COUNTOF(tch)); + lstrcat(tch,L"|"); + p1 = tch; + while (p2 = StrChr(p1,L'|')) { + *p2++ = L'\0'; + if (*p1) + SendDlgItemMessage(hwnd,33,CB_ADDSTRING,0,(LPARAM)p1); + p1 = p2; } + SendDlgItemMessage(hwnd,33,CB_SETCURSEL,(WPARAM)iPrintFooter,0); + + // Set color options + GetString(IDS_PRINT_COLOR,tch,COUNTOF(tch)); + lstrcat(tch,L"|"); + p1 = tch; + while (p2 = StrChr(p1,L'|')) { + *p2++ = L'\0'; + if (*p1) + SendDlgItemMessage(hwnd,34,CB_ADDSTRING,0,(LPARAM)p1); + p1 = p2; } + SendDlgItemMessage(hwnd,34,CB_SETCURSEL,(WPARAM)iPrintColor,0); + + // Make combos handier + SendDlgItemMessage(hwnd,32,CB_SETEXTENDEDUI,TRUE,0); + SendDlgItemMessage(hwnd,33,CB_SETEXTENDEDUI,TRUE,0); + SendDlgItemMessage(hwnd,34,CB_SETEXTENDEDUI,TRUE,0); + SendDlgItemMessage(hwnd,1137,CB_SETEXTENDEDUI,TRUE,0); + SendDlgItemMessage(hwnd,1138,CB_SETEXTENDEDUI,TRUE,0); + } + break; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK) + { + int iPos = (int)SendDlgItemMessage(hwnd,31,UDM_GETPOS,0,0); + if (HIWORD(iPos) == 0) + iPrintZoom = (int)(short)LOWORD(iPos); + else + iPrintZoom = 0; + + iPrintHeader = (int)SendDlgItemMessage(hwnd, 32, CB_GETCURSEL, 0, 0); + iPrintFooter = (int)SendDlgItemMessage(hwnd, 33, CB_GETCURSEL, 0, 0); + iPrintColor = (int)SendDlgItemMessage(hwnd, 34, CB_GETCURSEL, 0, 0); + } + break; + + default: + break; + } + return(0); +} + + +extern "C" void EditPrintSetup(HWND hwnd) +{ + DLGTEMPLATE* pDlgTemplate = + LoadThemedDialogTemplate(MAKEINTRESOURCE(IDD_PAGESETUP),g_hInstance); + + PAGESETUPDLG pdlg; + ZeroMemory(&pdlg,sizeof(PAGESETUPDLG)); + pdlg.lStructSize = sizeof(PAGESETUPDLG); + pdlg.Flags = PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGESETUPTEMPLATEHANDLE; + pdlg.lpfnPageSetupHook = PageSetupHook; + pdlg.hPageSetupTemplate = pDlgTemplate; + pdlg.hwndOwner = GetParent(hwnd); + pdlg.hInstance = g_hInstance; + + if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || + pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { + pdlg.Flags |= PSD_MARGINS; + + pdlg.rtMargin.left = pagesetupMargin.left; + pdlg.rtMargin.top = pagesetupMargin.top; + pdlg.rtMargin.right = pagesetupMargin.right; + pdlg.rtMargin.bottom = pagesetupMargin.bottom; + } + + pdlg.hDevMode = hDevMode; + pdlg.hDevNames = hDevNames; + + if (PageSetupDlg(&pdlg)) { + + pagesetupMargin.left = pdlg.rtMargin.left; + pagesetupMargin.top = pdlg.rtMargin.top; + pagesetupMargin.right = pdlg.rtMargin.right; + pagesetupMargin.bottom = pdlg.rtMargin.bottom; + + hDevMode = pdlg.hDevMode; + hDevNames = pdlg.hDevNames; + } + + LocalFree(pDlgTemplate); +} + + +//============================================================================= +// +// EditPrintInit() - Setup default page margin if no values from registry +// +extern "C" void EditPrintInit() +{ + if (pagesetupMargin.left == -1 || pagesetupMargin.top == -1 || + pagesetupMargin.right == -1 || pagesetupMargin.bottom == -1) + { + WCHAR localeInfo[3]; + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); + + if (localeInfo[0] == L'0') { // Metric system. L'1' is US System + pagesetupMargin.left = 2000; + pagesetupMargin.top = 2000; + pagesetupMargin.right = 2000; + pagesetupMargin.bottom = 2000; } + + else { + pagesetupMargin.left = 1000; + pagesetupMargin.top = 1000; + pagesetupMargin.right = 1000; + pagesetupMargin.bottom = 1000; } + } +} + + +// End of Print.cpp diff --git a/src/SciCall.h b/src/SciCall.h index e94f7a69..6b59572f 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -1,147 +1,147 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* SciCall.h -* Inline wrappers for Scintilla API calls, arranged in the order and grouping -* in which they appear in the Scintilla documentation. -* -* The use of these inline wrapper functions with declared types will ensure -* that we get the benefit of the compiler's type checking. -* -* -******************************************************************************/ - - -//============================================================================= -// -// g_hScintilla -// -// -extern HANDLE g_hScintilla; - -__forceinline void InitScintillaHandle(HWND hwnd) { - g_hScintilla = (HANDLE)SendMessage(hwnd, SCI_GETDIRECTPOINTER, 0, 0); -} - - -//============================================================================= -// -// SciCall() -// -// -LRESULT WINAPI Scintilla_DirectFunction(HANDLE, UINT, WPARAM, LPARAM); -#define SciCall(m, w, l) Scintilla_DirectFunction(g_hScintilla, m, w, l) - - -//============================================================================= -// -// DeclareSciCall[RV][0-2] Macros -// -// R: With an explicit return type -// V: No return type defined ("void"); defaults to SendMessage's LRESULT -// 0-2: Number of parameters to define -// -// -#define DeclareSciCallR0(fn, msg, ret) \ -__forceinline ret SciCall_##fn() { \ - return((ret)SciCall(SCI_##msg, 0, 0)); \ -} -#define DeclareSciCallR1(fn, msg, ret, type1, var1) \ -__forceinline ret SciCall_##fn(type1 var1) { \ - return((ret)SciCall(SCI_##msg, (WPARAM)(var1), 0)); \ -} -#define DeclareSciCallR2(fn, msg, ret, type1, var1, type2, var2) \ -__forceinline ret SciCall_##fn(type1 var1, type2 var2) { \ - return((ret)SciCall(SCI_##msg, (WPARAM)(var1), (LPARAM)(var2))); \ -} -#define DeclareSciCallV0(fn, msg) \ -__forceinline LRESULT SciCall_##fn() { \ - return(SciCall(SCI_##msg, 0, 0)); \ -} -#define DeclareSciCallV1(fn, msg, type1, var1) \ -__forceinline LRESULT SciCall_##fn(type1 var1) { \ - return(SciCall(SCI_##msg, (WPARAM)(var1), 0)); \ -} -#define DeclareSciCallV2(fn, msg, type1, var1, type2, var2) \ -__forceinline LRESULT SciCall_##fn(type1 var1, type2 var2) { \ - return(SciCall(SCI_##msg, (WPARAM)(var1), (LPARAM)(var2))); \ -} - - -//============================================================================= -// -// Selection and information -// -// -DeclareSciCallR0(GetLineCount, GETLINECOUNT, int); -DeclareSciCallV2(SetSel, SETSEL, int, anchorPos, int, currentPos); -DeclareSciCallV1(GotoPos, GOTOPOS, int, position); -DeclareSciCallV1(GotoLine, GOTOLINE, int, line); -DeclareSciCallR0(GetCurrentPos, GETCURRENTPOS, int); -DeclareSciCallR1(LineFromPosition, LINEFROMPOSITION, int, int, position); - - -//============================================================================= -// -// Scrolling and automatic scrolling -// -// -DeclareSciCallV0(ScrollCaret, SCROLLCARET); -DeclareSciCallV2(SetXCaretPolicy, SETXCARETPOLICY, int, caretPolicy, int, caretSlop); -DeclareSciCallV2(SetYCaretPolicy, SETYCARETPOLICY, int, caretPolicy, int, caretSlop); - - -//============================================================================= -// -// Style definition -// -// -DeclareSciCallR1(StyleGetFore, STYLEGETFORE, COLORREF, int, styleNumber); -DeclareSciCallR1(StyleGetBack, STYLEGETBACK, COLORREF, int, styleNumber); - - -//============================================================================= -// -// Margins -// -// -DeclareSciCallV2(SetMarginType, SETMARGINTYPEN, int, margin, int, type); -DeclareSciCallV2(SetMarginWidth, SETMARGINWIDTHN, int, margin, int, pixelWidth); -DeclareSciCallV2(SetMarginMask, SETMARGINMASKN, int, margin, int, mask); -DeclareSciCallV2(SetMarginSensitive, SETMARGINSENSITIVEN, int, margin, BOOL, sensitive); -DeclareSciCallV2(SetFoldMarginColour, SETFOLDMARGINCOLOUR, BOOL, useSetting, COLORREF, colour); -DeclareSciCallV2(SetFoldMarginHiColour, SETFOLDMARGINHICOLOUR, BOOL, useSetting, COLORREF, colour); - - -//============================================================================= -// -// Markers -// -// -DeclareSciCallV2(MarkerDefine, MARKERDEFINE, int, markerNumber, int, markerSymbols); -DeclareSciCallV2(MarkerSetFore, MARKERSETFORE, int, markerNumber, COLORREF, colour); -DeclareSciCallV2(MarkerSetBack, MARKERSETBACK, int, markerNumber, COLORREF, colour); - - -//============================================================================= -// -// Folding -// -// -DeclareSciCallR1(GetLineVisible, GETLINEVISIBLE, BOOL, int, line); -DeclareSciCallR1(GetFoldLevel, GETFOLDLEVEL, int, int, line); -DeclareSciCallV1(SetFoldFlags, SETFOLDFLAGS, int, flags); -DeclareSciCallR1(GetFoldParent, GETFOLDPARENT, int, int, line); -DeclareSciCallR1(GetFoldExpanded, GETFOLDEXPANDED, int, int, line); -DeclareSciCallV1(ToggleFold, TOGGLEFOLD, int, line); -DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, int, line); - - -//============================================================================= -// -// Lexer -// -// -DeclareSciCallV2(SetProperty, SETPROPERTY, const char *, key, const char *, value); +/****************************************************************************** +* +* +* Notepad2 +* +* SciCall.h +* Inline wrappers for Scintilla API calls, arranged in the order and grouping +* in which they appear in the Scintilla documentation. +* +* The use of these inline wrapper functions with declared types will ensure +* that we get the benefit of the compiler's type checking. +* +* +******************************************************************************/ + + +//============================================================================= +// +// g_hScintilla +// +// +extern HANDLE g_hScintilla; + +__forceinline void InitScintillaHandle(HWND hwnd) { + g_hScintilla = (HANDLE)SendMessage(hwnd, SCI_GETDIRECTPOINTER, 0, 0); +} + + +//============================================================================= +// +// SciCall() +// +// +LRESULT WINAPI Scintilla_DirectFunction(HANDLE, UINT, WPARAM, LPARAM); +#define SciCall(m, w, l) Scintilla_DirectFunction(g_hScintilla, m, w, l) + + +//============================================================================= +// +// DeclareSciCall[RV][0-2] Macros +// +// R: With an explicit return type +// V: No return type defined ("void"); defaults to SendMessage's LRESULT +// 0-2: Number of parameters to define +// +// +#define DeclareSciCallR0(fn, msg, ret) \ +__forceinline ret SciCall_##fn() { \ + return((ret)SciCall(SCI_##msg, 0, 0)); \ +} +#define DeclareSciCallR1(fn, msg, ret, type1, var1) \ +__forceinline ret SciCall_##fn(type1 var1) { \ + return((ret)SciCall(SCI_##msg, (WPARAM)(var1), 0)); \ +} +#define DeclareSciCallR2(fn, msg, ret, type1, var1, type2, var2) \ +__forceinline ret SciCall_##fn(type1 var1, type2 var2) { \ + return((ret)SciCall(SCI_##msg, (WPARAM)(var1), (LPARAM)(var2))); \ +} +#define DeclareSciCallV0(fn, msg) \ +__forceinline LRESULT SciCall_##fn() { \ + return(SciCall(SCI_##msg, 0, 0)); \ +} +#define DeclareSciCallV1(fn, msg, type1, var1) \ +__forceinline LRESULT SciCall_##fn(type1 var1) { \ + return(SciCall(SCI_##msg, (WPARAM)(var1), 0)); \ +} +#define DeclareSciCallV2(fn, msg, type1, var1, type2, var2) \ +__forceinline LRESULT SciCall_##fn(type1 var1, type2 var2) { \ + return(SciCall(SCI_##msg, (WPARAM)(var1), (LPARAM)(var2))); \ +} + + +//============================================================================= +// +// Selection and information +// +// +DeclareSciCallR0(GetLineCount, GETLINECOUNT, int); +DeclareSciCallV2(SetSel, SETSEL, int, anchorPos, int, currentPos); +DeclareSciCallV1(GotoPos, GOTOPOS, int, position); +DeclareSciCallV1(GotoLine, GOTOLINE, int, line); +DeclareSciCallR0(GetCurrentPos, GETCURRENTPOS, int); +DeclareSciCallR1(LineFromPosition, LINEFROMPOSITION, int, int, position); + + +//============================================================================= +// +// Scrolling and automatic scrolling +// +// +DeclareSciCallV0(ScrollCaret, SCROLLCARET); +DeclareSciCallV2(SetXCaretPolicy, SETXCARETPOLICY, int, caretPolicy, int, caretSlop); +DeclareSciCallV2(SetYCaretPolicy, SETYCARETPOLICY, int, caretPolicy, int, caretSlop); + + +//============================================================================= +// +// Style definition +// +// +DeclareSciCallR1(StyleGetFore, STYLEGETFORE, COLORREF, int, styleNumber); +DeclareSciCallR1(StyleGetBack, STYLEGETBACK, COLORREF, int, styleNumber); + + +//============================================================================= +// +// Margins +// +// +DeclareSciCallV2(SetMarginType, SETMARGINTYPEN, int, margin, int, type); +DeclareSciCallV2(SetMarginWidth, SETMARGINWIDTHN, int, margin, int, pixelWidth); +DeclareSciCallV2(SetMarginMask, SETMARGINMASKN, int, margin, int, mask); +DeclareSciCallV2(SetMarginSensitive, SETMARGINSENSITIVEN, int, margin, BOOL, sensitive); +DeclareSciCallV2(SetFoldMarginColour, SETFOLDMARGINCOLOUR, BOOL, useSetting, COLORREF, colour); +DeclareSciCallV2(SetFoldMarginHiColour, SETFOLDMARGINHICOLOUR, BOOL, useSetting, COLORREF, colour); + + +//============================================================================= +// +// Markers +// +// +DeclareSciCallV2(MarkerDefine, MARKERDEFINE, int, markerNumber, int, markerSymbols); +DeclareSciCallV2(MarkerSetFore, MARKERSETFORE, int, markerNumber, COLORREF, colour); +DeclareSciCallV2(MarkerSetBack, MARKERSETBACK, int, markerNumber, COLORREF, colour); + + +//============================================================================= +// +// Folding +// +// +DeclareSciCallR1(GetLineVisible, GETLINEVISIBLE, BOOL, int, line); +DeclareSciCallR1(GetFoldLevel, GETFOLDLEVEL, int, int, line); +DeclareSciCallV1(SetFoldFlags, SETFOLDFLAGS, int, flags); +DeclareSciCallR1(GetFoldParent, GETFOLDPARENT, int, int, line); +DeclareSciCallR1(GetFoldExpanded, GETFOLDEXPANDED, int, int, line); +DeclareSciCallV1(ToggleFold, TOGGLEFOLD, int, line); +DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, int, line); + + +//============================================================================= +// +// Lexer +// +// +DeclareSciCallV2(SetProperty, SETPROPERTY, const char *, key, const char *, value); diff --git a/src/Styles.c b/src/Styles.c index e2dace29..4492b3c7 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1,5169 +1,5383 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Styles.c -* Scintilla Style Management -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x501 -#endif -#include -#include -#include -#include -#include -#include -#include "scintilla.h" -#include "scilexer.h" -#include "notepad2.h" -#include "edit.h" -#include "styles.h" -#include "dialogs.h" -#include "helpers.h" -#include "resource.h" -#include "SciCall.h" - -extern int iEncoding; - - -#define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24)) - - -KEYWORDLIST KeyWords_NULL = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; log; asc; doc", L"", &KeyWords_NULL, { - /* 0 */ { STYLE_DEFAULT, 63100, L"Default Style", L"font:Default; size:10", L"" }, - /* 1 */ { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" }, - /* 2 */ { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+1; bold; fore:#FF0000", L"" }, - /* 3 */ { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+1; bold; fore:#000080", L"" }, - /* 4 */ { STYLE_CONTROLCHAR, 63104, L"Control Characters (Font)", L"size:-1", L"" }, - /* 5 */ { STYLE_INDENTGUIDE, 63105, L"Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, - /* 6 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63106, L"Selected Text (Colors)", L"back:#0A246A; eolfilled; alpha:95", L"" }, - /* 7 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63107, L"Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, - /* 8 */ { SCI_SETCARETLINEBACK, 63108, L"Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, - /* 9 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63109, L"Caret (Color, Size 1-3)", L"", L"" }, - /* 10 */ { SCI_SETEDGECOLOUR, 63110, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" }, - /* 11 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63111, L"Extra Line Spacing (Size)", L"size:2", L"" }, - - /* 12 */ { STYLE_DEFAULT, 63112, L"2nd Default Style", L"font:Courier New; size:10", L"" }, - /* 13 */ { STYLE_LINENUMBER, 63113, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" }, - /* 14 */ { STYLE_BRACELIGHT, 63114, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" }, - /* 15 */ { STYLE_BRACEBAD, 63115, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" }, - /* 16 */ { STYLE_CONTROLCHAR, 63116, L"2nd Control Characters (Font)", L"size:-1", L"" }, - /* 17 */ { STYLE_INDENTGUIDE, 63117, L"2nd Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, - /* 18 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63118, L"2nd Selected Text (Colors)", L"eolfilled", L"" }, - /* 19 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63119, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, - /* 20 */ { SCI_SETCARETLINEBACK, 63120, L"2nd Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, - /* 21 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" }, - /* 22 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, - /* 23 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_HTML = { -"!doctype ^aria- ^data- a abbr accept accept-charset accesskey acronym action address align alink " -"alt and applet archive area article aside async audio autocomplete autofocus autoplay axis b " -"background base basefont bb bdi bdo bgcolor big blockquote body border bordercolor br buffered button " -"canvas caption cellpadding cellspacing center challenge char charoff charset checkbox checked " -"cite class classid clear code codebase codetype col colgroup color cols colspan command compact " -"content contenteditable contextmenu controls coords crossorigin data datafld dataformatas datagrid " -"datalist datapagesize datasrc datetime dd declare default defer del details dfn dialog dir dirname " -"disabled div dl download draggable dropzone dt em embed enctype event eventsource face fieldset " -"figcaption figure file font footer for form formaction formenctype formmethod formnovalidate " -"formtarget frame frameborder frameset h1 h2 h3 h4 h5 h6 head header headers height hgroup hidden " -"high hr href hreflang hspace html http-equiv i icon id iframe image img input ins integrity isindex " -"ismap itemprop itemscope itemtype kbd keygen keytype kind label lang language leftmargin legend li link " -"list longdesc loop low main manifest map marginheight marginwidth mark max maxlength media mediagroup " -"menu menuitem meta meter method min multiple muted name nav noframes nohref noresize noscript noshade " -"novalidate nowrap object ol onabort onafterprint onbeforeprint onbeforeunload onblur oncancel oncanplay " -"oncanplaythrough onchange onclick onclose oncontextmenu oncuechange ondblclick ondrag ondragend ondragenter " -"ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange " -"onforminput onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata " -"onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel " -"onoffline ononline onpagehide onpageshow onpause onplay onplaying onpopstate onprogress " -"onratechange onreadystatechange onredo onreset onresize onscroll onseeked onseeking onselect " -"onshow onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload onvolumechange " -"onwaiting open optgroup optimum option output p param password pattern ping placeholder poster " -"pre prefix preload profile progress prompt property pubdate public q radio radiogroup readonly rel " -"required reset rev reversed role rows rowspan rp rt ruby rules s samp sandbox scheme scope scoped script " -"scrolling seamless section select selected shape size sizes small source span spellcheck src " -"srcdoc srclang standby start step strike strong style sub submit summary sup tabindex table " -"target tbody td text textarea tfoot th thead time title topmargin tr track translate tt type " -"typemustmatch u ul usemap valign value valuetype var version video vlink vspace wbr width wrap xml " -"xmlns", -"abstract boolean break byte case catch char class const continue debugger default delete do " -"double else enum export extends false final finally float for function goto if implements " -"import in instanceof int interface long native new null package private protected public " -"return short static super switch synchronized this throw throws transient true try typeof var " -"void volatile while with", -"alias and as attribute begin boolean byref byte byval call case class compare const continue " -"currency date declare dim do double each else elseif empty end enum eqv erase error event exit " -"explicit false for friend function get global gosub goto if imp implement in integer is let lib " -"load long loop lset me mid mod module new next not nothing null object on option optional or " -"preserve private property public raiseevent redim rem resume return rset select set single " -"static stop string sub then to true type unload until variant wend while with withevents xor", -"", -"__callstatic __class__ __compiler_halt_offset__ __dir__ __file__ __function__ __get __halt_compiler " -"__isset __line__ __method__ __namespace__ __set __sleep __trait__ __unset __wakeup " -"abstract and argc argv array as break callable case catch cfunction class clone closure const continue " -"declare default define die directory do e_all e_compile_error e_compile_warning e_core_error e_core_warning " -"e_deprecated e_error e_fatal e_notice e_parse e_strict e_user_deprecated e_user_error e_user_notice " -"e_user_warning e_warning echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile " -"eval exception exit extends false final for foreach function global goto http_cookie_vars http_env_vars " -"http_get_vars http_post_files http_post_vars http_server_vars if implements include include_once " -"instanceof insteadof interface isset list namespace new not null old_function or parent php_self " -"print private protected public require require_once return static stdclass switch this throw trait " -"true try unset use var virtual while xor", -"", "", "", "" }; - - -EDITLEXER lexHTML = { SCLEX_HTML, 63001, L"Web Source Code", L"html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc", L"", &KeyWords_HTML, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGEND,0,0), 63136, L"HTML Tag", L"fore:#648000", L"" }, - { SCE_H_TAGUNKNOWN, 63137, L"HTML Unknown Tag", L"fore:#C80000; back:#FFFF80", L"" }, - { SCE_H_ATTRIBUTE, 63138, L"HTML Attribute", L"fore:#FF4000", L"" }, - { SCE_H_ATTRIBUTEUNKNOWN, 63139, L"HTML Unknown Attribute", L"fore:#C80000; back:#FFFF80", L"" }, - { SCE_H_VALUE, 63140, L"HTML Value", L"fore:#3A6EA5", L"" }, - { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63141, L"HTML String", L"fore:#3A6EA5", L"" }, - { SCE_H_OTHER, 63142, L"HTML Other Inside Tag", L"fore:#3A6EA5", L"" }, - { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63143, L"HTML Comment", L"fore:#646464", L"" }, - { SCE_H_ENTITY, 63144, L"HTML Entity", L"fore:#B000B0", L"" }, - { SCE_H_DEFAULT, 63256, L"HTML Element Text", L"", L"" }, - { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" }, - { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" }, - { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" }, - { MULTI_STYLE(SCE_H_ASP,SCE_H_ASPAT,0,0), 63146, L"ASP Start Tag", L"bold; fore:#000080", L"" }, - //{ SCE_H_SCRIPT, L"Script", L"", L"" }, - { SCE_H_QUESTION, 63148, L"PHP Start Tag", L"bold; fore:#000080", L"" }, - { SCE_HPHP_DEFAULT, 63149, L"PHP Default", L"", L"" }, - { MULTI_STYLE(SCE_HPHP_COMMENT,SCE_HPHP_COMMENTLINE,0,0), 63157, L"PHP Comment", L"fore:#FF8000", L"" }, - { SCE_HPHP_WORD, 63152, L"PHP Keyword", L"bold; fore:#A46000", L"" }, - { SCE_HPHP_HSTRING, 63150, L"PHP String", L"fore:#008000", L"" }, - { SCE_HPHP_SIMPLESTRING, 63151, L"PHP Simple String", L"fore:#008000", L"" }, - { SCE_HPHP_NUMBER, 63153, L"PHP Number", L"fore:#FF0000", L"" }, - { SCE_HPHP_OPERATOR, 63158, L"PHP Operator", L"fore:#B000B0", L"" }, - { SCE_HPHP_VARIABLE, 63154, L"PHP Variable", L"italic; fore:#000080", L"" }, - { SCE_HPHP_HSTRING_VARIABLE, 63155, L"PHP String Variable", L"italic; fore:#000080", L"" }, - { SCE_HPHP_COMPLEX_VARIABLE, 63156, L"PHP Complex Variable", L"italic; fore:#000080", L"" }, - { MULTI_STYLE(SCE_HJ_DEFAULT,SCE_HJ_START,0,0), 63159, L"JS Default", L"", L"" }, - { MULTI_STYLE(SCE_HJ_COMMENT,SCE_HJ_COMMENTLINE,SCE_HJ_COMMENTDOC,0), 63160, L"JS Comment", L"fore:#646464", L"" }, - { SCE_HJ_KEYWORD, 63163, L"JS Keyword", L"bold; fore:#A46000", L"" }, - { SCE_HJ_WORD, 63162, L"JS Identifier", L"", L"" }, - { MULTI_STYLE(SCE_HJ_DOUBLESTRING,SCE_HJ_SINGLESTRING,SCE_HJ_STRINGEOL,0), 63164, L"JS String", L"fore:#008000", L"" }, - { SCE_HJ_REGEX, 63166, L"JS Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_HJ_NUMBER, 63161, L"JS Number", L"fore:#FF0000", L"" }, - { SCE_HJ_SYMBOLS, 63165, L"JS Symbols", L"fore:#B000B0", L"" }, - { MULTI_STYLE(SCE_HJA_DEFAULT,SCE_HJA_START,0,0), 63167, L"ASP JS Default", L"", L"" }, - { MULTI_STYLE(SCE_HJA_COMMENT,SCE_HJA_COMMENTLINE,SCE_HJA_COMMENTDOC,0), 63168, L"ASP JS Comment", L"fore:#646464", L"" }, - { SCE_HJA_KEYWORD, 63171, L"ASP JS Keyword", L"bold; fore:#A46000", L"" }, - { SCE_HJA_WORD, 63170, L"ASP JS Identifier", L"", L"" }, - { MULTI_STYLE(SCE_HJA_DOUBLESTRING,SCE_HJA_SINGLESTRING,SCE_HJA_STRINGEOL,0), 63172, L"ASP JS String", L"fore:#008000", L"" }, - { SCE_HJA_REGEX, 63174, L"ASP JS Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_HJA_NUMBER, 63169, L"ASP JS Number", L"fore:#FF0000", L"" }, - { SCE_HJA_SYMBOLS, 63173, L"ASP JS Symbols", L"fore:#B000B0", L"" }, - { MULTI_STYLE(SCE_HB_DEFAULT,SCE_HB_START,0,0), 63175, L"VBS Default", L"", L"" }, - { SCE_HB_COMMENTLINE, 63176, L"VBS Comment", L"fore:#646464", L"" }, - { SCE_HB_WORD, 63178, L"VBS Keyword", L"bold; fore:#B000B0", L"" }, - { SCE_HB_IDENTIFIER, 63180, L"VBS Identifier", L"", L"" }, - { MULTI_STYLE(SCE_HB_STRING,SCE_HB_STRINGEOL,0,0), 63179, L"VBS String", L"fore:#008000", L"" }, - { SCE_HB_NUMBER, 63177, L"VBS Number", L"fore:#FF0000", L"" }, - { MULTI_STYLE(SCE_HBA_DEFAULT,SCE_HBA_START,0,0), 63181, L"ASP VBS Default", L"", L"" }, - { SCE_HBA_COMMENTLINE, 63182, L"ASP VBS Comment", L"fore:#646464", L"" }, - { SCE_HBA_WORD, 63184, L"ASP VBS Keyword", L"bold; fore:#B000B0", L"" }, - { SCE_HBA_IDENTIFIER, 63186, L"ASP VBS Identifier", L"", L"" }, - { MULTI_STYLE(SCE_HBA_STRING,SCE_HBA_STRINGEOL,0,0), 63185, L"ASP VBS String", L"fore:#008000", L"" }, - { SCE_HBA_NUMBER, 63183, L"ASP VBS Number", L"fore:#FF0000", L"" }, - //{ SCE_HP_START, L"Phyton Start", L"", L"" }, - //{ SCE_HP_DEFAULT, L"Phyton Default", L"", L"" }, - //{ SCE_HP_COMMENTLINE, L"Phyton Comment Line", L"", L"" }, - //{ SCE_HP_NUMBER, L"Phyton Number", L"", L"" }, - //{ SCE_HP_STRING, L"Phyton String", L"", L"" }, - //{ SCE_HP_CHARACTER, L"Phyton Character", L"", L"" }, - //{ SCE_HP_WORD, L"Phyton Keyword", L"", L"" }, - //{ SCE_HP_TRIPLE, L"Phyton Triple", L"", L"" }, - //{ SCE_HP_TRIPLEDOUBLE, L"Phyton Triple Double", L"", L"" }, - //{ SCE_HP_CLASSNAME, L"Phyton Class Name", L"", L"" }, - //{ SCE_HP_DEFNAME, L"Phyton Def Name", L"", L"" }, - //{ SCE_HP_OPERATOR, L"Phyton Operator", L"", L"" }, - //{ SCE_HP_IDENTIFIER, L"Phyton Identifier", L"", L"" }, - //{ SCE_HPA_START, L"ASP Phyton Start", L"", L"" }, - //{ SCE_HPA_DEFAULT, L"ASP Phyton Default", L"", L"" }, - //{ SCE_HPA_COMMENTLINE, L"ASP Phyton Comment Line", L"", L"" }, - //{ SCE_HPA_NUMBER, L"ASP Phyton Number", L"", L"" }, - //{ SCE_HPA_STRING, L"ASP Phyton String", L"", L"" }, - //{ SCE_HPA_CHARACTER, L"ASP Phyton Character", L"", L"" }, - //{ SCE_HPA_WORD, L"ASP Phyton Keyword", L"", L"" }, - //{ SCE_HPA_TRIPLE, L"ASP Phyton Triple", L"", L"" }, - //{ SCE_HPA_TRIPLEDOUBLE, L"ASP Phyton Triple Double", L"", L"" }, - //{ SCE_HPA_CLASSNAME, L"ASP Phyton Class Name", L"", L"" }, - //{ SCE_HPA_DEFNAME, L"ASP Phyton Def Name", L"", L"" }, - //{ SCE_HPA_OPERATOR, L"ASP Phyton Operator", L"", L"" }, - //{ SCE_HPA_IDENTIFIER, L"ASP Phyton Identifier", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_XML = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexXML = { SCLEX_XML, 63002, L"XML Document", L"xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj", L"", &KeyWords_XML, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGUNKNOWN,SCE_H_TAGEND,0), 63187, L"XML Tag", L"fore:#881280", L"" }, - { MULTI_STYLE(SCE_H_ATTRIBUTE,SCE_H_ATTRIBUTEUNKNOWN,0,0), 63188, L"XML Attribute", L"fore:#994500", L"" }, - { SCE_H_VALUE, 63189, L"XML Value", L"fore:#1A1AA6", L"" }, - { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63190, L"XML String", L"fore:#1A1AA6", L"" }, - { SCE_H_OTHER, 63191, L"XML Other Inside Tag", L"fore:#1A1AA6", L"" }, - { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63192, L"XML Comment", L"fore:#646464", L"" }, - { SCE_H_ENTITY, 63193, L"XML Entity", L"fore:#B000B0", L"" }, - { SCE_H_DEFAULT, 63257, L"XML Element Text", L"", L"" }, - { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" }, - { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" }, - { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_CSS = { -"align-content align-items align-self alignment-adjust alignment-baseline animation animation-delay " -"animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name " -"animation-play-state animation-timing-function appearance ascent azimuth backface-visibility " -"background background-attachment background-blend-mode background-break background-clip background-color " -"background-image background-origin background-position background-repeat background-size " -"baseline baseline-shift bbox binding bleed bookmark-label bookmark-level bookmark-state " -"bookmark-target border border-bottom border-bottom-color border-bottom-left-radius " -"border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color " -"border-image border-image-outset border-image-repeat border-image-slice border-image-source " -"border-image-width border-left border-left-color border-left-style border-left-width " -"border-length border-radius border-right border-right-color border-right-style " -"border-right-width border-spacing border-style border-top border-top-color " -"border-top-left-radius border-top-right-radius border-top-style border-top-width border-width " -"bottom box-align box-decoration-break box-direction box-flex box-flex-group box-lines " -"box-ordinal-group box-orient box-pack box-shadow box-sizing break-after break-before " -"break-inside cap-height caption-side centerline change-bar change-bar-class change-bar-offset " -"change-bar-side clear clip clip-path clip-rule color color-profile column-count column-fill column-gap " -"column-rule column-rule-color column-rule-style column-rule-width columns column-span column-width " -"content counter-increment counter-reset crop cue cue-after cue-before cursor definition-src descent " -"direction display dominant-baseline drop-initial-after-adjust drop-initial-after-align " -"drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value " -"elevation empty-cells fill fit fit-position flex flex-basis flex-direction flex-flow flex-grow flex-shrink " -"flex-wrap float float-offset flow-from flow-into font font-family font-feature-settings font-kerning font-size " -"font-size-adjust font-stretch font-style font-synthesis font-variant font-weight grid-columns grid-rows " -"hanging-punctuation height hyphenate-after hyphenate-before hyphenate-character hyphenate-limit-chars " -"hyphenate-limit-last hyphenate-limit-zone hyphenate-lines hyphenate-resource hyphens icon image-orientation " -"image-resolution ime-mode inline-box-align insert-position interpret-as justify-content left letter-spacing " -"line-height line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy list-style " -"list-style-image list-style-position list-style-type make-element margin margin-bottom margin-left " -"margin-right margin-top mark mark-after mark-before marker-offset marks marquee-direction marquee-play-count " -"marquee-speed marquee-style mask mask-type mathline max-height max-width media min-height min-width " -"move-to nav-down nav-index nav-left nav-right nav-up object-fit object-position opacity order orphans " -"outline outline-color outline-offset outline-style outline-width overflow overflow-style overflow-wrap " -"overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page page-break-after " -"page-break-before page-break-inside page-policy panose-1 pause pause-after pause-before perspective " -"perspective-origin phonemes pitch pitch-range play-during pointer-events position presentation-level prototype " -"prototype-insert-policy prototype-insert-position punctuation-trim quotes region-overflow " -"rendering-intent resize rest rest-after rest-before richness right rotation rotation-point ruby-align " -"ruby-overhang ruby-position ruby-span shape-image-threshold shape-inside shape-outside size slope speak " -"speak-header speak-numeral speak-punctuation speech-rate src stemh stemv stress string-set tab-size table-layout " -"target target-name target-new target-position text-align text-align-last text-decoration text-decoration-color " -"text-decoration-line text-decoration-style text-emphasis text-height text-indent text-justify text-outline " -"text-overflow text-rendering text-replace text-shadow text-transform text-underline-position text-wrap top topline " -"transform transform-origin transform-style transition transition-delay transition-duration transition-property " -"transition-timing-function unicode-bidi unicode-range units-per-em vertical-align visibility " -"voice-balance voice-duration voice-family voice-pitch voice-pitch-range voice-rate voice-stress " -"voice-volume volume white-space white-space-collapse widows width widths will-change word-break word-spacing " -"word-wrap wrap wrap-flow wrap-margin wrap-padding wrap-through writing-mode x-height z-index", -"active after before checked choices default disabled empty enabled first first-child first-letter " -"first-line first-of-type focus hover indeterminate in-range invalid lang last-child last-of-type left " -"link not nth-child nth-last-child nth-last-of-type nth-of-type only-child only-of-type optional " -"out-of-range read-only read-write repeat-index repeat-item required right root target valid visited", -"", "", -"after before first-letter first-line selection", -"^-moz- ^-ms- ^-o- ^-webkit-", -"^-moz- ^-ms- ^-o- ^-webkit-", -"^-moz- ^-ms- ^-o- ^-webkit-", -"" }; - - -EDITLEXER lexCSS = { SCLEX_CSS, 63003, L"CSS Style Sheets", L"css", L"", &KeyWords_CSS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_CSS_DEFAULT, L"Default", L"", L"" }, - { SCE_CSS_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_CSS_TAG, 63136, L"HTML Tag", L"bold; fore:#0A246A", L"" }, - { SCE_CSS_CLASS, 63194, L"Tag-Class", L"fore:#648000", L"" }, - { SCE_CSS_ID, 63195, L"Tag-Id", L"fore:#648000", L"" }, - { SCE_CSS_ATTRIBUTE, 63196, L"Tag-Attribute", L"italic; fore:#648000", L"" }, - { MULTI_STYLE(SCE_CSS_PSEUDOCLASS,SCE_CSS_EXTENDED_PSEUDOCLASS,0,0), 63197, L"Pseudo-class", L"fore:#B000B0", L"" }, - { MULTI_STYLE(SCE_CSS_PSEUDOELEMENT,SCE_CSS_EXTENDED_PSEUDOELEMENT,0,0), 63361, L"Pseudo-element", L"fore:#B00050", L"" }, - { MULTI_STYLE(SCE_CSS_IDENTIFIER,SCE_CSS_IDENTIFIER2,SCE_CSS_IDENTIFIER3,SCE_CSS_EXTENDED_IDENTIFIER), 63199, L"CSS Property", L"fore:#FF4000", L"" }, - { MULTI_STYLE(SCE_CSS_DOUBLESTRING,SCE_CSS_SINGLESTRING,0,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_CSS_VALUE, 63201, L"Value", L"fore:#3A6EA5", L"" }, - { SCE_CSS_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { SCE_CSS_IMPORTANT, 63202, L"Important", L"bold; fore:#C80000", L"" }, - { SCE_CSS_DIRECTIVE, 63203, L"Directive", L"bold; fore:#000000; back:#FFF1A8", L"" }, - { SCE_CSS_MEDIA, 63382, L"Media", L"bold; fore:#0A246A", L"" }, - { SCE_CSS_VARIABLE, 63249, L"Variable", L"bold; fore:#FF4000", L"" }, - { SCE_CSS_UNKNOWN_PSEUDOCLASS, 63198, L"Unknown Pseudo-class", L"fore:#C80000; back:#FFFF80", L"" }, - { SCE_CSS_UNKNOWN_IDENTIFIER, 63200, L"Unknown Property", L"fore:#C80000; back:#FFFF80", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_CPP = { -"__abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event " -"__except __except__try __fastcall __finally __forceinline __gc __hook __identifier " -"__if_exists __if_not_exists __inline __int16 __int32 __int64 __int8 __interface __leave " -"__m128 __m128d __m128i __m64 __multiple_inheritance __nogc __noop __pin __property __raise " -"__sealed __single_inheritance __stdcall __super __try __try_cast __unhook __uuidof __value " -"__virtual_inheritance __wchar_t auto bool break case catch char class const const_cast " -"continue default defined delete do double dynamic_cast else enum explicit extern false float " -"for friend goto if inline int long mutable naked namespace new operator private protected " -"public register reinterpret_cast return short signed size_t sizeof static static_cast struct " -"switch template this throw true try typedef typeid typename union unsigned using uuid " -"virtual void volatile wchar_t while", -"", -"", "", "", "", "", "", "" }; - - -EDITLEXER lexCPP = { SCLEX_CPP, 63004, L"C/C++ Source Code", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", &KeyWords_CPP, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_C_DEFAULT, L"Default", L"", L"" }, - { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, - { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { MULTI_STYLE(SCE_C_PREPROCESSOR,SCE_C_PREPROCESSORCOMMENT,SCE_C_PREPROCESSORCOMMENTDOC,0), 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - //{ SCE_C_UUID, L"UUID", L"", L"" }, - //{ SCE_C_REGEX, L"Regex", L"", L"" }, - //{ SCE_C_WORD2, L"Word 2", L"", L"" }, - //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_CS = { -"abstract add alias as ascending async await base bool break by byte case catch char checked " -"class const continue decimal default delegate descending do double dynamic else " -"enum equals event explicit extern false finally fixed float for foreach from get " -"global goto group if implicit in int interface internal into is join lock let long " -"namespace new null object on operator orderby out override params partial private " -"protected public readonly ref remove return sbyte sealed select set short sizeof " -"stackalloc static string struct switch this throw true try typeof uint ulong " -"unchecked unsafe ushort using value var virtual void volatile where while yield", -"", "", -"AccessViolationException Action ActivationContext Activator AggregateException AppDomain " -"AppDomainInitializer AppDomainManager AppDomainManagerInitializationOptions AppDomainSetup " -"AppDomainUnloadedException ApplicationException ApplicationId ApplicationIdentity ArgIterator " -"ArgumentException ArgumentNullException ArgumentOutOfRangeException ArithmeticException Array " -"ArrayList ArraySegment ArrayTypeMismatchException AssemblyLoadEventArgs " -"AssemblyLoadEventHandler AsyncCallback Attribute AttributeTargets AttributeUsage " -"AttributeUsageAttribute BadImageFormatException Base64FormattingOptions BinaryReader " -"BinaryWriter BitArray BitConverter BlockingCollection Boolean Buffer BufferedStream " -"Byte CannotUnloadAppDomainException CaseInsensitiveComparer CaseInsensitiveHashCodeProvider " -"Char CharEnumerator CLSCompliant CLSCompliantAttribute CollectionBase CollectionDataContract " -"CollectionDataContractAttribute Color Comparer Comparison ConcurrentBag ConcurrentDictionary " -"ConcurrentQueue ConcurrentStack ConformanceLevel Console ConsoleCancelEventArgs " -"ConsoleCancelEventHandler ConsoleColor ConsoleKey ConsoleKeyInfo ConsoleModifiers " -"ConsoleSpecialKey ContextBoundObject ContextMarshalException ContextStatic " -"ContextStaticAttribute ContractNamespace ContractNamespaceAttribute Convert Converter " -"CrossAppDomainDelegate DataContract DataContractAttribute DataContractResolver " -"DataContractSerializer DataMember DataMemberAttribute DataMisalignedException DateTime " -"DateTimeKind DateTimeOffset DayOfWeek DBNull Decimal Delegate Dictionary DictionaryBase " -"DictionaryEntry Directory DirectoryInfo DirectoryNotFoundException DivideByZeroException " -"DllNotFoundException Double DriveInfo DriveNotFoundException DriveType DtdProcessing " -"DuplicateWaitObjectException EndOfStreamException EntityHandling EntryPointNotFoundException " -"Enum EnumMember EnumMemberAttribute Environment EnvironmentVariableTarget EqualityComparer " -"ErrorEventArgs ErrorEventHandler EventArgs EventHandler Exception ExecutionEngineException " -"ExportOptions ExtensionDataObject FieldAccessException File FileAccess FileAttributes " -"FileFormatException FileInfo FileLoadException FileMode FileNotFoundException FileOptions " -"FileShare FileStream FileStyleUriParser FileSystemEventArgs FileSystemEventHandler " -"FileSystemInfo FileSystemWatcher Flags FlagsAttribute FormatException Formatter " -"FormatterConverter FormatterServices Formatting FtpStyleUriParser Func GC GCCollectionMode " -"GCNotificationStatus GenericUriParser GenericUriParserOptions GopherStyleUriParser Guid " -"HandleInheritability HashSet Hashtable HttpStyleUriParser IAppDomainSetup IAsyncResult " -"ICloneable ICollection IComparable IComparer IConvertible ICustomFormatter " -"IDataContractSurrogate IDeserializationCallback IDictionary IDictionaryEnumerator IDisposable " -"IEnumerable IEnumerator IEqualityComparer IEquatable IExtensibleDataObject IFormatProvider " -"IFormattable IFormatter IFormatterConverter IFragmentCapableXmlDictionaryWriter " -"IgnoreDataMember IgnoreDataMemberAttribute IHashCodeProvider IHasXmlNode IList ImportOptions " -"IndexOutOfRangeException InsufficientExecutionStackException InsufficientMemoryException Int16 " -"Int32 Int64 InternalBufferOverflowException IntPtr InvalidCastException " -"InvalidDataContractException InvalidDataException InvalidOperationException " -"InvalidProgramException InvalidTimeZoneException IObjectReference IObservable IObserver " -"IODescription IODescriptionAttribute IOException IProducerConsumerCollection " -"ISafeSerializationData ISerializable ISerializationSurrogate IServiceProvider ISet " -"IStreamProvider IStructuralComparable IStructuralEquatable ISurrogateSelector " -"IXmlBinaryReaderInitializer IXmlBinaryWriterInitializer IXmlDictionary IXmlLineInfo " -"IXmlMtomReaderInitializer IXmlMtomWriterInitializer IXmlNamespaceResolver IXmlSchemaInfo " -"IXmlTextReaderInitializer IXmlTextWriterInitializer IXPathNavigable IXsltContextFunction " -"IXsltContextVariable KeyedByTypeCollection KeyNotFoundException KeyValuePair KnownType " -"KnownTypeAttribute Lazy LdapStyleUriParser LinkedList LinkedListNode List LoaderOptimization " -"LoaderOptimizationAttribute LoadOptions LocalDataStoreSlot MarshalByRefObject Math " -"MemberAccessException MemoryStream MethodAccessException MidpointRounding " -"MissingFieldException MissingMemberException MissingMethodException ModuleHandle MTAThread " -"MTAThreadAttribute MulticastDelegate MulticastNotSupportedException NamespaceHandling " -"NameTable NetDataContractSerializer NetPipeStyleUriParser NetTcpStyleUriParser " -"NewLineHandling NewsStyleUriParser NonSerialized NonSerializedAttribute " -"NotFiniteNumberException NotifyFilters NotImplementedException NotSupportedException Nullable " -"NullReferenceException Object ObjectDisposedException ObjectIDGenerator ObjectManager Obsolete " -"ObsoleteAttribute OnDeserialized OnDeserializedAttribute OnDeserializing " -"OnDeserializingAttribute OnSerialized OnSerializedAttribute OnSerializing " -"OnSerializingAttribute OnXmlDictionaryReaderClose OperatingSystem OperationCanceledException " -"OptionalField OptionalFieldAttribute OrderablePartitioner OutOfMemoryException " -"OverflowException ParamArray ParamArrayAttribute Partitioner Path PathTooLongException " -"PipeException PlatformID PlatformNotSupportedException Predicate Queue Random RankException " -"ReaderOptions ReadOnlyCollectionBase ReadState RenamedEventArgs RenamedEventHandler " -"ResolveEventArgs ResolveEventHandler RuntimeArgumentHandle RuntimeFieldHandle " -"RuntimeMethodHandle RuntimeTypeHandle SafeSerializationEventArgs SaveOptions SByte " -"SearchOption SeekOrigin Serializable SerializableAttribute SerializationBinder " -"SerializationEntry SerializationException SerializationInfo SerializationInfoEnumerator " -"SerializationObjectManager Single SortedDictionary SortedList SortedSet Stack " -"StackOverflowException STAThread STAThreadAttribute Stream StreamingContext " -"StreamingContextStates StreamReader StreamWriter String StringBuilder StringComparer StringComparison " -"StringReader StringSplitOptions StringWriter StructuralComparisons SurrogateSelector " -"SynchronizedCollection SynchronizedKeyedCollection SynchronizedReadOnlyCollection " -"SystemException TextReader TextWriter ThreadStatic ThreadStaticAttribute TimeoutException " -"TimeSpan TimeZone TimeZoneInfo TimeZoneNotFoundException Tuple Type TypeAccessException " -"TypeCode TypedReference TypeInitializationException TypeLoadException TypeUnloadedException " -"UInt16 UInt32 UInt64 UIntPtr UnauthorizedAccessException UnhandledExceptionEventArgs " -"UnhandledExceptionEventHandler UniqueId UnmanagedMemoryAccessor UnmanagedMemoryStream Uri " -"UriBuilder UriComponents UriFormat UriFormatException UriHostNameType UriIdnScope UriKind " -"UriParser UriPartial UriTemplate UriTemplateEquivalenceComparer UriTemplateMatch " -"UriTemplateMatchException UriTemplateTable UriTypeConverter ValidationEventArgs " -"ValidationEventHandler ValidationType ValueType Version Void WaitForChangedResult " -"WatcherChangeTypes WeakReference WhitespaceHandling WriteState XAttribute XCData XComment " -"XContainer XDeclaration XDocument XDocumentType XElement XmlAtomicValue XmlAttribute " -"XmlAttributeCollection XmlBinaryReaderSession XmlBinaryWriterSession XmlCaseOrder " -"XmlCDataSection XmlCharacterData XmlComment XmlConvert XmlDataDocument XmlDataType " -"XmlDateTimeSerializationMode XmlDeclaration XmlDictionary XmlDictionaryReader " -"XmlDictionaryReaderQuotas XmlDictionaryString XmlDictionaryWriter XmlDocument " -"XmlDocumentFragment XmlDocumentType XmlElement XmlEntity XmlEntityReference XmlException " -"XmlImplementation XmlLinkedNode XmlNamedNodeMap XmlNamespaceManager XmlNamespaceScope " -"XmlNameTable XmlNode XmlNodeChangedAction XmlNodeChangedEventArgs XmlNodeChangedEventHandler " -"XmlNodeList XmlNodeOrder XmlNodeReader XmlNodeType XmlNotation XmlObjectSerializer " -"XmlOutputMethod XmlParserContext XmlProcessingInstruction XmlQualifiedName XmlReader " -"XmlReaderSettings XmlResolver XmlSchema XmlSchemaAll XmlSchemaAnnotated XmlSchemaAnnotation " -"XmlSchemaAny XmlSchemaAnyAttribute XmlSchemaAppInfo XmlSchemaAttribute XmlSchemaAttributeGroup " -"XmlSchemaAttributeGroupRef XmlSchemaChoice XmlSchemaCollection XmlSchemaCollectionEnumerator " -"XmlSchemaCompilationSettings XmlSchemaComplexContent XmlSchemaComplexContentExtension " -"XmlSchemaComplexContentRestriction XmlSchemaComplexType XmlSchemaContent XmlSchemaContentModel " -"XmlSchemaContentProcessing XmlSchemaContentType XmlSchemaDatatype XmlSchemaDatatypeVariety " -"XmlSchemaDerivationMethod XmlSchemaDocumentation XmlSchemaElement XmlSchemaEnumerationFacet " -"XmlSchemaException XmlSchemaExternal XmlSchemaFacet XmlSchemaForm XmlSchemaFractionDigitsFacet " -"XmlSchemaGroup XmlSchemaGroupBase XmlSchemaGroupRef XmlSchemaIdentityConstraint " -"XmlSchemaImport XmlSchemaInclude XmlSchemaInference XmlSchemaInference.InferenceOption " -"XmlSchemaInferenceException XmlSchemaInfo XmlSchemaKey XmlSchemaKeyref XmlSchemaLengthFacet " -"XmlSchemaMaxExclusiveFacet XmlSchemaMaxInclusiveFacet XmlSchemaMaxLengthFacet " -"XmlSchemaMinExclusiveFacet XmlSchemaMinInclusiveFacet XmlSchemaMinLengthFacet " -"XmlSchemaNotation XmlSchemaNumericFacet XmlSchemaObject XmlSchemaObjectCollection " -"XmlSchemaObjectEnumerator XmlSchemaObjectTable XmlSchemaParticle XmlSchemaPatternFacet " -"XmlSchemaRedefine XmlSchemaSequence XmlSchemaSet XmlSchemaSimpleContent " -"XmlSchemaSimpleContentExtension XmlSchemaSimpleContentRestriction XmlSchemaSimpleType " -"XmlSchemaSimpleTypeContent XmlSchemaSimpleTypeList XmlSchemaSimpleTypeRestriction " -"XmlSchemaSimpleTypeUnion XmlSchemaTotalDigitsFacet XmlSchemaType XmlSchemaUnique " -"XmlSchemaUse XmlSchemaValidationException XmlSchemaValidationFlags XmlSchemaValidator " -"XmlSchemaValidity XmlSchemaWhiteSpaceFacet XmlSchemaXPath XmlSecureResolver " -"XmlSerializableServices XmlSeverityType XmlSignificantWhitespace XmlSortOrder XmlSpace " -"XmlText XmlTextReader XmlTextWriter XmlTokenizedType XmlTypeCode XmlUrlResolver " -"XmlValidatingReader XmlValueGetter XmlWhitespace XmlWriter XmlWriterSettings XName " -"XNamespace XNode XNodeDocumentOrderComparer XNodeEqualityComparer XObject XObjectChange " -"XObjectChangeEventArgs XPathDocument XPathException XPathExpression XPathItem " -"XPathNamespaceScope XPathNavigator XPathNodeIterator XPathNodeType XPathQueryGenerator " -"XPathResultType XProcessingInstruction XsdDataContractExporter XsdDataContractImporter " -"XslCompiledTransform XsltArgumentList XsltCompileException XsltContext XsltException " -"XsltMessageEncounteredEventArgs XsltMessageEncounteredEventHandler XslTransform XsltSettings " -"XStreamingElement XText", -"", "", "", "", "" }; - - -EDITLEXER lexCS = { SCLEX_CPP, 63005, L"C# Source Code", L"cs", L"", &KeyWords_CS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_C_DEFAULT, L"Default", L"", L"" }, - { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_C_VERBATIM, 63134, L"Verbatim String", L"fore:#008000", L"" }, - { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - //{ SCE_C_UUID, L"UUID", L"", L"" }, - //{ SCE_C_REGEX, L"Regex", L"", L"" }, - //{ SCE_C_WORD2, L"Word 2", L"", L"" }, - { SCE_C_GLOBALCLASS, 63337, L"Global Class", L"fore:#2B91AF", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_RC = { -"ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON " -"BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX " -"CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG " -"DIALOGEX DISCARDABLE EDITTEXT END EXSTYLE FONT GROUPBOX " -"ICON LANGUAGE LISTBOX LTEXT MENU MENUEX MENUITEM " -"MESSAGETABLE POPUP PUSHBUTTON RADIOBUTTON RCDATA RTEXT " -"SCROLLBAR SEPARATOR SHIFT STATE3 STRINGTABLE STYLE " -"TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexRC = { SCLEX_CPP, 63006, L"Resource Script", L"rc; rc2; rct; rh; r; dlg", L"", &KeyWords_RC, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_C_DEFAULT, L"Default", L"", L"" }, - { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, - { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" }, - { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - //{ SCE_C_UUID, L"UUID", L"", L"" }, - //{ SCE_C_REGEX, L"Regex", L"", L"" }, - //{ SCE_C_WORD2, L"Word 2", L"", L"" }, - //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_MAK = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexMAK = { SCLEX_MAKEFILE, 63007, L"Makefiles", L"mak; make; mk; dsp; msc; msvc", L"", &KeyWords_MAK, { - { STYLE_DEFAULT, 63126, L"Default", L"fore:#0A246A", L"" }, - //{ SCE_MAKE_DEFAULT, L"Default", L"", L"" }, - { SCE_MAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_MAKE_IDENTIFIER,SCE_MAKE_IDEOL,0,0), 63129, L"Identifier", L"fore:#003CE6", L"" }, - { SCE_MAKE_OPERATOR, 63132, L"Operator", L"", L"" }, - { SCE_MAKE_TARGET, 63204, L"Target", L"fore:#003CE6; back:#FFC000", L"" }, - { SCE_MAKE_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_VBS = { -"alias and as attribute begin boolean byref byte byval call case class compare const continue " -"currency date declare dim do double each else elseif empty end enum eqv erase error event exit " -"explicit false for friend function get global gosub goto if imp implement in integer is let lib " -"load long loop lset me mid mod module new next not nothing null object on option optional or " -"preserve private property public raiseevent redim rem resume return rset select set single " -"static stop string sub then to true type unload until variant wend while with withevents xor", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexVBS = { SCLEX_VBSCRIPT, 63008, L"VBScript", L"vbs; dsm", L"", &KeyWords_VBS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_B_DEFAULT, L"Default", L"", L"" }, - { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" }, - { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" }, - { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_B_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" }, - //{ SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" }, - //{ SCE_B_CONSTANT, L"Constant", L"", L"" }, - //{ SCE_B_DATE, L"Date", L"", L"" }, - //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" }, - //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" }, - //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" }, - //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_VB = { -"addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call " -"case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng " -"cstr ctype date decimal declare default delegate dim directcast do double each else elseif end " -"enum erase error event exit explicit externalsource false finally for friend function get " -"gettype gosub goto handles if implements imports in inherits integer interface is let lib like " -"long loop me mid mod module mustinherit mustoverride mybase myclass namespace new next not " -"nothing notinheritable notoverridable object on option optional or orelse overloads overridable " -"overrides paramarray preserve private property protected public raiseevent randomize readonly " -"redim rem removehandler resume return select set shadows shared short single static step stop " -"strict string structure sub synclock then throw to true try typeof unicode until variant when " -"while with withevents writeonly xor", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexVB = { SCLEX_VB, 63009, L"Visual Basic", L"vb; bas; frm; cls; ctl; pag; dsr; dob", L"", &KeyWords_VB, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_B_DEFAULT, L"Default", L"", L"" }, - { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" }, - { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" }, - { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_B_NUMBER,SCE_B_DATE,0,0), 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" }, - { SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" }, - //{ SCE_B_CONSTANT, L"Constant", L"", L"" }, - //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" }, - //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" }, - //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" }, - //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_JS = { -"abstract boolean break byte case catch char class const continue debugger default delete do " -"double else enum export extends false final finally float for function goto if implements " -"import in instanceof int interface let long native new null package private protected public " -"return short static super switch synchronized this throw throws transient true try typeof var " -"void volatile while with", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexJS = { SCLEX_CPP, 63010, L"JavaScript", L"js; jse; jsm; json; as", L"", &KeyWords_JS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_C_DEFAULT, L"Default", L"", L"" }, - { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, - { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - //{ SCE_C_UUID, L"UUID", L"", L"" }, - //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" }, - //{ SCE_C_WORD2, L"Word 2", L"", L"" }, - //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_JAVA = { -"@interface abstract assert boolean break byte case catch char class const " -"continue default do double else enum extends final finally float for future " -"generic goto if implements import inner instanceof int interface long " -"native new null outer package private protected public rest return " -"short static super switch synchronized this throw throws transient try " -"var void volatile while " -"@Deprecated @Documented @FlaskyTest @Inherited @JavascriptInterface " -"@LargeTest @MediumTest @Override @Retention " -"@SmallTest @Smoke @Supress @SupressLint @SupressWarnings @Target @TargetApi " -"@TestTarget @TestTargetClass @UiThreadTest", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexJAVA = { SCLEX_CPP, 63011, L"Java Source Code", L"java", L"", &KeyWords_JAVA, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_C_DEFAULT, L"Default", L"", L"" }, - { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, - { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - //{ SCE_C_UUID, L"UUID", L"", L"" }, - //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" }, - //{ SCE_C_WORD2, L"Word 2", L"", L"" }, - //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_PAS = { -"absolute abstract alias and array as asm assembler begin break case cdecl class const constructor continue cppdecl default " -"destructor dispose div do downto else end end. except exit export exports external false far far16 file finalization finally for " -"forward function goto if implementation in index inherited initialization inline interface is label library local message mod " -"name near new nil nostackframe not object of oldfpccall on operator or out overload override packed pascal private procedure " -"program property protected public published raise read record register reintroduce repeat resourcestring safecall self set shl " -"shr softfloat stdcall stored string then threadvar to true try type unit until uses var virtual while with write xor", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexPAS = { SCLEX_PASCAL, 63012, L"Pascal Source Code", L"pas; dpr; dpk; dfm; inc; pp", L"", &KeyWords_PAS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_PAS_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_PAS_COMMENT,SCE_PAS_COMMENT2,SCE_PAS_COMMENTLINE,0), 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_PAS_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" }, - { SCE_PAS_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_PAS_STRING,SCE_PAS_CHARACTER,SCE_PAS_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_PAS_NUMBER,SCE_PAS_HEXNUMBER,0,0), 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_PAS_OPERATOR, 63132, L"Operator", L"bold", L"" }, - { SCE_PAS_ASM, 63205, L"Inline Asm", L"fore:#0000FF", L"" }, - { MULTI_STYLE(SCE_PAS_PREPROCESSOR,SCE_PAS_PREPROCESSOR2,0,0), 63133, L"Preprocessor", L"fore:#FF00FF", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_ASM = { -"aaa aad aam aas adc add and arpl bound bsf bsr bswap bt btc btr bts call cbw cdq cflush clc cld " -"cli clts cmc cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle cmovna cmovnae " -"cmovnb cmovnbe cmovnc cmovne cmovng cmovnge cmovnl cmovnle cmovno cmovnp cmovns cmovnz cmovo " -"cmovp cmovpe cmovpo cmovs cmovz cmp cmps cmpsb cmpsd cmpsq cmpsw cmpxchg cmpxchg486 cmpxchg8b " -"cpuid cwd cwde daa das dec div emms enter esc femms hlt ibts icebp idiv imul in inc ins insb " -"insd insw int int01 int03 int1 int3 into invd invlpg iret iretd iretdf iretf iretw ja jae jb jbe " -"jc jcxz je jecxz jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz " -"jo jp jpe jpo js jz lahf lar lds lea leave les lfs lgdt lgs lidt lldt lmsw loadall loadall286 " -"lock lods lodsb lodsd lodsq lodsw loop loopd loope looped loopew loopne loopned loopnew loopnz " -"loopnzd loopnzw loopw loopz loopzd loopzw lsl lss ltr mov movs movsb movsd movsq movsw movsx " -"movsxd movzx mul neg nop not or out outs outsb outsd outsw pop popa popad popaw popf popfd popfw " -"push pusha pushad pushaw pushd pushf pushfd pushfw pushw rcl rcr rdmsr rdpmc rdshr rdtsc rep " -"repe repne repnz repz ret retf retn rol ror rsdc rsldt rsm rsts sahf sal salc sar sbb scas scasb " -"scasd scasq scasw seta setae setb setbe setc sete setg setge setl setle setna setnae setnb " -"setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets " -"setz sgdt shl shld shr shrd sidt sldt smi smint smintold smsw stc std sti stos stosb stosd stosq " -"stosw str sub svdc svldt svts syscall sysenter sysexit sysret test ud0 ud1 ud2 umov verr verw " -"wait wbinvd wrmsr wrshr xadd xbts xchg xlat xlatb xor", -"f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne " -"fcmovnu fcmovu fcom fcomi fcomip fcomp fcompp fcos fdecstp fdisi fdiv fdivp fdivr fdivrp feni " -"ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr " -"fld fld1 fldcw fldenv fldenvd fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex " -"fndisi fneni fninit fnop fnsave fnsaved fnsavew fnstcw fnstenv fnstenvd fnstenvw fnstsw fpatan " -"fprem fprem1 fptan frndint frstor frstord frstorw fsave fsaved fsavew fscale fsetpm fsin fsincos " -"fsqrt fst fstcw fstenv fstenvd fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fucom fucomp " -"fucompp fwait fxam fxch fxtract fyl2x fyl2xp1", -"ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp " -"ebx ecx edi edx eip es esi esp fs gs mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 r10 r10b r10d r10w r11 r11b " -"r11d r11w r12 r12b r12d r12w r13 r13b r13d r13w r14 r14b r14d r14w r15 r15b r15d r15w r8 r8b r8d " -"r8w r9 r9b r9d r9w rax rbp rbx rcx rdi rdx rip rsi rsp si sp ss st st0 st1 st2 st3 st4 st5 st6 " -"st7 tr3 tr4 tr5 tr6 tr7 xmm0 xmm1 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm2 xmm3 xmm4 xmm5 xmm6 " -"xmm7 xmm8 xmm9 ymm0 ymm1 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 " -"ymm9", -"%arg %assign %define %elif %elifctk %elifdef %elifid %elifidn %elifidni %elifmacro %elifnctk " -"%elifndef %elifnid %elifnidn %elifnidni %elifnmacro %elifnnum %elifnstr %elifnum %elifstr %else " -"%endif %endmacro %endrep %error %exitrep %iassign %idefine %if %ifctk %ifdef %ifid %ifidn " -"%ifidni %ifmacro %ifnctk %ifndef %ifnid %ifnidn %ifnidni %ifnmacro %ifnnum %ifnstr %ifnum %ifstr " -"%imacro %include %line %local %macro %out %pop %push %rep %repl %rotate %stacksize %strlen " -"%substr %undef %xdefine %xidefine .186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p " -".8086 .8087 .alpha .break .code .const .continue .cref .data .data? .dosseg .else .elseif .endif " -".endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef " -".errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro " -".listmacroall .model .msfloat .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall " -".seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist absolute " -"alias align alignb assume at bits catstr comm comment common cpu db dd df dosseg dq dt dup dw " -"echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn " -"elseifidni elseifnb elseifndef end endif endm endp ends endstruc eq equ even exitm export extern " -"externdef extrn for forc ge global goto group gt high highword iend if if1 if2 ifb ifdef ifdif " -"ifdifi ife ifidn ifidni ifnb ifndef import incbin include includelib instr invoke irp irpc " -"istruc label le length lengthof local low lowword lroffset lt macro mask mod name ne offset " -"opattr option org page popcontext proc proto ptr public purge pushcontext record repeat rept " -"resb resd resq rest resw section seg segment short size sizeof sizestr struc struct substr " -"subtitle subttl textequ this times title type typedef union use16 use32 while width", -"$ $$ %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 .bss .data .text ? @b @f a16 a32 abs addr all assumes at " -"basic byte c carry? casemap common compact cpu dotname dword emulator epilogue error export " -"expr16 expr32 far far16 far32 farstack flat forceframe fortran fword huge language large listing " -"ljmp loadds m510 medium memory near near16 near32 nearstack nodotname noemulator nokeyword " -"noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nosplit " -"nothing notpublic o16 o32 oldmacros oldstructs os_dos overflow? para parity? pascal private " -"prologue qword radix readonly real10 real4 real8 req sbyte scoped sdword seq setif2 sign? small " -"smallstack stdcall sword syscall tbyte tiny use16 use32 uses vararg word wrt zero?", -"addpd addps addsd addss andnpd andnps andpd andps blendpd blendps blendvpd blendvps cmpeqpd " -"cmpeqps cmpeqsd cmpeqss cmplepd cmpleps cmplesd cmpless cmpltpd cmpltps cmpltsd cmpltss cmpnepd " -"cmpneps cmpnesd cmpness cmpnlepd cmpnleps cmpnlesd cmpnless cmpnltpd cmpnltps cmpnltsd cmpnltss " -"cmpordpd cmpordps cmpordsd cmpordss cmpunordpd cmpunordps cmpunordsd cmpunordss comisd comiss " -"crc32 cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi " -"cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvtss2sd cvtss2si cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi " -"cvttsd2si cvttss2si divpd divps divsd divss dppd dpps extractps fxrstor fxsave insertps ldmxscr " -"lfence maskmovdq maskmovdqu maxpd maxps maxss mfence minpd minps minsd minss movapd movaps movd " -"movdq2q movdqa movdqu movhlps movhpd movhps movlhps movlpd movlps movmskpd movmskps movntdq " -"movntdqa movnti movntpd movntps movntq movq movq2dq movsd movss movupd movups mpsadbw mulpd " -"mulps mulsd mulss orpd orps packssdw packsswb packusdw packuswb paddb paddd paddq paddsb paddsiw " -"paddsw paddusb paddusw paddw pand pandn pause paveb pavgb pavgusb pavgw paxsd pblendvb pblendw " -"pcmpeqb pcmpeqd pcmpeqq pcmpeqw pcmpestri pcmpestrm pcmpgtb pcmpgtd pcmpgtq pcmpgtw pcmpistri " -"pcmpistrm pdistib pextrb pextrd pextrq pextrw pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt " -"pfmax pfmin pfmul pfnacc pfpnacc pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr " -"phminposuw pi2fd pinsrb pinsrd pinsrq pinsrw pmachriw pmaddwd pmagw pmaxsb pmaxsd pmaxsw pmaxub " -"pmaxud pmaxuw pminsb pminsd pminsw pminub pminud pminuw pmovmskb pmovsxbd pmovsxbq pmovsxbw " -"pmovsxdq pmovsxwd pmovsxwq pmovzxbd pmovzxbq pmovzxbw pmovzxdq pmovzxwd pmovzxwq pmuldq pmulhriw " -"pmulhrwa pmulhrwc pmulhuw pmulhw pmulld pmullw pmuludq pmvgezb pmvlzb pmvnzb pmvzb popcnt por " -"prefetch prefetchnta prefetcht0 prefetcht1 prefetcht2 prefetchw psadbw pshufd pshufhw pshuflw " -"pshufw pslld pslldq psllq psllw psrad psraw psrld psrldq psrlq psrlw psubb psubd psubq psubsb " -"psubsiw psubsw psubusb psubusw psubw pswapd ptest punpckhbw punpckhdq punpckhqdq punpckhwd " -"punpcklbw punpckldq punpcklqdq punpcklwd pxor rcpps rcpss roundpd roundps roundsd roundss " -"rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss " -"ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps", -"", "", "" }; - - -EDITLEXER lexASM = { SCLEX_ASM, 63013, L"Assembly Script", L"asm", L"", &KeyWords_ASM, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_ASM_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_ASM_COMMENT,SCE_ASM_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_ASM_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_ASM_STRING,SCE_ASM_CHARACTER,SCE_ASM_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_ASM_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_ASM_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" }, - { SCE_ASM_CPUINSTRUCTION, 63206, L"CPU Instruction", L"fore:#0A246A", L"" }, - { SCE_ASM_MATHINSTRUCTION, 63207, L"FPU Instruction", L"fore:#0A246A", L"" }, - { SCE_ASM_EXTINSTRUCTION, 63210, L"Extended Instruction", L"fore:#0A246A", L"" }, - { SCE_ASM_DIRECTIVE, 63203, L"Directive", L"fore:#0A246A", L"" }, - { SCE_ASM_DIRECTIVEOPERAND, 63209, L"Directive Operand", L"fore:#0A246A", L"" }, - { SCE_ASM_REGISTER, 63208, L"Register", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_PL = { -"__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__ abs accept alarm and atan2 AUTOLOAD BEGIN " -"bind binmode bless break caller chdir CHECK chmod chomp chop chown chr chroot close closedir " -"cmp connect continue CORE cos crypt dbmclose dbmopen default defined delete DESTROY die do " -"dump each else elsif END endgrent endhostent endnetent endprotoent endpwent endservent eof " -"eq EQ eval exec exists exit exp fcntl fileno flock for foreach fork format formline ge GE " -"getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin " -"getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname " -"getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport " -"getservent getsockname getsockopt given glob gmtime goto grep gt GT hex if index INIT int " -"ioctl join keys kill last lc lcfirst le LE length link listen local localtime lock log " -"lstat lt LT map mkdir msgctl msgget msgrcv msgsnd my ne NE next no not NULL oct open " -"opendir or ord our pack package pipe pop pos print printf prototype push qu quotemeta rand " -"read readdir readline readlink readpipe recv redo ref rename require reset return reverse " -"rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent " -"sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift " -"shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split " -"sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek " -"system syswrite tell telldir tie tied time times truncate uc ucfirst umask undef UNITCHECK " -"unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn " -"when while write xor", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexPL = { SCLEX_PERL, 63014, L"Perl Script", L"pl; pm; cgi; pod", L"", &KeyWords_PL, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_PL_DEFAULT, L"Default", L"", L"" }, - { SCE_PL_COMMENTLINE, 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_PL_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, - { SCE_PL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { SCE_PL_STRING, 63211, L"String double quoted", L"fore:#008000", L"" }, - { SCE_PL_CHARACTER, 63212, L"String single quoted", L"fore:#008000", L"" }, - { SCE_PL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_PL_OPERATOR, 63132, L"Operator", L"bold", L"" }, - { SCE_PL_SCALAR, 63215, L"Scalar $var", L"fore:#0A246A", L"" }, - { SCE_PL_ARRAY, 63216, L"Array @var", L"fore:#003CE6", L"" }, - { SCE_PL_HASH, 63217, L"Hash %var", L"fore:#B000B0", L"" }, - { SCE_PL_SYMBOLTABLE, 63218, L"Symbol table *var", L"fore:#3A6EA5", L"" }, - { SCE_PL_REGEX, 63219, L"Regex /re/ or m{re}", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_PL_REGSUBST, 63220, L"Substitution s/re/ore/", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_PL_BACKTICKS, 63221, L"Back ticks", L"fore:#E24000; back:#FFF1A8", L"" }, - { SCE_PL_HERE_DELIM, 63223, L"Here-doc (delimiter)", L"fore:#648000", L"" }, - { SCE_PL_HERE_Q, 63224, L"Here-doc (single quoted, q)", L"fore:#648000", L"" }, - { SCE_PL_HERE_QQ, 63225, L"Here-doc (double quoted, qq)", L"fore:#648000", L"" }, - { SCE_PL_HERE_QX, 63226, L"Here-doc (back ticks, qx)", L"fore:#E24000; back:#FFF1A8", L"" }, - { SCE_PL_STRING_Q, 63227, L"Single quoted string (generic, q)", L"fore:#008000", L"" }, - { SCE_PL_STRING_QQ, 63228, L"Double quoted string (qq)", L"fore:#008000", L"" }, - { SCE_PL_STRING_QX, 63229, L"Back ticks (qx)", L"fore:#E24000; back:#FFF1A8", L"" }, - { SCE_PL_STRING_QR, 63230, L"Regex (qr)", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_PL_STRING_QW, 63231, L"Array (qw)", L"fore:#003CE6", L"" }, - { SCE_PL_SUB_PROTOTYPE, 63253, L"Prototype", L"fore:#800080; back:#FFE2FF", L"" }, - { SCE_PL_FORMAT_IDENT, 63254, L"Format identifier", L"bold; fore:#648000; back:#FFF1A8", L"" }, - { SCE_PL_FORMAT, 63255, L"Format body", L"fore:#648000; back:#FFF1A8", L"" }, - { SCE_PL_POD, 63213, L"POD (common)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, - { SCE_PL_POD_VERB, 63214, L"POD (verbatim)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, - { SCE_PL_DATASECTION, 63222, L"Data section", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, - { SCE_PL_ERROR, 63252, L"Parsing error", L"fore:#C80000; back:#FFFF80", L"" }, - //{ SCE_PL_PUNCTUATION, L"Symbols / punctuation (not used)", L"", L"" }, - //{ SCE_PL_PREPROCESSOR, L"Preprocessor (not used)", L"", L"" }, - //{ SCE_PL_LONGQUOTE, L"Long quote (qq, qr, qw, qx) (not used)", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_INI = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexINI = { SCLEX_PROPERTIES, 63015, L"Configuration Files", L"ini; inf; reg; cfg; properties; oem; sif; url; sed; theme", L"", &KeyWords_INI, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_PROPS_DEFAULT, L"Default", L"", L"" }, - { SCE_PROPS_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_PROPS_SECTION, 63232, L"Section", L"fore:#000000; back:#FF8040; bold; eolfilled", L"" }, - { SCE_PROPS_ASSIGNMENT, 63233, L"Assignment", L"fore:#FF0000", L"" }, - { SCE_PROPS_DEFVAL, 63234, L"Default Value", L"fore:#FF0000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_BAT = { -"arp assoc attrib bcdedit bootcfg break cacls call cd change chcp chdir chkdsk chkntfs choice cipher " -"cleanmgr cls cmd cmdkey color com comp compact con convert copy country ctty date defined defrag del " -"dir disableextensions diskcomp diskcopy diskpart do doskey driverquery echo echo. else enableextensions " -"enabledelayedexpansion endlocal equ erase errorlevel exist exit expand fc find findstr for forfiles format " -"fsutil ftp ftype geq goto gpresult gpupdate graftabl gtr help icacls if in ipconfig kill label leq loadfix " -"loadhigh logman logoff lpt lss md mem mkdir mklink mode more move msg msiexe nbtstat neq net netstat netsh " -"not nslookup nul openfiles path pathping pause perfmon popd powercfg print prompt pushd rd recover reg regedit " -"regsvr32 rem ren rename replace rmdir robocopy route runas rundll32 sc schtasks sclist set setlocal sfc shift " -"shutdown sort start subst systeminfo taskkill tasklist time timeout title tracert tree type typeperf ver verify " -"vol wmic xcopy", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexBAT = { SCLEX_BATCH, 63016, L"Batch Files", L"bat; cmd", L"", &KeyWords_BAT, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_BAT_DEFAULT, L"Default", L"", L"" }, - { SCE_BAT_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_BAT_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, - { SCE_BAT_IDENTIFIER, 63129, L"Identifier", L"fore:#003CE6; back:#FFF1A8", L"" }, - { SCE_BAT_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { MULTI_STYLE(SCE_BAT_COMMAND,SCE_BAT_HIDE,0,0), 63236, L"Command", L"bold", L"" }, - { SCE_BAT_LABEL, 63235, L"Label", L"fore:#C80000; back:#F4F4F4; eolfilled", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_DIFF = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexDIFF = { SCLEX_DIFF, 63017, L"Diff Files", L"diff; patch", L"", &KeyWords_DIFF, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_DIFF_DEFAULT, L"Default", L"", L"" }, - { SCE_DIFF_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_DIFF_COMMAND, 63236, L"Command", L"bold; fore:#0A246A", L"" }, - { SCE_DIFF_HEADER, 63238, L"Source and Destination", L"fore:#C80000; back:#FFF1A8; eolfilled", L"" }, - { SCE_DIFF_POSITION, 63239, L"Position Setting", L"fore:#0000FF", L"" }, - { SCE_DIFF_ADDED, 63240, L"Line Addition", L"fore:#002000; back:#80FF80; eolfilled", L"" }, - { SCE_DIFF_DELETED, 63241, L"Line Removal", L"fore:#200000; back:#FF8080; eolfilled", L"" }, - { SCE_DIFF_CHANGED, 63242, L"Line Change", L"fore:#000020; back:#8080FF; eolfilled", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_SQL = { -"abort accessible action add after all alter analyze and as asc asensitive attach autoincrement " -"before begin between bigint binary bit blob both by call cascade case cast change char character " -"check collate column commit condition conflict constraint continue convert create cross current_date " -"current_time current_timestamp current_user cursor database databases date day_hour day_microsecond " -"day_minute day_second dec decimal declare default deferrable deferred delayed delete desc describe " -"detach deterministic distinct distinctrow div double drop dual each else elseif enclosed end enum " -"escape escaped except exclusive exists exit explain fail false fetch float float4 float8 for force " -"foreign from full fulltext glob grant group having high_priority hour_microsecond hour_minute " -"hour_second if ignore immediate in index infile initially inner inout insensitive insert instead int " -"int1 int2 int3 int4 int8 integer intersect interval into is isnull iterate join key keys kill " -"leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext " -"loop low_priority master_ssl_verify_server_cert match merge mediumblob mediumint mediumtext middleint " -"minute_microsecond minute_second mod modifies natural no no_write_to_binlog not notnull null numeric " -"of offset on optimize option optionally or order out outer outfile plan pragma precision primary " -"procedure purge query raise range read read_only read_write reads real references regexp reindex " -"release rename repeat replace require restrict return revoke right rlike rollback row rowid schema " -"schemas second_microsecond select sensitive separator set show smallint spatial specific sql " -"sql_big_result sql_calc_found_rows sql_small_result sqlexception sqlstate sqlwarning ssl starting " -"straight_join table temp temporary terminated text then time timestamp tinyblob tinyint tinytext to " -"trailing transaction trigger true undo union unique unlock unsigned update usage use using utc_date " -"utc_time utc_timestamp vacuum values varbinary varchar varcharacter varying view virtual when where " -"while with write xor year_month zerofill", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexSQL = { SCLEX_SQL, 63018, L"SQL Query", L"sql", L"", &KeyWords_SQL, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_SQL_DEFAULT, L"Default", L"", L"" }, - { SCE_SQL_COMMENT, 63127, L"Comment", L"fore:#505050", L"" }, - { SCE_SQL_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" }, - { MULTI_STYLE(SCE_SQL_STRING,SCE_SQL_CHARACTER,0,0), 63131, L"String", L"fore:#008000; back:#FFF1A8", L"" }, - { SCE_SQL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" }, - { SCE_SQL_QUOTEDIDENTIFIER, 63243, L"Quoted Identifier", L"fore:#800080; back:#FFCCFF", L"" }, - { SCE_SQL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_SQL_OPERATOR, 63132, L"Operator", L"bold; fore:#800080", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_PY = { -"and as assert break class continue def del elif else except " -"exec False finally for from global if import in is lambda None " -"nonlocal not or pass print raise return True try while with yield", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexPY = { SCLEX_PYTHON, 63019, L"Python Script", L"py; pyw", L"", &KeyWords_PY, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_P_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#880000", L"" }, - { SCE_P_WORD, 63128, L"Keyword", L"fore:#000088", L"" }, - { SCE_P_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,0,0), 63211, L"String double quoted", L"fore:#008800", L"" }, - { SCE_P_CHARACTER, 63212, L"String single quoted", L"fore:#008800", L"" }, - { SCE_P_TRIPLEDOUBLE, 63244, L"String triple double quotes", L"fore:#008800", L"" }, - { SCE_P_TRIPLE, 63245, L"String triple single quotes", L"fore:#008800", L"" }, - { SCE_P_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" }, - { SCE_P_OPERATOR, 63132, L"Operator", L"bold; fore:#666600", L"" }, - { SCE_P_DEFNAME, 63247, L"Function name", L"fore:#660066", L"" }, - { SCE_P_CLASSNAME, 63246, L"Class name", L"fore:#660066", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_CONF = { -"acceptfilter acceptmutex acceptpathinfo accessconfig accessfilename action addalt addaltbyencoding " -"addaltbytype addcharset adddefaultcharset adddescription addencoding addhandler addicon addiconbyencoding " -"addiconbytype addinputfilter addlanguage addmodule addmoduleinfo addoutputfilter addoutputfilterbytype " -"addtype agentlog alias aliasmatch all allow allowconnect allowencodedslashes allowmethods allowoverride " -"allowoverridelist anonymous anonymous_authoritative anonymous_logemail anonymous_mustgiveemail " -"anonymous_nouserid anonymous_verifyemail assignuserid asyncrequestworkerfactor authauthoritative " -"authbasicauthoritative authbasicfake authbasicprovider authbasicusedigestalgorithm authdbauthoritative " -"authdbduserpwquery authdbduserrealmquery authdbgroupfile authdbmauthoritative authdbmgroupfile " -"authdbmtype authdbmuserfile authdbuserfile authdigestalgorithm authdigestdomain authdigestfile " -"authdigestgroupfile authdigestnccheck authdigestnonceformat authdigestnoncelifetime authdigestprovider " -"authdigestqop authdigestshmemsize authformauthoritative authformbody authformdisablenostore authformfakebasicauth " -"authformlocation authformloginrequiredlocation authformloginsuccesslocation authformlogoutlocation authformmethod " -"authformmimetype authformpassword authformprovider authformsitepassphrase authformsize authformusername " -"authgroupfile authldapauthoritative authldapauthorizeprefix authldapbindauthoritative authldapbinddn " -"authldapbindpassword authldapcharsetconfig authldapcompareasuser authldapcomparednonserver " -"authldapdereferencealiases authldapenabled authldapfrontpagehack authldapgroupattribute " -"authldapgroupattributeisdn authldapinitialbindasuser authldapinitialbindpattern authldapmaxsubgroupdepth " -"authldapremoteuserattribute authldapremoteuserisdn authldapsearchasuser authldapsubgroupattribute " -"authldapsubgroupclass authldapurl authmerging authname authncachecontext authncacheenable authncacheprovidefor " -"authncachesocache authncachetimeout authnprovideralias authnzfcgicheckauthnprovider authnzfcgidefineprovider " -"authtype authuserfile authzdbdlogintoreferer authzdbdquery authzdbdredirectquery authzdbmtype " -"authzsendforbiddenonfailure balancergrowth balancerinherit balancermember balancerpersist bindaddress " -"browsermatch browsermatchnocase bs2000account bufferedlogs buffersize cachedefaultexpire cachedetailheader " -"cachedirlength cachedirlevels cachedisable cacheenable cacheexpirycheck cachefile cacheforcecompletion " -"cachegcclean cachegcdaily cachegcinterval cachegcmemusage cachegcunused cacheheader cacheignorecachecontrol " -"cacheignoreheaders cacheignorenolastmod cacheignorequerystring cacheignoreurlsessionidentifiers " -"cachekeybaseurl cachelastmodifiedfactor cachelock cachelockmaxage cachelockpath cachemaxexpire " -"cachemaxfilesize cacheminexpire cacheminfilesize cachenegotiateddocs cachequickhandler cachereadsize " -"cachereadtime cacheroot cachesize cachesocache cachesocachemaxsize cachesocachemaxtime cachesocachemintime " -"cachesocachereadsize cachesocachereadtime cachestaleonerror cachestoreexpired cachestorenostore cachestoreprivate " -"cachetimemargin cgidscripttimeout cgimapextension cgipassauth cgivar charsetdefault charsetoptions charsetsourceenc " -"checkcaseonly checkspelling childperuserid chrootdir clearmodulelist contentdigest cookiedomain cookieexpires " -"cookielog cookiename cookiestyle cookietracking coredumpdirectory customlog dav davdepthinfinity davgenericlockdb " -"davlockdb davmintimeout dbdexptime dbdinitsql dbdkeep dbdmax dbdmin dbdparams dbdpersist dbdpreparesql dbdriver " -"defaulticon defaultlanguage defaultruntimedir defaulttype define deflatebuffersize deflatecompressionlevel " -"deflatefilternote deflateinflatelimitrequestbody deflateinflateratioburst deflateinflateratiolimit deflatememlevel " -"deflatewindowsize deny directory directorycheckhandler directoryindex directoryindexredirect directorymatch " -"directoryslash documentroot dtraceprivileges dumpioinput dumpiooutput else elseif enableexceptionhook enablemmap " -"enablesendfile error errordocument errorlog errorlogformat example expiresactive expiresbytype expiresdefault " -"extendedstatus extfilterdefine extfilteroptions fallbackresource fancyindexing fileetag files filesmatch " -"filterchain filterdeclare filterprotocol filterprovider filtertrace forcelanguagepriority forcetype forensiclog " -"from globallog gracefulshutdowntimeout group h2direct h2maxsessionstreams h2maxworkeridleseconds h2maxworkers " -"h2minworkers h2moderntlsonly h2push h2pushdiarysize h2pushpriority h2serializeheaders h2sessionextrafiles " -"h2streammaxmemsize h2tlscooldownsecs h2tlswarmupsize h2upgrade h2windowsize header headername heartbeataddress " -"heartbeatlisten heartbeatmaxservers heartbeatstorage hostnamelookups identitycheck identitychecktimeout " -"if ifdefine ifmodule ifversion imapbase imapdefault imapmenu include includeoptional indexheadinsert " -"indexignore indexignorereset indexoptions indexorderdefault indexstylesheet inputsed isapiappendlogtoerrors " -"isapiappendlogtoquery isapicachefile isapifakeasync isapilognotsupported isapireadaheadbuffer keepalive " -"keepalivetimeout keptbodysize languagepriority ldapcacheentries ldapcachettl ldapconnectionpoolttl " -"ldapconnectiontimeout ldaplibrarydebug ldapopcacheentries ldapopcachettl ldapreferralhoplimit ldapreferrals " -"ldapretries ldapretrydelay ldapsharedcachefile ldapsharedcachesize ldaptimeout ldaptrustedca ldaptrustedcatype " -"ldaptrustedclientcert ldaptrustedglobalcert ldaptrustedmode ldapverifyservercert limit limitexcept " -"limitinternalrecursion limitrequestbody limitrequestfields limitrequestfieldsize limitrequestline " -"limitxmlrequestbody listen listenbacklog listencoresbucketsratio loadfile loadmodule location " -"locationmatch lockfile logformat logiotrackttfb loglevel logmessage luaauthzprovider luacodecache " -"luahookaccesschecker luahookauthchecker luahookcheckuserid luahookfixups luahookinsertfilter luahooklog " -"luahookmaptostorage luahooktranslatename luahooktypechecker luainherit luainputfilter luamaphandler " -"luaoutputfilter luapackagecpath luapackagepath luaquickhandler luaroot luascope macro maxclients " -"maxconnectionsperchild maxkeepaliverequests maxmemfree maxrangeoverlaps maxrangereversals maxranges " -"maxrequestsperchild maxrequestsperthread maxrequestworkers maxspareservers maxsparethreads maxthreads " -"maxthreadsperchild mcachemaxobjectcount mcachemaxobjectsize mcachemaxstreamingbuffer mcacheminobjectsize " -"mcacheremovalalgorithm mcachesize memcacheconnttl mergetrailers metadir metafiles metasuffix mimemagicfile " -"minspareservers minsparethreads mmapfile modemstandard modmimeusepathinfo multiviewsmatch mutex namevirtualhost " -"nocache noproxy numservers nwssltrustedcerts nwsslupgradeable options order outputsed passenv pidfile port " -"privilegesmode protocol protocolecho protocols protocolshonororder proxy proxyaddheaders proxybadheader " -"proxyblock proxydomain proxyerroroverride proxyexpressdbmfile proxyexpressdbmtype proxyexpressenable " -"proxyftpdircharset proxyftpescapewildcards proxyftplistonwildcard proxyhcexpr proxyhctemplate proxyhctpsize " -"proxyhtmlbufsize proxyhtmlcharsetout proxyhtmldoctype proxyhtmlenable proxyhtmlevents proxyhtmlextended " -"proxyhtmlfixups proxyhtmlinterp proxyhtmllinks proxyhtmlmeta proxyhtmlstripcomments proxyhtmlurlmap " -"proxyiobuffersize proxymatch proxymaxforwards proxypass proxypassinherit proxypassinterpolateenv " -"proxypassmatch proxypassreverse proxypassreversecookiedomain proxypassreversecookiepath proxypreservehost " -"proxyreceivebuffersize proxyremote proxyremotematch proxyrequests proxyscgiinternalredirect proxyscgisendfile " -"proxyset proxysourceaddress proxystatus proxytimeout proxyvia qsc qualifyredirecturl readmename " -"receivebuffersize redirect redirectmatch redirectpermanent redirecttemp refererignore refererlog " -"reflectorheader remoteipheader remoteipinternalproxy remoteipinternalproxylist remoteipproxiesheader " -"remoteiptrustedproxy remoteiptrustedproxylist removecharset removeencoding removehandler removeinputfilter " -"removelanguage removeoutputfilter removetype requestheader requestreadtimeout require requireall " -"requireany requirenone resourceconfig rewritebase rewritecond rewriteengine rewritelock rewritelog " -"rewriteloglevel rewritemap rewriteoptions rewriterule rlimitcpu rlimitmem rlimitnproc satisfy " -"scoreboardfile script scriptalias scriptaliasmatch scriptinterpretersource scriptlog scriptlogbuffer " -"scriptloglength scriptsock securelisten seerequesttail sendbuffersize serveradmin serveralias serverlimit " -"servername serverpath serverroot serversignature servertokens servertype session sessioncookiename " -"sessioncookiename2 sessioncookieremove sessioncryptocipher sessioncryptodriver sessioncryptopassphrase " -"sessioncryptopassphrasefile sessiondbdcookiename sessiondbdcookiename2 sessiondbdcookieremove " -"sessiondbddeletelabel sessiondbdinsertlabel sessiondbdperuser sessiondbdselectlabel sessiondbdupdatelabel " -"sessionenv sessionexclude sessionheader sessioninclude sessionmaxage setenv setenvif setenvifexpr " -"setenvifnocase sethandler setinputfilter setoutputfilter singlelisten ssiendtag ssierrormsg ssietag " -"ssilastmodified ssilegacyexprparser ssistarttag ssitimeformat ssiundefinedecho sslcacertificatefile " -"sslcacertificatepath sslcadnrequestfile sslcadnrequestpath sslcarevocationcheck sslcarevocationfile " -"sslcarevocationpath sslcertificatechainfile sslcertificatefile sslcertificatekeyfile sslciphersuite " -"sslcompression sslcryptodevice sslengine sslfips sslhonorcipherorder sslinsecurerenegotiation sslmutex " -"sslocspdefaultresponder sslocspenable sslocspoverrideresponder sslocspproxyurl sslocsprespondertimeout " -"sslocspresponsemaxage sslocspresponsetimeskew sslocspuserequestnonce sslopensslconfcmd ssloptions " -"sslpassphrasedialog sslprotocol sslproxycacertificatefile sslproxycacertificatepath sslproxycarevocationcheck " -"sslproxycarevocationfile sslproxycarevocationpath sslproxycheckpeercn sslproxycheckpeerexpire " -"sslproxycheckpeername sslproxyciphersuite sslproxyengine sslproxymachinecertificatechainfile " -"sslproxymachinecertificatefile sslproxymachinecertificatepath sslproxyprotocol sslproxyverify " -"sslproxyverifydepth sslrandomseed sslrenegbuffersize sslrequire sslrequiressl sslsessioncache " -"sslsessioncachetimeout sslsessionticketkeyfile sslsessiontickets sslsrpunknownuserseed " -"sslsrpverifierfile sslstaplingcache sslstaplingerrorcachetimeout sslstaplingfaketrylater " -"sslstaplingforceurl sslstaplingrespondertimeout sslstaplingresponsemaxage sslstaplingresponsetimeskew " -"sslstaplingreturnrespondererrors sslstaplingstandardcachetimeout sslstrictsnivhostcheck sslusername " -"sslusestapling sslverifyclient sslverifydepth startservers startthreads substitute substituteinheritbefore " -"substitutemaxlinelength suexec suexecusergroup threadlimit threadsperchild threadstacksize timeout " -"traceenable transferlog typesconfig undefine undefmacro unsetenv use usecanonicalname usecanonicalphysicalport " -"user userdir vhostcgimode vhostcgiprivs vhostgroup vhostprivs vhostsecure vhostuser virtualdocumentroot " -"virtualdocumentrootip virtualhost virtualscriptalias virtualscriptaliasip watchdoginterval win32disableacceptex " -"xbithack xml2encalias xml2encdefault xml2startparse", -"", //"on off standalone inetd force-response-1.0 downgrade-1.0 nokeepalive indexes includes followsymlinks none x-compress x-gzip", -"", "", "", "", "", "", "" }; - - -EDITLEXER lexCONF = { SCLEX_CONF, 63020, L"Apache Config Files", L"conf; htaccess", L"", &KeyWords_CONF, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { SCE_CONF_COMMENT, 63127, L"Comment", L"fore:#648000", L"" }, - { SCE_CONF_STRING, 63131, L"String", L"fore:#B000B0", L"" }, - { SCE_CONF_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" }, - { SCE_CONF_DIRECTIVE, 63203, L"Directive", L"fore:#003CE6", L"" }, - { SCE_CONF_IP, 63248, L"IP Address", L"bold; fore:#FF4000", L"" }, -// Not used by lexer { SCE_CONF_IDENTIFIER, L"Identifier", L"", L"" }, -// Lexer is buggy { SCE_CONF_OPERATOR, L"Operator", L"", L"" }, -// Lexer is buggy { SCE_CONF_PARAMETER, L"Runtime Directive Parameter", L"", L"" }, -// Lexer is buggy { SCE_CONF_EXTENSION, L"Extension", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_PS = { -"begin break catch continue data do dynamicparam else elseif end exit filter finally for foreach " -"from function if in local param private process return switch throw trap try until where while", -"add-computer add-content add-history add-member add-pssnapin add-type checkpoint-computer " -"clear-content clear-eventlog clear-history clear-host clear-item clear-itemproperty " -"clear-variable compare-object complete-transaction connect-wsman convertfrom-csv " -"convertfrom-securestring convertfrom-stringdata convert-path convertto-csv convertto-html " -"convertto-securestring convertto-xml copy-item copy-itemproperty debug-process " -"disable-computerrestore disable-psbreakpoint disable-psremoting disable-pssessionconfiguration " -"disable-wsmancredssp disconnect-wsman enable-computerrestore enable-psbreakpoint " -"enable-psremoting enable-pssessionconfiguration enable-wsmancredssp enter-pssession " -"exit-pssession export-alias export-clixml export-console export-counter export-csv " -"export-formatdata export-modulemember export-pssession foreach-object format-custom format-list " -"format-table format-wide get-acl get-alias get-authenticodesignature get-childitem get-command " -"get-computerrestorepoint get-content get-counter get-credential get-culture get-date get-event " -"get-eventlog get-eventsubscriber get-executionpolicy get-formatdata get-help get-history " -"get-host get-hotfix get-item get-itemproperty get-job get-location get-member get-module " -"get-pfxcertificate get-process get-psbreakpoint get-pscallstack get-psdrive get-psprovider " -"get-pssession get-pssessionconfiguration get-pssnapin get-random get-service get-tracesource " -"get-transaction get-uiculture get-unique get-variable get-verb get-winevent get-wmiobject " -"get-wsmancredssp get-wsmaninstance group-object import-alias import-clixml import-counter " -"import-csv import-localizeddata import-module import-pssession invoke-command invoke-expression " -"invoke-history invoke-item invoke-restmethod invoke-webrequest invoke-wmimethod " -"invoke-wsmanaction join-path limit-eventlog measure-command measure-object move-item " -"move-itemproperty new-alias new-event new-eventlog new-item new-itemproperty new-module " -"new-modulemanifest new-object new-psdrive new-pssession new-pssessionoption new-service " -"new-timespan new-variable new-webserviceproxy new-wsmaninstance new-wsmansessionoption " -"out-default out-file out-gridview out-host out-null out-printer out-string pop-location " -"push-location read-host receive-job register-engineevent register-objectevent " -"register-pssessionconfiguration register-wmievent remove-computer remove-event remove-eventlog " -"remove-item remove-itemproperty remove-job remove-module remove-psbreakpoint remove-psdrive " -"remove-pssession remove-pssnapin remove-variable remove-wmiobject remove-wsmaninstance " -"rename-item rename-itemproperty reset-computermachinepassword resolve-path restart-computer " -"restart-service restore-computer resume-service select-object select-string select-xml " -"send-mailmessage set-acl set-alias set-authenticodesignature set-content set-date " -"set-executionpolicy set-item set-itemproperty set-location set-psbreakpoint set-psdebug " -"set-pssessionconfiguration set-service set-strictmode set-tracesource set-variable " -"set-wmiinstance set-wsmaninstance set-wsmanquickconfig show-eventlog sort-object split-path " -"start-job start-process start-service start-sleep start-transaction start-transcript " -"stop-computer stop-job stop-process stop-service stop-transcript suspend-service tee-object " -"test-computersecurechannel test-connection test-modulemanifest test-path test-wsman " -"trace-command undo-transaction unregister-event unregister-pssessionconfiguration " -"update-formatdata update-list update-typedata use-transaction wait-event wait-job wait-process " -"where-object write-debug write-error write-eventlog write-host write-output write-progress " -"write-verbose write-warning", -"ac asnp cat cd chdir clc clear clhy cli clp cls clv compare copy cp cpi cpp cvpa dbp del diff " -"dir ebp echo epal epcsv epsn erase etsn exsn fc fl foreach ft fw gal gbp gc gci gcm gcs gdr ghy " -"gi gjb gl gm gmo gp gps group gsn gsnp gsv gu gv gwmi h help history icm iex ihy ii ipal ipcsv " -"ipmo ipsn ise iwmi kill lp ls man md measure mi mkdir more mount move mp mv nal ndr ni nmo nsn " -"nv ogv oh popd ps pushd pwd r rbp rcjb rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rv " -"rvpa rwmi sajb sal saps sasv sbp sc select set si sl sleep sort sp spjb spps spsv start sv swmi " -"tee type where wjb write", -"importsystemmodules prompt psedit tabexpansion", -"", "", "", "", "" }; - - -EDITLEXER lexPS = { SCLEX_POWERSHELL, 63021, L"PowerShell Script", L"ps1; psd1; psm1", L"", &KeyWords_PS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_POWERSHELL_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_POWERSHELL_COMMENT,SCE_POWERSHELL_COMMENTSTREAM,0,0), 63127, L"Comment", L"fore:#646464", L"" }, - { SCE_POWERSHELL_KEYWORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, - { SCE_POWERSHELL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_POWERSHELL_STRING,SCE_POWERSHELL_CHARACTER,0,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_POWERSHELL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_POWERSHELL_OPERATOR, 63132, L"Operator", L"bold", L"" }, - { SCE_POWERSHELL_VARIABLE, 63249, L"Variable", L"fore:#0A246A", L"" }, - { MULTI_STYLE(SCE_POWERSHELL_CMDLET,SCE_POWERSHELL_FUNCTION,0,0), 63250, L"Cmdlet", L"fore:#804000; back:#FFF1A8", L"" }, - { SCE_POWERSHELL_ALIAS, 63251, L"Alias", L"bold; fore:#0A246A", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_NSIS = { -"!addincludedir !addplugindir !appendfile !cd !define !delfile !echo !else !endif !error " -"!execute !finalize !getdllversion !if !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro !macro " -"!macroend !macroundef !makensis !packhdr !searchparse !searchreplace !system !tempfile !undef !verbose !warning " -".onguiend .onguiinit .oninit .oninstfailed .oninstsuccess .onmouseoversection .onrebootfailed .onselchange " -".onuserabort .onverifyinstdir un.onguiend un.onguiinit un.oninit un.onrebootfailed un.onuninstfailed un.onuninstsuccess " -"un.onuserabort abort addbrandingimage addsize allowrootdirinstall allowskipfiles autoclosewindow " -"bannertrimpath bgfont bggradient brandingtext bringtofront call callinstdll caption changeui checkbitmap " -"clearerrors completedtext componenttext copyfiles crccheck createdirectory createfont createshortcut " -"delete deleteinisec deleteinistr deleteregkey deleteregvalue detailprint detailsbuttontext dirstate dirtext " -"dirvar dirverify enablewindow enumregkey enumregvalue exch exec execshell execwait expandenvstrings " -"file filebufsize fileclose fileerrortext fileexists fileopen fileread filereadbyte filereadutf16le filereadword " -"fileseek filewrite filewritebyte filewriteutf16le filewriteword findclose findfirst findnext findproc " -"findwindow flushini getcurinsttype getcurrentaddress getdlgitem getdllversion getdllversionlocal " -"geterrorlevel getfiletime getfiletimelocal getfontname getfontnamelocal getfontversion getfontversionlocal " -"getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto hidewindow icon " -"ifabort iferrors iffileexists ifrebootflag ifsilent initpluginsdir installbuttontext installcolors installdir " -"installdirregkey instprogressflags insttype insttypegettext insttypesettext intcmp intcmpu intfmt intop " -"iswindow langstring licensebkcolor licensedata licenseforceselection licenselangstring licensetext " -"loadlanguagefile lockwindow logset logtext manifestsupportedos messagebox miscbuttontext name nop outfile page " -"pagecallbacks pop push quit readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel " -"reservefile return rmdir searchpath sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectionin " -"sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage " -"setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype " -"setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes " -"setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent " -"showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps " -"strcpy strlen subcaption unicode uninstallbuttontext uninstallcaption uninstallicon uninstallsubcaption uninstalltext " -"uninstpage unregdll var viaddversionkey vifileversion viproductversion windowicon writeinistr writeregbin " -"writeregdword writeregexpandstr writeregstr writeuninstaller xpstyle", -"${nsisdir} $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $instdir $outdir $cmdline " -"$language $programfiles $programfiles32 $programfiles64 $commonfiles $commonfiles32 $commonfiles64 " -"$desktop $exedir $exefile $exepath $windir $sysdir $temp $startmenu $smprograms $smstartup $quicklaunch " -"$documents $sendto $recent $favorites $music $pictures $videos $nethood $fonts $templates $appdata " -"$localappdata $printhood $internet_cache $cookies $history $profile $admintools $resources $resources_localized " -"$cdburn_area $hwndparent $pluginsdir ${__date__} ${__file__} ${__function__} ${__global__} ${__line__} " -"${__pageex__} ${__section__} ${__time__} ${__timestamp__} ${__uninstall__}", -"alt charset colored control cur date end global ignorecase leave shift smooth utcdate sw_hide sw_showmaximized " -"sw_showminimized sw_shownormal archive auto oname rebootok nonfatal ifempty nounload filesonly short mb_ok " -"mb_okcancel mb_abortretryignore mb_retrycancel mb_yesno mb_yesnocancel mb_iconexclamation mb_iconinformation " -"mb_iconquestion mb_iconstop mb_usericon mb_topmost mb_setforeground mb_right mb_rtlreading mb_defbutton1 " -"mb_defbutton2 mb_defbutton3 mb_defbutton4 idabort idcancel idignore idno idok idretry idyes sd current all " -"timeout imgid resizetofit listonly textonly both branding hkcr hkey_classes_root hklm hkey_local_machine hkcu " -"hkey_current_user hku hkey_users hkcc hkey_current_config hkdd hkey_dyn_data hkpd hkey_performance_data shctx " -"shell_context left right top bottom true false on off italic underline strike trimleft trimright trimcenter " -"idd_license idd_dir idd_selcom idd_inst idd_instfiles idd_uninst idd_verify force windows nocustom customstring " -"componentsonlyoncustom gray none user highest admin lang hide show nevershow normal silent silentlog solid final " -"zlib bzip2 lzma try ifnewer ifdiff lastused manual alwaysoff normal file_attribute_normal file_attribute_archive " -"hidden file_attribute_hidden offline file_attribute_offline readonly file_attribute_readonly system " -"file_attribute_system temporary file_attribute_temporary custom license components directory instfiles " -"uninstconfirm 32 64 enablecancel noworkingdir plugin rawnl winvista win7 win8 win8.1 win10", -"", "", "", "", "", "" }; - - -EDITLEXER lexNSIS = { SCLEX_NSIS, 63284, L"NSIS Script", L"nsi; nsh", L"", &KeyWords_NSIS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_NSIS_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_NSIS_COMMENT,SCE_NSIS_COMMENTBOX,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_NSIS_STRINGDQ,SCE_NSIS_STRINGLQ,SCE_NSIS_STRINGRQ,0), 63131, L"String", L"fore:#666666; back:#EEEEEE", L"" }, - { SCE_NSIS_FUNCTION, 63277, L"Function", L"fore:#0033CC", L"" }, - { SCE_NSIS_VARIABLE, 63249, L"Variable", L"fore:#CC3300", L"" }, - { SCE_NSIS_STRINGVAR, 63285, L"Variable within String", L"fore:#CC3300; back:#EEEEEE", L"" }, - { SCE_NSIS_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { SCE_NSIS_LABEL, 63286, L"Constant", L"fore:#FF9900", L"" }, - { SCE_NSIS_SECTIONDEF, 63232, L"Section", L"fore:#0033CC", L"" }, - { SCE_NSIS_SUBSECTIONDEF, 63287, L"Sub Section", L"fore:#0033CC", L"" }, - { SCE_NSIS_SECTIONGROUP, 63288, L"Section Group", L"fore:#0033CC", L"" }, - { SCE_NSIS_FUNCTIONDEF, 63289, L"Function Definition", L"fore:#0033CC", L"" }, - { SCE_NSIS_PAGEEX, 63290, L"PageEx", L"fore:#0033CC", L"" }, - { SCE_NSIS_IFDEFINEDEF, 63291, L"If Definition", L"fore:#0033CC", L"" }, - { SCE_NSIS_MACRODEF, 63292, L"Macro Definition", L"fore:#0033CC", L"" }, - //{ SCE_NSIS_USERDEFINED, L"User Defined", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_INNO = { -"code components custommessages dirs files icons ini installdelete langoptions languages messages " -"registry run setup types tasks uninstalldelete uninstallrun _istool", -"allowcancelduringinstall allownetworkdrive allownoicons allowrootdirectory allowuncpath alwaysrestart " -"alwaysshowcomponentslist alwaysshowdironreadypage alwaysshowgrouponreadypage alwaysusepersonalgroup appcomments " -"appcontact appcopyright appenddefaultdirname appenddefaultgroupname appid appmodifypath appmutex appname apppublisher " -"apppublisherurl appreadmefile appsupportphone appsupporturl appupdatesurl appvername appversion architecturesallowed " -"architecturesinstallin64bitmode backcolor backcolor2 backcolordirection backsolid beveledlabel changesassociations " -"changesenvironment closeapplications closeapplicationsfilter compression compressionthreads copyrightfontname " -"copyrightfontsize createappdir createuninstallregkey defaultdirname defaultgroupname defaultuserinfoname " -"defaultuserinfoorg defaultuserinfoserial dialogfontname dialogfontsize direxistswarning disabledirpage " -"disablefinishedpage disableprogramgrouppage disablereadymemo disablereadypage disablestartupprompt " -"disablewelcomepage diskclustersize diskslicesize diskspanning enabledirdoesntexistwarning encryption " -"extradiskspacerequired flatcomponentslist infoafterfile infobeforefile internalcompresslevel languagedetectionmethod " -"languagecodepage languageid languagename licensefile lzmaalgorithm lzmablocksize lzmadictionarysize lzmamatchfinder " -"lzmanumblockthreads lzmanumfastbytes lzmauseseparateprocess mergeduplicatefiles minversion onlybelowversion " -"outputbasefilename outputdir outputmanifestfile password privilegesrequired reservebytes restartapplications " -"restartifneededbyrun righttoleft setupiconfile setuplogging setupmutex showcomponentsizes showlanguagedialog showtaskstreelines " -"showundisplayablelanguages signeduninstaller signeduninstallerdir signtool signtoolretrycount slicesperdisk solidcompression " -"sourcedir strongassemblyname timestamprounding timestampsinutc titlefontname titlefontsize touchdate touchtime uninstallable " -"uninstalldisplayicon uninstalldisplayname uninstallfilesdir uninstalldisplaysize uninstalllogmode uninstallrestartcomputer " -"updateuninstalllogappname usepreviousappdir usepreviousgroup usepreviouslanguage useprevioussetuptype useprevioustasks " -"verb versioninfoproductname useprevioususerinfo userinfopage usesetupldr versioninfocompany versioninfocopyright " -"versioninfodescription versioninfoproductversion versioninfotextversion versioninfoversion versioninfoproducttextversion " -"welcomefontname welcomefontsize windowshowcaption windowstartmaximized windowresizable windowvisible wizardimagealphaformat " -"wizardimagebackcolor wizardimagefile wizardimagestretch wizardsmallimagefile", -"appusermodelid afterinstall attribs beforeinstall check comment components copymode description destdir destname excludes " -"extradiskspacerequired filename flags fontinstall groupdescription hotkey infoafterfile infobeforefile iconfilename " -"iconindex key languages licensefile messagesfile minversion name onlybelowversion parameters permissions root runonceid " -"section source statusmsg string subkey tasks terminalservicesaware type types valuedata valuename valuetype workingdir", -"append define dim else emit elif endif endsub error expr file for if ifdef ifexist ifndef ifnexist include insert pragma " -"sub undef", -"and begin break case const continue do downto else end except finally for function " -"if not of or procedure repeat then to try type until uses var while with", -"", "", "", "" }; - - -EDITLEXER lexINNO = { SCLEX_INNOSETUP, 63293, L"Inno Setup Script", L"iss; isl; islu", L"", &KeyWords_INNO, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_INNO_DEFAULT, L"Default", L"", L"" }, - { SCE_INNO_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_INNO_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, - { SCE_INNO_PARAMETER, 63294, L"Parameter", L"fore:#0000FF", L"" }, - { SCE_INNO_SECTION, 63232, L"Section", L"fore:#000080; bold", L"" }, - { SCE_INNO_PREPROC, 63133, L"Preprocessor", L"fore:#CC0000", L"" }, - { SCE_INNO_INLINE_EXPANSION, 63295, L"Inline Expansion", L"fore:#800080", L"" }, - { SCE_INNO_COMMENT_PASCAL, 63296, L"Pascal Comment", L"fore:#008000", L"" }, - { SCE_INNO_KEYWORD_PASCAL, 63297, L"Pascal Keyword", L"fore:#0000FF", L"" }, - { MULTI_STYLE(SCE_INNO_STRING_DOUBLE,SCE_INNO_STRING_SINGLE,0,0), 63131, L"String", L"", L"" }, - //{ SCE_INNO_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - //{ SCE_INNO_KEYWORD_USER, L"User Defined", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_RUBY = { -"__FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure " -"false for in if module next nil not or redo rescue retry return self super then true " -"undef unless until when while yield", -"", "", "", "", "", "", "", "" }; - -EDITLEXER lexRUBY = { SCLEX_RUBY, 63304, L"Ruby Script", L"rb; ruby; rbw; rake; rjs; Rakefile; gemspec", L"", &KeyWords_RUBY, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_P_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_RB_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_RB_WORD, 63128, L"Keyword", L"fore:#00007F", L"" }, - { SCE_RB_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { SCE_RB_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - { SCE_RB_OPERATOR, 63132, L"Operator", L"", L"" }, - { MULTI_STYLE(SCE_RB_STRING,SCE_RB_CHARACTER,SCE_P_STRINGEOL,0), 63131, L"String", L"fore:#FF8000", L"" }, - { SCE_RB_CLASSNAME, 63246, L"Class name", L"fore:#0000FF", L"" }, - { SCE_RB_DEFNAME, 63247, L"Function name", L"fore:#007F7F", L"" }, - { SCE_RB_POD, 63314, L"POD", L"fore:#004000; back:#C0FFC0; eolfilled", L"" }, - { SCE_RB_REGEX, 63315, L"Regex", L"fore:#000000; back:#A0FFA0", L"" }, - { SCE_RB_SYMBOL, 63316, L"Symbol", L"fore:#C0A030", L"" }, - { SCE_RB_MODULE_NAME, 63317, L"Module name", L"fore:#A000A0", L"" }, - { SCE_RB_INSTANCE_VAR, 63318, L"Instance Var", L"fore:#B00080", L"" }, - { SCE_RB_CLASS_VAR, 63319, L"Class Var", L"fore:#8000B0", L"" }, - { SCE_RB_DATASECTION, 63320, L"Data Section", L"fore:#600000; back:#FFF0D8; eolfilled", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_LUA = { -"and break do else elseif end false for function goto if " -"in local nil not or repeat return then true until while", -// Basic Functions -"_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring print rawget rawset " -"require tonumber tostring type unpack _ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT _STDERR " -"_STDIN _STDOUT call dostring foreach foreachi getn globals newtype sort tinsert tremove " -"_G getfenv getmetatable ipairs loadlib next pairs pcall rawequal setfenv setmetatable xpcall " -"string table math coroutine io os debug load module select", -// String Manipulation, Table Manipulation, Mathematical Functions -"abs acos asin atan atan2 ceil cos deg exp floor format frexp gsub ldexp log log10 max min " -"mod rad random randomseed sin sqrt strbyte strchar strfind strlen strlower strrep strsub strupper tan " -"string.byte string.char string.dump string.find string.len string.lower string.rep string.sub string.upper " -"string.format string.gfind string.gsub table.concat table.foreach table.foreachi table.getn table.sort " -"table.insert table.remove table.setn math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos " -"math.deg math.exp math.floor math.frexp math.ldexp math.log math.log10 math.max math.min math.mod " -"math.pi math.pow math.rad math.random math.randomseed math.sin math.sqrt math.tan string.gmatch " -"string.match string.reverse table.maxn math.cosh math.fmod math.modf math.sinh math.tanh math.huge", -// Input and Output Facilities & System Facilities Coroutine Manipulation, -//Input and Output Facilities, System Facilities (coroutine & io & os) -"openfile closefile readfrom writeto appendto remove rename flush seek tmpfile tmpname read " -"write clock date difftime execute exit getenv setlocale time coroutine.create coroutine.resume " -"coroutine.status coroutine.wrap coroutine.yield io.close io.flush io.input io.lines io.open io.output " -"io.read io.tmpfile io.type io.write io.stdin io.stdout io.stderr os.clock os.date os.difftime " -"os.execute os.exit os.getenv os.remove os.rename os.setlocale os.time os.tmpname coroutine.running " -"package.cpath package.loaded package.loadlib package.path package.preload package.seeall io.popen", -"", "", "", "", "" }; - - -EDITLEXER lexLUA = { SCLEX_LUA, 63298, L"Lua Script", L"lua", L"", &KeyWords_LUA, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_LUA_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_LUA_COMMENT,SCE_LUA_COMMENTLINE,SCE_LUA_COMMENTDOC,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_LUA_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - { SCE_LUA_WORD, 63128, L"Keyword", L"fore:#00007F", L"" }, - { SCE_LUA_WORD2, 63321, L"Basic Functions", L"fore:#00007F", L"" }, - { SCE_LUA_WORD3, 63322, L"String, Table & Math Functions", L"fore:#00007F", L"" }, - { SCE_LUA_WORD4, 63323, L"Input, Output & System Facilities", L"fore:#00007F", L"" }, - { MULTI_STYLE(SCE_LUA_STRING,SCE_LUA_STRINGEOL,SCE_LUA_CHARACTER,0), 63131, L"String", L"fore:#B000B0", L"" }, - { SCE_LUA_LITERALSTRING, 63302, L"Literal String", L"fore:#B000B0", L"" }, - { SCE_LUA_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - { SCE_LUA_OPERATOR, 63132, L"Operator", L"", L"" }, - { SCE_LUA_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { SCE_LUA_LABEL, 63235, L"Label", L"fore:#808000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_BASH = { -"alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal calendar case cat " -"cc cd chmod cksum clear cmp col comm compress continue cp cpio crypt csplit ctags cut date " -"dc dd declare deroff dev df diff diff3 dircmp dirname do done du echo ed egrep elif else " -"env esac eval ex exec exit expand export expr false fc fgrep fi file find fmt fold for function " -"functions getconf getopt getopts grep gres hash head help history iconv id if in integer " -"jobs join kill local lc let line ln logname look ls m4 mail mailx make man mkdir more mt mv " -"newgrp nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print printf ps pwd " -"read readonly red return rev rm rmdir sed select set sh shift size sleep sort spell split " -"start stop strings strip stty sum suspend sync tail tar tee test then time times touch tr " -"trap true tsort tty type typeset ulimit umask unalias uname uncompress unexpand uniq unpack " -"unset until uudecode uuencode vi vim vpax wait wc whence which while who wpaste wstart xargs " -"zcat chgrp chown chroot dir dircolors factor groups hostid install link md5sum mkfifo mknod " -"nice pinky printenv ptx readlink seq sha1sum shred stat su tac unlink users vdir whoami yes", -"", "", "", "", "", "", "", "" }; - - -EDITLEXER lexBASH = { SCLEX_BASH, 63259, L"Shell Script", L"sh", L"", &KeyWords_BASH, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { SCE_SH_ERROR, 63260, L"Error", L"", L"" }, - { SCE_SH_COMMENTLINE, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_SH_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - { SCE_SH_WORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, - { SCE_SH_STRING, 63211, L"String double quoted", L"fore:#008080", L"" }, - { SCE_SH_CHARACTER, 63212, L"String single quoted", L"fore:#800080", L"" }, - { SCE_SH_OPERATOR, 63132, L"Operator", L"", L"" }, - { SCE_SH_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { SCE_SH_SCALAR, 63268, L"Scalar", L"fore:#808000", L"" }, - { SCE_SH_PARAM, 63269, L"Parameter expansion", L"fore:#808000; back:#FFFF99", L"" }, - { SCE_SH_BACKTICKS, 63270, L"Back Ticks", L"fore:#FF0080", L"" }, - { SCE_SH_HERE_DELIM, 63271, L"Here-doc (Delimiter)", L"", L"" }, - { SCE_SH_HERE_Q, 63272, L"Here-doc (Single quoted, q)", L"fore:#008080", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_TCL = { -// TCL Keywords -"after append array auto_execok auto_import auto_load auto_load_index auto_qualify beep " -"bgerror binary break case catch cd clock close concat continue dde default echo else " -"elseif encoding eof error eval exec exit expr fblocked fconfigure fcopy file fileevent " -"flush for foreach format gets glob global history http if incr info interp join lappend " -"lindex linsert list llength load loadTk lrange lreplace lsearch lset lsort memory msgcat " -"namespace open package pid pkg::create pkg_mkIndex Platform-specific proc puts pwd " -"re_syntax read regexp registry regsub rename resource return scan seek set socket source " -"split string subst switch tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell time trace " -"unknown unset update uplevel upvar variable vwait while", -// TK Keywords -"bell bind bindtags bitmap button canvas checkbutton clipboard colors console cursors " -"destroy entry event focus font frame grab grid image Inter-client keysyms label labelframe " -"listbox lower menu menubutton message option options pack panedwindow photo place " -"radiobutton raise scale scrollbar selection send spinbox text tk tk_chooseColor " -"tk_chooseDirectory tk_dialog tk_focusNext tk_getOpenFile tk_messageBox tk_optionMenu " -"tk_popup tk_setPalette tkerror tkvars tkwait toplevel winfo wish wm", -// iTCL Keywords -"@scope body class code common component configbody constructor define destructor hull " -"import inherit itcl itk itk_component itk_initialize itk_interior itk_option iwidgets keep " -"method private protected public", -"", "", "", "", "", "" }; - - -#define SCE_TCL__MULTI_COMMENT MULTI_STYLE(SCE_TCL_COMMENT,SCE_TCL_COMMENTLINE,SCE_TCL_COMMENT_BOX,SCE_TCL_BLOCK_COMMENT) -#define SCE_TCL__MULTI_KEYWORD MULTI_STYLE(SCE_TCL_WORD,SCE_TCL_WORD2,SCE_TCL_WORD3,SCE_TCL_WORD_IN_QUOTE) -#define SCE_TCL__MULTI_SUBSTITUTION MULTI_STYLE(SCE_TCL_SUBSTITUTION,SCE_TCL_SUB_BRACE,0,0) - - -EDITLEXER lexTCL = { SCLEX_TCL, 63273, L"Tcl Script", L"tcl; itcl", L"", &KeyWords_TCL, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { SCE_TCL__MULTI_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_TCL__MULTI_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, - { SCE_TCL_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - { SCE_TCL_IN_QUOTE, 63131, L"String", L"fore:#008080", L"" }, - { SCE_TCL_OPERATOR, 63132, L"Operator", L"", L"" }, - { SCE_TCL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" }, - { SCE_TCL__MULTI_SUBSTITUTION, 63274, L"Substitution", L"fore:#CC0000", L"" }, - { SCE_TCL_MODIFIER, 63275, L"Modifier", L"fore:#FF00FF", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_AU3 = { -"and byref case const continuecase continueloop default dim do else elseif endfunc endif " -"endselect endswitch endwith enum exit exitloop false for func global if in local next not " -"or redim return select static step switch then to true until wend while with", -"abs acos adlibregister adlibunregister asc ascw asin assign atan autoitsetoption autoitwingettitle " -"autoitwinsettitle beep binary binarylen binarymid binarytostring bitand bitnot bitor bitrotate " -"bitshift bitxor blockinput break call cdtray ceiling chr chrw clipget clipput consoleread " -"consolewrite consolewriteerror controlclick controlcommand controldisable controlenable " -"controlfocus controlgetfocus controlgethandle controlgetpos controlgettext controlhide " -"controllistview controlmove controlsend controlsettext controlshow controltreeview cos dec " -"dircopy dircreate dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree dllcallbackgetptr " -"dllcallbackregister dllclose dllopen dllstructcreate dllstructgetdata dllstructgetptr " -"dllstructgetsize dllstructsetdata drivegetdrive drivegetfilesystem drivegetlabel drivegetserial " -"drivegettype drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree drivespacetotal " -"drivestatus envget envset envupdate eval execute exp filechangedir fileclose filecopy " -"filecreatentfslink filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile " -"fileflush filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut filegetshortname " -"filegetsize filegettime filegetversion fileinstall filemove fileopen fileopendialog fileread " -"filereadline filerecycle filerecycleempty filesavedialog fileselectfolder filesetattrib filesetpos " -"filesettime filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi guictrlcreatebutton " -"guictrlcreatecheckbox guictrlcreatecombo guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy " -"guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon guictrlcreateinput " -"guictrlcreatelabel guictrlcreatelist guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu " -"guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj guictrlcreatepic guictrlcreateprogress " -"guictrlcreateradio guictrlcreateslider guictrlcreatetab guictrlcreatetabitem guictrlcreatetreeview " -"guictrlcreatetreeviewitem guictrlcreateupdown guictrldelete guictrlgethandle guictrlgetstate " -"guictrlread guictrlrecvmsg guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy " -"guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata guictrlsetdefbkcolor " -"guictrlsetdefcolor guictrlsetfont guictrlsetgraphic guictrlsetimage guictrlsetlimit guictrlsetonevent " -"guictrlsetpos guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete " -"guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators guisetbkcolor guisetcoord " -"guisetcursor guisetfont guisethelp guiseticon guisetonevent guisetstate guisetstyle guistartgroup " -"guiswitch hex hotkeyset httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize " -"inetread inidelete iniread inireadsection inireadsectionnames inirenamesection iniwrite iniwritesection " -"inputbox int isadmin isarray isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword " -"isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor " -"mousegetpos mousemove mouseup mousewheel msgbox number objcreate objcreateinterface objevent objevent " -"objget objname onautoitexitregister onautoitexitunregister opt ping pixelchecksum pixelgetcolor " -"pixelsearch pluginclose pluginopen processclose processexists processgetstats processlist " -"processsetpriority processwait processwaitclose progressoff progresson progressset ptr random regdelete " -"regenumkey regenumval regread regwrite round run runas runaswait runwait send sendkeepactive " -"seterror setextended shellexecute shellexecutewait shutdown sin sleep soundplay soundsetwavevolume " -"splashimageon splashoff splashtexton sqrt srandom statusbargettext stderrread stdinwrite " -"stdioclose stdoutread string stringaddcr stringcompare stringformat stringfromasciiarray stringinstr " -"stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint stringislower " -"stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid " -"stringregexp stringregexpreplace stringreplace stringright stringsplit stringstripcr stringstripws " -"stringtoasciiarray stringtobinary stringtrimleft stringtrimright stringupper tan tcpaccept " -"tcpclosesocket tcpconnect tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup " -"timerdiff timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete " -"trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent trayitemsetstate " -"trayitemsettext traysetclick trayseticon traysetonevent traysetpauseicon traysetstate " -"traysettooltip traytip ubound udpbind udpclosesocket udpopen udprecv udpsend udpshutdown " -"udpstartup vargettype winactivate winactive winclose winexists winflash wingetcaretpos " -"wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess wingetstate " -"wingettext wingettitle winkill winlist winmenuselectitem winminimizeall winminimizeallundo " -"winmove winsetontop winsetstate winsettitle winsettrans winwait winwaitactive winwaitclose " -"winwaitnotactive", -"@appdatacommondir @appdatadir @autoitexe @autoitpid @autoitunicode @autoitversion @autoitx64 " -"@com_eventobj @commonfilesdir @compiled @computername @comspec @cpuarch @cr @crlf @desktopcommondir " -"@desktopdepth @desktopdir @desktopheight @desktoprefresh @desktopwidth @documentscommondir " -"@error @exitcode @exitmethod @extended @favoritescommondir @favoritesdir @gui_ctrlhandle " -"@gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid @gui_winhandle @homedrive @homepath @homeshare " -"@hotkeypressed @hour @inetgetactive @inetgetbytesread @ipaddress1 @ipaddress2 @ipaddress3 " -"@ipaddress4 @kblayout @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang " -"@mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir " -"@programscommondir @programsdir @scriptdir @scriptfullpath @scriptlinenumber @scriptname @sec " -"@startmenucommondir @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide @sw_lock " -"@sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault @sw_showmaximized @sw_showminimized " -"@sw_showminnoactive @sw_showna @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir " -"@tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday @windowsdir " -"@workingdir @yday @year", -"{!} {#} {^} {{} {}} {+} {alt} {altdown} {altup} {appskey} " -"{asc} {backspace} {break} {browser_back} {browser_favorites} {browser_forward} {browser_home} " -"{browser_refresh} {browser_search} {browser_stop} {bs} {capslock} {ctrldown} {ctrlup} " -"{del} {delete} {down} {end} {enter} {esc} {escape} {f1} {f10} {f11} {f12} {f2} {f3} " -"{f4} {f5} {f6} {f7} {f8} {f9} {home} {ins} {insert} {lalt} {launch_app1} {launch_app2} " -"{launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} {lwindown} {lwinup} {media_next} " -"{media_play_pause} {media_prev} {media_stop} {numlock} {numpad0} {numpad1} {numpad2} " -"{numpad3} {numpad4} {numpad5} {numpad6} {numpad7} {numpad8} {numpad9} {numpadadd} " -"{numpaddiv} {numpaddot} {numpadenter} {numpadmult} {numpadsub} {pause} {pgdn} {pgup} " -"{printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {rwinup} {scrolllock} " -"{shiftdown} {shiftup} {sleep} {space} {tab} {up} {volume_down} {volume_mute} {volume_up}", -"#ce #comments-end #comments-start #cs #include #include-once #noautoit3execute #notrayicon " -"#onautoitstartregister #requireadmin", -"#autoit3wrapper_au3check_parameters #autoit3wrapper_au3check_stop_onwarning " -"#autoit3wrapper_change2cui #autoit3wrapper_compression #autoit3wrapper_cvswrapper_parameters " -"#autoit3wrapper_icon #autoit3wrapper_outfile #autoit3wrapper_outfile_type #autoit3wrapper_plugin_funcs " -"#autoit3wrapper_res_comment #autoit3wrapper_res_description #autoit3wrapper_res_field " -"#autoit3wrapper_res_file_add #autoit3wrapper_res_fileversion #autoit3wrapper_res_fileversion_autoincrement " -"#autoit3wrapper_res_icon_add #autoit3wrapper_res_language #autoit3wrapper_res_legalcopyright " -"#autoit3wrapper_res_requestedexecutionlevel #autoit3wrapper_res_savesource #autoit3wrapper_run_after " -"#autoit3wrapper_run_au3check #autoit3wrapper_run_before #autoit3wrapper_run_cvswrapper " -"#autoit3wrapper_run_debug_mode #autoit3wrapper_run_obfuscator #autoit3wrapper_run_tidy " -"#autoit3wrapper_tidy_stop_onerror #autoit3wrapper_useansi #autoit3wrapper_useupx " -"#autoit3wrapper_usex64 #autoit3wrapper_version #endregion #forceref #obfuscator_ignore_funcs " -"#obfuscator_ignore_variables #obfuscator_parameters #region #tidy_parameters", -"", // Reserved for expand -"_arrayadd _arraybinarysearch _arraycombinations _arrayconcatenate _arraydelete _arraydisplay _arrayfindall " -"_arrayinsert _arraymax _arraymaxindex _arraymin _arrayminindex _arraypermute _arraypop _arraypush " -"_arrayreverse _arraysearch _arraysort _arrayswap _arraytoclip _arraytostring _arraytrim _arrayunique _assert " -"_choosecolor _choosefont _clipboard_changechain _clipboard_close _clipboard _countformats _clipboard_empty " -"_clipboard_enumformats _clipboard_formatstr _clipboard_getdata _clipboard_getdataex _clipboard_getformatname " -"_clipboard_getopenwindow _clipboard_getowner _clipboard_getpriorityformat _clipboard_getsequencenumber " -"_clipboard_getviewer _clipboard_isformatavailable _clipboard_open _clipboard_registerformat " -"_clipboard_setdata _clipboard_setdataex _clipboard_setviewer _clipputfile _colorconverthsltorgb " -"_colorconvertrgbtohsl _colorgetblue _colorgetcolorref _colorgetgreen _colorgetred _colorgetrgb " -"_colorsetcolorref _colorsetrgb _crypt_decryptdata _crypt_decryptfile _crypt_derivekey _crypt_destroykey " -"_crypt_encryptdata _crypt_encryptfile _crypt_hashdata _crypt_hashfile _crypt_shutdown _crypt_startup " -"_date_time_comparefiletime _date_time_dosdatetimetoarray _date_time_dosdatetimetofiletime " -"_date_time_dosdatetimetostr _date_time_dosdatetoarray _date_time_dosdatetostr _date_time_dostimetoarray " -"_date_time_dostimetostr _date_time_encodefiletime _date_time_encodesystemtime _date_time_filetimetoarray " -"_date_time_filetimetodosdatetime _date_time_filetimetolocalfiletime _date_time_filetimetostr " -"_date_time_filetimetosystemtime _date_time_getfiletime _date_time_getlocaltime _date_time_getsystemtime " -"_date_time_getsystemtimeadjustment _date_time_getsystemtimeasfiletime _date_time_getsystemtimes " -"_date_time_gettickcount _date_time_gettimezoneinformation _date_time_localfiletimetofiletime " -"_date_time_setfiletime _date_time_setlocaltime _date_time_setsystemtime _date_time_setsystemtimeadjustment " -"_date_time_settimezoneinformation _date_time_systemtimetoarray _date_time_systemtimetodatestr " -"_date_time_systemtimetodatetimestr _date_time_systemtimetofiletime _date_time_systemtimetotimestr " -"_date_time_systemtimetotzspecificlocaltime _date_time_tzspecificlocaltimetosystemtime _dateadd " -"_datedayofweek _datedaysinmonth _datediff _dateisleapyear _dateisvalid _datetimeformat _datetimesplit " -"_datetodayofweek _datetodayofweekiso _datetodayvalue _datetomonth _dayvaluetodate _debugbugreportenv " -"_debugout _debugreport _debugreportex _debugreportvar _debugsetup _degree _eventlog__backup _eventlog__clear " -"_eventlog__close _eventlog__count _eventlog__deregistersource _eventlog__full _eventlog__notify " -"_eventlog__oldest _eventlog__open _eventlog__openbackup _eventlog__read _eventlog__registersource " -"_eventlog__report _excelbookattach _excelbookclose _excelbooknew _excelbookopen _excelbooksave " -"_excelbooksaveas _excelcolumndelete _excelcolumninsert _excelfontsetproperties _excelhorizontalalignset " -"_excelhyperlinkinsert _excelnumberformat _excelreadarray _excelreadcell _excelreadsheettoarray " -"_excelrowdelete _excelrowinsert _excelsheetactivate _excelsheetaddnew _excelsheetdelete _excelsheetlist " -"_excelsheetmove _excelsheetnameget _excelsheetnameset _excelwritearray _excelwritecell _excelwriteformula " -"_excelwritesheetfromarray _filecountlines _filecreate _filelisttoarray _fileprint _filereadtoarray " -"_filewritefromarray _filewritelog _filewritetoline _ftp_close _ftp_command _ftp_connect " -"_ftp_decodeinternetstatus _ftp_dircreate _ftp_dirdelete _ftp_dirgetcurrent _ftp_dirputcontents " -"_ftp_dirsetcurrent _ftp_fileclose _ftp_filedelete _ftp_fileget _ftp_filegetsize _ftp_fileopen _ftp_fileput " -"_ftp_fileread _ftp_filerename _ftp_filetimelohitostr _ftp_findfileclose _ftp_findfilefirst _ftp_findfilenext " -"_ftp_getlastresponseinfo _ftp_listtoarray _ftp_listtoarray2d _ftp_listtoarrayex _ftp_open " -"_ftp_progressdownload _ftp_progressupload _ftp_setstatuscallback _gdiplus_arrowcapcreate " -"_gdiplus_arrowcapdispose _gdiplus_arrowcapgetfillstate _gdiplus_arrowcapgetheight " -"_gdiplus_arrowcapgetmiddleinset _gdiplus_arrowcapgetwidth _gdiplus_arrowcapsetfillstate " -"_gdiplus_arrowcapsetheight _gdiplus_arrowcapsetmiddleinset _gdiplus_arrowcapsetwidth " -"_gdiplus_bitmapclonearea _gdiplus_bitmapcreatefromfile _gdiplus_bitmapcreatefromgraphics " -"_gdiplus_bitmapcreatefromhbitmap _gdiplus_bitmapcreatehbitmapfrombitmap _gdiplus_bitmapdispose " -"_gdiplus_bitmaplockbits _gdiplus_bitmapunlockbits _gdiplus_brushclone _gdiplus_brushcreatesolid " -"_gdiplus_brushdispose _gdiplus_brushgetsolidcolor _gdiplus_brushgettype _gdiplus_brushsetsolidcolor " -"_gdiplus_customlinecapdispose _gdiplus_decoders _gdiplus_decodersgetcount _gdiplus_decodersgetsize " -"_gdiplus_drawimagepoints _gdiplus_encoders _gdiplus_encodersgetclsid _gdiplus_encodersgetcount " -"_gdiplus_encodersgetparamlist _gdiplus_encodersgetparamlistsize _gdiplus_encodersgetsize _gdiplus_fontcreate " -"_gdiplus_fontdispose _gdiplus_fontfamilycreate _gdiplus_fontfamilydispose _gdiplus_graphicsclear " -"_gdiplus_graphicscreatefromhdc _gdiplus_graphicscreatefromhwnd _gdiplus_graphicsdispose " -"_gdiplus_graphicsdrawarc _gdiplus_graphicsdrawbezier _gdiplus_graphicsdrawclosedcurve " -"_gdiplus_graphicsdrawcurve _gdiplus_graphicsdrawellipse _gdiplus_graphicsdrawimage " -"_gdiplus_graphicsdrawimagerect _gdiplus_graphicsdrawimagerectrect _gdiplus_graphicsdrawline " -"_gdiplus_graphicsdrawpie _gdiplus_graphicsdrawpolygon _gdiplus_graphicsdrawrect _gdiplus_graphicsdrawstring " -"_gdiplus_graphicsdrawstringex _gdiplus_graphicsfillclosedcurve _gdiplus_graphicsfillellipse " -"_gdiplus_graphicsfillpie _gdiplus_graphicsfillpolygon _gdiplus_graphicsfillrect _gdiplus_graphicsgetdc " -"_gdiplus_graphicsgetsmoothingmode _gdiplus_graphicsmeasurestring _gdiplus_graphicsreleasedc " -"_gdiplus_graphicssetsmoothingmode _gdiplus_graphicssettransform _gdiplus_imagedispose _gdiplus_imagegetflags " -"_gdiplus_imagegetgraphicscontext _gdiplus_imagegetheight _gdiplus_imagegethorizontalresolution " -"_gdiplus_imagegetpixelformat _gdiplus_imagegetrawformat _gdiplus_imagegettype " -"_gdiplus_imagegetverticalresolution _gdiplus_imagegetwidth _gdiplus_imageloadfromfile " -"_gdiplus_imagesavetofile _gdiplus_imagesavetofileex _gdiplus_matrixcreate _gdiplus_matrixdispose " -"_gdiplus_matrixrotate _gdiplus_matrixscale _gdiplus_matrixtranslate _gdiplus_paramadd _gdiplus_paraminit " -"_gdiplus_pencreate _gdiplus_pendispose _gdiplus_pengetalignment _gdiplus_pengetcolor " -"_gdiplus_pengetcustomendcap _gdiplus_pengetdashcap _gdiplus_pengetdashstyle _gdiplus_pengetendcap " -"_gdiplus_pengetwidth _gdiplus_pensetalignment _gdiplus_pensetcolor _gdiplus_pensetcustomendcap " -"_gdiplus_pensetdashcap _gdiplus_pensetdashstyle _gdiplus_pensetendcap _gdiplus_pensetwidth " -"_gdiplus_rectfcreate _gdiplus_shutdown _gdiplus_startup _gdiplus_stringformatcreate " -"_gdiplus_stringformatdispose _gdiplus_stringformatsetalign _getip _guictrlavi_close _guictrlavi_create " -"_guictrlavi_destroy _guictrlavi_isplaying _guictrlavi_open _guictrlavi_openex _guictrlavi_play " -"_guictrlavi_seek _guictrlavi_show _guictrlavi_stop _guictrlbutton_click _guictrlbutton_create " -"_guictrlbutton_destroy _guictrlbutton_enable _guictrlbutton_getcheck _guictrlbutton_getfocus " -"_guictrlbutton_getidealsize _guictrlbutton_getimage _guictrlbutton_getimagelist _guictrlbutton_getnote " -"_guictrlbutton_getnotelength _guictrlbutton_getsplitinfo _guictrlbutton_getstate _guictrlbutton_gettext " -"_guictrlbutton_gettextmargin _guictrlbutton_setcheck _guictrlbutton_setdontclick _guictrlbutton_setfocus " -"_guictrlbutton_setimage _guictrlbutton_setimagelist _guictrlbutton_setnote _guictrlbutton_setshield " -"_guictrlbutton_setsize _guictrlbutton_setsplitinfo _guictrlbutton_setstate _guictrlbutton_setstyle " -"_guictrlbutton_settext _guictrlbutton_settextmargin _guictrlbutton_show _guictrlcombobox_adddir " -"_guictrlcombobox_addstring _guictrlcombobox_autocomplete _guictrlcombobox_beginupdate " -"_guictrlcombobox_create _guictrlcombobox_deletestring _guictrlcombobox_destroy _guictrlcombobox_endupdate " -"_guictrlcombobox_findstring _guictrlcombobox_findstringexact _guictrlcombobox_getcomboboxinfo " -"_guictrlcombobox_getcount _guictrlcombobox_getcuebanner _guictrlcombobox_getcursel " -"_guictrlcombobox_getdroppedcontrolrect _guictrlcombobox_getdroppedcontrolrectex " -"_guictrlcombobox_getdroppedstate _guictrlcombobox_getdroppedwidth _guictrlcombobox_geteditsel " -"_guictrlcombobox_getedittext _guictrlcombobox_getextendedui _guictrlcombobox_gethorizontalextent " -"_guictrlcombobox_getitemheight _guictrlcombobox_getlbtext _guictrlcombobox_getlbtextlen " -"_guictrlcombobox_getlist _guictrlcombobox_getlistarray _guictrlcombobox_getlocale " -"_guictrlcombobox_getlocalecountry _guictrlcombobox_getlocalelang _guictrlcombobox_getlocaleprimlang " -"_guictrlcombobox_getlocalesublang _guictrlcombobox_getminvisible _guictrlcombobox_gettopindex " -"_guictrlcombobox_initstorage _guictrlcombobox_insertstring _guictrlcombobox_limittext " -"_guictrlcombobox_replaceeditsel _guictrlcombobox_resetcontent _guictrlcombobox_selectstring " -"_guictrlcombobox_setcuebanner _guictrlcombobox_setcursel _guictrlcombobox_setdroppedwidth " -"_guictrlcombobox_seteditsel _guictrlcombobox_setedittext _guictrlcombobox_setextendedui " -"_guictrlcombobox_sethorizontalextent _guictrlcombobox_setitemheight _guictrlcombobox_setminvisible " -"_guictrlcombobox_settopindex _guictrlcombobox_showdropdown _guictrlcomboboxex_adddir " -"_guictrlcomboboxex_addstring _guictrlcomboboxex_beginupdate _guictrlcomboboxex_create " -"_guictrlcomboboxex_createsolidbitmap _guictrlcomboboxex_deletestring _guictrlcomboboxex_destroy " -"_guictrlcomboboxex_endupdate _guictrlcomboboxex_findstringexact _guictrlcomboboxex_getcomboboxinfo " -"_guictrlcomboboxex_getcombocontrol _guictrlcomboboxex_getcount _guictrlcomboboxex_getcursel " -"_guictrlcomboboxex_getdroppedcontrolrect _guictrlcomboboxex_getdroppedcontrolrectex " -"_guictrlcomboboxex_getdroppedstate _guictrlcomboboxex_getdroppedwidth _guictrlcomboboxex_geteditcontrol " -"_guictrlcomboboxex_geteditsel _guictrlcomboboxex_getedittext _guictrlcomboboxex_getextendedstyle " -"_guictrlcomboboxex_getextendedui _guictrlcomboboxex_getimagelist _guictrlcomboboxex_getitem " -"_guictrlcomboboxex_getitemex _guictrlcomboboxex_getitemheight _guictrlcomboboxex_getitemimage " -"_guictrlcomboboxex_getitemindent _guictrlcomboboxex_getitemoverlayimage _guictrlcomboboxex_getitemparam " -"_guictrlcomboboxex_getitemselectedimage _guictrlcomboboxex_getitemtext _guictrlcomboboxex_getitemtextlen " -"_guictrlcomboboxex_getlist _guictrlcomboboxex_getlistarray _guictrlcomboboxex_getlocale " -"_guictrlcomboboxex_getlocalecountry _guictrlcomboboxex_getlocalelang _guictrlcomboboxex_getlocaleprimlang " -"_guictrlcomboboxex_getlocalesublang _guictrlcomboboxex_getminvisible _guictrlcomboboxex_gettopindex " -"_guictrlcomboboxex_getunicode _guictrlcomboboxex_initstorage _guictrlcomboboxex_insertstring " -"_guictrlcomboboxex_limittext _guictrlcomboboxex_replaceeditsel _guictrlcomboboxex_resetcontent " -"_guictrlcomboboxex_setcursel _guictrlcomboboxex_setdroppedwidth _guictrlcomboboxex_seteditsel " -"_guictrlcomboboxex_setedittext _guictrlcomboboxex_setextendedstyle _guictrlcomboboxex_setextendedui " -"_guictrlcomboboxex_setimagelist _guictrlcomboboxex_setitem _guictrlcomboboxex_setitemex " -"_guictrlcomboboxex_setitemheight _guictrlcomboboxex_setitemimage _guictrlcomboboxex_setitemindent " -"_guictrlcomboboxex_setitemoverlayimage _guictrlcomboboxex_setitemparam " -"_guictrlcomboboxex_setitemselectedimage _guictrlcomboboxex_setminvisible _guictrlcomboboxex_settopindex " -"_guictrlcomboboxex_setunicode _guictrlcomboboxex_showdropdown _guictrldtp_create _guictrldtp_destroy " -"_guictrldtp_getmccolor _guictrldtp_getmcfont _guictrldtp_getmonthcal _guictrldtp_getrange " -"_guictrldtp_getrangeex _guictrldtp_getsystemtime _guictrldtp_getsystemtimeex _guictrldtp_setformat " -"_guictrldtp_setmccolor _guictrldtp_setmcfont _guictrldtp_setrange _guictrldtp_setrangeex " -"_guictrldtp_setsystemtime _guictrldtp_setsystemtimeex _guictrledit_appendtext _guictrledit_beginupdate " -"_guictrledit_canundo _guictrledit_charfrompos _guictrledit_create _guictrledit_destroy " -"_guictrledit_emptyundobuffer _guictrledit_endupdate _guictrledit_find _guictrledit_fmtlines " -"_guictrledit_getfirstvisibleline _guictrledit_getlimittext _guictrledit_getline _guictrledit_getlinecount " -"_guictrledit_getmargins _guictrledit_getmodify _guictrledit_getpasswordchar _guictrledit_getrect " -"_guictrledit_getrectex _guictrledit_getsel _guictrledit_gettext _guictrledit_gettextlen " -"_guictrledit_hideballoontip _guictrledit_inserttext _guictrledit_linefromchar _guictrledit_lineindex " -"_guictrledit_linelength _guictrledit_linescroll _guictrledit_posfromchar _guictrledit_replacesel " -"_guictrledit_scroll _guictrledit_setlimittext _guictrledit_setmargins _guictrledit_setmodify " -"_guictrledit_setpasswordchar _guictrledit_setreadonly _guictrledit_setrect _guictrledit_setrectex " -"_guictrledit_setrectnp _guictrledit_setrectnpex _guictrledit_setsel _guictrledit_settabstops " -"_guictrledit_settext _guictrledit_showballoontip _guictrledit_undo _guictrlheader_additem " -"_guictrlheader_clearfilter _guictrlheader_clearfilterall _guictrlheader_create " -"_guictrlheader_createdragimage _guictrlheader_deleteitem _guictrlheader_destroy _guictrlheader_editfilter " -"_guictrlheader_getbitmapmargin _guictrlheader_getimagelist _guictrlheader_getitem " -"_guictrlheader_getitemalign _guictrlheader_getitembitmap _guictrlheader_getitemcount " -"_guictrlheader_getitemdisplay _guictrlheader_getitemflags _guictrlheader_getitemformat " -"_guictrlheader_getitemimage _guictrlheader_getitemorder _guictrlheader_getitemparam " -"_guictrlheader_getitemrect _guictrlheader_getitemrectex _guictrlheader_getitemtext " -"_guictrlheader_getitemwidth _guictrlheader_getorderarray _guictrlheader_getunicodeformat " -"_guictrlheader_hittest _guictrlheader_insertitem _guictrlheader_layout _guictrlheader_ordertoindex " -"_guictrlheader_setbitmapmargin _guictrlheader_setfilterchangetimeout _guictrlheader_sethotdivider " -"_guictrlheader_setimagelist _guictrlheader_setitem _guictrlheader_setitemalign " -"_guictrlheader_setitembitmap _guictrlheader_setitemdisplay _guictrlheader_setitemflags " -"_guictrlheader_setitemformat _guictrlheader_setitemimage _guictrlheader_setitemorder " -"_guictrlheader_setitemparam _guictrlheader_setitemtext _guictrlheader_setitemwidth " -"_guictrlheader_setorderarray _guictrlheader_setunicodeformat _guictrlipaddress_clearaddress " -"_guictrlipaddress_create _guictrlipaddress_destroy _guictrlipaddress_get _guictrlipaddress_getarray " -"_guictrlipaddress_getex _guictrlipaddress_isblank _guictrlipaddress_set _guictrlipaddress_setarray " -"_guictrlipaddress_setex _guictrlipaddress_setfocus _guictrlipaddress_setfont _guictrlipaddress_setrange " -"_guictrlipaddress_showhide _guictrllistbox_addfile _guictrllistbox_addstring _guictrllistbox_beginupdate " -"_guictrllistbox_clickitem _guictrllistbox_create _guictrllistbox_deletestring _guictrllistbox_destroy " -"_guictrllistbox_dir _guictrllistbox_endupdate _guictrllistbox_findintext _guictrllistbox_findstring " -"_guictrllistbox_getanchorindex _guictrllistbox_getcaretindex _guictrllistbox_getcount " -"_guictrllistbox_getcursel _guictrllistbox_gethorizontalextent _guictrllistbox_getitemdata " -"_guictrllistbox_getitemheight _guictrllistbox_getitemrect _guictrllistbox_getitemrectex " -"_guictrllistbox_getlistboxinfo _guictrllistbox_getlocale _guictrllistbox_getlocalecountry " -"_guictrllistbox_getlocalelang _guictrllistbox_getlocaleprimlang _guictrllistbox_getlocalesublang " -"_guictrllistbox_getsel _guictrllistbox_getselcount _guictrllistbox_getselitems " -"_guictrllistbox_getselitemstext _guictrllistbox_gettext _guictrllistbox_gettextlen " -"_guictrllistbox_gettopindex _guictrllistbox_initstorage _guictrllistbox_insertstring " -"_guictrllistbox_itemfrompoint _guictrllistbox_replacestring _guictrllistbox_resetcontent " -"_guictrllistbox_selectstring _guictrllistbox_selitemrange _guictrllistbox_selitemrangeex " -"_guictrllistbox_setanchorindex _guictrllistbox_setcaretindex _guictrllistbox_setcolumnwidth " -"_guictrllistbox_setcursel _guictrllistbox_sethorizontalextent _guictrllistbox_setitemdata " -"_guictrllistbox_setitemheight _guictrllistbox_setlocale _guictrllistbox_setsel _guictrllistbox_settabstops " -"_guictrllistbox_settopindex _guictrllistbox_sort _guictrllistbox_swapstring _guictrllistbox_updatehscroll " -"_guictrllistview_addarray _guictrllistview_addcolumn _guictrllistview_additem _guictrllistview_addsubitem " -"_guictrllistview_approximateviewheight _guictrllistview_approximateviewrect " -"_guictrllistview_approximateviewwidth _guictrllistview_arrange _guictrllistview_beginupdate " -"_guictrllistview_canceleditlabel _guictrllistview_clickitem _guictrllistview_copyitems " -"_guictrllistview_create _guictrllistview_createdragimage _guictrllistview_createsolidbitmap " -"_guictrllistview_deleteallitems _guictrllistview_deletecolumn _guictrllistview_deleteitem " -"_guictrllistview_deleteitemsselected _guictrllistview_destroy _guictrllistview_drawdragimage " -"_guictrllistview_editlabel _guictrllistview_enablegroupview _guictrllistview_endupdate " -"_guictrllistview_ensurevisible _guictrllistview_findintext _guictrllistview_finditem " -"_guictrllistview_findnearest _guictrllistview_findparam _guictrllistview_findtext " -"_guictrllistview_getbkcolor _guictrllistview_getbkimage _guictrllistview_getcallbackmask " -"_guictrllistview_getcolumn _guictrllistview_getcolumncount _guictrllistview_getcolumnorder " -"_guictrllistview_getcolumnorderarray _guictrllistview_getcolumnwidth _guictrllistview_getcounterpage " -"_guictrllistview_geteditcontrol _guictrllistview_getextendedlistviewstyle _guictrllistview_getfocusedgroup " -"_guictrllistview_getgroupcount _guictrllistview_getgroupinfo _guictrllistview_getgroupinfobyindex " -"_guictrllistview_getgrouprect _guictrllistview_getgroupviewenabled _guictrllistview_getheader " -"_guictrllistview_gethotcursor _guictrllistview_gethotitem _guictrllistview_gethovertime " -"_guictrllistview_getimagelist _guictrllistview_getisearchstring _guictrllistview_getitem " -"_guictrllistview_getitemchecked _guictrllistview_getitemcount _guictrllistview_getitemcut " -"_guictrllistview_getitemdrophilited _guictrllistview_getitemex _guictrllistview_getitemfocused " -"_guictrllistview_getitemgroupid _guictrllistview_getitemimage _guictrllistview_getitemindent " -"_guictrllistview_getitemparam _guictrllistview_getitemposition _guictrllistview_getitempositionx " -"_guictrllistview_getitempositiony _guictrllistview_getitemrect _guictrllistview_getitemrectex " -"_guictrllistview_getitemselected _guictrllistview_getitemspacing _guictrllistview_getitemspacingx " -"_guictrllistview_getitemspacingy _guictrllistview_getitemstate _guictrllistview_getitemstateimage " -"_guictrllistview_getitemtext _guictrllistview_getitemtextarray _guictrllistview_getitemtextstring " -"_guictrllistview_getnextitem _guictrllistview_getnumberofworkareas _guictrllistview_getorigin " -"_guictrllistview_getoriginx _guictrllistview_getoriginy _guictrllistview_getoutlinecolor " -"_guictrllistview_getselectedcolumn _guictrllistview_getselectedcount _guictrllistview_getselectedindices " -"_guictrllistview_getselectionmark _guictrllistview_getstringwidth _guictrllistview_getsubitemrect " -"_guictrllistview_gettextbkcolor _guictrllistview_gettextcolor _guictrllistview_gettooltips " -"_guictrllistview_gettopindex _guictrllistview_getunicodeformat _guictrllistview_getview " -"_guictrllistview_getviewdetails _guictrllistview_getviewlarge _guictrllistview_getviewlist " -"_guictrllistview_getviewrect _guictrllistview_getviewsmall _guictrllistview_getviewtile " -"_guictrllistview_hidecolumn _guictrllistview_hittest _guictrllistview_insertcolumn " -"_guictrllistview_insertgroup _guictrllistview_insertitem _guictrllistview_justifycolumn " -"_guictrllistview_mapidtoindex _guictrllistview_mapindextoid _guictrllistview_redrawitems " -"_guictrllistview_registersortcallback _guictrllistview_removeallgroups _guictrllistview_removegroup " -"_guictrllistview_scroll _guictrllistview_setbkcolor _guictrllistview_setbkimage " -"_guictrllistview_setcallbackmask _guictrllistview_setcolumn _guictrllistview_setcolumnorder " -"_guictrllistview_setcolumnorderarray _guictrllistview_setcolumnwidth " -"_guictrllistview_setextendedlistviewstyle _guictrllistview_setgroupinfo _guictrllistview_sethotitem " -"_guictrllistview_sethovertime _guictrllistview_seticonspacing _guictrllistview_setimagelist " -"_guictrllistview_setitem _guictrllistview_setitemchecked _guictrllistview_setitemcount " -"_guictrllistview_setitemcut _guictrllistview_setitemdrophilited _guictrllistview_setitemex " -"_guictrllistview_setitemfocused _guictrllistview_setitemgroupid _guictrllistview_setitemimage " -"_guictrllistview_setitemindent _guictrllistview_setitemparam _guictrllistview_setitemposition " -"_guictrllistview_setitemposition32 _guictrllistview_setitemselected _guictrllistview_setitemstate " -"_guictrllistview_setitemstateimage _guictrllistview_setitemtext _guictrllistview_setoutlinecolor " -"_guictrllistview_setselectedcolumn _guictrllistview_setselectionmark _guictrllistview_settextbkcolor " -"_guictrllistview_settextcolor _guictrllistview_settooltips _guictrllistview_setunicodeformat " -"_guictrllistview_setview _guictrllistview_setworkareas _guictrllistview_simplesort " -"_guictrllistview_sortitems _guictrllistview_subitemhittest _guictrllistview_unregistersortcallback " -"_guictrlmenu_addmenuitem _guictrlmenu_appendmenu _guictrlmenu_checkmenuitem _guictrlmenu_checkradioitem " -"_guictrlmenu_createmenu _guictrlmenu_createpopup _guictrlmenu_deletemenu _guictrlmenu_destroymenu " -"_guictrlmenu_drawmenubar _guictrlmenu_enablemenuitem _guictrlmenu_finditem _guictrlmenu_findparent " -"_guictrlmenu_getitembmp _guictrlmenu_getitembmpchecked _guictrlmenu_getitembmpunchecked " -"_guictrlmenu_getitemchecked _guictrlmenu_getitemcount _guictrlmenu_getitemdata _guictrlmenu_getitemdefault " -"_guictrlmenu_getitemdisabled _guictrlmenu_getitemenabled _guictrlmenu_getitemgrayed " -"_guictrlmenu_getitemhighlighted _guictrlmenu_getitemid _guictrlmenu_getiteminfo _guictrlmenu_getitemrect " -"_guictrlmenu_getitemrectex _guictrlmenu_getitemstate _guictrlmenu_getitemstateex " -"_guictrlmenu_getitemsubmenu _guictrlmenu_getitemtext _guictrlmenu_getitemtype _guictrlmenu_getmenu " -"_guictrlmenu_getmenubackground _guictrlmenu_getmenubarinfo _guictrlmenu_getmenucontexthelpid " -"_guictrlmenu_getmenudata _guictrlmenu_getmenudefaultitem _guictrlmenu_getmenuheight " -"_guictrlmenu_getmenuinfo _guictrlmenu_getmenustyle _guictrlmenu_getsystemmenu _guictrlmenu_insertmenuitem " -"_guictrlmenu_insertmenuitemex _guictrlmenu_ismenu _guictrlmenu_loadmenu _guictrlmenu_mapaccelerator " -"_guictrlmenu_menuitemfrompoint _guictrlmenu_removemenu _guictrlmenu_setitembitmaps _guictrlmenu_setitembmp " -"_guictrlmenu_setitembmpchecked _guictrlmenu_setitembmpunchecked _guictrlmenu_setitemchecked " -"_guictrlmenu_setitemdata _guictrlmenu_setitemdefault _guictrlmenu_setitemdisabled " -"_guictrlmenu_setitemenabled _guictrlmenu_setitemgrayed _guictrlmenu_setitemhighlighted " -"_guictrlmenu_setitemid _guictrlmenu_setiteminfo _guictrlmenu_setitemstate _guictrlmenu_setitemsubmenu " -"_guictrlmenu_setitemtext _guictrlmenu_setitemtype _guictrlmenu_setmenu _guictrlmenu_setmenubackground " -"_guictrlmenu_setmenucontexthelpid _guictrlmenu_setmenudata _guictrlmenu_setmenudefaultitem " -"_guictrlmenu_setmenuheight _guictrlmenu_setmenuinfo _guictrlmenu_setmenustyle _guictrlmenu_trackpopupmenu " -"_guictrlmonthcal_create _guictrlmonthcal_destroy _guictrlmonthcal_getcalendarborder " -"_guictrlmonthcal_getcalendarcount _guictrlmonthcal_getcolor _guictrlmonthcal_getcolorarray " -"_guictrlmonthcal_getcursel _guictrlmonthcal_getcurselstr _guictrlmonthcal_getfirstdow " -"_guictrlmonthcal_getfirstdowstr _guictrlmonthcal_getmaxselcount _guictrlmonthcal_getmaxtodaywidth " -"_guictrlmonthcal_getminreqheight _guictrlmonthcal_getminreqrect _guictrlmonthcal_getminreqrectarray " -"_guictrlmonthcal_getminreqwidth _guictrlmonthcal_getmonthdelta _guictrlmonthcal_getmonthrange " -"_guictrlmonthcal_getmonthrangemax _guictrlmonthcal_getmonthrangemaxstr _guictrlmonthcal_getmonthrangemin " -"_guictrlmonthcal_getmonthrangeminstr _guictrlmonthcal_getmonthrangespan _guictrlmonthcal_getrange " -"_guictrlmonthcal_getrangemax _guictrlmonthcal_getrangemaxstr _guictrlmonthcal_getrangemin " -"_guictrlmonthcal_getrangeminstr _guictrlmonthcal_getselrange _guictrlmonthcal_getselrangemax " -"_guictrlmonthcal_getselrangemaxstr _guictrlmonthcal_getselrangemin _guictrlmonthcal_getselrangeminstr " -"_guictrlmonthcal_gettoday _guictrlmonthcal_gettodaystr _guictrlmonthcal_getunicodeformat " -"_guictrlmonthcal_hittest _guictrlmonthcal_setcalendarborder _guictrlmonthcal_setcolor " -"_guictrlmonthcal_setcursel _guictrlmonthcal_setdaystate _guictrlmonthcal_setfirstdow " -"_guictrlmonthcal_setmaxselcount _guictrlmonthcal_setmonthdelta _guictrlmonthcal_setrange " -"_guictrlmonthcal_setselrange _guictrlmonthcal_settoday _guictrlmonthcal_setunicodeformat " -"_guictrlrebar_addband _guictrlrebar_addtoolbarband _guictrlrebar_begindrag _guictrlrebar_create " -"_guictrlrebar_deleteband _guictrlrebar_destroy _guictrlrebar_dragmove _guictrlrebar_enddrag " -"_guictrlrebar_getbandbackcolor _guictrlrebar_getbandborders _guictrlrebar_getbandbordersex " -"_guictrlrebar_getbandchildhandle _guictrlrebar_getbandchildsize _guictrlrebar_getbandcount " -"_guictrlrebar_getbandforecolor _guictrlrebar_getbandheadersize _guictrlrebar_getbandid " -"_guictrlrebar_getbandidealsize _guictrlrebar_getbandlength _guictrlrebar_getbandlparam " -"_guictrlrebar_getbandmargins _guictrlrebar_getbandmarginsex _guictrlrebar_getbandrect " -"_guictrlrebar_getbandrectex _guictrlrebar_getbandstyle _guictrlrebar_getbandstylebreak " -"_guictrlrebar_getbandstylechildedge _guictrlrebar_getbandstylefixedbmp _guictrlrebar_getbandstylefixedsize " -"_guictrlrebar_getbandstylegripperalways _guictrlrebar_getbandstylehidden " -"_guictrlrebar_getbandstylehidetitle _guictrlrebar_getbandstylenogripper _guictrlrebar_getbandstyletopalign " -"_guictrlrebar_getbandstyleusechevron _guictrlrebar_getbandstylevariableheight _guictrlrebar_getbandtext " -"_guictrlrebar_getbarheight _guictrlrebar_getbarinfo _guictrlrebar_getbkcolor _guictrlrebar_getcolorscheme " -"_guictrlrebar_getrowcount _guictrlrebar_getrowheight _guictrlrebar_gettextcolor _guictrlrebar_gettooltips " -"_guictrlrebar_getunicodeformat _guictrlrebar_hittest _guictrlrebar_idtoindex _guictrlrebar_maximizeband " -"_guictrlrebar_minimizeband _guictrlrebar_moveband _guictrlrebar_setbandbackcolor " -"_guictrlrebar_setbandforecolor _guictrlrebar_setbandheadersize _guictrlrebar_setbandid " -"_guictrlrebar_setbandidealsize _guictrlrebar_setbandlength _guictrlrebar_setbandlparam " -"_guictrlrebar_setbandstyle _guictrlrebar_setbandstylebreak _guictrlrebar_setbandstylechildedge " -"_guictrlrebar_setbandstylefixedbmp _guictrlrebar_setbandstylefixedsize " -"_guictrlrebar_setbandstylegripperalways _guictrlrebar_setbandstylehidden " -"_guictrlrebar_setbandstylehidetitle _guictrlrebar_setbandstylenogripper _guictrlrebar_setbandstyletopalign " -"_guictrlrebar_setbandstyleusechevron _guictrlrebar_setbandstylevariableheight _guictrlrebar_setbandtext " -"_guictrlrebar_setbarinfo _guictrlrebar_setbkcolor _guictrlrebar_setcolorscheme _guictrlrebar_settextcolor " -"_guictrlrebar_settooltips _guictrlrebar_setunicodeformat _guictrlrebar_showband " -"_guictrlrichedit_appendtext _guictrlrichedit_autodetecturl _guictrlrichedit_canpaste " -"_guictrlrichedit_canpastespecial _guictrlrichedit_canredo _guictrlrichedit_canundo " -"_guictrlrichedit_changefontsize _guictrlrichedit_copy _guictrlrichedit_create _guictrlrichedit_cut " -"_guictrlrichedit_deselect _guictrlrichedit_destroy _guictrlrichedit_emptyundobuffer " -"_guictrlrichedit_findtext _guictrlrichedit_findtextinrange _guictrlrichedit_getbkcolor " -"_guictrlrichedit_getcharattributes _guictrlrichedit_getcharbkcolor _guictrlrichedit_getcharcolor " -"_guictrlrichedit_getcharposfromxy _guictrlrichedit_getcharposofnextword " -"_guictrlrichedit_getcharposofpreviousword _guictrlrichedit_getcharwordbreakinfo " -"_guictrlrichedit_getfirstcharposonline _guictrlrichedit_getfont _guictrlrichedit_getlinecount " -"_guictrlrichedit_getlinelength _guictrlrichedit_getlinenumberfromcharpos _guictrlrichedit_getnextredo " -"_guictrlrichedit_getnextundo _guictrlrichedit_getnumberoffirstvisibleline " -"_guictrlrichedit_getparaalignment _guictrlrichedit_getparaattributes _guictrlrichedit_getparaborder " -"_guictrlrichedit_getparaindents _guictrlrichedit_getparanumbering _guictrlrichedit_getparashading " -"_guictrlrichedit_getparaspacing _guictrlrichedit_getparatabstops _guictrlrichedit_getpasswordchar " -"_guictrlrichedit_getrect _guictrlrichedit_getscrollpos _guictrlrichedit_getsel _guictrlrichedit_getselaa " -"_guictrlrichedit_getseltext _guictrlrichedit_getspaceunit _guictrlrichedit_gettext " -"_guictrlrichedit_gettextinline _guictrlrichedit_gettextinrange _guictrlrichedit_gettextlength " -"_guictrlrichedit_getversion _guictrlrichedit_getxyfromcharpos _guictrlrichedit_getzoom " -"_guictrlrichedit_gotocharpos _guictrlrichedit_hideselection _guictrlrichedit_inserttext " -"_guictrlrichedit_ismodified _guictrlrichedit_istextselected _guictrlrichedit_paste " -"_guictrlrichedit_pastespecial _guictrlrichedit_pauseredraw _guictrlrichedit_redo " -"_guictrlrichedit_replacetext _guictrlrichedit_resumeredraw _guictrlrichedit_scrolllineorpage " -"_guictrlrichedit_scrolllines _guictrlrichedit_scrolltocaret _guictrlrichedit_setbkcolor " -"_guictrlrichedit_setcharattributes _guictrlrichedit_setcharbkcolor _guictrlrichedit_setcharcolor " -"_guictrlrichedit_seteventmask _guictrlrichedit_setfont _guictrlrichedit_setlimitontext " -"_guictrlrichedit_setmodified _guictrlrichedit_setparaalignment _guictrlrichedit_setparaattributes " -"_guictrlrichedit_setparaborder _guictrlrichedit_setparaindents _guictrlrichedit_setparanumbering " -"_guictrlrichedit_setparashading _guictrlrichedit_setparaspacing _guictrlrichedit_setparatabstops " -"_guictrlrichedit_setpasswordchar _guictrlrichedit_setreadonly _guictrlrichedit_setrect " -"_guictrlrichedit_setscrollpos _guictrlrichedit_setsel _guictrlrichedit_setspaceunit " -"_guictrlrichedit_settabstops _guictrlrichedit_settext _guictrlrichedit_setundolimit " -"_guictrlrichedit_setzoom _guictrlrichedit_streamfromfile _guictrlrichedit_streamfromvar " -"_guictrlrichedit_streamtofile _guictrlrichedit_streamtovar _guictrlrichedit_undo _guictrlslider_clearsel " -"_guictrlslider_cleartics _guictrlslider_create _guictrlslider_destroy _guictrlslider_getbuddy " -"_guictrlslider_getchannelrect _guictrlslider_getchannelrectex _guictrlslider_getlinesize " -"_guictrlslider_getlogicaltics _guictrlslider_getnumtics _guictrlslider_getpagesize _guictrlslider_getpos " -"_guictrlslider_getrange _guictrlslider_getrangemax _guictrlslider_getrangemin _guictrlslider_getsel " -"_guictrlslider_getselend _guictrlslider_getselstart _guictrlslider_getthumblength " -"_guictrlslider_getthumbrect _guictrlslider_getthumbrectex _guictrlslider_gettic _guictrlslider_getticpos " -"_guictrlslider_gettooltips _guictrlslider_getunicodeformat _guictrlslider_setbuddy " -"_guictrlslider_setlinesize _guictrlslider_setpagesize _guictrlslider_setpos _guictrlslider_setrange " -"_guictrlslider_setrangemax _guictrlslider_setrangemin _guictrlslider_setsel _guictrlslider_setselend " -"_guictrlslider_setselstart _guictrlslider_setthumblength _guictrlslider_settic _guictrlslider_setticfreq " -"_guictrlslider_settipside _guictrlslider_settooltips _guictrlslider_setunicodeformat " -"_guictrlstatusbar_create _guictrlstatusbar_destroy _guictrlstatusbar_embedcontrol " -"_guictrlstatusbar_getborders _guictrlstatusbar_getbordershorz _guictrlstatusbar_getbordersrect " -"_guictrlstatusbar_getbordersvert _guictrlstatusbar_getcount _guictrlstatusbar_getheight " -"_guictrlstatusbar_geticon _guictrlstatusbar_getparts _guictrlstatusbar_getrect _guictrlstatusbar_getrectex " -"_guictrlstatusbar_gettext _guictrlstatusbar_gettextflags _guictrlstatusbar_gettextlength " -"_guictrlstatusbar_gettextlengthex _guictrlstatusbar_gettiptext _guictrlstatusbar_getunicodeformat " -"_guictrlstatusbar_getwidth _guictrlstatusbar_issimple _guictrlstatusbar_resize " -"_guictrlstatusbar_setbkcolor _guictrlstatusbar_seticon _guictrlstatusbar_setminheight " -"_guictrlstatusbar_setparts _guictrlstatusbar_setsimple _guictrlstatusbar_settext " -"_guictrlstatusbar_settiptext _guictrlstatusbar_setunicodeformat _guictrlstatusbar_showhide " -"_guictrltab_activatetab _guictrltab_clicktab _guictrltab_create _guictrltab_deleteallitems " -"_guictrltab_deleteitem _guictrltab_deselectall _guictrltab_destroy _guictrltab_findtab " -"_guictrltab_getcurfocus _guictrltab_getcursel _guictrltab_getdisplayrect _guictrltab_getdisplayrectex " -"_guictrltab_getextendedstyle _guictrltab_getimagelist _guictrltab_getitem _guictrltab_getitemcount " -"_guictrltab_getitemimage _guictrltab_getitemparam _guictrltab_getitemrect _guictrltab_getitemrectex " -"_guictrltab_getitemstate _guictrltab_getitemtext _guictrltab_getrowcount _guictrltab_gettooltips " -"_guictrltab_getunicodeformat _guictrltab_highlightitem _guictrltab_hittest _guictrltab_insertitem " -"_guictrltab_removeimage _guictrltab_setcurfocus _guictrltab_setcursel _guictrltab_setextendedstyle " -"_guictrltab_setimagelist _guictrltab_setitem _guictrltab_setitemimage _guictrltab_setitemparam " -"_guictrltab_setitemsize _guictrltab_setitemstate _guictrltab_setitemtext _guictrltab_setmintabwidth " -"_guictrltab_setpadding _guictrltab_settooltips _guictrltab_setunicodeformat _guictrltoolbar_addbitmap " -"_guictrltoolbar_addbutton _guictrltoolbar_addbuttonsep _guictrltoolbar_addstring " -"_guictrltoolbar_buttoncount _guictrltoolbar_checkbutton _guictrltoolbar_clickaccel " -"_guictrltoolbar_clickbutton _guictrltoolbar_clickindex _guictrltoolbar_commandtoindex " -"_guictrltoolbar_create _guictrltoolbar_customize _guictrltoolbar_deletebutton _guictrltoolbar_destroy " -"_guictrltoolbar_enablebutton _guictrltoolbar_findtoolbar _guictrltoolbar_getanchorhighlight " -"_guictrltoolbar_getbitmapflags _guictrltoolbar_getbuttonbitmap _guictrltoolbar_getbuttoninfo " -"_guictrltoolbar_getbuttoninfoex _guictrltoolbar_getbuttonparam _guictrltoolbar_getbuttonrect " -"_guictrltoolbar_getbuttonrectex _guictrltoolbar_getbuttonsize _guictrltoolbar_getbuttonstate " -"_guictrltoolbar_getbuttonstyle _guictrltoolbar_getbuttontext _guictrltoolbar_getcolorscheme " -"_guictrltoolbar_getdisabledimagelist _guictrltoolbar_getextendedstyle _guictrltoolbar_gethotimagelist " -"_guictrltoolbar_gethotitem _guictrltoolbar_getimagelist _guictrltoolbar_getinsertmark " -"_guictrltoolbar_getinsertmarkcolor _guictrltoolbar_getmaxsize _guictrltoolbar_getmetrics " -"_guictrltoolbar_getpadding _guictrltoolbar_getrows _guictrltoolbar_getstring _guictrltoolbar_getstyle " -"_guictrltoolbar_getstylealtdrag _guictrltoolbar_getstylecustomerase _guictrltoolbar_getstyleflat " -"_guictrltoolbar_getstylelist _guictrltoolbar_getstyleregisterdrop _guictrltoolbar_getstyletooltips " -"_guictrltoolbar_getstyletransparent _guictrltoolbar_getstylewrapable _guictrltoolbar_gettextrows " -"_guictrltoolbar_gettooltips _guictrltoolbar_getunicodeformat _guictrltoolbar_hidebutton " -"_guictrltoolbar_highlightbutton _guictrltoolbar_hittest _guictrltoolbar_indextocommand " -"_guictrltoolbar_insertbutton _guictrltoolbar_insertmarkhittest _guictrltoolbar_isbuttonchecked " -"_guictrltoolbar_isbuttonenabled _guictrltoolbar_isbuttonhidden _guictrltoolbar_isbuttonhighlighted " -"_guictrltoolbar_isbuttonindeterminate _guictrltoolbar_isbuttonpressed _guictrltoolbar_loadbitmap " -"_guictrltoolbar_loadimages _guictrltoolbar_mapaccelerator _guictrltoolbar_movebutton " -"_guictrltoolbar_pressbutton _guictrltoolbar_setanchorhighlight _guictrltoolbar_setbitmapsize " -"_guictrltoolbar_setbuttonbitmap _guictrltoolbar_setbuttoninfo _guictrltoolbar_setbuttoninfoex " -"_guictrltoolbar_setbuttonparam _guictrltoolbar_setbuttonsize _guictrltoolbar_setbuttonstate " -"_guictrltoolbar_setbuttonstyle _guictrltoolbar_setbuttontext _guictrltoolbar_setbuttonwidth " -"_guictrltoolbar_setcmdid _guictrltoolbar_setcolorscheme _guictrltoolbar_setdisabledimagelist " -"_guictrltoolbar_setdrawtextflags _guictrltoolbar_setextendedstyle _guictrltoolbar_sethotimagelist " -"_guictrltoolbar_sethotitem _guictrltoolbar_setimagelist _guictrltoolbar_setindent " -"_guictrltoolbar_setindeterminate _guictrltoolbar_setinsertmark _guictrltoolbar_setinsertmarkcolor " -"_guictrltoolbar_setmaxtextrows _guictrltoolbar_setmetrics _guictrltoolbar_setpadding " -"_guictrltoolbar_setparent _guictrltoolbar_setrows _guictrltoolbar_setstyle _guictrltoolbar_setstylealtdrag " -"_guictrltoolbar_setstylecustomerase _guictrltoolbar_setstyleflat _guictrltoolbar_setstylelist " -"_guictrltoolbar_setstyleregisterdrop _guictrltoolbar_setstyletooltips _guictrltoolbar_setstyletransparent " -"_guictrltoolbar_setstylewrapable _guictrltoolbar_settooltips _guictrltoolbar_setunicodeformat " -"_guictrltoolbar_setwindowtheme _guictrltreeview_add _guictrltreeview_addchild " -"_guictrltreeview_addchildfirst _guictrltreeview_addfirst _guictrltreeview_beginupdate " -"_guictrltreeview_clickitem _guictrltreeview_create _guictrltreeview_createdragimage " -"_guictrltreeview_createsolidbitmap _guictrltreeview_delete _guictrltreeview_deleteall " -"_guictrltreeview_deletechildren _guictrltreeview_destroy _guictrltreeview_displayrect " -"_guictrltreeview_displayrectex _guictrltreeview_edittext _guictrltreeview_endedit " -"_guictrltreeview_endupdate _guictrltreeview_ensurevisible _guictrltreeview_expand " -"_guictrltreeview_expandedonce _guictrltreeview_finditem _guictrltreeview_finditemex " -"_guictrltreeview_getbkcolor _guictrltreeview_getbold _guictrltreeview_getchecked " -"_guictrltreeview_getchildcount _guictrltreeview_getchildren _guictrltreeview_getcount " -"_guictrltreeview_getcut _guictrltreeview_getdroptarget _guictrltreeview_geteditcontrol " -"_guictrltreeview_getexpanded _guictrltreeview_getfirstchild _guictrltreeview_getfirstitem " -"_guictrltreeview_getfirstvisible _guictrltreeview_getfocused _guictrltreeview_getheight " -"_guictrltreeview_getimageindex _guictrltreeview_getimagelisticonhandle _guictrltreeview_getindent " -"_guictrltreeview_getinsertmarkcolor _guictrltreeview_getisearchstring _guictrltreeview_getitembyindex " -"_guictrltreeview_getitemhandle _guictrltreeview_getitemparam _guictrltreeview_getlastchild " -"_guictrltreeview_getlinecolor _guictrltreeview_getnext _guictrltreeview_getnextchild " -"_guictrltreeview_getnextsibling _guictrltreeview_getnextvisible _guictrltreeview_getnormalimagelist " -"_guictrltreeview_getparenthandle _guictrltreeview_getparentparam _guictrltreeview_getprev " -"_guictrltreeview_getprevchild _guictrltreeview_getprevsibling _guictrltreeview_getprevvisible " -"_guictrltreeview_getscrolltime _guictrltreeview_getselected _guictrltreeview_getselectedimageindex " -"_guictrltreeview_getselection _guictrltreeview_getsiblingcount _guictrltreeview_getstate " -"_guictrltreeview_getstateimageindex _guictrltreeview_getstateimagelist _guictrltreeview_gettext " -"_guictrltreeview_gettextcolor _guictrltreeview_gettooltips _guictrltreeview_gettree " -"_guictrltreeview_getunicodeformat _guictrltreeview_getvisible _guictrltreeview_getvisiblecount " -"_guictrltreeview_hittest _guictrltreeview_hittestex _guictrltreeview_hittestitem _guictrltreeview_index " -"_guictrltreeview_insertitem _guictrltreeview_isfirstitem _guictrltreeview_isparent _guictrltreeview_level " -"_guictrltreeview_selectitem _guictrltreeview_selectitembyindex _guictrltreeview_setbkcolor " -"_guictrltreeview_setbold _guictrltreeview_setchecked _guictrltreeview_setcheckedbyindex " -"_guictrltreeview_setchildren _guictrltreeview_setcut _guictrltreeview_setdroptarget " -"_guictrltreeview_setfocused _guictrltreeview_setheight _guictrltreeview_seticon " -"_guictrltreeview_setimageindex _guictrltreeview_setindent _guictrltreeview_setinsertmark " -"_guictrltreeview_setinsertmarkcolor _guictrltreeview_setitemheight _guictrltreeview_setitemparam " -"_guictrltreeview_setlinecolor _guictrltreeview_setnormalimagelist _guictrltreeview_setscrolltime " -"_guictrltreeview_setselected _guictrltreeview_setselectedimageindex _guictrltreeview_setstate " -"_guictrltreeview_setstateimageindex _guictrltreeview_setstateimagelist _guictrltreeview_settext " -"_guictrltreeview_settextcolor _guictrltreeview_settooltips _guictrltreeview_setunicodeformat " -"_guictrltreeview_sort _guiimagelist_add _guiimagelist_addbitmap _guiimagelist_addicon " -"_guiimagelist_addmasked _guiimagelist_begindrag _guiimagelist_copy _guiimagelist_create " -"_guiimagelist_destroy _guiimagelist_destroyicon _guiimagelist_dragenter _guiimagelist_dragleave " -"_guiimagelist_dragmove _guiimagelist_draw _guiimagelist_drawex _guiimagelist_duplicate " -"_guiimagelist_enddrag _guiimagelist_getbkcolor _guiimagelist_geticon _guiimagelist_geticonheight " -"_guiimagelist_geticonsize _guiimagelist_geticonsizeex _guiimagelist_geticonwidth " -"_guiimagelist_getimagecount _guiimagelist_getimageinfoex _guiimagelist_remove _guiimagelist_replaceicon " -"_guiimagelist_setbkcolor _guiimagelist_seticonsize _guiimagelist_setimagecount _guiimagelist_swap " -"_guiscrollbars_enablescrollbar _guiscrollbars_getscrollbarinfoex _guiscrollbars_getscrollbarrect " -"_guiscrollbars_getscrollbarrgstate _guiscrollbars_getscrollbarxylinebutton " -"_guiscrollbars_getscrollbarxythumbbottom _guiscrollbars_getscrollbarxythumbtop " -"_guiscrollbars_getscrollinfo _guiscrollbars_getscrollinfoex _guiscrollbars_getscrollinfomax " -"_guiscrollbars_getscrollinfomin _guiscrollbars_getscrollinfopage _guiscrollbars_getscrollinfopos " -"_guiscrollbars_getscrollinfotrackpos _guiscrollbars_getscrollpos _guiscrollbars_getscrollrange " -"_guiscrollbars_init _guiscrollbars_scrollwindow _guiscrollbars_setscrollinfo " -"_guiscrollbars_setscrollinfomax _guiscrollbars_setscrollinfomin _guiscrollbars_setscrollinfopage " -"_guiscrollbars_setscrollinfopos _guiscrollbars_setscrollrange _guiscrollbars_showscrollbar " -"_guitooltip_activate _guitooltip_addtool _guitooltip_adjustrect _guitooltip_bitstottf _guitooltip_create " -"_guitooltip_deltool _guitooltip_destroy _guitooltip_enumtools _guitooltip_getbubbleheight " -"_guitooltip_getbubblesize _guitooltip_getbubblewidth _guitooltip_getcurrenttool _guitooltip_getdelaytime " -"_guitooltip_getmargin _guitooltip_getmarginex _guitooltip_getmaxtipwidth _guitooltip_gettext " -"_guitooltip_gettipbkcolor _guitooltip_gettiptextcolor _guitooltip_gettitlebitmap _guitooltip_gettitletext " -"_guitooltip_gettoolcount _guitooltip_gettoolinfo _guitooltip_hittest _guitooltip_newtoolrect " -"_guitooltip_pop _guitooltip_popup _guitooltip_setdelaytime _guitooltip_setmargin " -"_guitooltip_setmaxtipwidth _guitooltip_settipbkcolor _guitooltip_settiptextcolor _guitooltip_settitle " -"_guitooltip_settoolinfo _guitooltip_setwindowtheme _guitooltip_toolexists _guitooltip_tooltoarray " -"_guitooltip_trackactivate _guitooltip_trackposition _guitooltip_ttftobits _guitooltip_update " -"_guitooltip_updatetiptext _hextostring _ie_example _ie_introduction _ie_versioninfo _ieaction _ieattach " -"_iebodyreadhtml _iebodyreadtext _iebodywritehtml _iecreate _iecreateembedded _iedocgetobj _iedocinserthtml " -"_iedocinserttext _iedocreadhtml _iedocwritehtml _ieerrorhandlerderegister _ieerrorhandlerregister " -"_ieerrornotify _ieformelementcheckboxselect _ieformelementgetcollection _ieformelementgetobjbyname " -"_ieformelementgetvalue _ieformelementoptionselect _ieformelementradioselect _ieformelementsetvalue " -"_ieformgetcollection _ieformgetobjbyname _ieformimageclick _ieformreset _ieformsubmit " -"_ieframegetcollection _ieframegetobjbyname _iegetobjbyid _iegetobjbyname _ieheadinserteventscript " -"_ieimgclick _ieimggetcollection _ieisframeset _ielinkclickbyindex _ielinkclickbytext _ielinkgetcollection " -"_ieloadwait _ieloadwaittimeout _ienavigate _iepropertyget _iepropertyset _iequit _ietablegetcollection " -"_ietablewritetoarray _ietagnameallgetcollection _ietagnamegetcollection _iif _inetexplorercapable " -"_inetgetsource _inetmail _inetsmtpmail _ispressed _mathcheckdiv _max _memglobalalloc _memglobalfree " -"_memgloballock _memglobalsize _memglobalunlock _memmovememory _memvirtualalloc _memvirtualallocex " -"_memvirtualfree _memvirtualfreeex _min _mousetrap _namedpipes_callnamedpipe _namedpipes_connectnamedpipe " -"_namedpipes_createnamedpipe _namedpipes_createpipe _namedpipes_disconnectnamedpipe " -"_namedpipes_getnamedpipehandlestate _namedpipes_getnamedpipeinfo _namedpipes_peeknamedpipe " -"_namedpipes_setnamedpipehandlestate _namedpipes_transactnamedpipe _namedpipes_waitnamedpipe " -"_net_share_connectionenum _net_share_fileclose _net_share_fileenum _net_share_filegetinfo " -"_net_share_permstr _net_share_resourcestr _net_share_sessiondel _net_share_sessionenum " -"_net_share_sessiongetinfo _net_share_shareadd _net_share_sharecheck _net_share_sharedel " -"_net_share_shareenum _net_share_sharegetinfo _net_share_sharesetinfo _net_share_statisticsgetsvr " -"_net_share_statisticsgetwrk _now _nowcalc _nowcalcdate _nowdate _nowtime _pathfull _pathgetrelative " -"_pathmake _pathsplit _processgetname _processgetpriority _radian _replacestringinfile _rundos " -"_screencapture_capture _screencapture_capturewnd _screencapture_saveimage _screencapture_setbmpformat " -"_screencapture_setjpgquality _screencapture_settifcolordepth _screencapture_settifcompression " -"_security__adjusttokenprivileges _security__createprocesswithtoken _security__duplicatetokenex " -"_security__getaccountsid _security__getlengthsid _security__gettokeninformation _security__impersonateself " -"_security__isvalidsid _security__lookupaccountname _security__lookupaccountsid " -"_security__lookupprivilegevalue _security__openprocesstoken _security__openthreadtoken " -"_security__openthreadtokenex _security__setprivilege _security__settokeninformation " -"_security__sidtostringsid _security__sidtypestr _security__stringsidtosid _sendmessage _sendmessagea " -"_setdate _settime _singleton _soundclose _soundlength _soundopen _soundpause _soundplay _soundpos " -"_soundresume _soundseek _soundstatus _soundstop _sqlite_changes _sqlite_close _sqlite_display2dresult " -"_sqlite_encode _sqlite_errcode _sqlite_errmsg _sqlite_escape _sqlite_exec _sqlite_fastencode " -"_sqlite_fastescape _sqlite_fetchdata _sqlite_fetchnames _sqlite_gettable _sqlite_gettable2d " -"_sqlite_lastinsertrowid _sqlite_libversion _sqlite_open _sqlite_query _sqlite_queryfinalize " -"_sqlite_queryreset _sqlite_querysinglerow _sqlite_safemode _sqlite_settimeout _sqlite_shutdown " -"_sqlite_sqliteexe _sqlite_startup _sqlite_totalchanges _stringbetween _stringencrypt _stringexplode " -"_stringinsert _stringproper _stringrepeat _stringreverse _stringtohex _tcpiptoname _tempfile _tickstotime " -"_timer_diff _timer_getidletime _timer_gettimerid _timer_init _timer_killalltimers _timer_killtimer " -"_timer_settimer _timetoticks _versioncompare _viclose _viexeccommand _vifindgpib _vigpibbusreset _vigtl " -"_viinteractivecontrol _viopen _visetattribute _visettimeout _weeknumberiso _winapi_attachconsole " -"_winapi_attachthreadinput _winapi_beep _winapi_bitblt _winapi_callnexthookex _winapi_callwindowproc " -"_winapi_clienttoscreen _winapi_closehandle _winapi_combinergn _winapi_commdlgextendederror " -"_winapi_copyicon _winapi_createbitmap _winapi_createcompatiblebitmap _winapi_createcompatibledc " -"_winapi_createevent _winapi_createfile _winapi_createfont _winapi_createfontindirect _winapi_createpen " -"_winapi_createprocess _winapi_createrectrgn _winapi_createroundrectrgn _winapi_createsolidbitmap " -"_winapi_createsolidbrush _winapi_createwindowex _winapi_defwindowproc _winapi_deletedc " -"_winapi_deleteobject _winapi_destroyicon _winapi_destroywindow _winapi_drawedge _winapi_drawframecontrol " -"_winapi_drawicon _winapi_drawiconex _winapi_drawline _winapi_drawtext _winapi_duplicatehandle " -"_winapi_enablewindow _winapi_enumdisplaydevices _winapi_enumwindows _winapi_enumwindowspopup " -"_winapi_enumwindowstop _winapi_expandenvironmentstrings _winapi_extracticonex _winapi_fatalappexit " -"_winapi_fillrect _winapi_findexecutable _winapi_findwindow _winapi_flashwindow _winapi_flashwindowex " -"_winapi_floattoint _winapi_flushfilebuffers _winapi_formatmessage _winapi_framerect _winapi_freelibrary " -"_winapi_getancestor _winapi_getasynckeystate _winapi_getbkmode _winapi_getclassname " -"_winapi_getclientheight _winapi_getclientrect _winapi_getclientwidth _winapi_getcurrentprocess " -"_winapi_getcurrentprocessid _winapi_getcurrentthread _winapi_getcurrentthreadid _winapi_getcursorinfo " -"_winapi_getdc _winapi_getdesktopwindow _winapi_getdevicecaps _winapi_getdibits _winapi_getdlgctrlid " -"_winapi_getdlgitem _winapi_getfilesizeex _winapi_getfocus _winapi_getforegroundwindow " -"_winapi_getguiresources _winapi_geticoninfo _winapi_getlasterror _winapi_getlasterrormessage " -"_winapi_getlayeredwindowattributes _winapi_getmodulehandle _winapi_getmousepos _winapi_getmouseposx " -"_winapi_getmouseposy _winapi_getobject _winapi_getopenfilename _winapi_getoverlappedresult " -"_winapi_getparent _winapi_getprocessaffinitymask _winapi_getsavefilename _winapi_getstdhandle " -"_winapi_getstockobject _winapi_getsyscolor _winapi_getsyscolorbrush _winapi_getsystemmetrics " -"_winapi_gettextextentpoint32 _winapi_gettextmetrics _winapi_getwindow _winapi_getwindowdc " -"_winapi_getwindowheight _winapi_getwindowlong _winapi_getwindowplacement _winapi_getwindowrect " -"_winapi_getwindowrgn _winapi_getwindowtext _winapi_getwindowthreadprocessid _winapi_getwindowwidth " -"_winapi_getxyfrompoint _winapi_globalmemorystatus _winapi_guidfromstring _winapi_guidfromstringex " -"_winapi_hiword _winapi_inprocess _winapi_inttofloat _winapi_invalidaterect _winapi_isclassname " -"_winapi_iswindow _winapi_iswindowvisible _winapi_lineto _winapi_loadbitmap _winapi_loadimage " -"_winapi_loadlibrary _winapi_loadlibraryex _winapi_loadshell32icon _winapi_loadstring _winapi_localfree " -"_winapi_loword _winapi_makelangid _winapi_makelcid _winapi_makelong _winapi_makeqword _winapi_messagebeep " -"_winapi_mouse_event _winapi_moveto _winapi_movewindow _winapi_msgbox _winapi_muldiv " -"_winapi_multibytetowidechar _winapi_multibytetowidecharex _winapi_openprocess _winapi_pathfindonpath " -"_winapi_pointfromrect _winapi_postmessage _winapi_primarylangid _winapi_ptinrect _winapi_readfile " -"_winapi_readprocessmemory _winapi_rectisempty _winapi_redrawwindow _winapi_registerwindowmessage " -"_winapi_releasecapture _winapi_releasedc _winapi_screentoclient _winapi_selectobject _winapi_setbkcolor " -"_winapi_setbkmode _winapi_setcapture _winapi_setcursor _winapi_setdefaultprinter _winapi_setdibits " -"_winapi_setendoffile _winapi_setevent _winapi_setfilepointer _winapi_setfocus _winapi_setfont " -"_winapi_sethandleinformation _winapi_setlasterror _winapi_setlayeredwindowattributes _winapi_setparent " -"_winapi_setprocessaffinitymask _winapi_setsyscolors _winapi_settextcolor _winapi_setwindowlong " -"_winapi_setwindowplacement _winapi_setwindowpos _winapi_setwindowrgn _winapi_setwindowshookex " -"_winapi_setwindowtext _winapi_showcursor _winapi_showerror _winapi_showmsg _winapi_showwindow " -"_winapi_stringfromguid _winapi_stringlena _winapi_stringlenw _winapi_sublangid " -"_winapi_systemparametersinfo _winapi_twipsperpixelx _winapi_twipsperpixely _winapi_unhookwindowshookex " -"_winapi_updatelayeredwindow _winapi_updatewindow _winapi_waitforinputidle _winapi_waitformultipleobjects " -"_winapi_waitforsingleobject _winapi_widechartomultibyte _winapi_windowfrompoint _winapi_writeconsole " -"_winapi_writefile _winapi_writeprocessmemory _winnet_addconnection _winnet_addconnection2 " -"_winnet_addconnection3 _winnet_cancelconnection _winnet_cancelconnection2 _winnet_closeenum " -"_winnet_connectiondialog _winnet_connectiondialog1 _winnet_disconnectdialog _winnet_disconnectdialog1 " -"_winnet_enumresource _winnet_getconnection _winnet_getconnectionperformance _winnet_getlasterror " -"_winnet_getnetworkinformation _winnet_getprovidername _winnet_getresourceinformation " -"_winnet_getresourceparent _winnet_getuniversalname _winnet_getuser _winnet_openenum " -"_winnet_restoreconnection _winnet_useconnection _word_versioninfo _wordattach _wordcreate _worddocadd " -"_worddocaddlink _worddocaddpicture _worddocclose _worddocfindreplace _worddocgetcollection " -"_worddoclinkgetcollection _worddocopen _worddocprint _worddocpropertyget _worddocpropertyset _worddocsave " -"_worddocsaveas _worderrorhandlerderegister _worderrorhandlerregister _worderrornotify _wordmacrorun " -"_wordpropertyget _wordpropertyset _wordquit", -"" }; - - -EDITLEXER lexAU3 = { SCLEX_AU3, 63276, L"AutoIt3 Script", L"au3", L"", &KeyWords_AU3, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_AU3_COMMENT,SCE_AU3_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_AU3_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - { SCE_AU3_FUNCTION, 63277, L"Function", L"fore:#0000FF", L"" }, - { SCE_AU3_UDF, 63360, L"User-Defined Function", L"fore:#0000FF", L"" }, - { SCE_AU3_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, - { SCE_AU3_MACRO, 63278, L"Macro", L"fore:#0080FF", L"" }, - { SCE_AU3_STRING, 63131, L"String", L"fore:#008080", L"" }, - { SCE_AU3_OPERATOR, 63132, L"Operator", L"fore:#C000C0", L"" }, - { SCE_AU3_VARIABLE, 63249, L"Variable", L"fore:#808000", L"" }, - { SCE_AU3_SENT, 63279, L"Send Key", L"fore:#FF0000", L"" }, - { SCE_AU3_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - { SCE_AU3_SPECIAL, 63280, L"Special", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -EDITLEXER lexLATEX = { SCLEX_LATEX, 63281, L"LaTeX Files", L"tex; latex; sty", L"", &KeyWords_NULL, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_L_COMMAND,SCE_L_SHORTCMD,SCE_L_CMDOPT,0), 63236, L"Command", L"fore:#0000FF", L"" }, - { MULTI_STYLE(SCE_L_COMMENT,SCE_L_COMMENT2,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_L_MATH,SCE_L_MATH2,0,0), 63283, L"Math", L"fore:#FF0000", L"" }, - { SCE_L_SPECIAL, 63330, L"Special Char", L"fore:#AAAA00", L"" }, - { MULTI_STYLE(SCE_L_TAG,SCE_L_TAG2,0,0), 63282, L"Tag", L"fore:#0000FF", L"" }, - { SCE_L_VERBATIM, 63331, L"Verbatim Segment", L"fore:#666666", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -EDITLEXER lexANSI = { SCLEX_NULL, 63258, L"ANSI Art", L"nfo; diz", L"", &KeyWords_NULL, { - { STYLE_DEFAULT, 63126, L"Default", L"font:Lucida Console", L"" }, - { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" }, - { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+0", L"" }, - { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+0", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_AHK = { -"break continue else exit exitapp gosub goto if ifequal ifexist ifgreater ifgreaterorequal " -"ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist ifnotinstring ifwinactive " -"ifwinexist ifwinnotactive ifwinnotexist loop onexit pause repeat return settimer sleep " -"suspend static global local var byref while until for class try catch throw", -"autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus " -"controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode " -"critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat " -"envadd envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir " -"filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion " -"fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir " -"fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate " -"groupadd groupclose groupdeactivategui guicontrol guicontrolget hideautoitwin hotkey imagesearch " -"inidelete iniread iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu " -"mouseclick mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch " -"postmessage process progress random regdelete regread regwrite reload run runas runwait send " -"sendevent sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate " -"setcontroldelay setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate " -"setscrolllockstate setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort " -"soundbeep soundget soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff " -"splashtexton splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen " -"stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright stringupper " -"sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom winclose winget " -"wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle winhide winkill " -"winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove winrestore winset " -"winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive fileencoding", -"abs acos asc asin atan ceil chr cos dllcall exp fileexist floor getkeystate numget numput " -"registercallback il_add il_create il_destroy instr islabel isfunc ln log lv_add lv_delete " -"lv_deletecol lv_getcount lv_getnext lv_gettext lv_insert lv_insertcol lv_modify lv_modifycol " -"lv_setimagelist mod onmessage round regexmatch regexreplace sb_seticon sb_setparts sb_settext " -"sin sqrt strlen substr tan tv_add tv_delete tv_getchild tv_getcount tv_getnext tv_get tv_getparent " -"tv_getprev tv_getselection tv_gettext tv_modify tv_setimagelist varsetcapacity winactive winexist " -"trim ltrim rtrim fileopen strget strput object array isobject objinsert objremove objminindex " -"objmaxindex objsetcapacity objgetcapacity objgetaddress objnewenum objaddref objrelease objhaskey " -"objclone _insert _remove _minindex _maxindex _setcapacity _getcapacity _getaddress _newenum _addref " -"_release _haskey _clone comobjcreate comobjget comobjconnect comobjerror comobjactive comobjenwrap " -"comobjunwrap comobjparameter comobjmissing comobjtype comobjvalue comobjarray comobjquery comobjflags " -"func getkeyname getkeyvk getkeysc isbyref exception", -"allowsamelinecomments clipboardtimeout commentflag errorstdout escapechar hotkeyinterval " -"hotkeymodifiertimeout hotstring if iftimeout ifwinactive ifwinexist include includeagain " -"installkeybdhook installmousehook keyhistory ltrim maxhotkeysperinterval maxmem maxthreads " -"maxthreadsbuffer maxthreadsperhotkey menumaskkey noenv notrayicon persistent singleinstance " -"usehook warn winactivateforce", -"shift lshift rshift alt lalt ralt control lcontrol rcontrol ctrl lctrl rctrl lwin rwin appskey " -"altdown altup shiftdown shiftup ctrldown ctrlup lwindown lwinup rwindown rwinup lbutton rbutton " -"mbutton wheelup wheeldown xbutton1 xbutton2 joy1 joy2 joy3 joy4 joy5 joy6 joy7 joy8 joy9 joy10 " -"joy11 joy12 joy13 joy14 joy15 joy16 joy17 joy18 joy19 joy20 joy21 joy22 joy23 joy24 joy25 joy26 " -"joy27 joy28 joy29 joy30 joy31 joy32 joyx joyy joyz joyr joyu joyv joypov joyname joybuttons " -"joyaxes joyinfo space tab enter escape esc backspace bs delete del insert ins pgup pgdn home end " -"up down left right printscreen ctrlbreak pause scrolllock capslock numlock numpad0 numpad1 numpad2 " -"numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9 numpadmult numpadadd numpadsub numpaddiv " -"numpaddot numpaddel numpadins numpadclear numpadup numpaddown numpadleft numpadright numpadhome " -"numpadend numpadpgup numpadpgdn numpadenter f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 " -"f16 f17 f18 f19 f20 f21 f22 f23 f24 browser_back browser_forward browser_refresh browser_stop " -"browser_search browser_favorites browser_home volume_mute volume_down volume_up media_next " -"media_prev media_stop media_play_pause launch_mail launch_media launch_app1 launch_app2 blind " -"click raw wheelleft wheelright", -"a_ahkpath a_ahkversion a_appdata a_appdatacommon a_autotrim a_batchlines a_caretx a_carety " -"a_computername a_controldelay a_cursor a_dd a_ddd a_dddd a_defaultmousespeed a_desktop " -"a_desktopcommon a_detecthiddentext a_detecthiddenwindows a_endchar a_eventinfo a_exitreason " -"a_formatfloat a_formatinteger a_gui a_guievent a_guicontrol a_guicontrolevent a_guiheight " -"a_guiwidth a_guix a_guiy a_hour a_iconfile a_iconhidden a_iconnumber a_icontip a_index " -"a_ipaddress1 a_ipaddress2 a_ipaddress3 a_ipaddress4 a_isadmin a_iscompiled a_issuspended " -"a_keydelay a_language a_lasterror a_linefile a_linenumber a_loopfield a_loopfileattrib " -"a_loopfiledir a_loopfileext a_loopfilefullpath a_loopfilelongpath a_loopfilename " -"a_loopfileshortname a_loopfileshortpath a_loopfilesize a_loopfilesizekb a_loopfilesizemb " -"a_loopfiletimeaccessed a_loopfiletimecreated a_loopfiletimemodified a_loopreadline a_loopregkey " -"a_loopregname a_loopregsubkey a_loopregtimemodified a_loopregtype a_mday a_min a_mm a_mmm " -"a_mmmm a_mon a_mousedelay a_msec a_mydocuments a_now a_nowutc a_numbatchlines a_ostype " -"a_osversion a_priorhotkey a_programfiles a_programs a_programscommon a_screenheight " -"a_screenwidth a_scriptdir a_scriptfullpath a_scriptname a_sec a_space a_startmenu " -"a_startmenucommon a_startup a_startupcommon a_stringcasesense a_tab a_temp a_thishotkey " -"a_thismenu a_thismenuitem a_thismenuitempos a_tickcount a_timeidle a_timeidlephysical " -"a_timesincepriorhotkey a_timesincethishotkey a_titlematchmode a_titlematchmodespeed " -"a_username a_wday a_windelay a_windir a_workingdir a_yday a_year a_yweek a_yyyy " -"clipboard clipboardall comspec errorlevel programfiles true false a_thisfunc a_thislabel " -"a_ispaused a_iscritical a_isunicode a_ptrsize a_scripthwnd a_priorkey", -"ltrim rtrim join ahk_id ahk_pid ahk_class ahk_group ahk_exe processname processpath minmax " -"controllist statuscd filesystem setlabel alwaysontop mainwindow nomainwindow useerrorlevel " -"altsubmit hscroll vscroll imagelist wantctrla wantf2 vis visfirst wantreturn backgroundtrans " -"minimizebox maximizebox sysmenu toolwindow exstyle check3 checkedgray readonly notab lastfound " -"lastfoundexist alttab shiftalttab alttabmenu alttabandmenu alttabmenudismiss controllisthwnd " -"hwnd deref pow bitnot bitand bitor bitxor bitshiftleft bitshiftright sendandmouse mousemove " -"mousemoveoff hkey_local_machine hkey_users hkey_current_user hkey_classes_root hkey_current_config " -"hklm hku hkcu hkcr hkcc reg_sz reg_expand_sz reg_multi_sz reg_dword reg_qword reg_binary reg_link " -"reg_resource_list reg_full_resource_descriptor reg_resource_requirements_list reg_dword_big_endian " -"regex pixel mouse screen relative rgb low belownormal normal abovenormal high realtime between " -"contains in is integer float number digit xdigit integerfast floatfast alpha upper lower alnum " -"time date not or and topmost top bottom transparent transcolor redraw region id idlast count " -"list capacity eject lock unlock label serial type status seconds minutes hours days read parse " -"logoff close error single shutdown menu exit reload tray add rename check uncheck togglecheck " -"enable disable toggleenable default nodefault standard nostandard color delete deleteall icon " -"noicon tip click show edit progress hotkey text picture pic groupbox button checkbox radio " -"dropdownlist ddl combobox statusbar treeview listbox listview datetime monthcal updown slider " -"tab tab2 activex iconsmall tile report sortdesc nosort nosorthdr grid hdr autosize range xm ym " -"ys xs xp yp font resize owner submit nohide minimize maximize restore noactivate na cancel " -"destroy center margin owndialogs guiescape guiclose guisize guicontextmenu guidropfiles tabstop " -"section wrap border top bottom buttons expand first lines number uppercase lowercase limit " -"password multi group background bold italic strike underline norm theme caption delimiter flash " -"style checked password hidden left right center section move focus hide choose choosestring text " -"pos enabled disabled visible notimers interrupt priority waitclose unicode tocodepage fromcodepage " -"yes no ok cancel abort retry ignore force on off all send wanttab monitorcount monitorprimary " -"monitorname monitorworkarea pid this base extends __get __set __call __delete __new new " -"useunsetlocal useunsetglobal useenv localsameasglobal", -"", "" }; - - -EDITLEXER lexAHK = { SCLEX_AHK, 63305, L"AutoHotkey Script", L"ahk; ia; scriptlet", L"", &KeyWords_AHK, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_AHK_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_AHK_COMMENTLINE,SCE_AHK_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_AHK_ESCAPE, 63306, L"Escape", L"fore:#FF8000", L"" }, - { SCE_AHK_SYNOPERATOR, 63307, L"Syntax Operator", L"fore:#7F200F", L"" }, - { SCE_AHK_EXPOPERATOR, 63308, L"Expression operator", L"fore:#FF4F00", L"" }, - { SCE_AHK_STRING, 63131, L"String", L"fore:#404040", L"" }, - { SCE_AHK_NUMBER, 63130, L"Number", L"fore:#2F4F7F", L"" }, - { SCE_AHK_IDENTIFIER, 63129, L"Identifier", L"fore:#CF2F0F", L"" }, - { SCE_AHK_VARREF, 63309, L"Variable dereferencing", L"fore:#CF2F0F; back:#E4FFE4", L"" }, - { SCE_AHK_LABEL, 63235, L"Label", L"fore:#000000; back:#FFFFA1", L"" }, - { SCE_AHK_WORD_CF, 63310, L"Flow of control", L"fore:#480048; bold", L"" }, - { SCE_AHK_WORD_CMD, 63236, L"Command", L"fore:#004080", L"" }, - { SCE_AHK_WORD_FN, 63277, L"Function", L"fore:#0F707F; italics", L"" }, - { SCE_AHK_WORD_DIR, 63203, L"Directive", L"fore:#F04020; italics", L"" }, - { SCE_AHK_WORD_KB, 63311, L"Keys & buttons", L"fore:#FF00FF; bold", L"" }, - { SCE_AHK_WORD_VAR, 63312, L"Built-in Variables", L"fore:#CF00CF; italics", L"" }, - { SCE_AHK_WORD_SP, 63280, L"Special", L"fore:#0000FF; italics", L"" }, - //{ SCE_AHK_WORD_UD, 63106, L"User Defined", L"fore:#800020", L"" }, - { SCE_AHK_VARREFKW, 63313, L"Variable keyword", L"fore:#CF00CF; italics; back:#F9F9FF", L"" }, - { SCE_AHK_ERROR, 63260, L"Error", L"back:#FFC0C0", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_CMAKE = { -"add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library " -"add_subdirectory add_test aux_source_directory build_command build_name cmake_minimum_required " -"configure_file create_test_sourcelist else elseif enable_language enable_testing endforeach endif " -"endmacro endwhile exec_program execute_process export_library_dependencies file find_file find_library " -"find_package find_path find_program fltk_wrap_ui foreach get_cmake_property get_directory_property " -"get_filename_component get_source_file_property get_target_property get_test_property if include " -"include_directories include_external_msproject include_regular_expression install install_files " -"install_programs install_targets link_directories link_libraries list load_cache load_command " -"macro make_directory mark_as_advanced math message option output_required_files project qt_wrap_cpp " -"qt_wrap_ui remove remove_definitions separate_arguments set set_directory_properties set_source_files_properties " -"set_target_properties set_tests_properties site_name source_group string subdir_depends subdirs " -"target_link_libraries try_compile try_run use_mangled_mesa utility_source variable_requires vtk_make_instantiator " -"vtk_wrap_java vtk_wrap_python vtk_wrap_tcl while write_file", -"ABSOLUTE ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ALL AND APPEND ARGS ASCII BEFORE CACHE CACHE_VARIABLES " -"CLEAR COMMAND COMMANDS COMMAND_NAME COMMENT COMPARE COMPILE_FLAGS COPYONLY DEFINED DEFINE_SYMBOL " -"DEPENDS DOC EQUAL ESCAPE_QUOTES EXCLUDE EXCLUDE_FROM_ALL EXISTS EXPORT_MACRO EXT EXTRA_INCLUDE " -"FATAL_ERROR FILE FILES FORCE FUNCTION GENERATED GLOB GLOB_RECURSE GREATER GROUP_SIZE HEADER_FILE_ONLY " -"HEADER_LOCATION IMMEDIATE INCLUDES INCLUDE_DIRECTORIES INCLUDE_INTERNALS INCLUDE_REGULAR_EXPRESSION " -"LESS LINK_DIRECTORIES LINK_FLAGS LOCATION MACOSX_BUNDLE MACROS MAIN_DEPENDENCY MAKE_DIRECTORY MATCH " -"MATCHALL MATCHES MODULE NAME NAME_WE NOT NOTEQUAL NO_SYSTEM_PATH OBJECT_DEPENDS OPTIONAL OR OUTPUT " -"OUTPUT_VARIABLE PATH PATHS POST_BUILD POST_INSTALL_SCRIPT PREFIX PREORDER PRE_BUILD PRE_INSTALL_SCRIPT " -"PRE_LINK PROGRAM PROGRAM_ARGS PROPERTIES QUIET RANGE READ REGEX REGULAR_EXPRESSION REPLACE REQUIRED " -"RETURN_VALUE RUNTIME_DIRECTORY SEND_ERROR SHARED SOURCES STATIC STATUS STREQUAL STRGREATER STRLESS " -"SUFFIX TARGET TOLOWER TOUPPER VAR VARIABLES VERSION WIN32 WRAP_EXCLUDE WRITE APPLE MINGW MSYS CYGWIN " -"BORLAND WATCOM MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 OFF ON", -"", "", "", "", "", "", "" }; - - -EDITLEXER lexCmake = { SCLEX_CMAKE, 63324, L"Cmake Script", L"cmake; ctest", L"", &KeyWords_CMAKE, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_CMAKE_DEFAULT, L"Default", L"", L"" }, - { SCE_CMAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, - { MULTI_STYLE(SCE_CMAKE_STRINGDQ,SCE_CMAKE_STRINGLQ,SCE_CMAKE_STRINGRQ,0), 63131, L"String", L"back:#EEEEEE; fore:#7F007F", L"" }, - { SCE_CMAKE_COMMANDS, 63277, L"Function", L"fore:#00007F", L"" }, - { SCE_CMAKE_PARAMETERS, 63294, L"Parameter", L"fore:#7F200F", L"" }, - { SCE_CMAKE_VARIABLE, 63249, L"Variable", L"fore:#CC3300", L"" }, - { SCE_CMAKE_WHILEDEF, 63325, L"While def", L"fore:#00007F", L"" }, - { SCE_CMAKE_FOREACHDEF, 63326, L"For each def", L"fore:#00007F", L"" }, - { SCE_CMAKE_IFDEFINEDEF, 63327, L"If def", L"fore:#00007F", L"" }, - { SCE_CMAKE_MACRODEF, 63328, L"Macro def", L"fore:#00007F", L"" }, - { SCE_CMAKE_STRINGVAR, 63329, L"Variable within string", L"back:#EEEEEE; fore:#CC3300", L"" }, - { SCE_CMAKE_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, - //{ SCE_CMAKE_USERDEFINED, 63106, L"User Defined", L"fore:#800020", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_AVS = { -"true false return global", -"addborders alignedsplice amplify amplifydb animate applyrange assumebff assumefieldbased assumefps " -"assumeframebased assumesamplerate assumescaledfps assumetff audiodub audiodubex avifilesource " -"avisource bicubicresize bilinearresize blackmanresize blackness blankclip blur bob cache changefps " -"colorbars colorkeymask coloryuv compare complementparity conditionalfilter conditionalreader " -"convertaudio convertaudioto16bit convertaudioto24bit convertaudioto32bit convertaudioto8bit " -"convertaudiotofloat convertbacktoyuy2 convertfps converttobackyuy2 converttomono converttorgb " -"converttorgb24 converttorgb32 converttoy8 converttoyv16 converttoyv24 converttoyv411 converttoyuy2 " -"converttoyv12 crop cropbottom delayaudio deleteframe dissolve distributor doubleweave duplicateframe " -"ensurevbrmp3sync fadein fadein0 fadein2 fadeio fadeio0 fadeio2 fadeout fadeout0 fadeout2 fixbrokenchromaupsampling " -"fixluminance fliphorizontal flipvertical frameevaluate freezeframe gaussresize generalconvolution " -"getchannel getchannels getmtmode getparity grayscale greyscale histogram horizontalreduceby2 " -"imagereader imagesource imagewriter info interleave internalcache internalcachemt invert killaudio " -"killvideo lanczos4resize lanczosresize layer letterbox levels limiter loop mask maskhs max merge " -"mergeargb mergechannels mergechroma mergeluma mergergb messageclip min mixaudio monotostereo normalize " -"null opendmlsource overlay peculiarblend pointresize pulldown reduceby2 resampleaudio resetmask reverse " -"rgbadjust scriptclip segmentedavisource segmenteddirectshowsource selecteven selectevery selectodd " -"selectrangeevery separatefields setmtmode sharpen showalpha showblue showfiveversions showframenumber " -"showgreen showred showsmpte showtime sincresize skewrows spatialsoften spline16resize spline36resize " -"spline64resize ssrc stackhorizontal stackvertical subtitle subtract supereq swapfields swapuv " -"temporalsoften timestretch tone trim turn180 turnleft turnright tweak unalignedsplice utoy utoy8 " -"version verticalreduceby2 vtoy vtoy8 wavsource weave writefile writefileend writefileif writefilestart " -"ytouv", -"addgrain addgrainc agc_hdragc analyzelogo animeivtc asharp audiograph autocrop autoyuy2 avsrecursion " -"awarpsharp bassaudiosource bicublinresize bifrost binarize blendfields blindpp blockbuster bordercontrol " -"cfielddiff cframediff chromashift cnr2 colormatrix combmask contra convolution3d convolution3dyv12 " -"dctfilter ddcc deblendlogo deblock deblock_qed decimate decomb dedup deen deflate degrainmedian depan " -"depanestimate depaninterleave depanscenes depanstabilize descratch despot dfttest dgbob dgdecode_mpeg2source " -"dgsource directshowsource distancefunction dss2 dup dupmc edeen edgemask ediupsizer eedi2 eedi3 eedi3_rpow2 " -"expand faerydust fastbicubicresize fastbilinearresize fastediupsizer dedgemask fdecimate ffaudiosource " -"ffdshow ffindex ffmpegsource ffmpegsource2 fft3dfilter fft3dgpu ffvideosource fielddeinterlace fielddiff " -"fillmargins fity2uv fity2u fity2v fitu2y fitv2y fluxsmooth fluxsmoothst fluxsmootht framediff framenumber " -"frfun3b frfun7 gicocu golddust gradfun2db grapesmoother greedyhma grid guavacomb hqdn3d hybridfupp " -"hysteresymask ibob improvesceneswitch inflate inpand inpaintlogo interframe interlacedresize " -"interlacedwarpedresize interleaved2planar iscombed iscombedt iscombedtivtc kerneldeint leakkernelbob " -"leakkerneldeint limitedsharpen limitedsharpenfaster logic lsfmod lumafilter lumayv12 manalyse " -"maskeddeinterlace maskedmerge maskedmix mblockfps mcompensate mctemporaldenoise mctemporaldenoisepp " -"mdegrain1 mdegrain2 mdegrain3 mdepan medianblur mergehints mflow mflowblur mflowfps mflowinter minblur " -"mipsmooth mmask moderatesharpen monitorfilter motionmask mpasource mpeg2source mrecalculate mscdetection " -"msharpen mshow msmooth msu_fieldshiftfixer msu_frc msuper mt mt_adddiff mt_average mt_binarize mt_circle " -"mt_clamp mt_convolution mt_deflate mt_diamond mt_edge mt_ellipse mt_expand mt_freeellipse mt_freelosange " -"mt_freerectangle mt_hysteresis mt_infix mt_inflate mt_inpand mt_invert mt_logic mt_losange mt_lut mt_lutf " -"mt_luts mt_lutspa mt_lutsx mt_lutxy mt_lutxyz mt_makediff mt_mappedblur mt_merge mt_motion mt_polish " -"mt_rectangle mt_square mti mtsource multidecimate mvanalyse mvblockfps mvchangecompensate mvcompensate " -"mvdegrain1 mvdegrain2 mvdegrain3 mvdenoise mvdepan mvflow mvflowblur mvflowfps mvflowfps2 mvflowinter " -"mvincrease mvmask mvrecalculate mvscdetection mvshow nicac3source nicdtssource niclpcmsource nicmpasource " -"nicmpg123source nnedi nnedi2 nnedi2_rpow2 nnedi3 nnedi3_rpow2 nomosmooth overlaymask peachsmoother pixiedust " -"planar2interleaved qtgmc qtinput rawavsource rawsource reduceflicker reinterpolate411 removedirt removedust " -"removegrain removegrainhd removetemporalgrain repair requestlinear reversefielddominance rgb3dlut rgdeinterlace " -"rgsdeinterlace rgblut rotate sangnom seesaw sharpen2 showchannels showcombedtivtc smartdecimate smartdeinterlace " -"smdegrain smoothdeinterlace smoothuv soothess soxfilter spacedust sshiq ssim ssiq stmedianfilter t3dlut tanisotropic " -"tbilateral tcanny tcomb tcombmask tcpserver tcpsource tdecimate tdeint tedgemask telecide temporalcleaner " -"temporalrepair temporalsmoother tfieldblank tfm tisophote tivtc tmaskblank tmaskedmerge tmaskedmerge3 tmm " -"tmonitor tnlmeans tomsmocomp toon textsub ttempsmooth ttempsmoothf tunsharp unblock uncomb undot unfilter " -"unsharpmask vaguedenoiser variableblur verticalcleaner videoscope vinverse vobsub vqmcalc warpedresize warpsharp " -"xsharpen yadif yadifmod yuy2lut yv12convolution yv12interlacedreduceby2 yv12interlacedselecttopfields " -"yv12layer yv12lut yv12lutxy yv12substract yv12torgb24 yv12toyuy2", -"abs apply assert bool ceil chr clip continueddenominator continuednumerator cos default defined eval " -"averagechromau averagechromav averageluma chromaudifference chromavdifference lumadifference " -"exist exp findstr float floor frac hexvalue import int isbool isclip isfloat isint isstring lcase leftstr " -"load_stdcall_plugin loadcplugin loadplugin loadvfapiplugin loadvirtualdubplugin log midstr muldiv nop " -"opt_allowfloataudio opt_avipadscanlines opt_dwchannelmask opt_usewaveextensible opt_vdubplanarhack " -"pi pow rand revstr rightstr round scriptdir scriptfile scriptname select setmemorymax setplanarlegacyalignment " -"rgbdifference rgbdifferencefromprevious rgbdifferencetonext udifferencefromprevious udifferencetonext " -"setworkingdir sign sin spline sqrt string strlen time ucase undefined value versionnumber versionstring " -"uplanemax uplanemedian uplanemin uplaneminmaxdifference vdifferencefromprevious vdifferencetonext " -"vplanemax vplanemedian vplanemin vplaneminmaxdifference ydifferencefromprevious ydifferencetonext " -"yplanemax yplanemedian yplanemin yplaneminmaxdifference", -"audiobits audiochannels audiolength audiolengthf audiorate framecount framerate frameratedenominator " -"frameratenumerator getleftchannel getrightchannel hasaudio hasvideo height isaudiofloat isaudioint " -"isfieldbased isframebased isinterleaved isplanar isrgb isrgb24 isrgb32 isyuv isyuy2 isyv12 width", -"", "", "", "" }; - - -EDITLEXER lexAVS = { SCLEX_AVS, 63332, L"AviSynth Script", L"avs; avsi", L"", &KeyWords_AVS, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_AVS_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_AVS_COMMENTLINE,SCE_AVS_COMMENTBLOCK,SCE_AVS_COMMENTBLOCKN,0), 63127, L"Comment", L"fore:#008000", L"" }, - { SCE_AVS_OPERATOR, 63132, L"Operator", L"", L"" }, - { MULTI_STYLE(SCE_AVS_STRING,SCE_AVS_TRIPLESTRING,0,0), 63131, L"String", L"fore:#7F007F", L"" }, - { SCE_AVS_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" }, - { SCE_AVS_KEYWORD, 63128, L"Keyword", L"fore:#00007F; bold", L"" }, - { SCE_AVS_FILTER, 63333, L"Filter", L"fore:#00007F; bold", L"" }, - { SCE_AVS_PLUGIN, 63334, L"Plugin", L"fore:#0080C0; bold", L"" }, - { SCE_AVS_FUNCTION, 63277, L"Function", L"fore:#007F7F", L"" }, - { SCE_AVS_CLIPPROP, 63335, L"Clip property", L"fore:#00007F", L"" }, - //{ SCE_AVS_USERDFN, 63106, L"User Defined", L"fore:#8000FF", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_MARKDOWN = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexMARKDOWN = { SCLEX_MARKDOWN, 63336, L"Markdown", L"md; markdown; mdown; mkdn; mkd", L"", &KeyWords_MARKDOWN, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_MARKDOWN_DEFAULT, L"Default", L"", L"" }, - { SCE_MARKDOWN_LINE_BEGIN, 63338, L"Line Begin", L"", L"" }, - { MULTI_STYLE(SCE_MARKDOWN_STRONG1,SCE_MARKDOWN_STRONG2,0,0), 63339, L"Strong", L"bold", L"" }, - { MULTI_STYLE(SCE_MARKDOWN_EM1,SCE_MARKDOWN_EM2,0,0), 63340, L"Emphasis", L"italic", L"" }, - { SCE_MARKDOWN_HEADER1, 63341, L"Header 1", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_HEADER2, 63342, L"Header 2", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_HEADER3, 63343, L"Header 3", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_HEADER4, 63344, L"Header 4", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_HEADER5, 63345, L"Header 5", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_HEADER6, 63346, L"Header 6", L"fore:#FF0088; bold", L"" }, - { SCE_MARKDOWN_PRECHAR, 63347, L"Pre char", L"fore:#00007F", L"" }, - { SCE_MARKDOWN_ULIST_ITEM, 63348, L"Unordered list", L"fore:#0080FF; bold", L"" }, - { SCE_MARKDOWN_OLIST_ITEM, 63349, L"Ordered list", L"fore:#0080FF; bold", L"" }, - { SCE_MARKDOWN_BLOCKQUOTE, 63350, L"Block quote", L"fore:#00007F", L"" }, - { SCE_MARKDOWN_STRIKEOUT, 63351, L"Strikeout", L"", L"" }, - { SCE_MARKDOWN_HRULE, 63352, L"Horizontal rule", L"bold", L"" }, - { SCE_MARKDOWN_LINK, 63353, L"Link", L"fore:#0000FF", L"" }, - { MULTI_STYLE(SCE_MARKDOWN_CODE,SCE_MARKDOWN_CODE2,SCE_MARKDOWN_CODEBK,0), 63354, L"Code", L"fore:#00007F; back:#EBEBEB", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_YAML = { -"y n yes no on off true false", "", "", "", "", "", "", "", "" }; - -EDITLEXER lexYAML = { SCLEX_YAML, 63355, L"YAML", L"yaml; yml", L"", &KeyWords_YAML, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_YAML_DEFAULT, L"Default", L"", L"" }, - { SCE_YAML_COMMENT, 63127, L"Comment", L"fore:#008800", L"" }, - { SCE_YAML_IDENTIFIER, 63129, L"Identifier", L"bold; fore:#0A246A", L"" }, - { SCE_YAML_KEYWORD, 63128, L"Keyword", L"fore:#880088", L"" }, - { SCE_YAML_NUMBER, 63130, L"Number", L"fore:#FF8000", L"" }, - { SCE_YAML_REFERENCE, 63356, L"Reference", L"fore:#008888", L"" }, - { SCE_YAML_DOCUMENT, 63357, L"Document", L"fore:#FFFFFF; bold; back:#000088; eolfilled", L"" }, - { SCE_YAML_TEXT, 63358, L"Text", L"fore:#404040", L"" }, - { SCE_YAML_ERROR, 63359, L"Error", L"fore:#FFFFFF; bold; italic; back:#FF0000; eolfilled", L"" }, - { SCE_YAML_OPERATOR, 63132, L"Operator", L"fore:#333366", L"" }, - { -1, 00000, L"", L"", L"" } } }; - -KEYWORDLIST KeyWords_VHDL = { -"access after alias all architecture array assert attribute begin block body buffer bus case component configuration " -"constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in " -"inertial inout is label library linkage literal loop map new next null of on open others out package port postponed " -"procedure process pure range record register reject report return select severity shared signal subtype then " -"to transport type unaffected units until use variable wait when while with", -"abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor", -"left right low high ascending image value pos val succ pred leftof rightof base range reverse_range length delayed stable " -"quiet transaction event active last_event last_active last_value driving driving_value simple_name path_name instance_name", -"now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector to_stdulogicvector " -"to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left rotate_right resize to_integer " -"to_unsigned to_signed std_match to_01", -"std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed std_logic_textio std_logic_unsigned " -"numeric_bit numeric_std math_complex math_real vital_primitives vital_timing", -"boolean bit character severity_level integer real time delay_length natural positive string bit_vector file_open_kind " -"file_open_status line text side width std_ulogic std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed", -"", "", "" }; - -EDITLEXER lexVHDL = { SCLEX_VHDL, 63370, L"VHDL", L"vhdl; vhd", L"", &KeyWords_VHDL, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_VHDL_COMMENTLINEBANG, SCE_VHDL_COMMENT, SCE_VHDL_BLOCK_COMMENT, 0), 63127, L"Comment", L"fore:#008800", L"" }, - { SCE_VHDL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - { MULTI_STYLE(SCE_VHDL_STRING, SCE_VHDL_STRINGEOL, 0, 0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_VHDL_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { SCE_VHDL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, - { SCE_VHDL_KEYWORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, - { SCE_VHDL_STDOPERATOR, 63371, L"Standard operator", L"bold; fore:#0A246A", L"" }, - { SCE_VHDL_ATTRIBUTE, 63372, L"Attribute", L"", L"" }, - { SCE_VHDL_STDFUNCTION, 63373, L"Standard function", L"", L"" }, - { SCE_VHDL_STDPACKAGE, 63374, L"Standard package", L"", L"" }, - { SCE_VHDL_STDTYPE, 63375, L"Standard type", L"fore:#FF8000", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -KEYWORDLIST KeyWords_COFFEESCRIPT = { -"", "", "", "", "", "", "", "", "" }; - - -EDITLEXER lexCOFFEESCRIPT = { SCLEX_COFFEESCRIPT, 63362, L"Coffeescript", L"coffee; Cakefile", L"", &KeyWords_COFFEESCRIPT, { - { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, - //{ SCE_COFFEESCRIPT_DEFAULT, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_COMMENT,SCE_COFFEESCRIPT_COMMENTLINE,SCE_COFFEESCRIPT_COMMENTDOC,SCE_COFFEESCRIPT_COMMENTBLOCK), 63127, L"Comment", L"fore:#646464", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_STRING,SCE_COFFEESCRIPT_STRINGEOL,SCE_COFFEESCRIPT_STRINGRAW,0), 63131, L"String", L"fore:#008000", L"" }, - { SCE_COFFEESCRIPT_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, - { SCE_COFFEESCRIPT_IDENTIFIER, 63129, L"Identifier", L"bold; fore:#0A246A", L"" }, - { SCE_COFFEESCRIPT_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, - { SCE_COFFEESCRIPT_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, - //{ SCE_COFFEESCRIPT_CHARACTER, 63376, L"Character", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT,0), 63315, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_COFFEESCRIPT_GLOBALCLASS, 63378, L"Global Class", L"", L"" }, - //{ MULTI_STYLE(SCE_COFFEESCRIPT_COMMENTLINEDOC,SCE_COFFEESCRIPT_COMMENTDOCKEYWORD,SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR,0), 63379, L"Comment line", L"fore:#646464", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_WORD,SCE_COFFEESCRIPT_WORD2,0,0), 63380, L"Word", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_VERBATIM,SCE_COFFEESCRIPT_TRIPLEVERBATIM,0,0), 63381, L"Verbatim", L"", L"" }, - { -1, 00000, L"", L"", L"" } } }; - - -// This array holds all the lexers... -// Don't forget to change the number of the lexer for HTML and XML -// in Notepad2.c ParseCommandLine() if you change this array! -PEDITLEXER pLexArray[NUMLEXERS] = -{ - &lexDefault, - &lexANSI, - &lexAVS, - &lexCONF, //Apache Config Scripts - &lexASM, - &lexAHK, - &lexAU3, - &lexBAT, - &lexCOFFEESCRIPT, - &lexINI, - &lexCPP, - &lexCS, - &lexCmake, - &lexCSS, - &lexDIFF, - &lexINNO, - &lexJAVA, - &lexJS, - &lexMAK, - &lexMARKDOWN, - &lexLATEX, - &lexLUA, - &lexNSIS, - &lexPAS, - &lexPL, - &lexPS, - &lexPY, - &lexRC, - &lexRUBY, - &lexBASH, - &lexSQL, - &lexTCL, - &lexVBS, - &lexVB, - &lexHTML, - &lexXML, - &lexYAML, - &lexVHDL -}; - - -// Currently used lexer -PEDITLEXER pLexCurrent = &lexDefault; -COLORREF crCustom[16]; -BOOL bUse2ndDefaultStyle; -BOOL fStylesModified = FALSE; -BOOL fWarnedNoIniFile = FALSE; -BOOL fIsConsolasAvailable = FALSE; -int iBaseFontSize = 10; -int iDefaultLexer; -BOOL bAutoSelect; -int cxStyleSelectDlg; -int cyStyleSelectDlg; -extern int iDefaultCodePage; -extern int iDefaultCharSet; -extern BOOL bHiliteCurrentLine; - - -//============================================================================= -// -// Style_Load() -// -void Style_Load() -{ - int i,iLexer; - WCHAR tch[32]; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - // Custom colors - crCustom [0] = RGB(0x00,0x00,0x00); - crCustom [1] = RGB(0x0A,0x24,0x6A); - crCustom [2] = RGB(0x3A,0x6E,0xA5); - crCustom [3] = RGB(0x00,0x3C,0xE6); - crCustom [4] = RGB(0x00,0x66,0x33); - crCustom [5] = RGB(0x60,0x80,0x20); - crCustom [6] = RGB(0x64,0x80,0x00); - crCustom [7] = RGB(0xA4,0x60,0x00); - crCustom [8] = RGB(0xFF,0xFF,0xFF); - crCustom [9] = RGB(0xFF,0xFF,0xE2); - crCustom[10] = RGB(0xFF,0xF1,0xA8); - crCustom[11] = RGB(0xFF,0xC0,0x00); - crCustom[12] = RGB(0xFF,0x40,0x00); - crCustom[13] = RGB(0xC8,0x00,0x00); - crCustom[14] = RGB(0xB0,0x00,0xB0); - crCustom[15] = RGB(0xB2,0x8B,0x40); - - LoadIniSection(L"Custom Colors",pIniSection,cchIniSection); - for (i = 0; i < 16; i++) { - int itok; - int irgb; - WCHAR wch[32]; - wsprintf(tch,L"%02i",i+1); - if (IniSectionGetString(pIniSection,tch,L"",wch,COUNTOF(wch))) { - if (wch[0] == L'#') { - itok = swscanf(CharNext(wch),L"%x",&irgb); - if (itok == 1) - crCustom[i] = RGB((irgb&0xFF0000) >> 16,(irgb&0xFF00) >> 8,irgb&0xFF); - } - } - } - - LoadIniSection(L"Styles",pIniSection,cchIniSection); - // 2nd default - bUse2ndDefaultStyle = (IniSectionGetInt(pIniSection,L"Use2ndDefaultStyle",0)) ? 1 : 0; - - // default scheme - iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0); - iDefaultLexer = min(max(iDefaultLexer,0),NUMLEXERS-1); - - // auto select - bAutoSelect = (IniSectionGetInt(pIniSection,L"AutoSelect",1)) ? 1 : 0; - - // scheme select dlg dimensions - cxStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeX",304); - cxStyleSelectDlg = max(cxStyleSelectDlg,0); - - cyStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeY",0); - cyStyleSelectDlg = max(cyStyleSelectDlg,324); - - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - LoadIniSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection); - if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, - pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) - lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt, - COUNTOF(pLexArray[iLexer]->szExtensions)); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName, - pLexArray[iLexer]->Styles[i].pszDefault, - pLexArray[iLexer]->Styles[i].szValue, - COUNTOF(pLexArray[iLexer]->Styles[i].szValue)); - i++; - } - } - LocalFree(pIniSection); -} - - -//============================================================================= -// -// Style_Save() -// -void Style_Save() -{ - int i,iLexer; - WCHAR tch[32]; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - // Custom colors - for (i = 0; i < 16; i++) { - WCHAR wch[32]; - wsprintf(tch,L"%02i",i+1); - wsprintf(wch,L"#%02X%02X%02X", - (int)GetRValue(crCustom[i]),(int)GetGValue(crCustom[i]),(int)GetBValue(crCustom[i])); - IniSectionSetString(pIniSection,tch,wch); - } - SaveIniSection(L"Custom Colors",pIniSection); - ZeroMemory(pIniSection,cchIniSection); - - // auto select - IniSectionSetInt(pIniSection,L"Use2ndDefaultStyle",bUse2ndDefaultStyle); - - // default scheme - IniSectionSetInt(pIniSection,L"DefaultScheme",iDefaultLexer); - - // auto select - IniSectionSetInt(pIniSection,L"AutoSelect",bAutoSelect); - - // scheme select dlg dimensions - IniSectionSetInt(pIniSection,L"SelectDlgSizeX",cxStyleSelectDlg); - IniSectionSetInt(pIniSection,L"SelectDlgSizeY",cyStyleSelectDlg); - - SaveIniSection(L"Styles",pIniSection); - - if (!fStylesModified) { - LocalFree(pIniSection); - return; - } - - ZeroMemory(pIniSection,cchIniSection); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,pLexArray[iLexer]->Styles[i].szValue); - i++; - } - SaveIniSection(pLexArray[iLexer]->pszName,pIniSection); - ZeroMemory(pIniSection,cchIniSection); - } - LocalFree(pIniSection); -} - - -//============================================================================= -// -// Style_Import() -// -BOOL Style_Import(HWND hwnd) -{ - WCHAR szFile[MAX_PATH * 2] = L""; - WCHAR szFilter[256]; - OPENFILENAME ofn; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter)); - PrepareFilterStr(szFilter); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile = szFile; - ofn.lpstrDefExt = L"ini"; - ofn.nMaxFile = COUNTOF(szFile); - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT - | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/; - - if (GetOpenFileName(&ofn)) { - - int i,iLexer; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - if (GetPrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection,szFile)) { - if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, - pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) - lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt, - COUNTOF(pLexArray[iLexer]->szExtensions)); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName, - pLexArray[iLexer]->Styles[i].pszDefault, - pLexArray[iLexer]->Styles[i].szValue, - COUNTOF(pLexArray[iLexer]->Styles[i].szValue)); - i++; - } - } - } - LocalFree(pIniSection); - return(TRUE); - } - return(FALSE); -} - -//============================================================================= -// -// Style_Export() -// -BOOL Style_Export(HWND hwnd) -{ - WCHAR szFile[MAX_PATH * 2] = L""; - WCHAR szFilter[256]; - OPENFILENAME ofn; - DWORD dwError = ERROR_SUCCESS; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter)); - PrepareFilterStr(szFilter); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile = szFile; - ofn.lpstrDefExt = L"ini"; - ofn.nMaxFile = COUNTOF(szFile); - ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT - | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/ | OFN_OVERWRITEPROMPT; - - if (GetSaveFileName(&ofn)) { - - int i,iLexer; - WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); - int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,pLexArray[iLexer]->Styles[i].szValue); - i++; - } - if (!WritePrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,szFile)) - dwError = GetLastError(); - ZeroMemory(pIniSection,cchIniSection); - } - LocalFree(pIniSection); - - if (dwError != ERROR_SUCCESS) { - MsgBox(MBINFO,IDS_EXPORT_FAIL,szFile); - } - return(TRUE); - } - return(FALSE); -} - - -//============================================================================= -// -// Style_SetLexer() -// -void Style_SetLexer(HWND hwnd,PEDITLEXER pLexNew) -{ - int i; - //WCHAR *p; - int rgb; - int iValue; - int iIdx; - int iStyleBits; - WCHAR wchCaretStyle[64] = L""; - - // Select default if NULL is specified - if (!pLexNew) - pLexNew = pLexArray[iDefaultLexer]; - - // Lexer - SendMessage(hwnd,SCI_SETLEXER,pLexNew->iLexer,0); - - iStyleBits = (int)SendMessage(hwnd,SCI_GETSTYLEBITSNEEDED,0,0); - SendMessage(hwnd,SCI_SETSTYLEBITS,(WPARAM)iStyleBits,0); - - if (pLexNew->iLexer == SCLEX_XML) - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.xml.allow.scripts",(LPARAM)"1"); - if (pLexNew->iLexer == SCLEX_CPP) { - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"styling.within.preprocessor",(LPARAM)"1"); - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.cpp.track.preprocessor",(LPARAM)"0"); - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.cpp.update.preprocessor",(LPARAM)"0"); - } - else if (pLexNew->iLexer == SCLEX_PASCAL) - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.pascal.smart.highlighting",(LPARAM)"1"); - else if (pLexNew->iLexer == SCLEX_SQL) { - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"sql.backslash.escapes",(LPARAM)"1"); - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.sql.backticks.identifier",(LPARAM)"1"); - SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.sql.numbersign.comment",(LPARAM)"1"); - } - else if (pLexNew->iLexer == SCLEX_NSIS) - SciCall_SetProperty("nsis.ignorecase", "1"); - - // Code folding - SciCall_SetProperty("fold", "1"); - SciCall_SetProperty("fold.compact", "0"); - SciCall_SetProperty("fold.comment", "1"); - SciCall_SetProperty("fold.html", "1"); - SciCall_SetProperty("fold.preprocessor", "1"); - SciCall_SetProperty("fold.cpp.comment.explicit", "0"); - - // Add KeyWord Lists - for (i = 0; i < 9; i++) - SendMessage(hwnd,SCI_SETKEYWORDS,i,(LPARAM)pLexNew->pKeyWords->pszKeyWords[i]); - - // Use 2nd default style - iIdx = (bUse2ndDefaultStyle) ? 12 : 0; - - // Font quality setup, check availability of Consolas - Style_SetFontQuality(hwnd,lexDefault.Styles[0+iIdx].szValue); - fIsConsolasAvailable = IsFontAvailable(L"Consolas"); - - // Clear - SendMessage(hwnd,SCI_CLEARDOCUMENTSTYLE,0,0); - - // Default Values are always set - SendMessage(hwnd,SCI_STYLERESETDEFAULT,0,0); - SendMessage(hwnd,SCI_STYLESETCHARACTERSET,STYLE_DEFAULT,(LPARAM)DEFAULT_CHARSET); - iBaseFontSize = 10; - Style_SetStyles(hwnd,lexDefault.Styles[0+iIdx].iStyle,lexDefault.Styles[0+iIdx].szValue); // default - Style_StrGetSize(lexDefault.Styles[0+iIdx].szValue,&iBaseFontSize); // base size - - // Auto-select codepage according to charset - //Style_SetACPfromCharSet(hwnd); - - if (!Style_StrGetColor(TRUE,lexDefault.Styles[0+iIdx].szValue,&iValue)) - SendMessage(hwnd,SCI_STYLESETFORE,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color - if (!Style_StrGetColor(FALSE,lexDefault.Styles[0+iIdx].szValue,&iValue)) - SendMessage(hwnd,SCI_STYLESETBACK,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOW)); // default window color - - if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) - Style_SetStyles(hwnd,pLexNew->Styles[0].iStyle,pLexNew->Styles[0].szValue); // lexer default - SendMessage(hwnd,SCI_STYLECLEARALL,0,0); - - Style_SetStyles(hwnd,lexDefault.Styles[1+iIdx].iStyle,lexDefault.Styles[1+iIdx].szValue); // linenumber - Style_SetStyles(hwnd,lexDefault.Styles[2+iIdx].iStyle,lexDefault.Styles[2+iIdx].szValue); // brace light - Style_SetStyles(hwnd,lexDefault.Styles[3+iIdx].iStyle,lexDefault.Styles[3+iIdx].szValue); // brace bad - if (pLexNew != &lexANSI) - Style_SetStyles(hwnd,lexDefault.Styles[4+iIdx].iStyle,lexDefault.Styles[4+iIdx].szValue); // control char - Style_SetStyles(hwnd,lexDefault.Styles[5+iIdx].iStyle,lexDefault.Styles[5+iIdx].szValue); // indent guide - - // More default values... - if (Style_StrGetColor(TRUE,lexDefault.Styles[6+iIdx].szValue,&rgb)) { // selection fore - SendMessage(hwnd,SCI_SETSELFORE,TRUE,rgb); - SendMessage(hwnd,SCI_SETADDITIONALSELFORE,rgb,0); - } - else { - SendMessage(hwnd,SCI_SETSELFORE,0,0); - SendMessage(hwnd,SCI_SETADDITIONALSELFORE,0,0); - } - - if (Style_StrGetColor(FALSE,lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection back - SendMessage(hwnd,SCI_SETSELBACK,TRUE,iValue); - SendMessage(hwnd,SCI_SETADDITIONALSELBACK,iValue,0); - } - else { - SendMessage(hwnd,SCI_SETSELBACK,TRUE,RGB(0xC0,0xC0,0xC0)); // use a default value... - SendMessage(hwnd,SCI_SETADDITIONALSELBACK,RGB(0xC0,0xC0,0xC0),0); - } - - if (Style_StrGetAlpha(lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection alpha - SendMessage(hwnd,SCI_SETSELALPHA,iValue,0); - SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,iValue,0); - } - else { - SendMessage(hwnd,SCI_SETSELALPHA,SC_ALPHA_NOALPHA,0); - SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,SC_ALPHA_NOALPHA,0); - } - - if (StrStrI(lexDefault.Styles[6+iIdx].szValue,L"eolfilled")) // selection eolfilled - SendMessage(hwnd,SCI_SETSELEOLFILLED,1,0); - else - SendMessage(hwnd,SCI_SETSELEOLFILLED,0,0); - - if (Style_StrGetColor(TRUE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace fore - SendMessage(hwnd,SCI_SETWHITESPACEFORE,TRUE,rgb); - else - SendMessage(hwnd,SCI_SETWHITESPACEFORE,0,0); - - if (Style_StrGetColor(FALSE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace back - SendMessage(hwnd,SCI_SETWHITESPACEBACK,TRUE,rgb); - else - SendMessage(hwnd,SCI_SETWHITESPACEBACK,0,0); // use a default value... - - // whitespace dot size - iValue = 1; - if (Style_StrGetSize(lexDefault.Styles[7+iIdx].szValue,&iValue)) { - - WCHAR tch[32]; - WCHAR wchStyle[COUNTOF(lexDefault.Styles[0].szValue)]; - lstrcpyn(wchStyle,lexDefault.Styles[7+iIdx].szValue,COUNTOF(lexDefault.Styles[0].szValue)); - - iValue = max(min(iValue,5),0); - wsprintf(lexDefault.Styles[7+iIdx].szValue,L"size:%i",iValue); - - if (Style_StrGetColor(TRUE,wchStyle,&rgb)) { - wsprintf(tch,L"; fore:#%02X%02X%02X", - (int)GetRValue(rgb), - (int)GetGValue(rgb), - (int)GetBValue(rgb)); - lstrcat(lexDefault.Styles[7+iIdx].szValue,tch); - } - - if (Style_StrGetColor(FALSE,wchStyle,&rgb)) { - wsprintf(tch,L"; back:#%02X%02X%02X", - (int)GetRValue(rgb), - (int)GetGValue(rgb), - (int)GetBValue(rgb)); - lstrcat(lexDefault.Styles[7+iIdx].szValue,tch); - } - } - SendMessage(hwnd,SCI_SETWHITESPACESIZE,iValue,0); - - if (bHiliteCurrentLine) { - - if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back - { - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0); - SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0); - - if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue)) - SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0); - else - SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0); - } - else - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); - } - else - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); - - // caret style and width - if (StrStr(lexDefault.Styles[9+iIdx].szValue,L"block")) { - SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_BLOCK,0); - lstrcpy(wchCaretStyle,L"block"); - } - else { - WCHAR wch[32]; - iValue = 1; - if (Style_StrGetSize(lexDefault.Styles[9+iIdx].szValue,&iValue)) { - iValue = max(min(iValue,3),1); - wsprintf(wch,L"size:%i",iValue); - lstrcat(wchCaretStyle,wch); - } - SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_LINE,0); - SendMessage(hwnd,SCI_SETCARETWIDTH,iValue,0); - } - if (StrStr(lexDefault.Styles[9+iIdx].szValue,L"noblink")) { - SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)0,0); - if (lstrlen(wchCaretStyle)) - lstrcat(wchCaretStyle,L"; "); - lstrcat(wchCaretStyle,L"noblink"); - } - else - SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)GetCaretBlinkTime(),0); - - // caret fore - if (!Style_StrGetColor(TRUE,lexDefault.Styles[9+iIdx].szValue,&rgb)) - rgb = GetSysColor(COLOR_WINDOWTEXT); - else { - WCHAR wch[32]; - wsprintf(wch,L"fore:#%02X%02X%02X", - (int)GetRValue(rgb), - (int)GetGValue(rgb), - (int)GetBValue(rgb)); - if (lstrlen(wchCaretStyle)) - lstrcat(wchCaretStyle,L"; "); - lstrcat(wchCaretStyle,wch); - } - if (!VerifyContrast(rgb,(COLORREF)SendMessage(hwnd,SCI_STYLEGETBACK,0,0))) - rgb = (int)SendMessage(hwnd,SCI_STYLEGETFORE,0,0); - SendMessage(hwnd,SCI_SETCARETFORE,rgb,0); - SendMessage(hwnd,SCI_SETADDITIONALCARETFORE,rgb,0); - lstrcpy(lexDefault.Styles[9+iIdx].szValue,wchCaretStyle); - - if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) { - if (Style_StrGetColor(TRUE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge fore - SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); - else - SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); - } - else { - if (Style_StrGetColor(FALSE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge back - SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); - else - SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); - } - - // Extra Line Spacing - if (Style_StrGetSize(lexDefault.Styles[11+iIdx].szValue,&iValue) && pLexNew != &lexANSI) { - int iAscent = 0; - int iDescent = 0; - iValue = min(max(iValue,0),64); - wsprintf(lexDefault.Styles[11+iIdx].szValue,L"size:%i",iValue); - if (iValue % 2) { - iAscent++; - iValue--; - } - iAscent += iValue / 2; - iDescent += iValue / 2; - SendMessage(hwnd,SCI_SETEXTRAASCENT,(WPARAM)iAscent,0); - SendMessage(hwnd,SCI_SETEXTRADESCENT,(WPARAM)iDescent,0); - } - else { - SendMessage(hwnd,SCI_SETEXTRAASCENT,0,0); - SendMessage(hwnd,SCI_SETEXTRADESCENT,0,0); - //wsprintf(lexDefault.Styles[11+iIdx].szValue,L"size:0"); - } - - { // set folding style; braces are for scoping only - static const int iMarkerIDs[] = - { - SC_MARKNUM_FOLDEROPEN, - SC_MARKNUM_FOLDER, - SC_MARKNUM_FOLDERSUB, - SC_MARKNUM_FOLDERTAIL, - SC_MARKNUM_FOLDEREND, - SC_MARKNUM_FOLDEROPENMID, - SC_MARKNUM_FOLDERMIDTAIL - }; - - int i; - - COLORREF clrFore = SciCall_StyleGetFore(STYLE_DEFAULT); - COLORREF clrBack = SciCall_StyleGetBack(STYLE_DEFAULT); - - SciCall_SetFoldMarginColour(TRUE, clrBack); - SciCall_SetFoldMarginHiColour(TRUE, clrBack); - - // Set marker color to the average of clrFore and clrBack - clrFore = (((clrFore & 0xFF0000) + (clrBack & 0xFF0000)) >> 1 & 0xFF0000) | - (((clrFore & 0x00FF00) + (clrBack & 0x00FF00)) >> 1 & 0x00FF00) | - (((clrFore & 0x0000FF) + (clrBack & 0x0000FF)) >> 1 & 0x0000FF); - - // Rounding hack for pure white against pure black - if (clrFore == 0x7F7F7F) clrFore = 0x808080; - - for (i = 0; i < COUNTOF(iMarkerIDs); ++i) - { - SciCall_MarkerSetBack(iMarkerIDs[i], clrFore); - SciCall_MarkerSetFore(iMarkerIDs[i], clrBack); - } - } // end set folding style - - if (SendMessage(hwnd,SCI_GETINDENTATIONGUIDES,0,0) != SC_IV_NONE) - Style_SetIndentGuides(hwnd,TRUE); - - if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) - { - int j; - i = 1; - while (pLexNew->Styles[i].iStyle != -1) { - - for (j = 0; j < 4 && (pLexNew->Styles[i].iStyle8[j] != 0 || j == 0); ++j) - Style_SetStyles(hwnd,pLexNew->Styles[i].iStyle8[j],pLexNew->Styles[i].szValue); - - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { - int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, - SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { - int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, SCE_HJ_DOUBLESTRING, - SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, SCE_HJ_SYMBOLS }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { - int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, - SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { - int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { - int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { - int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING, SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR, - SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY, SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { - int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, - SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, - SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, - SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, - SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, - SCE_HPA_IDENTIFIER }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_XML && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { - int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION, - SCE_HPHP_DEFAULT, SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, - SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, - SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE, SCE_HJ_START, SCE_HJ_DEFAULT, - SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, - SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, - SCE_HJ_SYMBOLS, SCE_HJA_START, SCE_HJA_DEFAULT, SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, - SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, - SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS, SCE_HB_START, SCE_HB_DEFAULT, - SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, - SCE_HB_NUMBER, SCE_HBA_START, SCE_HBA_DEFAULT, SCE_HBA_COMMENTLINE, SCE_HBA_WORD, - SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER, SCE_HP_START, - SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD, - SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR, - SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, - SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, - SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew->iLexer == SCLEX_CPP && pLexNew->Styles[i].iStyle8[0] == SCE_C_COMMENT) { - int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - - if (pLexNew -> iLexer == SCLEX_SQL && pLexNew->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { - int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR }; - for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); - } - i++; - } - } - - SendMessage(hwnd,SCI_COLOURISE,0,(LPARAM)-1); - - // Save current lexer - pLexCurrent = pLexNew; -} - - -//============================================================================= -// -// Style_SetLongLineColors() -// -void Style_SetLongLineColors(HWND hwnd) -{ - int rgb; - - // Use 2nd default style - int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; - - if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) { - if (Style_StrGetColor(TRUE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge fore - SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); - else - SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); - } - else { - if (Style_StrGetColor(FALSE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge back - SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); - else - SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); - } -} - - -//============================================================================= -// -// Style_SetCurrentLineBackground() -// -void Style_SetCurrentLineBackground(HWND hwnd) -{ - int rgb, iValue; - - // Use 2nd default style - int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; - - if (bHiliteCurrentLine) { - - if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back - { - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0); - SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0); - - if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue)) - SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0); - else - SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0); - } - else - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); - } - else - SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); -} - - -//============================================================================= -// -// Style_SniffShebang() -// -PEDITLEXER __fastcall Style_SniffShebang(char *pchText) -{ - if (StrCmpNA(pchText,"#!",2) == 0) { - char *pch = pchText + 2; - while (*pch == ' ' || *pch == '\t') - pch++; - while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') - pch++; - if ((pch - pchText) >= 3 && StrCmpNA(pch-3,"env",3) == 0) { - while (*pch == ' ') - pch++; - while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') - pch++; - } - if ((pch - pchText) >= 3 && StrCmpNIA(pch-3,"php",3) == 0) - return(&lexHTML); - else if ((pch - pchText) >= 4 && StrCmpNIA(pch-4,"perl",4) == 0) - return(&lexPL); - else if ((pch - pchText) >= 6 && StrCmpNIA(pch-6,"python",6) == 0) - return(&lexPY); - else if ((pch - pchText) >= 3 && StrCmpNA(pch-3,"tcl",3) == 0) - return(&lexTCL); - else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"wish",4) == 0) - return(&lexTCL); - else if ((pch - pchText) >= 5 && StrCmpNA(pch-5,"tclsh",5) == 0) - return(&lexTCL); - else if ((pch - pchText) >= 2 && StrCmpNA(pch-2,"sh",2) == 0) - return(&lexBASH); - else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"ruby",4) == 0) - return(&lexRUBY); - else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"node",4) == 0) - return(&lexJS); - } - - return(NULL); -} - - -//============================================================================= -// -// Style_MatchLexer() -// -PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames) -{ - int i; - WCHAR tch[256+16]; - WCHAR *p1,*p2; - - if (!bCheckNames) { - - for (i = 0; i < NUMLEXERS; i++) { - - ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch)); - lstrcpy(tch,pLexArray[i]->szExtensions); - p1 = tch; - while (*p1) { - if (p2 = StrChr(p1,L';')) - *p2 = L'\0'; - else - p2 = StrEnd(p1); - StrTrim(p1,L" ."); - if (lstrcmpi(p1,lpszMatch) == 0) - return(pLexArray[i]); - p1 = p2+1; - } - } - } - - else { - - int cch = lstrlen(lpszMatch); - if (cch >= 3) { - - for (i = 0; i < NUMLEXERS; i++) { - if (StrCmpNI(pLexArray[i]->pszName,lpszMatch,cch) == 0) - return(pLexArray[i]); - } - } - } - return(NULL); -} - - -//============================================================================= -// -// Style_SetLexerFromFile() -// -extern int fNoHTMLGuess; -extern int fNoCGIGuess; -extern FILEVARS fvCurFile; - -void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) -{ - LPWSTR lpszExt = PathFindExtension(lpszFile); - BOOL bFound = FALSE; - PEDITLEXER pLexNew = pLexArray[iDefaultLexer]; - PEDITLEXER pLexSniffed; - - if ((fvCurFile.mask & FV_MODE) && fvCurFile.tchMode[0]) { - - WCHAR wchMode[32]; - PEDITLEXER pLexMode; - UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); - MultiByteToWideChar(cp,0,fvCurFile.tchMode,-1,wchMode,COUNTOF(wchMode)); - - if (!fNoCGIGuess && (lstrcmpi(wchMode,L"cgi") == 0 || lstrcmpi(wchMode,L"fcgi") == 0)) { - char tchText[256]; - SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); - StrTrimA(tchText," \t\n\r"); - if (pLexSniffed = Style_SniffShebang(tchText)) { - if (iEncoding != g_DOSEncoding || pLexSniffed != &lexDefault || ( - lstrcmpi(lpszExt,L"nfo") && lstrcmpi(lpszExt,L"diz"))) { - // Although .nfo and .diz were removed from the default lexer's - // default extensions list, they may still presist in the user's INI - pLexNew = pLexSniffed; - bFound = TRUE; - } - } - } - - if (!bFound) { - if (pLexMode = Style_MatchLexer(wchMode,FALSE)) { - pLexNew = pLexMode; - bFound = TRUE; - } - else if (pLexMode = Style_MatchLexer(wchMode,TRUE)) { - pLexNew = pLexMode; - bFound = TRUE; - } - } - } - - if (!bFound && bAutoSelect && /* bAutoSelect == FALSE skips lexer search */ - (lpszFile && lstrlen(lpszFile) > 0 && *lpszExt)) { - - if (*lpszExt == L'.') - lpszExt++; - - if (!fNoCGIGuess && (lstrcmpi(lpszExt,L"cgi") == 0 || lstrcmpi(lpszExt,L"fcgi") == 0)) { - char tchText[256]; - SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); - StrTrimA(tchText," \t\n\r"); - if (pLexSniffed = Style_SniffShebang(tchText)) { - pLexNew = pLexSniffed; - bFound = TRUE; - } - } - - if (!bFound && lstrcmpi(PathFindFileName(lpszFile),L"cmakelists.txt") == 0) { - pLexNew = &lexCmake; - bFound = TRUE; - } - - // check associated extensions - if (!bFound) { - if (pLexSniffed = Style_MatchLexer(lpszExt,FALSE)) { - pLexNew = pLexSniffed; - bFound = TRUE; - } - } - } - - if (!bFound && bAutoSelect && - lstrcmpi(PathFindFileName(lpszFile),L"makefile") == 0) { - pLexNew = &lexMAK; - bFound = TRUE; - } - - if (!bFound && bAutoSelect && - lstrcmpi(PathFindFileName(lpszFile),L"rakefile") == 0) { - pLexNew = &lexRUBY; - bFound = TRUE; - } - - if (!bFound && bAutoSelect && - lstrcmpi(PathFindFileName(lpszFile),L"mozconfig") == 0) { - pLexNew = &lexBASH; - bFound = TRUE; - } - - if (!bFound && bAutoSelect && (!fNoHTMLGuess || !fNoCGIGuess)) { - char tchText[512]; - SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); - StrTrimA(tchText," \t\n\r"); - if (!fNoHTMLGuess && tchText[0] == '<') { - if (StrStrIA(tchText,"= 0 && id < NUMLEXERS) { - Style_SetLexer(hwnd,pLexArray[id]); - } -} - - -//============================================================================= -// -// Style_ToggleUse2ndDefault() -// -void Style_ToggleUse2ndDefault(HWND hwnd) -{ - bUse2ndDefaultStyle = (bUse2ndDefaultStyle) ? 0 : 1; - Style_SetLexer(hwnd,pLexCurrent); -} - - -//============================================================================= -// -// Style_SetDefaultFont() -// -void Style_SetDefaultFont(HWND hwnd) -{ - int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; - if (Style_SelectFont(hwnd, - lexDefault.Styles[0+iIdx].szValue, - COUNTOF(lexDefault.Styles[0].szValue), - TRUE)) { - fStylesModified = TRUE; - Style_SetLexer(hwnd,pLexCurrent); - } -} - - -//============================================================================= -// -// Style_GetUse2ndDefault() -// -BOOL Style_GetUse2ndDefault(HWND hwnd) -{ - return (bUse2ndDefaultStyle); -} - - -//============================================================================= -// -// Style_SetIndentGuides() -// -extern int flagSimpleIndentGuides; - -void Style_SetIndentGuides(HWND hwnd,BOOL bShow) -{ - int iIndentView = SC_IV_NONE; - if (bShow) { - if (!flagSimpleIndentGuides) { - if (SendMessage(hwnd,SCI_GETLEXER,0,0) == SCLEX_PYTHON) - iIndentView = SC_IV_LOOKFORWARD; - else - iIndentView = SC_IV_LOOKBOTH; - } - else - iIndentView = SC_IV_REAL; - } - SendMessage(hwnd,SCI_SETINDENTATIONGUIDES,iIndentView,0); -} - - -//============================================================================= -// -// Style_GetFileOpenDlgFilter() -// -extern WCHAR tchFileDlgFilters[5*1024]; - -BOOL Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter) -{ - if (lstrlen(tchFileDlgFilters) == 0) - GetString(IDS_FILTER_ALL,lpszFilter,cchFilter); - else { - lstrcpyn(lpszFilter,tchFileDlgFilters,cchFilter-2); - lstrcat(lpszFilter,L"||"); - } - PrepareFilterStr(lpszFilter); - return TRUE; -} - - -//============================================================================= -// -// Style_StrGetFont() -// -BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont) -{ - WCHAR tch[256]; - WCHAR *p; - - if (p = StrStrI(lpszStyle,L"font:")) - { - lstrcpy(tch,p + CSTRLEN(L"font:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - - if (lstrcmpi(tch,L"Default") == 0) - { - if (fIsConsolasAvailable) - lstrcpyn(lpszFont,L"Consolas",cchFont); - else - lstrcpyn(lpszFont,L"Lucida Console",cchFont); - } - else - { - lstrcpyn(lpszFont,tch,cchFont); - } - - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetFontQuality() -// -BOOL Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality) -{ - WCHAR tch[256]; - WCHAR *p; - - if (p = StrStrI(lpszStyle,L"smoothing:")) - { - lstrcpy(tch,p + CSTRLEN(L"smoothing:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - if (lstrcmpi(tch,L"none") == 0 || - lstrcmpi(tch,L"standard") == 0 || - lstrcmpi(tch,L"cleartype") == 0 || - lstrcmpi(tch,L"default") == 0) { - lstrcpyn(lpszQuality,tch,cchQuality); - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetCharSet() -// -BOOL Style_StrGetCharSet(LPCWSTR lpszStyle,int *i) -{ - WCHAR tch[256]; - WCHAR *p; - int iValue; - int itok; - - if (p = StrStrI(lpszStyle,L"charset:")) - { - lstrcpy(tch,p + CSTRLEN(L"charset:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - itok = swscanf(tch,L"%i",&iValue); - if (itok == 1) - { - *i = iValue; - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetSize() -// -BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i) -{ - WCHAR tch[256]; - WCHAR *p; - int iValue; - int iSign = 0; - int itok; - - if (p = StrStrI(lpszStyle,L"size:")) - { - lstrcpy(tch,p + CSTRLEN(L"size:")); - if (tch[0] == L'+') - { - iSign = 1; - tch[0] = L' '; - } - else if (tch[0] == L'-') - { - iSign = -1; - tch[0] = L' '; - } - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - itok = swscanf(tch,L"%i",&iValue); - if (itok == 1) - { - if (iSign == 0) - *i = iValue; - else - *i = max(0,iBaseFontSize + iValue * iSign); // size must be + - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetSizeStr() -// -BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize) -{ - WCHAR tch[256]; - WCHAR *p; - - if (p = StrStrI(lpszStyle,L"size:")) - { - lstrcpy(tch,p + CSTRLEN(L"size:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - lstrcpyn(lpszSize,tch,cchSize); - return TRUE; - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetColor() -// -BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb) -{ - WCHAR tch[256]; - WCHAR *p; - int iValue; - int itok; - WCHAR *pItem = (bFore) ? L"fore:" : L"back:"; - - if (p = StrStrI(lpszStyle,pItem)) - { - lstrcpy(tch,p + lstrlen(pItem)); - if (tch[0] == L'#') - tch[0] = L' '; - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - itok = swscanf(tch,L"%x",&iValue); - if (itok == 1) - { - *rgb = RGB((iValue&0xFF0000) >> 16,(iValue&0xFF00) >> 8,iValue&0xFF); - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetCase() -// -BOOL Style_StrGetCase(LPCWSTR lpszStyle,int *i) -{ - WCHAR tch[256]; - WCHAR *p; - - if (p = StrStrI(lpszStyle,L"case:")) - { - lstrcpy(tch,p + CSTRLEN(L"case:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - if (tch[0] == L'u' || tch[0] == L'U') { - *i = SC_CASE_UPPER; - return TRUE; - } - else if (tch[0] == L'l' || tch[0] == L'L') { - *i = SC_CASE_LOWER; - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_StrGetAlpha() -// -BOOL Style_StrGetAlpha(LPCWSTR lpszStyle,int *i) -{ - WCHAR tch[256]; - WCHAR *p; - int iValue; - int itok; - - if (p = StrStrI(lpszStyle,L"alpha:")) - { - lstrcpy(tch,p + CSTRLEN(L"alpha:")); - if (p = StrChr(tch,L';')) - *p = L'\0'; - TrimString(tch); - itok = swscanf(tch,L"%i",&iValue); - if (itok == 1) - { - *i = min(max(SC_ALPHA_TRANSPARENT,iValue),SC_ALPHA_OPAQUE); - return TRUE; - } - } - return FALSE; -} - - -//============================================================================= -// -// Style_SelectFont() -// -BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle) -{ - CHOOSEFONT cf; - LOGFONT lf; - WCHAR szNewStyle[512]; - int iValue; - WCHAR tch[32]; - HDC hdc; - - ZeroMemory(&cf,sizeof(CHOOSEFONT)); - ZeroMemory(&lf,sizeof(LOGFONT)); - - // Map lpszStyle to LOGFONT - if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) - lstrcpyn(lf.lfFaceName,tch,COUNTOF(lf.lfFaceName)); - if (Style_StrGetCharSet(lpszStyle,&iValue)) - lf.lfCharSet = iValue; - if (Style_StrGetSize(lpszStyle,&iValue)) { - hdc = GetDC(hwnd); - lf.lfHeight = -MulDiv(iValue,GetDeviceCaps(hdc,LOGPIXELSY),72); - ReleaseDC(hwnd,hdc); - } - lf.lfWeight = (StrStrI(lpszStyle,L"bold")) ? FW_BOLD : FW_NORMAL; - lf.lfItalic = (StrStrI(lpszStyle,L"italic")) ? 1 : 0; - - // Init cf - cf.lStructSize = sizeof(CHOOSEFONT); - cf.hwndOwner = hwnd; - cf.lpLogFont = &lf; - cf.Flags = CF_INITTOLOGFONTSTRUCT /*| CF_NOSCRIPTSEL*/ | CF_SCREENFONTS; - - if (HIBYTE(GetKeyState(VK_SHIFT))) - cf.Flags |= CF_FIXEDPITCHONLY; - - if (!ChooseFont(&cf) || !lstrlen(lf.lfFaceName)) - return FALSE; - - // Map back to lpszStyle - lstrcpy(szNewStyle,L"font:"); - lstrcat(szNewStyle,lf.lfFaceName); - if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) - { - lstrcat(szNewStyle,L"; smoothing:"); - lstrcat(szNewStyle,tch); - } - if (bDefaultStyle && - lf.lfCharSet != DEFAULT_CHARSET && - lf.lfCharSet != ANSI_CHARSET && - lf.lfCharSet != iDefaultCharSet) { - lstrcat(szNewStyle,L"; charset:"); - wsprintf(tch,L"%i",lf.lfCharSet); - lstrcat(szNewStyle,tch); - } - lstrcat(szNewStyle,L"; size:"); - wsprintf(tch,L"%i",cf.iPointSize/10); - lstrcat(szNewStyle,tch); - if (cf.nFontType & BOLD_FONTTYPE) - lstrcat(szNewStyle,L"; bold"); - if (cf.nFontType & ITALIC_FONTTYPE) - lstrcat(szNewStyle,L"; italic"); - - if (StrStrI(lpszStyle,L"underline")) - lstrcat(szNewStyle,L"; underline"); - - // save colors - if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) - { - wsprintf(tch,L"; fore:#%02X%02X%02X", - (int)GetRValue(iValue), - (int)GetGValue(iValue), - (int)GetBValue(iValue)); - lstrcat(szNewStyle,tch); - } - if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) - { - wsprintf(tch,L"; back:#%02X%02X%02X", - (int)GetRValue(iValue), - (int)GetGValue(iValue), - (int)GetBValue(iValue)); - lstrcat(szNewStyle,tch); - } - - if (StrStrI(lpszStyle,L"eolfilled")) - lstrcat(szNewStyle,L"; eolfilled"); - - if (Style_StrGetCase(lpszStyle,&iValue)) { - lstrcat(szNewStyle,L"; case:"); - lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L""); - } - - if (Style_StrGetAlpha(lpszStyle,&iValue)) { - lstrcat(szNewStyle,L"; alpha:"); - wsprintf(tch,L"%i",iValue); - lstrcat(szNewStyle,tch); - } - - lstrcpyn(lpszStyle,szNewStyle,cchStyle); - return TRUE; -} - - -//============================================================================= -// -// Style_SelectColor() -// -BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle) -{ - CHOOSECOLOR cc; - WCHAR szNewStyle[512]; - int iRGBResult; - int iValue; - WCHAR tch[32]; - - ZeroMemory(&cc,sizeof(CHOOSECOLOR)); - - iRGBResult = (bFore) ? GetSysColor(COLOR_WINDOWTEXT) : GetSysColor(COLOR_WINDOW); - Style_StrGetColor(bFore,lpszStyle,&iRGBResult); - - cc.lStructSize = sizeof(CHOOSECOLOR); - cc.hwndOwner = hwnd; - cc.rgbResult = iRGBResult; - cc.lpCustColors = crCustom; - cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR; - - if (!ChooseColor(&cc)) - return FALSE; - - iRGBResult = cc.rgbResult; - - // Rebuild style string - lstrcpy(szNewStyle,L""); - if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) - { - lstrcat(szNewStyle,L"font:"); - lstrcat(szNewStyle,tch); - } - if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - lstrcat(szNewStyle,L"smoothing:"); - lstrcat(szNewStyle,tch); - } - if (Style_StrGetCharSet(lpszStyle,&iValue)) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - wsprintf(tch,L"charset:%i",iValue); - lstrcat(szNewStyle,tch); - } - if (Style_StrGetSizeStr(lpszStyle,tch,COUNTOF(tch))) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - lstrcat(szNewStyle,L"size:"); - lstrcat(szNewStyle,tch); - } - - if (StrStrI(lpszStyle,L"bold")) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - lstrcat(szNewStyle,L"bold"); - } - if (StrStrI(lpszStyle,L"italic")) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - lstrcat(szNewStyle,L"italic"); - } - if (StrStrI(lpszStyle,L"underline")) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - lstrcat(szNewStyle,L"underline"); - } - - if (bFore) - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - wsprintf(tch,L"fore:#%02X%02X%02X", - (int)GetRValue(iRGBResult), - (int)GetGValue(iRGBResult), - (int)GetBValue(iRGBResult)); - lstrcat(szNewStyle,tch); - if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) - { - wsprintf(tch,L"; back:#%02X%02X%02X", - (int)GetRValue(iValue), - (int)GetGValue(iValue), - (int)GetBValue(iValue)); - lstrcat(szNewStyle,tch); - } - } - else - { - if (lstrlen(szNewStyle)) - lstrcat(szNewStyle,L"; "); - if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) - { - wsprintf(tch,L"fore:#%02X%02X%02X; ", - (int)GetRValue(iValue), - (int)GetGValue(iValue), - (int)GetBValue(iValue)); - lstrcat(szNewStyle,tch); - } - wsprintf(tch,L"back:#%02X%02X%02X", - (int)GetRValue(iRGBResult), - (int)GetGValue(iRGBResult), - (int)GetBValue(iRGBResult)); - lstrcat(szNewStyle,tch); - } - - if (StrStrI(lpszStyle,L"eolfilled")) - lstrcat(szNewStyle,L"; eolfilled"); - - if (Style_StrGetCase(lpszStyle,&iValue)) { - lstrcat(szNewStyle,L"; case:"); - lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L""); - } - - if (Style_StrGetAlpha(lpszStyle,&iValue)) { - lstrcat(szNewStyle,L"; alpha:"); - wsprintf(tch,L"%i",iValue); - lstrcat(szNewStyle,tch); - } - - if (StrStrI(lpszStyle,L"block")) - lstrcat(szNewStyle,L"; block"); - - if (StrStrI(lpszStyle,L"noblink")) - lstrcat(szNewStyle,L"; noblink"); - - lstrcpyn(lpszStyle,szNewStyle,cchStyle); - return TRUE; -} - - -//============================================================================= -// -// Style_SetStyles() -// -void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) -{ - - WCHAR tch[256]; - WCHAR *p; - int iValue; - - // Font - if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { - char mch[256]; - WideCharToMultiByte(CP_UTF8,0,tch,-1,mch,COUNTOF(mch),NULL,NULL); - SendMessage(hwnd,SCI_STYLESETFONT,iStyle,(LPARAM)mch); - } - - // Size - if (Style_StrGetSize(lpszStyle,&iValue)) - SendMessage(hwnd,SCI_STYLESETSIZE,iStyle,(LPARAM)iValue); - - // Fore - if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) - SendMessage(hwnd,SCI_STYLESETFORE,iStyle,(LPARAM)iValue); - - // Back - if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) - SendMessage(hwnd,SCI_STYLESETBACK,iStyle,(LPARAM)iValue); - - // Bold - if (p = StrStrI(lpszStyle,L"bold")) - SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)TRUE); - else - SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)FALSE); - - // Italic - if (p = StrStrI(lpszStyle,L"italic")) - SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)TRUE); - else - SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)FALSE); - - // Underline - if (p = StrStrI(lpszStyle,L"underline")) - SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)TRUE); - else - SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)FALSE); - - // EOL Filled - if (p = StrStrI(lpszStyle,L"eolfilled")) - SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)TRUE); - else - SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)FALSE); - - // Case - if (Style_StrGetCase(lpszStyle,&iValue)) - SendMessage(hwnd,SCI_STYLESETCASE,iStyle,(LPARAM)iValue); - - // Character Set - if (Style_StrGetCharSet(lpszStyle,&iValue)) - SendMessage(hwnd,SCI_STYLESETCHARACTERSET,iStyle,(LPARAM)iValue); - -} - - -//============================================================================= -// -// Style_SetFontQuality() -// -void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { - - WPARAM wQuality = SC_EFF_QUALITY_DEFAULT; - WCHAR tch[32]; - - if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) { - if (lstrcmpi(tch,L"none") == 0) - wQuality = SC_EFF_QUALITY_NON_ANTIALIASED; - else if (lstrcmpi(tch,L"standard") == 0) - wQuality = SC_EFF_QUALITY_ANTIALIASED; - else if (lstrcmpi(tch,L"cleartype") == 0) - wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; - else - wQuality = SC_EFF_QUALITY_DEFAULT; - } - else { - WCHAR tch[32]; - if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { - if (lstrcmpi(tch,L"Calibri") == 0 || - lstrcmpi(tch,L"Cambria") == 0 || - lstrcmpi(tch,L"Candara") == 0 || - lstrcmpi(tch,L"Consolas") == 0 || - lstrcmpi(tch,L"Constantia") == 0 || - lstrcmpi(tch,L"Corbel") == 0 || - lstrcmpi(tch,L"Segoe UI") == 0) - wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; - } - else - wQuality = SC_EFF_QUALITY_DEFAULT; - } - SendMessage(hwnd,SCI_SETFONTQUALITY,wQuality,0); -} - - -//============================================================================= -// -// Style_GetCurrentLexerName() -// -void Style_GetCurrentLexerName(LPWSTR lpszName,int cchName) -{ - if (!GetString(pLexCurrent->rid,lpszName,cchName)) - lstrcpyn(lpszName,pLexCurrent->pszName,cchName); -} - - -//============================================================================= -// -// Style_GetLexerIconId() -// -int Style_GetLexerIconId(PEDITLEXER plex) -{ - WCHAR *p; - WCHAR *pszExtensions; - WCHAR *pszFile; - - SHFILEINFO shfi; - - if (lstrlen(plex->szExtensions)) - pszExtensions = plex->szExtensions; - else - pszExtensions = plex->pszDefExt; - - pszFile = GlobalAlloc(GPTR,sizeof(WCHAR)*(lstrlen(pszExtensions) + CSTRLEN(L"*.txt") + 16)); - lstrcpy(pszFile,L"*."); - lstrcat(pszFile,pszExtensions); - if (p = StrChr(pszFile,L';')) - *p = L'\0'; - - // check for ; at beginning - if (lstrlen(pszFile) < 3) - lstrcat(pszFile,L"txt"); - - SHGetFileInfo(pszFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); - - GlobalFree(pszFile); - - return (shfi.iIcon); -} - - -//============================================================================= -// -// Style_AddLexerToTreeView() -// -HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) -{ - int i = 0; - WCHAR tch[128]; - - HTREEITEM hTreeNode; - - TVINSERTSTRUCT tvis; - ZeroMemory(&tvis,sizeof(TVINSERTSTRUCT)); - - tvis.hInsertAfter = TVI_LAST; - - tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; - if (GetString(plex->rid,tch,COUNTOF(tch))) - tvis.item.pszText = tch; - else - tvis.item.pszText = plex->pszName; - tvis.item.iImage = Style_GetLexerIconId(plex); - tvis.item.iSelectedImage = tvis.item.iImage; - tvis.item.lParam = (LPARAM)plex; - - hTreeNode = (HTREEITEM)TreeView_InsertItem(hwnd,&tvis); - - tvis.hParent = hTreeNode; - - tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; - //tvis.item.iImage = -1; - //tvis.item.iSelectedImage = -1; - - while (plex->Styles[i].iStyle != -1) { - - if (GetString(plex->Styles[i].rid,tch,COUNTOF(tch))) - tvis.item.pszText = tch; - else - tvis.item.pszText = plex->Styles[i].pszName; - tvis.item.lParam = (LPARAM)(&plex->Styles[i]); - TreeView_InsertItem(hwnd,&tvis); - i++; - } - - return hTreeNode; -} - - -//============================================================================= -// -// Style_AddLexerToListView() -// -void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex) -{ - WCHAR tch[128]; - LVITEM lvi; - ZeroMemory(&lvi,sizeof(LVITEM)); - - lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; - lvi.iItem = ListView_GetItemCount(hwnd); - if (GetString(plex->rid,tch,COUNTOF(tch))) - lvi.pszText = tch; - else - lvi.pszText = plex->pszName; - lvi.iImage = Style_GetLexerIconId(plex); - lvi.lParam = (LPARAM)plex; - - ListView_InsertItem(hwnd,&lvi); -} - - -//============================================================================= -// -// Style_ConfigDlgProc() -// -INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static HWND hwndTV; - static BOOL fDragging; - static PEDITLEXER pCurrentLexer; - static PEDITSTYLE pCurrentStyle; - static HFONT hFontTitle; - static HBRUSH hbrFore; - static HBRUSH hbrBack; - - switch(umsg) - { - - case WM_INITDIALOG: - { - int i; - SHFILEINFO shfi; - LOGFONT lf; - HTREEITEM currentLex = { 0 }; - int found = 0; - - hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); - fDragging = FALSE; - - TreeView_SetImageList(hwndTV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL); - - // Add lexers - for (i = 0; i < NUMLEXERS; i++) - { - if (!found && lstrcmp(pLexArray[i]->pszName,pLexCurrent->pszName) == 0) - { - found = 1; - currentLex = Style_AddLexerToTreeView(hwndTV,pLexArray[i]); - } - else - Style_AddLexerToTreeView(hwndTV,pLexArray[i]); - } - - pCurrentStyle = 0; - - //SetExplorerTheme(hwndTV); - //TreeView_Expand(hwndTV,TreeView_GetRoot(hwndTV),TVE_EXPAND); - TreeView_Select(hwndTV,currentLex,TVGN_CARET); - - SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT,COUNTOF(lexDefault.Styles[0].szValue)-1,0); - - MakeBitmapButton(hwnd,IDC_PREVSTYLE,g_hInstance,IDB_PREV); - MakeBitmapButton(hwnd,IDC_NEXTSTYLE,g_hInstance,IDB_NEXT); - - // Setup title font - if (hFontTitle) - DeleteObject(hFontTitle); - if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_TITLE,WM_GETFONT,0,0))) - hFontTitle = GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFontTitle,sizeof(LOGFONT),&lf); - lf.lfHeight += lf.lfHeight / 5; - lf.lfWeight = FW_BOLD; - hFontTitle = CreateFontIndirect(&lf); - SendDlgItemMessage(hwnd,IDC_TITLE,WM_SETFONT,(WPARAM)hFontTitle,TRUE); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - DeleteBitmapButton(hwnd,IDC_STYLEFORE); - DeleteBitmapButton(hwnd,IDC_STYLEBACK); - DeleteBitmapButton(hwnd,IDC_PREVSTYLE); - DeleteBitmapButton(hwnd,IDC_NEXTSTYLE); - return FALSE; - - - case WM_NOTIFY: - - if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) - { - LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; - - switch (lpnmtv->hdr.code) - { - - case TVN_SELCHANGED: - { - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - } - - // a lexer has been selected - if (!TreeView_GetParent(hwndTV,lpnmtv->itemNew.hItem)) - { - WCHAR wch[128]; - - GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; - - pCurrentStyle = 0; - if (pCurrentLexer = (PEDITLEXER)lpnmtv->itemNew.lParam) - { - SetDlgItemText(hwnd,IDC_STYLELABEL,wch); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); - } - else - { - SetDlgItemText(hwnd,IDC_STYLELABEL,L""); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); - SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); - } - } - - // a style has been selected - else - { - WCHAR wch[128]; - - GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; - - - pCurrentLexer = 0; - if (pCurrentStyle = (PEDITSTYLE)lpnmtv->itemNew.lParam) - { - SetDlgItemText(hwnd,IDC_STYLELABEL,StrEnd(wch)+1); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),TRUE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),TRUE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),TRUE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),TRUE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),TRUE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),TRUE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),TRUE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); - } - else - { - SetDlgItemText(hwnd,IDC_STYLELABEL,L""); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); - EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); - //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); - SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); - } - } - } - break; - - case TVN_BEGINDRAG: - { - //HIMAGELIST himl; - - //if (pCurrentStyle) - // GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - TreeView_Select(hwndTV,lpnmtv->itemNew.hItem,TVGN_CARET); - - //himl = TreeView_CreateDragImage(hwndTV,lpnmtv->itemNew.hItem); - //ImageList_BeginDrag(himl,0,0,0); - //ImageList_DragEnter(hwndTV,lpnmtv->ptDrag.x,lpnmtv->ptDrag.y); - if (pCurrentStyle) - DestroyCursor(SetCursor(LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_COPY)))); - else - DestroyCursor(SetCursor(LoadCursor(NULL,IDC_NO))); - - SetCapture(hwnd); - fDragging = TRUE; - } - - } - } - - break; - - - case WM_MOUSEMOVE: - { - HTREEITEM htiTarget; - TVHITTESTINFO tvht; - - if (fDragging && pCurrentStyle) - { - LONG xCur = LOWORD(lParam); - LONG yCur = HIWORD(lParam); - - //ImageList_DragMove(xCur,yCur); - //ImageList_DragShowNolock(FALSE); - - tvht.pt.x = xCur; - tvht.pt.y = yCur; - - //ClientToScreen(hwnd,&tvht.pt); - //ScreenToClient(hwndTV,&tvht.pt); - MapWindowPoints(hwnd,hwndTV,&tvht.pt,1); - - if ((htiTarget = TreeView_HitTest(hwndTV,&tvht)) != NULL && - TreeView_GetParent(hwndTV,htiTarget) != NULL) - { - TreeView_SelectDropTarget(hwndTV,htiTarget); - //TreeView_Expand(hwndTV,htiTarget,TVE_EXPAND); - TreeView_EnsureVisible(hwndTV,htiTarget); - } - else - TreeView_SelectDropTarget(hwndTV,NULL); - - //ImageList_DragShowNolock(TRUE); - } - } - break; - - - case WM_LBUTTONUP: - { - if (fDragging) - { - HTREEITEM htiTarget; - - //ImageList_EndDrag(); - - if (htiTarget = TreeView_GetDropHilight(hwndTV)) - { - WCHAR tchCopy[256]; - TreeView_SelectDropTarget(hwndTV,NULL); - GetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy,COUNTOF(tchCopy)); - TreeView_Select(hwndTV,htiTarget,TVGN_CARET); - - // after select, this is new current item - if (pCurrentStyle) - { - lstrcpy(pCurrentStyle->szValue,tchCopy); - SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tchCopy,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tchCopy,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tchCopy,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tchCopy,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - } - } - ReleaseCapture(); - DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); - fDragging = FALSE; - } - } - break; - - - case WM_CANCELMODE: - { - if (fDragging) - { - //ImageList_EndDrag(); - TreeView_SelectDropTarget(hwndTV,NULL); - ReleaseCapture(); - DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); - fDragging = FALSE; - } - } - break; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_PREVSTYLE: - if (TreeView_GetSelection(hwndTV)) - TreeView_Select(hwndTV,TreeView_GetPrevVisible(hwndTV, - TreeView_GetSelection(hwndTV)),TVGN_CARET); - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_NEXTSTYLE: - if (TreeView_GetSelection(hwndTV)) - TreeView_Select(hwndTV,TreeView_GetNextVisible(hwndTV, - TreeView_GetSelection(hwndTV)),TVGN_CARET); - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_STYLEFONT: - if (pCurrentStyle) - { - WCHAR tch[256]; - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - if (Style_SelectFont(hwnd,tch,COUNTOF(tch), - lstrcmpi(pCurrentStyle->pszName,L"Default Style") == 0 || - lstrcmpi(pCurrentStyle->pszName,L"2nd Default Style") == 0)) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - } - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_STYLEFORE: - if (pCurrentStyle) - { - WCHAR tch[256]; - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch))) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - } - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_STYLEBACK: - if (pCurrentStyle) - { - WCHAR tch[256]; - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch))) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - } - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_STYLEDEFAULT: - if (pCurrentStyle) - { - lstrcpy(pCurrentStyle->szValue,pCurrentStyle->pszDefault); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED)); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); - } - else if (pCurrentLexer) { - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - //case IDC_STYLEBOLD: - // if (pCurrentStyle) - // { - // WCHAR tch[256]; - // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - // Style_StrSetAttribute(tch,COUNTOF(tch),L"bold",IsDlgButtonChecked(hwnd,IDC_STYLEBOLD)); - // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - // } - // break; - - //case IDC_STYLEITALIC: - // if (pCurrentStyle) - // { - // WCHAR tch[256]; - // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - // Style_StrSetAttribute(tch,COUNTOF(tch),L"italic",IsDlgButtonChecked(hwnd,IDC_STYLEITALIC)); - // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - // } - // break; - - //case IDC_STYLEUNDERLINE: - // if (pCurrentStyle) - // { - // WCHAR tch[256]; - // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - // Style_StrSetAttribute(tch,COUNTOF(tch),L"underline",IsDlgButtonChecked(hwnd,IDC_STYLEUNDERLINE)); - // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - // } - // break; - - //case IDC_STYLEEOLFILLED: - // if (pCurrentStyle) - // { - // WCHAR tch[256]; - // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - // Style_StrSetAttribute(tch,COUNTOF(tch),L"eolfilled",IsDlgButtonChecked(hwnd,IDC_STYLEEOLFILLED)); - // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - // } - // break; - - case IDC_STYLEEDIT: - { - if (HIWORD(wParam) == EN_CHANGE) { - int cr; - WCHAR tch[256]; - - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - - cr = -1; - Style_StrGetColor(TRUE,tch,&cr); - MakeColorPickButton(hwnd,IDC_STYLEFORE,g_hInstance,cr); - - cr = -1; - Style_StrGetColor(FALSE,tch,&cr); - MakeColorPickButton(hwnd,IDC_STYLEBACK,g_hInstance,cr); - } - } - break; - - case IDC_IMPORT: - { - HWND hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); - - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - } - - if (Style_Import(hwnd)) { - - if (pCurrentStyle) - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); - else if (pCurrentLexer) - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); - - TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET); - } - } - break; - - case IDC_EXPORT: - { - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - } - - Style_Export(hwnd); - } - break; - - case IDC_PREVIEW: - { - // Hack from outside - extern HWND hwndEdit; - extern void UpdateLineNumerWidth(); - - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - } - - Style_SetLexer(hwndEdit,pLexCurrent); - UpdateLineNumberWidth(); - } - break; - - case IDOK: - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); - } - EndDialog(hwnd,IDOK); - break; - - case IDCANCEL: - if (fDragging) - SendMessage(hwnd,WM_CANCELMODE,0,0); - else - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// Style_ConfigDlg() -// -void Style_ConfigDlg(HWND hwnd) -{ - - WCHAR *StyleBackup[1024]; - int c,cItems,i,iLexer; - - // Backup Styles - c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - StyleBackup[c++] = StrDup(pLexArray[iLexer]->Styles[i].szValue); - i++; - } - } - cItems = c; - - if (IDCANCEL == ThemedDialogBoxParam(g_hInstance, - MAKEINTRESOURCE(IDD_STYLECONFIG), - GetParent(hwnd),Style_ConfigDlgProc, - (LPARAM)&StyleBackup)) - { - // Restore Styles - c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { - lstrcpy(pLexArray[iLexer]->szExtensions,StyleBackup[c++]); - i = 0; - while (pLexArray[iLexer]->Styles[i].iStyle != -1) { - lstrcpy(pLexArray[iLexer]->Styles[i].szValue,StyleBackup[c++]); - i++; - } - } - } - - else { - fStylesModified = TRUE; - if (lstrlen(szIniFile) == 0 && !fWarnedNoIniFile) { - MsgBox(MBWARN,IDS_SETTINGSNOTSAVED); - fWarnedNoIniFile = TRUE; - } - } - - for (c = 0; c < cItems; c++) - LocalFree(StyleBackup[c]); - - // Apply new (or previous) Styles - Style_SetLexer(hwnd,pLexCurrent); -} - - -//============================================================================= -// -// Style_SelectLexerDlgProc() -// -INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) -{ - - static int cxClient; - static int cyClient; - static int mmiPtMaxY; - static int mmiPtMinX; - - static HWND hwndLV; - static int iInternalDefault; - - switch(umsg) - { - - case WM_INITDIALOG: - { - int i; - int lvItems; - LVITEM lvi; - SHFILEINFO shfi; - LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - - RECT rc; - WCHAR tch[MAX_PATH]; - int cGrip; - - GetClientRect(hwnd,&rc); - cxClient = rc.right - rc.left; - cyClient = rc.bottom - rc.top; - - AdjustWindowRectEx(&rc,GetWindowLong(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0); - mmiPtMinX = rc.right-rc.left; - mmiPtMaxY = rc.bottom-rc.top; - - if (cxStyleSelectDlg < (rc.right-rc.left)) - cxStyleSelectDlg = rc.right-rc.left; - if (cyStyleSelectDlg < (rc.bottom-rc.top)) - cyStyleSelectDlg = rc.bottom-rc.top; - SetWindowPos(hwnd,NULL,rc.left,rc.top,cxStyleSelectDlg,cyStyleSelectDlg,SWP_NOZORDER); - - SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); - SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - - GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,tch,COUNTOF(tch),MF_BYCOMMAND); - InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,tch); - InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); - - SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE, - GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS); - - cGrip = GetSystemMetrics(SM_CXHTHUMB); - SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,cxClient-cGrip, - cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER); - - hwndLV = GetDlgItem(hwnd,IDC_STYLELIST); - - ListView_SetImageList(hwndLV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), - LVSIL_SMALL); - - ListView_SetImageList(hwndLV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), - LVSIL_NORMAL); - - //SetExplorerTheme(hwndLV); - ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); - ListView_InsertColumn(hwndLV,0,&lvc); - - // Add lexers - for (i = 0; i < NUMLEXERS; i++) - Style_AddLexerToListView(hwndLV,pLexArray[i]); - - ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); - - // Select current lexer - lvItems = ListView_GetItemCount(hwndLV); - lvi.mask = LVIF_PARAM; - for (i = 0; i < lvItems; i++) { - lvi.iItem = i; - ListView_GetItem(hwndLV,&lvi);; - if (lstrcmp(((PEDITLEXER)lvi.lParam)->pszName,pLexCurrent->pszName) == 0) { - ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); - ListView_EnsureVisible(hwndLV,i,FALSE); - if (iDefaultLexer == i) { - CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED); - } - } - } - - iInternalDefault = iDefaultLexer; - - if (bAutoSelect) - CheckDlgButton(hwnd,IDC_AUTOSELECT,BST_CHECKED); - - CenterDlgInParent(hwnd); - } - return TRUE; - - - case WM_DESTROY: - { - RECT rc; - - GetWindowRect(hwnd,&rc); - cxStyleSelectDlg = rc.right-rc.left; - cyStyleSelectDlg = rc.bottom-rc.top; - } - return FALSE; - - - case WM_SIZE: - { - RECT rc; - - int dxClient = LOWORD(lParam) - cxClient; - int dyClient = HIWORD(lParam) - cyClient; - cxClient = LOWORD(lParam); - cyClient = HIWORD(lParam); - - GetWindowRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,TRUE); - - GetWindowRect(GetDlgItem(hwnd,IDOK),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDOK),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDOK),NULL,TRUE); - - GetWindowRect(GetDlgItem(hwnd,IDCANCEL),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDCANCEL),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDCANCEL),NULL,TRUE); - - GetWindowRect(GetDlgItem(hwnd,IDC_STYLELIST),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_STYLELIST),NULL,0,0,rc.right-rc.left+dxClient,rc.bottom-rc.top+dyClient,SWP_NOZORDER|SWP_NOMOVE); - ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_STYLELIST),0,LVSCW_AUTOSIZE_USEHEADER); - InvalidateRect(GetDlgItem(hwnd,IDC_STYLELIST),NULL,TRUE); - - GetWindowRect(GetDlgItem(hwnd,IDC_AUTOSELECT),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,TRUE); - - GetWindowRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),&rc); - MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); - SetWindowPos(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); - InvalidateRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,TRUE); - } - return TRUE; - - - case WM_GETMINMAXINFO: - { - LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; - lpmmi->ptMinTrackSize.x = mmiPtMinX; - lpmmi->ptMinTrackSize.y = mmiPtMaxY; - //lpmmi->ptMaxTrackSize.y = mmiPtMaxY; - } - return TRUE; - - - case WM_NOTIFY: { - if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) { - - switch (((LPNMHDR)(lParam))->code) { - - case NM_DBLCLK: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; - - case LVN_ITEMCHANGED: - case LVN_DELETEITEM: { - int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - if (iInternalDefault == i) - CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED); - else - CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_UNCHECKED); - EnableWindow(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),i != -1); - EnableWindow(GetDlgItem(hwnd,IDOK),i != -1); - } - break; - } - } - } - - return TRUE; - - - case WM_COMMAND: - - switch(LOWORD(wParam)) - { - - case IDC_DEFAULTSCHEME: - if (IsDlgButtonChecked(hwnd,IDC_DEFAULTSCHEME) == BST_CHECKED) - iInternalDefault = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - else - iInternalDefault = 0; - break; - - - case IDOK: - { - LVITEM lvi; - - lvi.mask = LVIF_PARAM; - lvi.iItem = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - if (ListView_GetItem(hwndLV,&lvi)) { - pLexCurrent = (PEDITLEXER)lvi.lParam; - iDefaultLexer = iInternalDefault; - bAutoSelect = (IsDlgButtonChecked(hwnd,IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; - EndDialog(hwnd,IDOK); - } - } - break; - - - case IDCANCEL: - EndDialog(hwnd,IDCANCEL); - break; - - } - - return TRUE; - - } - - return FALSE; - -} - - -//============================================================================= -// -// Style_SelectLexerDlg() -// -void Style_SelectLexerDlg(HWND hwnd) -{ - if (IDOK == ThemedDialogBoxParam(g_hInstance, - MAKEINTRESOURCE(IDD_STYLESELECT), - GetParent(hwnd),Style_SelectLexerDlgProc,0)) - - Style_SetLexer(hwnd,pLexCurrent); -} - - -// End of Styles.c +/****************************************************************************** +* +* +* Notepad2 +* +* Styles.c +* Scintilla Style Management +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x501 +#endif +#include +#include +#include +#include +#include +#include +#include "scintilla.h" +#include "scilexer.h" +#include "notepad2.h" +#include "edit.h" +#include "styles.h" +#include "dialogs.h" +#include "helpers.h" +#include "resource.h" +#include "SciCall.h" + +extern int iEncoding; + + +#define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24)) + + +KEYWORDLIST KeyWords_NULL = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; log; asc; doc", L"", &KeyWords_NULL, { + /* 0 */ { STYLE_DEFAULT, 63100, L"Default Style", L"font:Default; size:10", L"" }, + /* 1 */ { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" }, + /* 2 */ { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+1; bold; fore:#FF0000", L"" }, + /* 3 */ { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+1; bold; fore:#000080", L"" }, + /* 4 */ { STYLE_CONTROLCHAR, 63104, L"Control Characters (Font)", L"size:-1", L"" }, + /* 5 */ { STYLE_INDENTGUIDE, 63105, L"Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, + /* 6 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63106, L"Selected Text (Colors)", L"back:#0A246A; eolfilled; alpha:95", L"" }, + /* 7 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63107, L"Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, + /* 8 */ { SCI_SETCARETLINEBACK, 63108, L"Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, + /* 9 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63109, L"Caret (Color, Size 1-3)", L"", L"" }, + /* 10 */ { SCI_SETEDGECOLOUR, 63110, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" }, + /* 11 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63111, L"Extra Line Spacing (Size)", L"size:2", L"" }, + + /* 12 */ { STYLE_DEFAULT, 63112, L"2nd Default Style", L"font:Courier New; size:10", L"" }, + /* 13 */ { STYLE_LINENUMBER, 63113, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" }, + /* 14 */ { STYLE_BRACELIGHT, 63114, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" }, + /* 15 */ { STYLE_BRACEBAD, 63115, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" }, + /* 16 */ { STYLE_CONTROLCHAR, 63116, L"2nd Control Characters (Font)", L"size:-1", L"" }, + /* 17 */ { STYLE_INDENTGUIDE, 63117, L"2nd Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, + /* 18 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63118, L"2nd Selected Text (Colors)", L"eolfilled", L"" }, + /* 19 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63119, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, + /* 20 */ { SCI_SETCARETLINEBACK, 63120, L"2nd Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, + /* 21 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" }, + /* 22 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, + /* 23 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_HTML = { +"!doctype ^aria- ^data- a abbr accept accept-charset accesskey acronym action address align alink " +"alt and applet archive area article aside async audio autocomplete autofocus autoplay axis b " +"background base basefont bb bdi bdo bgcolor big blockquote body border bordercolor br buffered button " +"canvas caption cellpadding cellspacing center challenge char charoff charset checkbox checked " +"cite class classid clear code codebase codetype col colgroup color cols colspan command compact " +"content contenteditable contextmenu controls coords crossorigin data datafld dataformatas datagrid " +"datalist datapagesize datasrc datetime dd declare default defer del details dfn dialog dir dirname " +"disabled div dl download draggable dropzone dt em embed enctype event eventsource face fieldset " +"figcaption figure file font footer for form formaction formenctype formmethod formnovalidate " +"formtarget frame frameborder frameset h1 h2 h3 h4 h5 h6 head header headers height hgroup hidden " +"high hr href hreflang hspace html http-equiv i icon id iframe image img input ins integrity isindex " +"ismap itemprop itemscope itemtype kbd keygen keytype kind label lang language leftmargin legend li link " +"list longdesc loop low main manifest map marginheight marginwidth mark max maxlength media mediagroup " +"menu menuitem meta meter method min multiple muted name nav noframes nohref noresize noscript noshade " +"novalidate nowrap object ol onabort onafterprint onbeforeprint onbeforeunload onblur oncancel oncanplay " +"oncanplaythrough onchange onclick onclose oncontextmenu oncuechange ondblclick ondrag ondragend ondragenter " +"ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onformchange " +"onforminput onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata " +"onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel " +"onoffline ononline onpagehide onpageshow onpause onplay onplaying onpopstate onprogress " +"onratechange onreadystatechange onredo onreset onresize onscroll onseeked onseeking onselect " +"onshow onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload onvolumechange " +"onwaiting open optgroup optimum option output p param password pattern ping placeholder poster " +"pre prefix preload profile progress prompt property pubdate public q radio radiogroup readonly rel " +"required reset rev reversed role rows rowspan rp rt ruby rules s samp sandbox scheme scope scoped script " +"scrolling seamless section select selected shape size sizes small source span spellcheck src " +"srcdoc srclang standby start step strike strong style sub submit summary sup tabindex table " +"target tbody td text textarea tfoot th thead time title topmargin tr track translate tt type " +"typemustmatch u ul usemap valign value valuetype var version video vlink vspace wbr width wrap xml " +"xmlns", +"abstract boolean break byte case catch char class const continue debugger default delete do " +"double else enum export extends false final finally float for function goto if implements " +"import in instanceof int interface long native new null package private protected public " +"return short static super switch synchronized this throw throws transient true try typeof var " +"void volatile while with", +"alias and as attribute begin boolean byref byte byval call case class compare const continue " +"currency date declare dim do double each else elseif empty end enum eqv erase error event exit " +"explicit false for friend function get global gosub goto if imp implement in integer is let lib " +"load long loop lset me mid mod module new next not nothing null object on option optional or " +"preserve private property public raiseevent redim rem resume return rset select set single " +"static stop string sub then to true type unload until variant wend while with withevents xor", +"", +"__callstatic __class__ __compiler_halt_offset__ __dir__ __file__ __function__ __get __halt_compiler " +"__isset __line__ __method__ __namespace__ __set __sleep __trait__ __unset __wakeup " +"abstract and argc argv array as break callable case catch cfunction class clone closure const continue " +"declare default define die directory do e_all e_compile_error e_compile_warning e_core_error e_core_warning " +"e_deprecated e_error e_fatal e_notice e_parse e_strict e_user_deprecated e_user_error e_user_notice " +"e_user_warning e_warning echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile " +"eval exception exit extends false final for foreach function global goto http_cookie_vars http_env_vars " +"http_get_vars http_post_files http_post_vars http_server_vars if implements include include_once " +"instanceof insteadof interface isset list namespace new not null old_function or parent php_self " +"print private protected public require require_once return static stdclass switch this throw trait " +"true try unset use var virtual while xor", +"", "", "", "" }; + + +EDITLEXER lexHTML = { SCLEX_HTML, 63001, L"Web Source Code", L"html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc", L"", &KeyWords_HTML, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGEND,0,0), 63136, L"HTML Tag", L"fore:#648000", L"" }, + { SCE_H_TAGUNKNOWN, 63137, L"HTML Unknown Tag", L"fore:#C80000; back:#FFFF80", L"" }, + { SCE_H_ATTRIBUTE, 63138, L"HTML Attribute", L"fore:#FF4000", L"" }, + { SCE_H_ATTRIBUTEUNKNOWN, 63139, L"HTML Unknown Attribute", L"fore:#C80000; back:#FFFF80", L"" }, + { SCE_H_VALUE, 63140, L"HTML Value", L"fore:#3A6EA5", L"" }, + { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63141, L"HTML String", L"fore:#3A6EA5", L"" }, + { SCE_H_OTHER, 63142, L"HTML Other Inside Tag", L"fore:#3A6EA5", L"" }, + { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63143, L"HTML Comment", L"fore:#646464", L"" }, + { SCE_H_ENTITY, 63144, L"HTML Entity", L"fore:#B000B0", L"" }, + { SCE_H_DEFAULT, 63256, L"HTML Element Text", L"", L"" }, + { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" }, + { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" }, + { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" }, + { MULTI_STYLE(SCE_H_ASP,SCE_H_ASPAT,0,0), 63146, L"ASP Start Tag", L"bold; fore:#000080", L"" }, + //{ SCE_H_SCRIPT, L"Script", L"", L"" }, + { SCE_H_QUESTION, 63148, L"PHP Start Tag", L"bold; fore:#000080", L"" }, + { SCE_HPHP_DEFAULT, 63149, L"PHP Default", L"", L"" }, + { MULTI_STYLE(SCE_HPHP_COMMENT,SCE_HPHP_COMMENTLINE,0,0), 63157, L"PHP Comment", L"fore:#FF8000", L"" }, + { SCE_HPHP_WORD, 63152, L"PHP Keyword", L"bold; fore:#A46000", L"" }, + { SCE_HPHP_HSTRING, 63150, L"PHP String", L"fore:#008000", L"" }, + { SCE_HPHP_SIMPLESTRING, 63151, L"PHP Simple String", L"fore:#008000", L"" }, + { SCE_HPHP_NUMBER, 63153, L"PHP Number", L"fore:#FF0000", L"" }, + { SCE_HPHP_OPERATOR, 63158, L"PHP Operator", L"fore:#B000B0", L"" }, + { SCE_HPHP_VARIABLE, 63154, L"PHP Variable", L"italic; fore:#000080", L"" }, + { SCE_HPHP_HSTRING_VARIABLE, 63155, L"PHP String Variable", L"italic; fore:#000080", L"" }, + { SCE_HPHP_COMPLEX_VARIABLE, 63156, L"PHP Complex Variable", L"italic; fore:#000080", L"" }, + { MULTI_STYLE(SCE_HJ_DEFAULT,SCE_HJ_START,0,0), 63159, L"JS Default", L"", L"" }, + { MULTI_STYLE(SCE_HJ_COMMENT,SCE_HJ_COMMENTLINE,SCE_HJ_COMMENTDOC,0), 63160, L"JS Comment", L"fore:#646464", L"" }, + { SCE_HJ_KEYWORD, 63163, L"JS Keyword", L"bold; fore:#A46000", L"" }, + { SCE_HJ_WORD, 63162, L"JS Identifier", L"", L"" }, + { MULTI_STYLE(SCE_HJ_DOUBLESTRING,SCE_HJ_SINGLESTRING,SCE_HJ_STRINGEOL,0), 63164, L"JS String", L"fore:#008000", L"" }, + { SCE_HJ_REGEX, 63166, L"JS Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_HJ_NUMBER, 63161, L"JS Number", L"fore:#FF0000", L"" }, + { SCE_HJ_SYMBOLS, 63165, L"JS Symbols", L"fore:#B000B0", L"" }, + { MULTI_STYLE(SCE_HJA_DEFAULT,SCE_HJA_START,0,0), 63167, L"ASP JS Default", L"", L"" }, + { MULTI_STYLE(SCE_HJA_COMMENT,SCE_HJA_COMMENTLINE,SCE_HJA_COMMENTDOC,0), 63168, L"ASP JS Comment", L"fore:#646464", L"" }, + { SCE_HJA_KEYWORD, 63171, L"ASP JS Keyword", L"bold; fore:#A46000", L"" }, + { SCE_HJA_WORD, 63170, L"ASP JS Identifier", L"", L"" }, + { MULTI_STYLE(SCE_HJA_DOUBLESTRING,SCE_HJA_SINGLESTRING,SCE_HJA_STRINGEOL,0), 63172, L"ASP JS String", L"fore:#008000", L"" }, + { SCE_HJA_REGEX, 63174, L"ASP JS Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_HJA_NUMBER, 63169, L"ASP JS Number", L"fore:#FF0000", L"" }, + { SCE_HJA_SYMBOLS, 63173, L"ASP JS Symbols", L"fore:#B000B0", L"" }, + { MULTI_STYLE(SCE_HB_DEFAULT,SCE_HB_START,0,0), 63175, L"VBS Default", L"", L"" }, + { SCE_HB_COMMENTLINE, 63176, L"VBS Comment", L"fore:#646464", L"" }, + { SCE_HB_WORD, 63178, L"VBS Keyword", L"bold; fore:#B000B0", L"" }, + { SCE_HB_IDENTIFIER, 63180, L"VBS Identifier", L"", L"" }, + { MULTI_STYLE(SCE_HB_STRING,SCE_HB_STRINGEOL,0,0), 63179, L"VBS String", L"fore:#008000", L"" }, + { SCE_HB_NUMBER, 63177, L"VBS Number", L"fore:#FF0000", L"" }, + { MULTI_STYLE(SCE_HBA_DEFAULT,SCE_HBA_START,0,0), 63181, L"ASP VBS Default", L"", L"" }, + { SCE_HBA_COMMENTLINE, 63182, L"ASP VBS Comment", L"fore:#646464", L"" }, + { SCE_HBA_WORD, 63184, L"ASP VBS Keyword", L"bold; fore:#B000B0", L"" }, + { SCE_HBA_IDENTIFIER, 63186, L"ASP VBS Identifier", L"", L"" }, + { MULTI_STYLE(SCE_HBA_STRING,SCE_HBA_STRINGEOL,0,0), 63185, L"ASP VBS String", L"fore:#008000", L"" }, + { SCE_HBA_NUMBER, 63183, L"ASP VBS Number", L"fore:#FF0000", L"" }, + //{ SCE_HP_START, L"Phyton Start", L"", L"" }, + //{ SCE_HP_DEFAULT, L"Phyton Default", L"", L"" }, + //{ SCE_HP_COMMENTLINE, L"Phyton Comment Line", L"", L"" }, + //{ SCE_HP_NUMBER, L"Phyton Number", L"", L"" }, + //{ SCE_HP_STRING, L"Phyton String", L"", L"" }, + //{ SCE_HP_CHARACTER, L"Phyton Character", L"", L"" }, + //{ SCE_HP_WORD, L"Phyton Keyword", L"", L"" }, + //{ SCE_HP_TRIPLE, L"Phyton Triple", L"", L"" }, + //{ SCE_HP_TRIPLEDOUBLE, L"Phyton Triple Double", L"", L"" }, + //{ SCE_HP_CLASSNAME, L"Phyton Class Name", L"", L"" }, + //{ SCE_HP_DEFNAME, L"Phyton Def Name", L"", L"" }, + //{ SCE_HP_OPERATOR, L"Phyton Operator", L"", L"" }, + //{ SCE_HP_IDENTIFIER, L"Phyton Identifier", L"", L"" }, + //{ SCE_HPA_START, L"ASP Phyton Start", L"", L"" }, + //{ SCE_HPA_DEFAULT, L"ASP Phyton Default", L"", L"" }, + //{ SCE_HPA_COMMENTLINE, L"ASP Phyton Comment Line", L"", L"" }, + //{ SCE_HPA_NUMBER, L"ASP Phyton Number", L"", L"" }, + //{ SCE_HPA_STRING, L"ASP Phyton String", L"", L"" }, + //{ SCE_HPA_CHARACTER, L"ASP Phyton Character", L"", L"" }, + //{ SCE_HPA_WORD, L"ASP Phyton Keyword", L"", L"" }, + //{ SCE_HPA_TRIPLE, L"ASP Phyton Triple", L"", L"" }, + //{ SCE_HPA_TRIPLEDOUBLE, L"ASP Phyton Triple Double", L"", L"" }, + //{ SCE_HPA_CLASSNAME, L"ASP Phyton Class Name", L"", L"" }, + //{ SCE_HPA_DEFNAME, L"ASP Phyton Def Name", L"", L"" }, + //{ SCE_HPA_OPERATOR, L"ASP Phyton Operator", L"", L"" }, + //{ SCE_HPA_IDENTIFIER, L"ASP Phyton Identifier", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_XML = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexXML = { SCLEX_XML, 63002, L"XML Document", L"xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj", L"", &KeyWords_XML, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGUNKNOWN,SCE_H_TAGEND,0), 63187, L"XML Tag", L"fore:#881280", L"" }, + { MULTI_STYLE(SCE_H_ATTRIBUTE,SCE_H_ATTRIBUTEUNKNOWN,0,0), 63188, L"XML Attribute", L"fore:#994500", L"" }, + { SCE_H_VALUE, 63189, L"XML Value", L"fore:#1A1AA6", L"" }, + { MULTI_STYLE(SCE_H_DOUBLESTRING,SCE_H_SINGLESTRING,0,0), 63190, L"XML String", L"fore:#1A1AA6", L"" }, + { SCE_H_OTHER, 63191, L"XML Other Inside Tag", L"fore:#1A1AA6", L"" }, + { MULTI_STYLE(SCE_H_COMMENT,SCE_H_XCCOMMENT,0,0), 63192, L"XML Comment", L"fore:#646464", L"" }, + { SCE_H_ENTITY, 63193, L"XML Entity", L"fore:#B000B0", L"" }, + { SCE_H_DEFAULT, 63257, L"XML Element Text", L"", L"" }, + { MULTI_STYLE(SCE_H_XMLSTART,SCE_H_XMLEND,0,0), 63145, L"XML Identifier", L"bold; fore:#881280", L"" }, + { SCE_H_SGML_DEFAULT, 63237, L"SGML", L"fore:#881280", L"" }, + { SCE_H_CDATA, 63147, L"CDATA", L"fore:#646464", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_CSS = { +"align-content align-items align-self alignment-adjust alignment-baseline animation animation-delay " +"animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name " +"animation-play-state animation-timing-function appearance ascent azimuth backface-visibility " +"background background-attachment background-blend-mode background-break background-clip background-color " +"background-image background-origin background-position background-repeat background-size " +"baseline baseline-shift bbox binding bleed bookmark-label bookmark-level bookmark-state " +"bookmark-target border border-bottom border-bottom-color border-bottom-left-radius " +"border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color " +"border-image border-image-outset border-image-repeat border-image-slice border-image-source " +"border-image-width border-left border-left-color border-left-style border-left-width " +"border-length border-radius border-right border-right-color border-right-style " +"border-right-width border-spacing border-style border-top border-top-color " +"border-top-left-radius border-top-right-radius border-top-style border-top-width border-width " +"bottom box-align box-decoration-break box-direction box-flex box-flex-group box-lines " +"box-ordinal-group box-orient box-pack box-shadow box-sizing break-after break-before " +"break-inside cap-height caption-side centerline change-bar change-bar-class change-bar-offset " +"change-bar-side clear clip clip-path clip-rule color color-profile column-count column-fill column-gap " +"column-rule column-rule-color column-rule-style column-rule-width columns column-span column-width " +"content counter-increment counter-reset crop cue cue-after cue-before cursor definition-src descent " +"direction display dominant-baseline drop-initial-after-adjust drop-initial-after-align " +"drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value " +"elevation empty-cells fill fit fit-position flex flex-basis flex-direction flex-flow flex-grow flex-shrink " +"flex-wrap float float-offset flow-from flow-into font font-family font-feature-settings font-kerning font-size " +"font-size-adjust font-stretch font-style font-synthesis font-variant font-weight grid-columns grid-rows " +"hanging-punctuation height hyphenate-after hyphenate-before hyphenate-character hyphenate-limit-chars " +"hyphenate-limit-last hyphenate-limit-zone hyphenate-lines hyphenate-resource hyphens icon image-orientation " +"image-resolution ime-mode inline-box-align insert-position interpret-as justify-content left letter-spacing " +"line-height line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy list-style " +"list-style-image list-style-position list-style-type make-element margin margin-bottom margin-left " +"margin-right margin-top mark mark-after mark-before marker-offset marks marquee-direction marquee-play-count " +"marquee-speed marquee-style mask mask-type mathline max-height max-width media min-height min-width " +"move-to nav-down nav-index nav-left nav-right nav-up object-fit object-position opacity order orphans " +"outline outline-color outline-offset outline-style outline-width overflow overflow-style overflow-wrap " +"overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page page-break-after " +"page-break-before page-break-inside page-policy panose-1 pause pause-after pause-before perspective " +"perspective-origin phonemes pitch pitch-range play-during pointer-events position presentation-level prototype " +"prototype-insert-policy prototype-insert-position punctuation-trim quotes region-overflow " +"rendering-intent resize rest rest-after rest-before richness right rotation rotation-point ruby-align " +"ruby-overhang ruby-position ruby-span shape-image-threshold shape-inside shape-outside size slope speak " +"speak-header speak-numeral speak-punctuation speech-rate src stemh stemv stress string-set tab-size table-layout " +"target target-name target-new target-position text-align text-align-last text-decoration text-decoration-color " +"text-decoration-line text-decoration-style text-emphasis text-height text-indent text-justify text-outline " +"text-overflow text-rendering text-replace text-shadow text-transform text-underline-position text-wrap top topline " +"transform transform-origin transform-style transition transition-delay transition-duration transition-property " +"transition-timing-function unicode-bidi unicode-range units-per-em vertical-align visibility " +"voice-balance voice-duration voice-family voice-pitch voice-pitch-range voice-rate voice-stress " +"voice-volume volume white-space white-space-collapse widows width widths will-change word-break word-spacing " +"word-wrap wrap wrap-flow wrap-margin wrap-padding wrap-through writing-mode x-height z-index", +"active after before checked choices default disabled empty enabled first first-child first-letter " +"first-line first-of-type focus hover indeterminate in-range invalid lang last-child last-of-type left " +"link not nth-child nth-last-child nth-last-of-type nth-of-type only-child only-of-type optional " +"out-of-range read-only read-write repeat-index repeat-item required right root target valid visited", +"", "", +"after before first-letter first-line selection", +"^-moz- ^-ms- ^-o- ^-webkit-", +"^-moz- ^-ms- ^-o- ^-webkit-", +"^-moz- ^-ms- ^-o- ^-webkit-", +"" }; + + +EDITLEXER lexCSS = { SCLEX_CSS, 63003, L"CSS Style Sheets", L"css", L"", &KeyWords_CSS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_CSS_DEFAULT, L"Default", L"", L"" }, + { SCE_CSS_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_CSS_TAG, 63136, L"HTML Tag", L"bold; fore:#0A246A", L"" }, + { SCE_CSS_CLASS, 63194, L"Tag-Class", L"fore:#648000", L"" }, + { SCE_CSS_ID, 63195, L"Tag-Id", L"fore:#648000", L"" }, + { SCE_CSS_ATTRIBUTE, 63196, L"Tag-Attribute", L"italic; fore:#648000", L"" }, + { MULTI_STYLE(SCE_CSS_PSEUDOCLASS,SCE_CSS_EXTENDED_PSEUDOCLASS,0,0), 63197, L"Pseudo-class", L"fore:#B000B0", L"" }, + { MULTI_STYLE(SCE_CSS_PSEUDOELEMENT,SCE_CSS_EXTENDED_PSEUDOELEMENT,0,0), 63361, L"Pseudo-element", L"fore:#B00050", L"" }, + { MULTI_STYLE(SCE_CSS_IDENTIFIER,SCE_CSS_IDENTIFIER2,SCE_CSS_IDENTIFIER3,SCE_CSS_EXTENDED_IDENTIFIER), 63199, L"CSS Property", L"fore:#FF4000", L"" }, + { MULTI_STYLE(SCE_CSS_DOUBLESTRING,SCE_CSS_SINGLESTRING,0,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_CSS_VALUE, 63201, L"Value", L"fore:#3A6EA5", L"" }, + { SCE_CSS_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { SCE_CSS_IMPORTANT, 63202, L"Important", L"bold; fore:#C80000", L"" }, + { SCE_CSS_DIRECTIVE, 63203, L"Directive", L"bold; fore:#000000; back:#FFF1A8", L"" }, + { SCE_CSS_MEDIA, 63382, L"Media", L"bold; fore:#0A246A", L"" }, + { SCE_CSS_VARIABLE, 63249, L"Variable", L"bold; fore:#FF4000", L"" }, + { SCE_CSS_UNKNOWN_PSEUDOCLASS, 63198, L"Unknown Pseudo-class", L"fore:#C80000; back:#FFFF80", L"" }, + { SCE_CSS_UNKNOWN_IDENTIFIER, 63200, L"Unknown Property", L"fore:#C80000; back:#FFFF80", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_CPP = { +"__abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event " +"__except __except__try __fastcall __finally __forceinline __gc __hook __identifier " +"__if_exists __if_not_exists __inline __int16 __int32 __int64 __int8 __interface __leave " +"__m128 __m128d __m128i __m64 __multiple_inheritance __nogc __noop __pin __property __raise " +"__sealed __single_inheritance __stdcall __super __try __try_cast __unhook __uuidof __value " +"__virtual_inheritance __wchar_t auto bool break case catch char class const const_cast " +"continue default defined delete do double dynamic_cast else enum explicit extern false float " +"for friend goto if inline int long mutable naked namespace new operator private protected " +"public register reinterpret_cast return short signed size_t sizeof static static_cast struct " +"switch template this throw true try typedef typeid typename union unsigned using uuid " +"virtual void volatile wchar_t while", +"", +"", "", "", "", "", "", "" }; + + +EDITLEXER lexCPP = { SCLEX_CPP, 63004, L"C/C++ Source Code", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", &KeyWords_CPP, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, + { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { MULTI_STYLE(SCE_C_PREPROCESSOR,SCE_C_PREPROCESSORCOMMENT,SCE_C_PREPROCESSORCOMMENTDOC,0), 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + //{ SCE_C_UUID, L"UUID", L"", L"" }, + //{ SCE_C_REGEX, L"Regex", L"", L"" }, + //{ SCE_C_WORD2, L"Word 2", L"", L"" }, + //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_CS = { +"abstract add alias as ascending async await base bool break by byte case catch char checked " +"class const continue decimal default delegate descending do double dynamic else " +"enum equals event explicit extern false finally fixed float for foreach from get " +"global goto group if implicit in int interface internal into is join lock let long " +"namespace new null object on operator orderby out override params partial private " +"protected public readonly ref remove return sbyte sealed select set short sizeof " +"stackalloc static string struct switch this throw true try typeof uint ulong " +"unchecked unsafe ushort using value var virtual void volatile where while yield", +"", "", +"AccessViolationException Action ActivationContext Activator AggregateException AppDomain " +"AppDomainInitializer AppDomainManager AppDomainManagerInitializationOptions AppDomainSetup " +"AppDomainUnloadedException ApplicationException ApplicationId ApplicationIdentity ArgIterator " +"ArgumentException ArgumentNullException ArgumentOutOfRangeException ArithmeticException Array " +"ArrayList ArraySegment ArrayTypeMismatchException AssemblyLoadEventArgs " +"AssemblyLoadEventHandler AsyncCallback Attribute AttributeTargets AttributeUsage " +"AttributeUsageAttribute BadImageFormatException Base64FormattingOptions BinaryReader " +"BinaryWriter BitArray BitConverter BlockingCollection Boolean Buffer BufferedStream " +"Byte CannotUnloadAppDomainException CaseInsensitiveComparer CaseInsensitiveHashCodeProvider " +"Char CharEnumerator CLSCompliant CLSCompliantAttribute CollectionBase CollectionDataContract " +"CollectionDataContractAttribute Color Comparer Comparison ConcurrentBag ConcurrentDictionary " +"ConcurrentQueue ConcurrentStack ConformanceLevel Console ConsoleCancelEventArgs " +"ConsoleCancelEventHandler ConsoleColor ConsoleKey ConsoleKeyInfo ConsoleModifiers " +"ConsoleSpecialKey ContextBoundObject ContextMarshalException ContextStatic " +"ContextStaticAttribute ContractNamespace ContractNamespaceAttribute Convert Converter " +"CrossAppDomainDelegate DataContract DataContractAttribute DataContractResolver " +"DataContractSerializer DataMember DataMemberAttribute DataMisalignedException DateTime " +"DateTimeKind DateTimeOffset DayOfWeek DBNull Decimal Delegate Dictionary DictionaryBase " +"DictionaryEntry Directory DirectoryInfo DirectoryNotFoundException DivideByZeroException " +"DllNotFoundException Double DriveInfo DriveNotFoundException DriveType DtdProcessing " +"DuplicateWaitObjectException EndOfStreamException EntityHandling EntryPointNotFoundException " +"Enum EnumMember EnumMemberAttribute Environment EnvironmentVariableTarget EqualityComparer " +"ErrorEventArgs ErrorEventHandler EventArgs EventHandler Exception ExecutionEngineException " +"ExportOptions ExtensionDataObject FieldAccessException File FileAccess FileAttributes " +"FileFormatException FileInfo FileLoadException FileMode FileNotFoundException FileOptions " +"FileShare FileStream FileStyleUriParser FileSystemEventArgs FileSystemEventHandler " +"FileSystemInfo FileSystemWatcher Flags FlagsAttribute FormatException Formatter " +"FormatterConverter FormatterServices Formatting FtpStyleUriParser Func GC GCCollectionMode " +"GCNotificationStatus GenericUriParser GenericUriParserOptions GopherStyleUriParser Guid " +"HandleInheritability HashSet Hashtable HttpStyleUriParser IAppDomainSetup IAsyncResult " +"ICloneable ICollection IComparable IComparer IConvertible ICustomFormatter " +"IDataContractSurrogate IDeserializationCallback IDictionary IDictionaryEnumerator IDisposable " +"IEnumerable IEnumerator IEqualityComparer IEquatable IExtensibleDataObject IFormatProvider " +"IFormattable IFormatter IFormatterConverter IFragmentCapableXmlDictionaryWriter " +"IgnoreDataMember IgnoreDataMemberAttribute IHashCodeProvider IHasXmlNode IList ImportOptions " +"IndexOutOfRangeException InsufficientExecutionStackException InsufficientMemoryException Int16 " +"Int32 Int64 InternalBufferOverflowException IntPtr InvalidCastException " +"InvalidDataContractException InvalidDataException InvalidOperationException " +"InvalidProgramException InvalidTimeZoneException IObjectReference IObservable IObserver " +"IODescription IODescriptionAttribute IOException IProducerConsumerCollection " +"ISafeSerializationData ISerializable ISerializationSurrogate IServiceProvider ISet " +"IStreamProvider IStructuralComparable IStructuralEquatable ISurrogateSelector " +"IXmlBinaryReaderInitializer IXmlBinaryWriterInitializer IXmlDictionary IXmlLineInfo " +"IXmlMtomReaderInitializer IXmlMtomWriterInitializer IXmlNamespaceResolver IXmlSchemaInfo " +"IXmlTextReaderInitializer IXmlTextWriterInitializer IXPathNavigable IXsltContextFunction " +"IXsltContextVariable KeyedByTypeCollection KeyNotFoundException KeyValuePair KnownType " +"KnownTypeAttribute Lazy LdapStyleUriParser LinkedList LinkedListNode List LoaderOptimization " +"LoaderOptimizationAttribute LoadOptions LocalDataStoreSlot MarshalByRefObject Math " +"MemberAccessException MemoryStream MethodAccessException MidpointRounding " +"MissingFieldException MissingMemberException MissingMethodException ModuleHandle MTAThread " +"MTAThreadAttribute MulticastDelegate MulticastNotSupportedException NamespaceHandling " +"NameTable NetDataContractSerializer NetPipeStyleUriParser NetTcpStyleUriParser " +"NewLineHandling NewsStyleUriParser NonSerialized NonSerializedAttribute " +"NotFiniteNumberException NotifyFilters NotImplementedException NotSupportedException Nullable " +"NullReferenceException Object ObjectDisposedException ObjectIDGenerator ObjectManager Obsolete " +"ObsoleteAttribute OnDeserialized OnDeserializedAttribute OnDeserializing " +"OnDeserializingAttribute OnSerialized OnSerializedAttribute OnSerializing " +"OnSerializingAttribute OnXmlDictionaryReaderClose OperatingSystem OperationCanceledException " +"OptionalField OptionalFieldAttribute OrderablePartitioner OutOfMemoryException " +"OverflowException ParamArray ParamArrayAttribute Partitioner Path PathTooLongException " +"PipeException PlatformID PlatformNotSupportedException Predicate Queue Random RankException " +"ReaderOptions ReadOnlyCollectionBase ReadState RenamedEventArgs RenamedEventHandler " +"ResolveEventArgs ResolveEventHandler RuntimeArgumentHandle RuntimeFieldHandle " +"RuntimeMethodHandle RuntimeTypeHandle SafeSerializationEventArgs SaveOptions SByte " +"SearchOption SeekOrigin Serializable SerializableAttribute SerializationBinder " +"SerializationEntry SerializationException SerializationInfo SerializationInfoEnumerator " +"SerializationObjectManager Single SortedDictionary SortedList SortedSet Stack " +"StackOverflowException STAThread STAThreadAttribute Stream StreamingContext " +"StreamingContextStates StreamReader StreamWriter String StringBuilder StringComparer StringComparison " +"StringReader StringSplitOptions StringWriter StructuralComparisons SurrogateSelector " +"SynchronizedCollection SynchronizedKeyedCollection SynchronizedReadOnlyCollection " +"SystemException TextReader TextWriter ThreadStatic ThreadStaticAttribute TimeoutException " +"TimeSpan TimeZone TimeZoneInfo TimeZoneNotFoundException Tuple Type TypeAccessException " +"TypeCode TypedReference TypeInitializationException TypeLoadException TypeUnloadedException " +"UInt16 UInt32 UInt64 UIntPtr UnauthorizedAccessException UnhandledExceptionEventArgs " +"UnhandledExceptionEventHandler UniqueId UnmanagedMemoryAccessor UnmanagedMemoryStream Uri " +"UriBuilder UriComponents UriFormat UriFormatException UriHostNameType UriIdnScope UriKind " +"UriParser UriPartial UriTemplate UriTemplateEquivalenceComparer UriTemplateMatch " +"UriTemplateMatchException UriTemplateTable UriTypeConverter ValidationEventArgs " +"ValidationEventHandler ValidationType ValueType Version Void WaitForChangedResult " +"WatcherChangeTypes WeakReference WhitespaceHandling WriteState XAttribute XCData XComment " +"XContainer XDeclaration XDocument XDocumentType XElement XmlAtomicValue XmlAttribute " +"XmlAttributeCollection XmlBinaryReaderSession XmlBinaryWriterSession XmlCaseOrder " +"XmlCDataSection XmlCharacterData XmlComment XmlConvert XmlDataDocument XmlDataType " +"XmlDateTimeSerializationMode XmlDeclaration XmlDictionary XmlDictionaryReader " +"XmlDictionaryReaderQuotas XmlDictionaryString XmlDictionaryWriter XmlDocument " +"XmlDocumentFragment XmlDocumentType XmlElement XmlEntity XmlEntityReference XmlException " +"XmlImplementation XmlLinkedNode XmlNamedNodeMap XmlNamespaceManager XmlNamespaceScope " +"XmlNameTable XmlNode XmlNodeChangedAction XmlNodeChangedEventArgs XmlNodeChangedEventHandler " +"XmlNodeList XmlNodeOrder XmlNodeReader XmlNodeType XmlNotation XmlObjectSerializer " +"XmlOutputMethod XmlParserContext XmlProcessingInstruction XmlQualifiedName XmlReader " +"XmlReaderSettings XmlResolver XmlSchema XmlSchemaAll XmlSchemaAnnotated XmlSchemaAnnotation " +"XmlSchemaAny XmlSchemaAnyAttribute XmlSchemaAppInfo XmlSchemaAttribute XmlSchemaAttributeGroup " +"XmlSchemaAttributeGroupRef XmlSchemaChoice XmlSchemaCollection XmlSchemaCollectionEnumerator " +"XmlSchemaCompilationSettings XmlSchemaComplexContent XmlSchemaComplexContentExtension " +"XmlSchemaComplexContentRestriction XmlSchemaComplexType XmlSchemaContent XmlSchemaContentModel " +"XmlSchemaContentProcessing XmlSchemaContentType XmlSchemaDatatype XmlSchemaDatatypeVariety " +"XmlSchemaDerivationMethod XmlSchemaDocumentation XmlSchemaElement XmlSchemaEnumerationFacet " +"XmlSchemaException XmlSchemaExternal XmlSchemaFacet XmlSchemaForm XmlSchemaFractionDigitsFacet " +"XmlSchemaGroup XmlSchemaGroupBase XmlSchemaGroupRef XmlSchemaIdentityConstraint " +"XmlSchemaImport XmlSchemaInclude XmlSchemaInference XmlSchemaInference.InferenceOption " +"XmlSchemaInferenceException XmlSchemaInfo XmlSchemaKey XmlSchemaKeyref XmlSchemaLengthFacet " +"XmlSchemaMaxExclusiveFacet XmlSchemaMaxInclusiveFacet XmlSchemaMaxLengthFacet " +"XmlSchemaMinExclusiveFacet XmlSchemaMinInclusiveFacet XmlSchemaMinLengthFacet " +"XmlSchemaNotation XmlSchemaNumericFacet XmlSchemaObject XmlSchemaObjectCollection " +"XmlSchemaObjectEnumerator XmlSchemaObjectTable XmlSchemaParticle XmlSchemaPatternFacet " +"XmlSchemaRedefine XmlSchemaSequence XmlSchemaSet XmlSchemaSimpleContent " +"XmlSchemaSimpleContentExtension XmlSchemaSimpleContentRestriction XmlSchemaSimpleType " +"XmlSchemaSimpleTypeContent XmlSchemaSimpleTypeList XmlSchemaSimpleTypeRestriction " +"XmlSchemaSimpleTypeUnion XmlSchemaTotalDigitsFacet XmlSchemaType XmlSchemaUnique " +"XmlSchemaUse XmlSchemaValidationException XmlSchemaValidationFlags XmlSchemaValidator " +"XmlSchemaValidity XmlSchemaWhiteSpaceFacet XmlSchemaXPath XmlSecureResolver " +"XmlSerializableServices XmlSeverityType XmlSignificantWhitespace XmlSortOrder XmlSpace " +"XmlText XmlTextReader XmlTextWriter XmlTokenizedType XmlTypeCode XmlUrlResolver " +"XmlValidatingReader XmlValueGetter XmlWhitespace XmlWriter XmlWriterSettings XName " +"XNamespace XNode XNodeDocumentOrderComparer XNodeEqualityComparer XObject XObjectChange " +"XObjectChangeEventArgs XPathDocument XPathException XPathExpression XPathItem " +"XPathNamespaceScope XPathNavigator XPathNodeIterator XPathNodeType XPathQueryGenerator " +"XPathResultType XProcessingInstruction XsdDataContractExporter XsdDataContractImporter " +"XslCompiledTransform XsltArgumentList XsltCompileException XsltContext XsltException " +"XsltMessageEncounteredEventArgs XsltMessageEncounteredEventHandler XslTransform XsltSettings " +"XStreamingElement XText", +"", "", "", "", "" }; + + +EDITLEXER lexCS = { SCLEX_CPP, 63005, L"C# Source Code", L"cs", L"", &KeyWords_CS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_C_VERBATIM, 63134, L"Verbatim String", L"fore:#008000", L"" }, + { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + //{ SCE_C_UUID, L"UUID", L"", L"" }, + //{ SCE_C_REGEX, L"Regex", L"", L"" }, + //{ SCE_C_WORD2, L"Word 2", L"", L"" }, + { SCE_C_GLOBALCLASS, 63337, L"Global Class", L"fore:#2B91AF", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_RC = { +"ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON " +"BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX " +"CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG " +"DIALOGEX DISCARDABLE EDITTEXT END EXSTYLE FONT GROUPBOX " +"ICON LANGUAGE LISTBOX LTEXT MENU MENUEX MENUITEM " +"MESSAGETABLE POPUP PUSHBUTTON RADIOBUTTON RCDATA RTEXT " +"SCROLLBAR SEPARATOR SHIFT STATE3 STRINGTABLE STYLE " +"TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexRC = { SCLEX_CPP, 63006, L"Resource Script", L"rc; rc2; rct; rh; r; dlg", L"", &KeyWords_RC, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, + { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" }, + { SCE_C_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + //{ SCE_C_UUID, L"UUID", L"", L"" }, + //{ SCE_C_REGEX, L"Regex", L"", L"" }, + //{ SCE_C_WORD2, L"Word 2", L"", L"" }, + //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_MAK = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexMAK = { SCLEX_MAKEFILE, 63007, L"Makefiles", L"mak; make; mk; dsp; msc; msvc", L"", &KeyWords_MAK, { + { STYLE_DEFAULT, 63126, L"Default", L"fore:#0A246A", L"" }, + //{ SCE_MAKE_DEFAULT, L"Default", L"", L"" }, + { SCE_MAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_MAKE_IDENTIFIER,SCE_MAKE_IDEOL,0,0), 63129, L"Identifier", L"fore:#003CE6", L"" }, + { SCE_MAKE_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_MAKE_TARGET, 63204, L"Target", L"fore:#003CE6; back:#FFC000", L"" }, + { SCE_MAKE_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_VBS = { +"alias and as attribute begin boolean byref byte byval call case class compare const continue " +"currency date declare dim do double each else elseif empty end enum eqv erase error event exit " +"explicit false for friend function get global gosub goto if imp implement in integer is let lib " +"load long loop lset me mid mod module new next not nothing null object on option optional or " +"preserve private property public raiseevent redim rem resume return rset select set single " +"static stop string sub then to true type unload until variant wend while with withevents xor", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexVBS = { SCLEX_VBSCRIPT, 63008, L"VBScript", L"vbs; dsm", L"", &KeyWords_VBS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_B_DEFAULT, L"Default", L"", L"" }, + { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" }, + { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" }, + { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_B_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" }, + //{ SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" }, + //{ SCE_B_CONSTANT, L"Constant", L"", L"" }, + //{ SCE_B_DATE, L"Date", L"", L"" }, + //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" }, + //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" }, + //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" }, + //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_VB = { +"addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call " +"case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng " +"cstr ctype date decimal declare default delegate dim directcast do double each else elseif end " +"enum erase error event exit explicit externalsource false finally for friend function get " +"gettype gosub goto handles if implements imports in inherits integer interface is let lib like " +"long loop me mid mod module mustinherit mustoverride mybase myclass namespace new next not " +"nothing notinheritable notoverridable object on option optional or orelse overloads overridable " +"overrides paramarray preserve private property protected public raiseevent randomize readonly " +"redim rem removehandler resume return select set shadows shared short single static step stop " +"strict string structure sub synclock then throw to true try typeof unicode until variant when " +"while with withevents writeonly xor", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexVB = { SCLEX_VB, 63009, L"Visual Basic", L"vb; bas; frm; cls; ctl; pag; dsr; dob", L"", &KeyWords_VB, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_B_DEFAULT, L"Default", L"", L"" }, + { SCE_B_COMMENT, 63127, L"Comment", L"fore:#808080", L"" }, + { SCE_B_KEYWORD, 63128, L"Keyword", L"bold; fore:#B000B0", L"" }, + { SCE_B_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_B_STRING,SCE_B_STRINGEOL,0,0), 63131, L"String", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_B_NUMBER,SCE_B_DATE,0,0), 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_B_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_B_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF9C00", L"" }, + //{ SCE_B_CONSTANT, L"Constant", L"", L"" }, + //{ SCE_B_KEYWORD2, L"Keyword 2", L"", L"" }, + //{ SCE_B_KEYWORD3, L"Keyword 3", L"", L"" }, + //{ SCE_B_KEYWORD4, L"Keyword 4", L"", L"" }, + //{ SCE_B_ASM, L"Inline Asm", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_JS = { +"abstract boolean break byte case catch char class const continue debugger default delete do " +"double else enum export extends false final finally float for function goto if implements " +"import in instanceof int interface let long native new null package private protected public " +"return short static super switch synchronized this throw throws transient true try typeof var " +"void volatile while with", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexJS = { SCLEX_CPP, 63010, L"JavaScript", L"js; jse; jsm; json; as", L"", &KeyWords_JS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, + { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + //{ SCE_C_UUID, L"UUID", L"", L"" }, + //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" }, + //{ SCE_C_WORD2, L"Word 2", L"", L"" }, + //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_JAVA = { +"@interface abstract assert boolean break byte case catch char class const " +"continue default do double else enum extends final finally float for future " +"generic goto if implements import inner instanceof int interface long " +"native new null outer package private protected public rest return " +"short static super switch synchronized this throw throws transient try " +"var void volatile while " +"@Deprecated @Documented @FlaskyTest @Inherited @JavascriptInterface " +"@LargeTest @MediumTest @Override @Retention " +"@SmallTest @Smoke @Supress @SupressLint @SupressWarnings @Target @TargetApi " +"@TestTarget @TestTargetClass @UiThreadTest", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexJAVA = { SCLEX_CPP, 63011, L"Java Source Code", L"java", L"", &KeyWords_JAVA, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_COMMENT, 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#A46000", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, + { SCE_C_REGEX, 63135, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + //{ SCE_C_UUID, L"UUID", L"", L"" }, + //{ SCE_C_PREPROCESSOR, L"Preprocessor", L"fore:#FF8000", L"" }, + //{ SCE_C_WORD2, L"Word 2", L"", L"" }, + //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_PAS = { +"absolute abstract alias and array as asm assembler begin break case cdecl class const constructor continue cppdecl default " +"destructor dispose div do downto else end end. except exit export exports external false far far16 file finalization finally for " +"forward function goto if implementation in index inherited initialization inline interface is label library local message mod " +"name near new nil nostackframe not object of oldfpccall on operator or out overload override packed pascal private procedure " +"program property protected public published raise read record register reintroduce repeat resourcestring safecall self set shl " +"shr softfloat stdcall stored string then threadvar to true try type unit until uses var virtual while with write xor", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexPAS = { SCLEX_PASCAL, 63012, L"Pascal Source Code", L"pas; dpr; dpk; dfm; inc; pp", L"", &KeyWords_PAS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_PAS_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_PAS_COMMENT,SCE_PAS_COMMENT2,SCE_PAS_COMMENTLINE,0), 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_PAS_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" }, + { SCE_PAS_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_PAS_STRING,SCE_PAS_CHARACTER,SCE_PAS_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_PAS_NUMBER,SCE_PAS_HEXNUMBER,0,0), 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_PAS_OPERATOR, 63132, L"Operator", L"bold", L"" }, + { SCE_PAS_ASM, 63205, L"Inline Asm", L"fore:#0000FF", L"" }, + { MULTI_STYLE(SCE_PAS_PREPROCESSOR,SCE_PAS_PREPROCESSOR2,0,0), 63133, L"Preprocessor", L"fore:#FF00FF", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_ASM = { +"aaa aad aam aas adc add and arpl bound bsf bsr bswap bt btc btr bts call cbw cdq cflush clc cld " +"cli clts cmc cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle cmovna cmovnae " +"cmovnb cmovnbe cmovnc cmovne cmovng cmovnge cmovnl cmovnle cmovno cmovnp cmovns cmovnz cmovo " +"cmovp cmovpe cmovpo cmovs cmovz cmp cmps cmpsb cmpsd cmpsq cmpsw cmpxchg cmpxchg486 cmpxchg8b " +"cpuid cwd cwde daa das dec div emms enter esc femms hlt ibts icebp idiv imul in inc ins insb " +"insd insw int int01 int03 int1 int3 into invd invlpg iret iretd iretdf iretf iretw ja jae jb jbe " +"jc jcxz je jecxz jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz " +"jo jp jpe jpo js jz lahf lar lds lea leave les lfs lgdt lgs lidt lldt lmsw loadall loadall286 " +"lock lods lodsb lodsd lodsq lodsw loop loopd loope looped loopew loopne loopned loopnew loopnz " +"loopnzd loopnzw loopw loopz loopzd loopzw lsl lss ltr mov movs movsb movsd movsq movsw movsx " +"movsxd movzx mul neg nop not or out outs outsb outsd outsw pop popa popad popaw popf popfd popfw " +"push pusha pushad pushaw pushd pushf pushfd pushfw pushw rcl rcr rdmsr rdpmc rdshr rdtsc rep " +"repe repne repnz repz ret retf retn rol ror rsdc rsldt rsm rsts sahf sal salc sar sbb scas scasb " +"scasd scasq scasw seta setae setb setbe setc sete setg setge setl setle setna setnae setnb " +"setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets " +"setz sgdt shl shld shr shrd sidt sldt smi smint smintold smsw stc std sti stos stosb stosd stosq " +"stosw str sub svdc svldt svts syscall sysenter sysexit sysret test ud0 ud1 ud2 umov verr verw " +"wait wbinvd wrmsr wrshr xadd xbts xchg xlat xlatb xor", +"f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne " +"fcmovnu fcmovu fcom fcomi fcomip fcomp fcompp fcos fdecstp fdisi fdiv fdivp fdivr fdivrp feni " +"ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr " +"fld fld1 fldcw fldenv fldenvd fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex " +"fndisi fneni fninit fnop fnsave fnsaved fnsavew fnstcw fnstenv fnstenvd fnstenvw fnstsw fpatan " +"fprem fprem1 fptan frndint frstor frstord frstorw fsave fsaved fsavew fscale fsetpm fsin fsincos " +"fsqrt fst fstcw fstenv fstenvd fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fucom fucomp " +"fucompp fwait fxam fxch fxtract fyl2x fyl2xp1", +"ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp " +"ebx ecx edi edx eip es esi esp fs gs mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 r10 r10b r10d r10w r11 r11b " +"r11d r11w r12 r12b r12d r12w r13 r13b r13d r13w r14 r14b r14d r14w r15 r15b r15d r15w r8 r8b r8d " +"r8w r9 r9b r9d r9w rax rbp rbx rcx rdi rdx rip rsi rsp si sp ss st st0 st1 st2 st3 st4 st5 st6 " +"st7 tr3 tr4 tr5 tr6 tr7 xmm0 xmm1 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm2 xmm3 xmm4 xmm5 xmm6 " +"xmm7 xmm8 xmm9 ymm0 ymm1 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 " +"ymm9", +"%arg %assign %define %elif %elifctk %elifdef %elifid %elifidn %elifidni %elifmacro %elifnctk " +"%elifndef %elifnid %elifnidn %elifnidni %elifnmacro %elifnnum %elifnstr %elifnum %elifstr %else " +"%endif %endmacro %endrep %error %exitrep %iassign %idefine %if %ifctk %ifdef %ifid %ifidn " +"%ifidni %ifmacro %ifnctk %ifndef %ifnid %ifnidn %ifnidni %ifnmacro %ifnnum %ifnstr %ifnum %ifstr " +"%imacro %include %line %local %macro %out %pop %push %rep %repl %rotate %stacksize %strlen " +"%substr %undef %xdefine %xidefine .186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p " +".8086 .8087 .alpha .break .code .const .continue .cref .data .data? .dosseg .else .elseif .endif " +".endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef " +".errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro " +".listmacroall .model .msfloat .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall " +".seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist absolute " +"alias align alignb assume at bits catstr comm comment common cpu db dd df dosseg dq dt dup dw " +"echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn " +"elseifidni elseifnb elseifndef end endif endm endp ends endstruc eq equ even exitm export extern " +"externdef extrn for forc ge global goto group gt high highword iend if if1 if2 ifb ifdef ifdif " +"ifdifi ife ifidn ifidni ifnb ifndef import incbin include includelib instr invoke irp irpc " +"istruc label le length lengthof local low lowword lroffset lt macro mask mod name ne offset " +"opattr option org page popcontext proc proto ptr public purge pushcontext record repeat rept " +"resb resd resq rest resw section seg segment short size sizeof sizestr struc struct substr " +"subtitle subttl textequ this times title type typedef union use16 use32 while width", +"$ $$ %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 .bss .data .text ? @b @f a16 a32 abs addr all assumes at " +"basic byte c carry? casemap common compact cpu dotname dword emulator epilogue error export " +"expr16 expr32 far far16 far32 farstack flat forceframe fortran fword huge language large listing " +"ljmp loadds m510 medium memory near near16 near32 nearstack nodotname noemulator nokeyword " +"noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nosplit " +"nothing notpublic o16 o32 oldmacros oldstructs os_dos overflow? para parity? pascal private " +"prologue qword radix readonly real10 real4 real8 req sbyte scoped sdword seq setif2 sign? small " +"smallstack stdcall sword syscall tbyte tiny use16 use32 uses vararg word wrt zero?", +"addpd addps addsd addss andnpd andnps andpd andps blendpd blendps blendvpd blendvps cmpeqpd " +"cmpeqps cmpeqsd cmpeqss cmplepd cmpleps cmplesd cmpless cmpltpd cmpltps cmpltsd cmpltss cmpnepd " +"cmpneps cmpnesd cmpness cmpnlepd cmpnleps cmpnlesd cmpnless cmpnltpd cmpnltps cmpnltsd cmpnltss " +"cmpordpd cmpordps cmpordsd cmpordss cmpunordpd cmpunordps cmpunordsd cmpunordss comisd comiss " +"crc32 cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi " +"cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvtss2sd cvtss2si cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi " +"cvttsd2si cvttss2si divpd divps divsd divss dppd dpps extractps fxrstor fxsave insertps ldmxscr " +"lfence maskmovdq maskmovdqu maxpd maxps maxss mfence minpd minps minsd minss movapd movaps movd " +"movdq2q movdqa movdqu movhlps movhpd movhps movlhps movlpd movlps movmskpd movmskps movntdq " +"movntdqa movnti movntpd movntps movntq movq movq2dq movsd movss movupd movups mpsadbw mulpd " +"mulps mulsd mulss orpd orps packssdw packsswb packusdw packuswb paddb paddd paddq paddsb paddsiw " +"paddsw paddusb paddusw paddw pand pandn pause paveb pavgb pavgusb pavgw paxsd pblendvb pblendw " +"pcmpeqb pcmpeqd pcmpeqq pcmpeqw pcmpestri pcmpestrm pcmpgtb pcmpgtd pcmpgtq pcmpgtw pcmpistri " +"pcmpistrm pdistib pextrb pextrd pextrq pextrw pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt " +"pfmax pfmin pfmul pfnacc pfpnacc pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr " +"phminposuw pi2fd pinsrb pinsrd pinsrq pinsrw pmachriw pmaddwd pmagw pmaxsb pmaxsd pmaxsw pmaxub " +"pmaxud pmaxuw pminsb pminsd pminsw pminub pminud pminuw pmovmskb pmovsxbd pmovsxbq pmovsxbw " +"pmovsxdq pmovsxwd pmovsxwq pmovzxbd pmovzxbq pmovzxbw pmovzxdq pmovzxwd pmovzxwq pmuldq pmulhriw " +"pmulhrwa pmulhrwc pmulhuw pmulhw pmulld pmullw pmuludq pmvgezb pmvlzb pmvnzb pmvzb popcnt por " +"prefetch prefetchnta prefetcht0 prefetcht1 prefetcht2 prefetchw psadbw pshufd pshufhw pshuflw " +"pshufw pslld pslldq psllq psllw psrad psraw psrld psrldq psrlq psrlw psubb psubd psubq psubsb " +"psubsiw psubsw psubusb psubusw psubw pswapd ptest punpckhbw punpckhdq punpckhqdq punpckhwd " +"punpcklbw punpckldq punpcklqdq punpcklwd pxor rcpps rcpss roundpd roundps roundsd roundss " +"rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss " +"ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps", +"", "", "" }; + + +EDITLEXER lexASM = { SCLEX_ASM, 63013, L"Assembly Script", L"asm", L"", &KeyWords_ASM, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_ASM_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_ASM_COMMENT,SCE_ASM_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_ASM_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_ASM_STRING,SCE_ASM_CHARACTER,SCE_ASM_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_ASM_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_ASM_OPERATOR, 63132, L"Operator", L"fore:#0A246A", L"" }, + { SCE_ASM_CPUINSTRUCTION, 63206, L"CPU Instruction", L"fore:#0A246A", L"" }, + { SCE_ASM_MATHINSTRUCTION, 63207, L"FPU Instruction", L"fore:#0A246A", L"" }, + { SCE_ASM_EXTINSTRUCTION, 63210, L"Extended Instruction", L"fore:#0A246A", L"" }, + { SCE_ASM_DIRECTIVE, 63203, L"Directive", L"fore:#0A246A", L"" }, + { SCE_ASM_DIRECTIVEOPERAND, 63209, L"Directive Operand", L"fore:#0A246A", L"" }, + { SCE_ASM_REGISTER, 63208, L"Register", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_PL = { +"__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__ abs accept alarm and atan2 AUTOLOAD BEGIN " +"bind binmode bless break caller chdir CHECK chmod chomp chop chown chr chroot close closedir " +"cmp connect continue CORE cos crypt dbmclose dbmopen default defined delete DESTROY die do " +"dump each else elsif END endgrent endhostent endnetent endprotoent endpwent endservent eof " +"eq EQ eval exec exists exit exp fcntl fileno flock for foreach fork format formline ge GE " +"getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin " +"getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname " +"getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport " +"getservent getsockname getsockopt given glob gmtime goto grep gt GT hex if index INIT int " +"ioctl join keys kill last lc lcfirst le LE length link listen local localtime lock log " +"lstat lt LT map mkdir msgctl msgget msgrcv msgsnd my ne NE next no not NULL oct open " +"opendir or ord our pack package pipe pop pos print printf prototype push qu quotemeta rand " +"read readdir readline readlink readpipe recv redo ref rename require reset return reverse " +"rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent " +"sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift " +"shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split " +"sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek " +"system syswrite tell telldir tie tied time times truncate uc ucfirst umask undef UNITCHECK " +"unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn " +"when while write xor", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexPL = { SCLEX_PERL, 63014, L"Perl Script", L"pl; pm; cgi; pod", L"", &KeyWords_PL, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_PL_DEFAULT, L"Default", L"", L"" }, + { SCE_PL_COMMENTLINE, 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_PL_WORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, + { SCE_PL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_PL_STRING, 63211, L"String double quoted", L"fore:#008000", L"" }, + { SCE_PL_CHARACTER, 63212, L"String single quoted", L"fore:#008000", L"" }, + { SCE_PL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_PL_OPERATOR, 63132, L"Operator", L"bold", L"" }, + { SCE_PL_SCALAR, 63215, L"Scalar $var", L"fore:#0A246A", L"" }, + { SCE_PL_ARRAY, 63216, L"Array @var", L"fore:#003CE6", L"" }, + { SCE_PL_HASH, 63217, L"Hash %var", L"fore:#B000B0", L"" }, + { SCE_PL_SYMBOLTABLE, 63218, L"Symbol table *var", L"fore:#3A6EA5", L"" }, + { SCE_PL_REGEX, 63219, L"Regex /re/ or m{re}", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_PL_REGSUBST, 63220, L"Substitution s/re/ore/", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_PL_BACKTICKS, 63221, L"Back ticks", L"fore:#E24000; back:#FFF1A8", L"" }, + { SCE_PL_HERE_DELIM, 63223, L"Here-doc (delimiter)", L"fore:#648000", L"" }, + { SCE_PL_HERE_Q, 63224, L"Here-doc (single quoted, q)", L"fore:#648000", L"" }, + { SCE_PL_HERE_QQ, 63225, L"Here-doc (double quoted, qq)", L"fore:#648000", L"" }, + { SCE_PL_HERE_QX, 63226, L"Here-doc (back ticks, qx)", L"fore:#E24000; back:#FFF1A8", L"" }, + { SCE_PL_STRING_Q, 63227, L"Single quoted string (generic, q)", L"fore:#008000", L"" }, + { SCE_PL_STRING_QQ, 63228, L"Double quoted string (qq)", L"fore:#008000", L"" }, + { SCE_PL_STRING_QX, 63229, L"Back ticks (qx)", L"fore:#E24000; back:#FFF1A8", L"" }, + { SCE_PL_STRING_QR, 63230, L"Regex (qr)", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_PL_STRING_QW, 63231, L"Array (qw)", L"fore:#003CE6", L"" }, + { SCE_PL_SUB_PROTOTYPE, 63253, L"Prototype", L"fore:#800080; back:#FFE2FF", L"" }, + { SCE_PL_FORMAT_IDENT, 63254, L"Format identifier", L"bold; fore:#648000; back:#FFF1A8", L"" }, + { SCE_PL_FORMAT, 63255, L"Format body", L"fore:#648000; back:#FFF1A8", L"" }, + { SCE_PL_POD, 63213, L"POD (common)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, + { SCE_PL_POD_VERB, 63214, L"POD (verbatim)", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, + { SCE_PL_DATASECTION, 63222, L"Data section", L"fore:#A46000; back:#FFFFC0; eolfilled", L"" }, + { SCE_PL_ERROR, 63252, L"Parsing error", L"fore:#C80000; back:#FFFF80", L"" }, + //{ SCE_PL_PUNCTUATION, L"Symbols / punctuation (not used)", L"", L"" }, + //{ SCE_PL_PREPROCESSOR, L"Preprocessor (not used)", L"", L"" }, + //{ SCE_PL_LONGQUOTE, L"Long quote (qq, qr, qw, qx) (not used)", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_INI = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexINI = { SCLEX_PROPERTIES, 63015, L"Configuration Files", L"ini; inf; reg; cfg; properties; oem; sif; url; sed; theme", L"", &KeyWords_INI, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_PROPS_DEFAULT, L"Default", L"", L"" }, + { SCE_PROPS_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_PROPS_SECTION, 63232, L"Section", L"fore:#000000; back:#FF8040; bold; eolfilled", L"" }, + { SCE_PROPS_ASSIGNMENT, 63233, L"Assignment", L"fore:#FF0000", L"" }, + { SCE_PROPS_DEFVAL, 63234, L"Default Value", L"fore:#FF0000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_BAT = { +"arp assoc attrib bcdedit bootcfg break cacls call cd change chcp chdir chkdsk chkntfs choice cipher " +"cleanmgr cls cmd cmdkey color com comp compact con convert copy country ctty date defined defrag del " +"dir disableextensions diskcomp diskcopy diskpart do doskey driverquery echo echo. else enableextensions " +"enabledelayedexpansion endlocal equ erase errorlevel exist exit expand fc find findstr for forfiles format " +"fsutil ftp ftype geq goto gpresult gpupdate graftabl gtr help icacls if in ipconfig kill label leq loadfix " +"loadhigh logman logoff lpt lss md mem mkdir mklink mode more move msg msiexe nbtstat neq net netstat netsh " +"not nslookup nul openfiles path pathping pause perfmon popd powercfg print prompt pushd rd recover reg regedit " +"regsvr32 rem ren rename replace rmdir robocopy route runas rundll32 sc schtasks sclist set setlocal sfc shift " +"shutdown sort start subst systeminfo taskkill tasklist time timeout title tracert tree type typeperf ver verify " +"vol wmic xcopy", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexBAT = { SCLEX_BATCH, 63016, L"Batch Files", L"bat; cmd", L"", &KeyWords_BAT, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_BAT_DEFAULT, L"Default", L"", L"" }, + { SCE_BAT_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_BAT_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, + { SCE_BAT_IDENTIFIER, 63129, L"Identifier", L"fore:#003CE6; back:#FFF1A8", L"" }, + { SCE_BAT_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { MULTI_STYLE(SCE_BAT_COMMAND,SCE_BAT_HIDE,0,0), 63236, L"Command", L"bold", L"" }, + { SCE_BAT_LABEL, 63235, L"Label", L"fore:#C80000; back:#F4F4F4; eolfilled", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_DIFF = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexDIFF = { SCLEX_DIFF, 63017, L"Diff Files", L"diff; patch", L"", &KeyWords_DIFF, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_DIFF_DEFAULT, L"Default", L"", L"" }, + { SCE_DIFF_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_DIFF_COMMAND, 63236, L"Command", L"bold; fore:#0A246A", L"" }, + { SCE_DIFF_HEADER, 63238, L"Source and Destination", L"fore:#C80000; back:#FFF1A8; eolfilled", L"" }, + { SCE_DIFF_POSITION, 63239, L"Position Setting", L"fore:#0000FF", L"" }, + { SCE_DIFF_ADDED, 63240, L"Line Addition", L"fore:#002000; back:#80FF80; eolfilled", L"" }, + { SCE_DIFF_DELETED, 63241, L"Line Removal", L"fore:#200000; back:#FF8080; eolfilled", L"" }, + { SCE_DIFF_CHANGED, 63242, L"Line Change", L"fore:#000020; back:#8080FF; eolfilled", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_SQL = { +"abort accessible action add after all alter analyze and as asc asensitive attach autoincrement " +"before begin between bigint binary bit blob both by call cascade case cast change char character " +"check collate column commit condition conflict constraint continue convert create cross current_date " +"current_time current_timestamp current_user cursor database databases date day_hour day_microsecond " +"day_minute day_second dec decimal declare default deferrable deferred delayed delete desc describe " +"detach deterministic distinct distinctrow div double drop dual each else elseif enclosed end enum " +"escape escaped except exclusive exists exit explain fail false fetch float float4 float8 for force " +"foreign from full fulltext glob grant group having high_priority hour_microsecond hour_minute " +"hour_second if ignore immediate in index infile initially inner inout insensitive insert instead int " +"int1 int2 int3 int4 int8 integer intersect interval into is isnull iterate join key keys kill " +"leading leave left like limit linear lines load localtime localtimestamp lock long longblob longtext " +"loop low_priority master_ssl_verify_server_cert match merge mediumblob mediumint mediumtext middleint " +"minute_microsecond minute_second mod modifies natural no no_write_to_binlog not notnull null numeric " +"of offset on optimize option optionally or order out outer outfile plan pragma precision primary " +"procedure purge query raise range read read_only read_write reads real references regexp reindex " +"release rename repeat replace require restrict return revoke right rlike rollback row rowid schema " +"schemas second_microsecond select sensitive separator set show smallint spatial specific sql " +"sql_big_result sql_calc_found_rows sql_small_result sqlexception sqlstate sqlwarning ssl starting " +"straight_join table temp temporary terminated text then time timestamp tinyblob tinyint tinytext to " +"trailing transaction trigger true undo union unique unlock unsigned update usage use using utc_date " +"utc_time utc_timestamp vacuum values varbinary varchar varcharacter varying view virtual when where " +"while with write xor year_month zerofill", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexSQL = { SCLEX_SQL, 63018, L"SQL Query", L"sql", L"", &KeyWords_SQL, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_SQL_DEFAULT, L"Default", L"", L"" }, + { SCE_SQL_COMMENT, 63127, L"Comment", L"fore:#505050", L"" }, + { SCE_SQL_WORD, 63128, L"Keyword", L"bold; fore:#800080", L"" }, + { MULTI_STYLE(SCE_SQL_STRING,SCE_SQL_CHARACTER,0,0), 63131, L"String", L"fore:#008000; back:#FFF1A8", L"" }, + { SCE_SQL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" }, + { SCE_SQL_QUOTEDIDENTIFIER, 63243, L"Quoted Identifier", L"fore:#800080; back:#FFCCFF", L"" }, + { SCE_SQL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_SQL_OPERATOR, 63132, L"Operator", L"bold; fore:#800080", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_PY = { +"and as assert break class continue def del elif else except " +"exec False finally for from global if import in is lambda None " +"nonlocal not or pass print raise return True try while with yield", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexPY = { SCLEX_PYTHON, 63019, L"Python Script", L"py; pyw", L"", &KeyWords_PY, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_P_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#880000", L"" }, + { SCE_P_WORD, 63128, L"Keyword", L"fore:#000088", L"" }, + { SCE_P_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,0,0), 63211, L"String double quoted", L"fore:#008800", L"" }, + { SCE_P_CHARACTER, 63212, L"String single quoted", L"fore:#008800", L"" }, + { SCE_P_TRIPLEDOUBLE, 63244, L"String triple double quotes", L"fore:#008800", L"" }, + { SCE_P_TRIPLE, 63245, L"String triple single quotes", L"fore:#008800", L"" }, + { SCE_P_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" }, + { SCE_P_OPERATOR, 63132, L"Operator", L"bold; fore:#666600", L"" }, + { SCE_P_DEFNAME, 63247, L"Function name", L"fore:#660066", L"" }, + { SCE_P_CLASSNAME, 63246, L"Class name", L"fore:#660066", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_CONF = { +"acceptfilter acceptmutex acceptpathinfo accessconfig accessfilename action addalt addaltbyencoding " +"addaltbytype addcharset adddefaultcharset adddescription addencoding addhandler addicon addiconbyencoding " +"addiconbytype addinputfilter addlanguage addmodule addmoduleinfo addoutputfilter addoutputfilterbytype " +"addtype agentlog alias aliasmatch all allow allowconnect allowencodedslashes allowmethods allowoverride " +"allowoverridelist anonymous anonymous_authoritative anonymous_logemail anonymous_mustgiveemail " +"anonymous_nouserid anonymous_verifyemail assignuserid asyncrequestworkerfactor authauthoritative " +"authbasicauthoritative authbasicfake authbasicprovider authbasicusedigestalgorithm authdbauthoritative " +"authdbduserpwquery authdbduserrealmquery authdbgroupfile authdbmauthoritative authdbmgroupfile " +"authdbmtype authdbmuserfile authdbuserfile authdigestalgorithm authdigestdomain authdigestfile " +"authdigestgroupfile authdigestnccheck authdigestnonceformat authdigestnoncelifetime authdigestprovider " +"authdigestqop authdigestshmemsize authformauthoritative authformbody authformdisablenostore authformfakebasicauth " +"authformlocation authformloginrequiredlocation authformloginsuccesslocation authformlogoutlocation authformmethod " +"authformmimetype authformpassword authformprovider authformsitepassphrase authformsize authformusername " +"authgroupfile authldapauthoritative authldapauthorizeprefix authldapbindauthoritative authldapbinddn " +"authldapbindpassword authldapcharsetconfig authldapcompareasuser authldapcomparednonserver " +"authldapdereferencealiases authldapenabled authldapfrontpagehack authldapgroupattribute " +"authldapgroupattributeisdn authldapinitialbindasuser authldapinitialbindpattern authldapmaxsubgroupdepth " +"authldapremoteuserattribute authldapremoteuserisdn authldapsearchasuser authldapsubgroupattribute " +"authldapsubgroupclass authldapurl authmerging authname authncachecontext authncacheenable authncacheprovidefor " +"authncachesocache authncachetimeout authnprovideralias authnzfcgicheckauthnprovider authnzfcgidefineprovider " +"authtype authuserfile authzdbdlogintoreferer authzdbdquery authzdbdredirectquery authzdbmtype " +"authzsendforbiddenonfailure balancergrowth balancerinherit balancermember balancerpersist bindaddress " +"browsermatch browsermatchnocase bs2000account bufferedlogs buffersize cachedefaultexpire cachedetailheader " +"cachedirlength cachedirlevels cachedisable cacheenable cacheexpirycheck cachefile cacheforcecompletion " +"cachegcclean cachegcdaily cachegcinterval cachegcmemusage cachegcunused cacheheader cacheignorecachecontrol " +"cacheignoreheaders cacheignorenolastmod cacheignorequerystring cacheignoreurlsessionidentifiers " +"cachekeybaseurl cachelastmodifiedfactor cachelock cachelockmaxage cachelockpath cachemaxexpire " +"cachemaxfilesize cacheminexpire cacheminfilesize cachenegotiateddocs cachequickhandler cachereadsize " +"cachereadtime cacheroot cachesize cachesocache cachesocachemaxsize cachesocachemaxtime cachesocachemintime " +"cachesocachereadsize cachesocachereadtime cachestaleonerror cachestoreexpired cachestorenostore cachestoreprivate " +"cachetimemargin cgidscripttimeout cgimapextension cgipassauth cgivar charsetdefault charsetoptions charsetsourceenc " +"checkcaseonly checkspelling childperuserid chrootdir clearmodulelist contentdigest cookiedomain cookieexpires " +"cookielog cookiename cookiestyle cookietracking coredumpdirectory customlog dav davdepthinfinity davgenericlockdb " +"davlockdb davmintimeout dbdexptime dbdinitsql dbdkeep dbdmax dbdmin dbdparams dbdpersist dbdpreparesql dbdriver " +"defaulticon defaultlanguage defaultruntimedir defaulttype define deflatebuffersize deflatecompressionlevel " +"deflatefilternote deflateinflatelimitrequestbody deflateinflateratioburst deflateinflateratiolimit deflatememlevel " +"deflatewindowsize deny directory directorycheckhandler directoryindex directoryindexredirect directorymatch " +"directoryslash documentroot dtraceprivileges dumpioinput dumpiooutput else elseif enableexceptionhook enablemmap " +"enablesendfile error errordocument errorlog errorlogformat example expiresactive expiresbytype expiresdefault " +"extendedstatus extfilterdefine extfilteroptions fallbackresource fancyindexing fileetag files filesmatch " +"filterchain filterdeclare filterprotocol filterprovider filtertrace forcelanguagepriority forcetype forensiclog " +"from globallog gracefulshutdowntimeout group h2direct h2maxsessionstreams h2maxworkeridleseconds h2maxworkers " +"h2minworkers h2moderntlsonly h2push h2pushdiarysize h2pushpriority h2serializeheaders h2sessionextrafiles " +"h2streammaxmemsize h2tlscooldownsecs h2tlswarmupsize h2upgrade h2windowsize header headername heartbeataddress " +"heartbeatlisten heartbeatmaxservers heartbeatstorage hostnamelookups identitycheck identitychecktimeout " +"if ifdefine ifmodule ifversion imapbase imapdefault imapmenu include includeoptional indexheadinsert " +"indexignore indexignorereset indexoptions indexorderdefault indexstylesheet inputsed isapiappendlogtoerrors " +"isapiappendlogtoquery isapicachefile isapifakeasync isapilognotsupported isapireadaheadbuffer keepalive " +"keepalivetimeout keptbodysize languagepriority ldapcacheentries ldapcachettl ldapconnectionpoolttl " +"ldapconnectiontimeout ldaplibrarydebug ldapopcacheentries ldapopcachettl ldapreferralhoplimit ldapreferrals " +"ldapretries ldapretrydelay ldapsharedcachefile ldapsharedcachesize ldaptimeout ldaptrustedca ldaptrustedcatype " +"ldaptrustedclientcert ldaptrustedglobalcert ldaptrustedmode ldapverifyservercert limit limitexcept " +"limitinternalrecursion limitrequestbody limitrequestfields limitrequestfieldsize limitrequestline " +"limitxmlrequestbody listen listenbacklog listencoresbucketsratio loadfile loadmodule location " +"locationmatch lockfile logformat logiotrackttfb loglevel logmessage luaauthzprovider luacodecache " +"luahookaccesschecker luahookauthchecker luahookcheckuserid luahookfixups luahookinsertfilter luahooklog " +"luahookmaptostorage luahooktranslatename luahooktypechecker luainherit luainputfilter luamaphandler " +"luaoutputfilter luapackagecpath luapackagepath luaquickhandler luaroot luascope macro maxclients " +"maxconnectionsperchild maxkeepaliverequests maxmemfree maxrangeoverlaps maxrangereversals maxranges " +"maxrequestsperchild maxrequestsperthread maxrequestworkers maxspareservers maxsparethreads maxthreads " +"maxthreadsperchild mcachemaxobjectcount mcachemaxobjectsize mcachemaxstreamingbuffer mcacheminobjectsize " +"mcacheremovalalgorithm mcachesize memcacheconnttl mergetrailers metadir metafiles metasuffix mimemagicfile " +"minspareservers minsparethreads mmapfile modemstandard modmimeusepathinfo multiviewsmatch mutex namevirtualhost " +"nocache noproxy numservers nwssltrustedcerts nwsslupgradeable options order outputsed passenv pidfile port " +"privilegesmode protocol protocolecho protocols protocolshonororder proxy proxyaddheaders proxybadheader " +"proxyblock proxydomain proxyerroroverride proxyexpressdbmfile proxyexpressdbmtype proxyexpressenable " +"proxyftpdircharset proxyftpescapewildcards proxyftplistonwildcard proxyhcexpr proxyhctemplate proxyhctpsize " +"proxyhtmlbufsize proxyhtmlcharsetout proxyhtmldoctype proxyhtmlenable proxyhtmlevents proxyhtmlextended " +"proxyhtmlfixups proxyhtmlinterp proxyhtmllinks proxyhtmlmeta proxyhtmlstripcomments proxyhtmlurlmap " +"proxyiobuffersize proxymatch proxymaxforwards proxypass proxypassinherit proxypassinterpolateenv " +"proxypassmatch proxypassreverse proxypassreversecookiedomain proxypassreversecookiepath proxypreservehost " +"proxyreceivebuffersize proxyremote proxyremotematch proxyrequests proxyscgiinternalredirect proxyscgisendfile " +"proxyset proxysourceaddress proxystatus proxytimeout proxyvia qsc qualifyredirecturl readmename " +"receivebuffersize redirect redirectmatch redirectpermanent redirecttemp refererignore refererlog " +"reflectorheader remoteipheader remoteipinternalproxy remoteipinternalproxylist remoteipproxiesheader " +"remoteiptrustedproxy remoteiptrustedproxylist removecharset removeencoding removehandler removeinputfilter " +"removelanguage removeoutputfilter removetype requestheader requestreadtimeout require requireall " +"requireany requirenone resourceconfig rewritebase rewritecond rewriteengine rewritelock rewritelog " +"rewriteloglevel rewritemap rewriteoptions rewriterule rlimitcpu rlimitmem rlimitnproc satisfy " +"scoreboardfile script scriptalias scriptaliasmatch scriptinterpretersource scriptlog scriptlogbuffer " +"scriptloglength scriptsock securelisten seerequesttail sendbuffersize serveradmin serveralias serverlimit " +"servername serverpath serverroot serversignature servertokens servertype session sessioncookiename " +"sessioncookiename2 sessioncookieremove sessioncryptocipher sessioncryptodriver sessioncryptopassphrase " +"sessioncryptopassphrasefile sessiondbdcookiename sessiondbdcookiename2 sessiondbdcookieremove " +"sessiondbddeletelabel sessiondbdinsertlabel sessiondbdperuser sessiondbdselectlabel sessiondbdupdatelabel " +"sessionenv sessionexclude sessionheader sessioninclude sessionmaxage setenv setenvif setenvifexpr " +"setenvifnocase sethandler setinputfilter setoutputfilter singlelisten ssiendtag ssierrormsg ssietag " +"ssilastmodified ssilegacyexprparser ssistarttag ssitimeformat ssiundefinedecho sslcacertificatefile " +"sslcacertificatepath sslcadnrequestfile sslcadnrequestpath sslcarevocationcheck sslcarevocationfile " +"sslcarevocationpath sslcertificatechainfile sslcertificatefile sslcertificatekeyfile sslciphersuite " +"sslcompression sslcryptodevice sslengine sslfips sslhonorcipherorder sslinsecurerenegotiation sslmutex " +"sslocspdefaultresponder sslocspenable sslocspoverrideresponder sslocspproxyurl sslocsprespondertimeout " +"sslocspresponsemaxage sslocspresponsetimeskew sslocspuserequestnonce sslopensslconfcmd ssloptions " +"sslpassphrasedialog sslprotocol sslproxycacertificatefile sslproxycacertificatepath sslproxycarevocationcheck " +"sslproxycarevocationfile sslproxycarevocationpath sslproxycheckpeercn sslproxycheckpeerexpire " +"sslproxycheckpeername sslproxyciphersuite sslproxyengine sslproxymachinecertificatechainfile " +"sslproxymachinecertificatefile sslproxymachinecertificatepath sslproxyprotocol sslproxyverify " +"sslproxyverifydepth sslrandomseed sslrenegbuffersize sslrequire sslrequiressl sslsessioncache " +"sslsessioncachetimeout sslsessionticketkeyfile sslsessiontickets sslsrpunknownuserseed " +"sslsrpverifierfile sslstaplingcache sslstaplingerrorcachetimeout sslstaplingfaketrylater " +"sslstaplingforceurl sslstaplingrespondertimeout sslstaplingresponsemaxage sslstaplingresponsetimeskew " +"sslstaplingreturnrespondererrors sslstaplingstandardcachetimeout sslstrictsnivhostcheck sslusername " +"sslusestapling sslverifyclient sslverifydepth startservers startthreads substitute substituteinheritbefore " +"substitutemaxlinelength suexec suexecusergroup threadlimit threadsperchild threadstacksize timeout " +"traceenable transferlog typesconfig undefine undefmacro unsetenv use usecanonicalname usecanonicalphysicalport " +"user userdir vhostcgimode vhostcgiprivs vhostgroup vhostprivs vhostsecure vhostuser virtualdocumentroot " +"virtualdocumentrootip virtualhost virtualscriptalias virtualscriptaliasip watchdoginterval win32disableacceptex " +"xbithack xml2encalias xml2encdefault xml2startparse", +"", //"on off standalone inetd force-response-1.0 downgrade-1.0 nokeepalive indexes includes followsymlinks none x-compress x-gzip", +"", "", "", "", "", "", "" }; + + +EDITLEXER lexCONF = { SCLEX_CONF, 63020, L"Apache Config Files", L"conf; htaccess", L"", &KeyWords_CONF, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { SCE_CONF_COMMENT, 63127, L"Comment", L"fore:#648000", L"" }, + { SCE_CONF_STRING, 63131, L"String", L"fore:#B000B0", L"" }, + { SCE_CONF_NUMBER, 63130, L"Number", L"fore:#FF4000", L"" }, + { SCE_CONF_DIRECTIVE, 63203, L"Directive", L"fore:#003CE6", L"" }, + { SCE_CONF_IP, 63248, L"IP Address", L"bold; fore:#FF4000", L"" }, +// Not used by lexer { SCE_CONF_IDENTIFIER, L"Identifier", L"", L"" }, +// Lexer is buggy { SCE_CONF_OPERATOR, L"Operator", L"", L"" }, +// Lexer is buggy { SCE_CONF_PARAMETER, L"Runtime Directive Parameter", L"", L"" }, +// Lexer is buggy { SCE_CONF_EXTENSION, L"Extension", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_PS = { +"begin break catch continue data do dynamicparam else elseif end exit filter finally for foreach " +"from function if in local param private process return switch throw trap try until where while", +"add-computer add-content add-history add-member add-pssnapin add-type checkpoint-computer " +"clear-content clear-eventlog clear-history clear-host clear-item clear-itemproperty " +"clear-variable compare-object complete-transaction connect-wsman convertfrom-csv " +"convertfrom-securestring convertfrom-stringdata convert-path convertto-csv convertto-html " +"convertto-securestring convertto-xml copy-item copy-itemproperty debug-process " +"disable-computerrestore disable-psbreakpoint disable-psremoting disable-pssessionconfiguration " +"disable-wsmancredssp disconnect-wsman enable-computerrestore enable-psbreakpoint " +"enable-psremoting enable-pssessionconfiguration enable-wsmancredssp enter-pssession " +"exit-pssession export-alias export-clixml export-console export-counter export-csv " +"export-formatdata export-modulemember export-pssession foreach-object format-custom format-list " +"format-table format-wide get-acl get-alias get-authenticodesignature get-childitem get-command " +"get-computerrestorepoint get-content get-counter get-credential get-culture get-date get-event " +"get-eventlog get-eventsubscriber get-executionpolicy get-formatdata get-help get-history " +"get-host get-hotfix get-item get-itemproperty get-job get-location get-member get-module " +"get-pfxcertificate get-process get-psbreakpoint get-pscallstack get-psdrive get-psprovider " +"get-pssession get-pssessionconfiguration get-pssnapin get-random get-service get-tracesource " +"get-transaction get-uiculture get-unique get-variable get-verb get-winevent get-wmiobject " +"get-wsmancredssp get-wsmaninstance group-object import-alias import-clixml import-counter " +"import-csv import-localizeddata import-module import-pssession invoke-command invoke-expression " +"invoke-history invoke-item invoke-restmethod invoke-webrequest invoke-wmimethod " +"invoke-wsmanaction join-path limit-eventlog measure-command measure-object move-item " +"move-itemproperty new-alias new-event new-eventlog new-item new-itemproperty new-module " +"new-modulemanifest new-object new-psdrive new-pssession new-pssessionoption new-service " +"new-timespan new-variable new-webserviceproxy new-wsmaninstance new-wsmansessionoption " +"out-default out-file out-gridview out-host out-null out-printer out-string pop-location " +"push-location read-host receive-job register-engineevent register-objectevent " +"register-pssessionconfiguration register-wmievent remove-computer remove-event remove-eventlog " +"remove-item remove-itemproperty remove-job remove-module remove-psbreakpoint remove-psdrive " +"remove-pssession remove-pssnapin remove-variable remove-wmiobject remove-wsmaninstance " +"rename-item rename-itemproperty reset-computermachinepassword resolve-path restart-computer " +"restart-service restore-computer resume-service select-object select-string select-xml " +"send-mailmessage set-acl set-alias set-authenticodesignature set-content set-date " +"set-executionpolicy set-item set-itemproperty set-location set-psbreakpoint set-psdebug " +"set-pssessionconfiguration set-service set-strictmode set-tracesource set-variable " +"set-wmiinstance set-wsmaninstance set-wsmanquickconfig show-eventlog sort-object split-path " +"start-job start-process start-service start-sleep start-transaction start-transcript " +"stop-computer stop-job stop-process stop-service stop-transcript suspend-service tee-object " +"test-computersecurechannel test-connection test-modulemanifest test-path test-wsman " +"trace-command undo-transaction unregister-event unregister-pssessionconfiguration " +"update-formatdata update-list update-typedata use-transaction wait-event wait-job wait-process " +"where-object write-debug write-error write-eventlog write-host write-output write-progress " +"write-verbose write-warning", +"ac asnp cat cd chdir clc clear clhy cli clp cls clv compare copy cp cpi cpp cvpa dbp del diff " +"dir ebp echo epal epcsv epsn erase etsn exsn fc fl foreach ft fw gal gbp gc gci gcm gcs gdr ghy " +"gi gjb gl gm gmo gp gps group gsn gsnp gsv gu gv gwmi h help history icm iex ihy ii ipal ipcsv " +"ipmo ipsn ise iwmi kill lp ls man md measure mi mkdir more mount move mp mv nal ndr ni nmo nsn " +"nv ogv oh popd ps pushd pwd r rbp rcjb rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rv " +"rvpa rwmi sajb sal saps sasv sbp sc select set si sl sleep sort sp spjb spps spsv start sv swmi " +"tee type where wjb write", +"importsystemmodules prompt psedit tabexpansion", +"", "", "", "", "" }; + + +EDITLEXER lexPS = { SCLEX_POWERSHELL, 63021, L"PowerShell Script", L"ps1; psd1; psm1", L"", &KeyWords_PS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_POWERSHELL_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_POWERSHELL_COMMENT,SCE_POWERSHELL_COMMENTSTREAM,0,0), 63127, L"Comment", L"fore:#646464", L"" }, + { SCE_POWERSHELL_KEYWORD, 63128, L"Keyword", L"bold; fore:#804000", L"" }, + { SCE_POWERSHELL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_POWERSHELL_STRING,SCE_POWERSHELL_CHARACTER,0,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_POWERSHELL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_POWERSHELL_OPERATOR, 63132, L"Operator", L"bold", L"" }, + { SCE_POWERSHELL_VARIABLE, 63249, L"Variable", L"fore:#0A246A", L"" }, + { MULTI_STYLE(SCE_POWERSHELL_CMDLET,SCE_POWERSHELL_FUNCTION,0,0), 63250, L"Cmdlet", L"fore:#804000; back:#FFF1A8", L"" }, + { SCE_POWERSHELL_ALIAS, 63251, L"Alias", L"bold; fore:#0A246A", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_NSIS = { +"!addincludedir !addplugindir !appendfile !cd !define !delfile !echo !else !endif !error " +"!execute !finalize !getdllversion !if !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro !macro " +"!macroend !macroundef !makensis !packhdr !searchparse !searchreplace !system !tempfile !undef !verbose !warning " +".onguiend .onguiinit .oninit .oninstfailed .oninstsuccess .onmouseoversection .onrebootfailed .onselchange " +".onuserabort .onverifyinstdir un.onguiend un.onguiinit un.oninit un.onrebootfailed un.onuninstfailed un.onuninstsuccess " +"un.onuserabort abort addbrandingimage addsize allowrootdirinstall allowskipfiles autoclosewindow " +"bannertrimpath bgfont bggradient brandingtext bringtofront call callinstdll caption changeui checkbitmap " +"clearerrors completedtext componenttext copyfiles crccheck createdirectory createfont createshortcut " +"delete deleteinisec deleteinistr deleteregkey deleteregvalue detailprint detailsbuttontext dirstate dirtext " +"dirvar dirverify enablewindow enumregkey enumregvalue exch exec execshell execwait expandenvstrings " +"file filebufsize fileclose fileerrortext fileexists fileopen fileread filereadbyte filereadutf16le filereadword " +"fileseek filewrite filewritebyte filewriteutf16le filewriteword findclose findfirst findnext findproc " +"findwindow flushini getcurinsttype getcurrentaddress getdlgitem getdllversion getdllversionlocal " +"geterrorlevel getfiletime getfiletimelocal getfontname getfontnamelocal getfontversion getfontversionlocal " +"getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto hidewindow icon " +"ifabort iferrors iffileexists ifrebootflag ifsilent initpluginsdir installbuttontext installcolors installdir " +"installdirregkey instprogressflags insttype insttypegettext insttypesettext intcmp intcmpu intfmt intop " +"iswindow langstring licensebkcolor licensedata licenseforceselection licenselangstring licensetext " +"loadlanguagefile lockwindow logset logtext manifestsupportedos messagebox miscbuttontext name nop outfile page " +"pagecallbacks pop push quit readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel " +"reservefile return rmdir searchpath sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectionin " +"sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage " +"setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype " +"setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes " +"setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent " +"showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps " +"strcpy strlen subcaption unicode uninstallbuttontext uninstallcaption uninstallicon uninstallsubcaption uninstalltext " +"uninstpage unregdll var viaddversionkey vifileversion viproductversion windowicon writeinistr writeregbin " +"writeregdword writeregexpandstr writeregstr writeuninstaller xpstyle", +"${nsisdir} $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $instdir $outdir $cmdline " +"$language $programfiles $programfiles32 $programfiles64 $commonfiles $commonfiles32 $commonfiles64 " +"$desktop $exedir $exefile $exepath $windir $sysdir $temp $startmenu $smprograms $smstartup $quicklaunch " +"$documents $sendto $recent $favorites $music $pictures $videos $nethood $fonts $templates $appdata " +"$localappdata $printhood $internet_cache $cookies $history $profile $admintools $resources $resources_localized " +"$cdburn_area $hwndparent $pluginsdir ${__date__} ${__file__} ${__function__} ${__global__} ${__line__} " +"${__pageex__} ${__section__} ${__time__} ${__timestamp__} ${__uninstall__}", +"alt charset colored control cur date end global ignorecase leave shift smooth utcdate sw_hide sw_showmaximized " +"sw_showminimized sw_shownormal archive auto oname rebootok nonfatal ifempty nounload filesonly short mb_ok " +"mb_okcancel mb_abortretryignore mb_retrycancel mb_yesno mb_yesnocancel mb_iconexclamation mb_iconinformation " +"mb_iconquestion mb_iconstop mb_usericon mb_topmost mb_setforeground mb_right mb_rtlreading mb_defbutton1 " +"mb_defbutton2 mb_defbutton3 mb_defbutton4 idabort idcancel idignore idno idok idretry idyes sd current all " +"timeout imgid resizetofit listonly textonly both branding hkcr hkey_classes_root hklm hkey_local_machine hkcu " +"hkey_current_user hku hkey_users hkcc hkey_current_config hkdd hkey_dyn_data hkpd hkey_performance_data shctx " +"shell_context left right top bottom true false on off italic underline strike trimleft trimright trimcenter " +"idd_license idd_dir idd_selcom idd_inst idd_instfiles idd_uninst idd_verify force windows nocustom customstring " +"componentsonlyoncustom gray none user highest admin lang hide show nevershow normal silent silentlog solid final " +"zlib bzip2 lzma try ifnewer ifdiff lastused manual alwaysoff normal file_attribute_normal file_attribute_archive " +"hidden file_attribute_hidden offline file_attribute_offline readonly file_attribute_readonly system " +"file_attribute_system temporary file_attribute_temporary custom license components directory instfiles " +"uninstconfirm 32 64 enablecancel noworkingdir plugin rawnl winvista win7 win8 win8.1 win10", +"", "", "", "", "", "" }; + + +EDITLEXER lexNSIS = { SCLEX_NSIS, 63284, L"NSIS Script", L"nsi; nsh", L"", &KeyWords_NSIS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_NSIS_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_NSIS_COMMENT,SCE_NSIS_COMMENTBOX,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_NSIS_STRINGDQ,SCE_NSIS_STRINGLQ,SCE_NSIS_STRINGRQ,0), 63131, L"String", L"fore:#666666; back:#EEEEEE", L"" }, + { SCE_NSIS_FUNCTION, 63277, L"Function", L"fore:#0033CC", L"" }, + { SCE_NSIS_VARIABLE, 63249, L"Variable", L"fore:#CC3300", L"" }, + { SCE_NSIS_STRINGVAR, 63285, L"Variable within String", L"fore:#CC3300; back:#EEEEEE", L"" }, + { SCE_NSIS_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { SCE_NSIS_LABEL, 63286, L"Constant", L"fore:#FF9900", L"" }, + { SCE_NSIS_SECTIONDEF, 63232, L"Section", L"fore:#0033CC", L"" }, + { SCE_NSIS_SUBSECTIONDEF, 63287, L"Sub Section", L"fore:#0033CC", L"" }, + { SCE_NSIS_SECTIONGROUP, 63288, L"Section Group", L"fore:#0033CC", L"" }, + { SCE_NSIS_FUNCTIONDEF, 63289, L"Function Definition", L"fore:#0033CC", L"" }, + { SCE_NSIS_PAGEEX, 63290, L"PageEx", L"fore:#0033CC", L"" }, + { SCE_NSIS_IFDEFINEDEF, 63291, L"If Definition", L"fore:#0033CC", L"" }, + { SCE_NSIS_MACRODEF, 63292, L"Macro Definition", L"fore:#0033CC", L"" }, + //{ SCE_NSIS_USERDEFINED, L"User Defined", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_INNO = { +"code components custommessages dirs files icons ini installdelete langoptions languages messages " +"registry run setup types tasks uninstalldelete uninstallrun _istool", +"allowcancelduringinstall allownetworkdrive allownoicons allowrootdirectory allowuncpath alwaysrestart " +"alwaysshowcomponentslist alwaysshowdironreadypage alwaysshowgrouponreadypage alwaysusepersonalgroup appcomments " +"appcontact appcopyright appenddefaultdirname appenddefaultgroupname appid appmodifypath appmutex appname apppublisher " +"apppublisherurl appreadmefile appsupportphone appsupporturl appupdatesurl appvername appversion architecturesallowed " +"architecturesinstallin64bitmode backcolor backcolor2 backcolordirection backsolid beveledlabel changesassociations " +"changesenvironment closeapplications closeapplicationsfilter compression compressionthreads copyrightfontname " +"copyrightfontsize createappdir createuninstallregkey defaultdirname defaultgroupname defaultuserinfoname " +"defaultuserinfoorg defaultuserinfoserial dialogfontname dialogfontsize direxistswarning disabledirpage " +"disablefinishedpage disableprogramgrouppage disablereadymemo disablereadypage disablestartupprompt " +"disablewelcomepage diskclustersize diskslicesize diskspanning enabledirdoesntexistwarning encryption " +"extradiskspacerequired flatcomponentslist infoafterfile infobeforefile internalcompresslevel languagedetectionmethod " +"languagecodepage languageid languagename licensefile lzmaalgorithm lzmablocksize lzmadictionarysize lzmamatchfinder " +"lzmanumblockthreads lzmanumfastbytes lzmauseseparateprocess mergeduplicatefiles minversion onlybelowversion " +"outputbasefilename outputdir outputmanifestfile password privilegesrequired reservebytes restartapplications " +"restartifneededbyrun righttoleft setupiconfile setuplogging setupmutex showcomponentsizes showlanguagedialog showtaskstreelines " +"showundisplayablelanguages signeduninstaller signeduninstallerdir signtool signtoolretrycount slicesperdisk solidcompression " +"sourcedir strongassemblyname timestamprounding timestampsinutc titlefontname titlefontsize touchdate touchtime uninstallable " +"uninstalldisplayicon uninstalldisplayname uninstallfilesdir uninstalldisplaysize uninstalllogmode uninstallrestartcomputer " +"updateuninstalllogappname usepreviousappdir usepreviousgroup usepreviouslanguage useprevioussetuptype useprevioustasks " +"verb versioninfoproductname useprevioususerinfo userinfopage usesetupldr versioninfocompany versioninfocopyright " +"versioninfodescription versioninfoproductversion versioninfotextversion versioninfoversion versioninfoproducttextversion " +"welcomefontname welcomefontsize windowshowcaption windowstartmaximized windowresizable windowvisible wizardimagealphaformat " +"wizardimagebackcolor wizardimagefile wizardimagestretch wizardsmallimagefile", +"appusermodelid afterinstall attribs beforeinstall check comment components copymode description destdir destname excludes " +"extradiskspacerequired filename flags fontinstall groupdescription hotkey infoafterfile infobeforefile iconfilename " +"iconindex key languages licensefile messagesfile minversion name onlybelowversion parameters permissions root runonceid " +"section source statusmsg string subkey tasks terminalservicesaware type types valuedata valuename valuetype workingdir", +"append define dim else emit elif endif endsub error expr file for if ifdef ifexist ifndef ifnexist include insert pragma " +"sub undef", +"and begin break case const continue do downto else end except finally for function " +"if not of or procedure repeat then to try type until uses var while with", +"", "", "", "" }; + + +EDITLEXER lexINNO = { SCLEX_INNOSETUP, 63293, L"Inno Setup Script", L"iss; isl; islu", L"", &KeyWords_INNO, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_INNO_DEFAULT, L"Default", L"", L"" }, + { SCE_INNO_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_INNO_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, + { SCE_INNO_PARAMETER, 63294, L"Parameter", L"fore:#0000FF", L"" }, + { SCE_INNO_SECTION, 63232, L"Section", L"fore:#000080; bold", L"" }, + { SCE_INNO_PREPROC, 63133, L"Preprocessor", L"fore:#CC0000", L"" }, + { SCE_INNO_INLINE_EXPANSION, 63295, L"Inline Expansion", L"fore:#800080", L"" }, + { SCE_INNO_COMMENT_PASCAL, 63296, L"Pascal Comment", L"fore:#008000", L"" }, + { SCE_INNO_KEYWORD_PASCAL, 63297, L"Pascal Keyword", L"fore:#0000FF", L"" }, + { MULTI_STYLE(SCE_INNO_STRING_DOUBLE,SCE_INNO_STRING_SINGLE,0,0), 63131, L"String", L"", L"" }, + //{ SCE_INNO_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + //{ SCE_INNO_KEYWORD_USER, L"User Defined", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_RUBY = { +"__FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure " +"false for in if module next nil not or redo rescue retry return self super then true " +"undef unless until when while yield", +"", "", "", "", "", "", "", "" }; + +EDITLEXER lexRUBY = { SCLEX_RUBY, 63304, L"Ruby Script", L"rb; ruby; rbw; rake; rjs; Rakefile; gemspec", L"", &KeyWords_RUBY, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_P_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_RB_COMMENTLINE,SCE_P_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_RB_WORD, 63128, L"Keyword", L"fore:#00007F", L"" }, + { SCE_RB_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_RB_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + { SCE_RB_OPERATOR, 63132, L"Operator", L"", L"" }, + { MULTI_STYLE(SCE_RB_STRING,SCE_RB_CHARACTER,SCE_P_STRINGEOL,0), 63131, L"String", L"fore:#FF8000", L"" }, + { SCE_RB_CLASSNAME, 63246, L"Class name", L"fore:#0000FF", L"" }, + { SCE_RB_DEFNAME, 63247, L"Function name", L"fore:#007F7F", L"" }, + { SCE_RB_POD, 63314, L"POD", L"fore:#004000; back:#C0FFC0; eolfilled", L"" }, + { SCE_RB_REGEX, 63315, L"Regex", L"fore:#000000; back:#A0FFA0", L"" }, + { SCE_RB_SYMBOL, 63316, L"Symbol", L"fore:#C0A030", L"" }, + { SCE_RB_MODULE_NAME, 63317, L"Module name", L"fore:#A000A0", L"" }, + { SCE_RB_INSTANCE_VAR, 63318, L"Instance Var", L"fore:#B00080", L"" }, + { SCE_RB_CLASS_VAR, 63319, L"Class Var", L"fore:#8000B0", L"" }, + { SCE_RB_DATASECTION, 63320, L"Data Section", L"fore:#600000; back:#FFF0D8; eolfilled", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_LUA = { +"and break do else elseif end false for function goto if " +"in local nil not or repeat return then true until while", +// Basic Functions +"_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring print rawget rawset " +"require tonumber tostring type unpack _ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT _STDERR " +"_STDIN _STDOUT call dostring foreach foreachi getn globals newtype sort tinsert tremove " +"_G getfenv getmetatable ipairs loadlib next pairs pcall rawequal setfenv setmetatable xpcall " +"string table math coroutine io os debug load module select", +// String Manipulation, Table Manipulation, Mathematical Functions +"abs acos asin atan atan2 ceil cos deg exp floor format frexp gsub ldexp log log10 max min " +"mod rad random randomseed sin sqrt strbyte strchar strfind strlen strlower strrep strsub strupper tan " +"string.byte string.char string.dump string.find string.len string.lower string.rep string.sub string.upper " +"string.format string.gfind string.gsub table.concat table.foreach table.foreachi table.getn table.sort " +"table.insert table.remove table.setn math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos " +"math.deg math.exp math.floor math.frexp math.ldexp math.log math.log10 math.max math.min math.mod " +"math.pi math.pow math.rad math.random math.randomseed math.sin math.sqrt math.tan string.gmatch " +"string.match string.reverse table.maxn math.cosh math.fmod math.modf math.sinh math.tanh math.huge", +// Input and Output Facilities & System Facilities Coroutine Manipulation, +//Input and Output Facilities, System Facilities (coroutine & io & os) +"openfile closefile readfrom writeto appendto remove rename flush seek tmpfile tmpname read " +"write clock date difftime execute exit getenv setlocale time coroutine.create coroutine.resume " +"coroutine.status coroutine.wrap coroutine.yield io.close io.flush io.input io.lines io.open io.output " +"io.read io.tmpfile io.type io.write io.stdin io.stdout io.stderr os.clock os.date os.difftime " +"os.execute os.exit os.getenv os.remove os.rename os.setlocale os.time os.tmpname coroutine.running " +"package.cpath package.loaded package.loadlib package.path package.preload package.seeall io.popen", +"", "", "", "", "" }; + + +EDITLEXER lexLUA = { SCLEX_LUA, 63298, L"Lua Script", L"lua", L"", &KeyWords_LUA, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_LUA_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_LUA_COMMENT,SCE_LUA_COMMENTLINE,SCE_LUA_COMMENTDOC,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_LUA_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + { SCE_LUA_WORD, 63128, L"Keyword", L"fore:#00007F", L"" }, + { SCE_LUA_WORD2, 63321, L"Basic Functions", L"fore:#00007F", L"" }, + { SCE_LUA_WORD3, 63322, L"String, Table & Math Functions", L"fore:#00007F", L"" }, + { SCE_LUA_WORD4, 63323, L"Input, Output & System Facilities", L"fore:#00007F", L"" }, + { MULTI_STYLE(SCE_LUA_STRING,SCE_LUA_STRINGEOL,SCE_LUA_CHARACTER,0), 63131, L"String", L"fore:#B000B0", L"" }, + { SCE_LUA_LITERALSTRING, 63302, L"Literal String", L"fore:#B000B0", L"" }, + { SCE_LUA_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + { SCE_LUA_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_LUA_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_LUA_LABEL, 63235, L"Label", L"fore:#808000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_BASH = { +"alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal calendar case cat " +"cc cd chmod cksum clear cmp col comm compress continue cp cpio crypt csplit ctags cut date " +"dc dd declare deroff dev df diff diff3 dircmp dirname do done du echo ed egrep elif else " +"env esac eval ex exec exit expand export expr false fc fgrep fi file find fmt fold for function " +"functions getconf getopt getopts grep gres hash head help history iconv id if in integer " +"jobs join kill local lc let line ln logname look ls m4 mail mailx make man mkdir more mt mv " +"newgrp nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print printf ps pwd " +"read readonly red return rev rm rmdir sed select set sh shift size sleep sort spell split " +"start stop strings strip stty sum suspend sync tail tar tee test then time times touch tr " +"trap true tsort tty type typeset ulimit umask unalias uname uncompress unexpand uniq unpack " +"unset until uudecode uuencode vi vim vpax wait wc whence which while who wpaste wstart xargs " +"zcat chgrp chown chroot dir dircolors factor groups hostid install link md5sum mkfifo mknod " +"nice pinky printenv ptx readlink seq sha1sum shred stat su tac unlink users vdir whoami yes", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexBASH = { SCLEX_BASH, 63259, L"Shell Script", L"sh", L"", &KeyWords_BASH, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { SCE_SH_ERROR, 63260, L"Error", L"", L"" }, + { SCE_SH_COMMENTLINE, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_SH_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + { SCE_SH_WORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, + { SCE_SH_STRING, 63211, L"String double quoted", L"fore:#008080", L"" }, + { SCE_SH_CHARACTER, 63212, L"String single quoted", L"fore:#800080", L"" }, + { SCE_SH_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_SH_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_SH_SCALAR, 63268, L"Scalar", L"fore:#808000", L"" }, + { SCE_SH_PARAM, 63269, L"Parameter expansion", L"fore:#808000; back:#FFFF99", L"" }, + { SCE_SH_BACKTICKS, 63270, L"Back Ticks", L"fore:#FF0080", L"" }, + { SCE_SH_HERE_DELIM, 63271, L"Here-doc (Delimiter)", L"", L"" }, + { SCE_SH_HERE_Q, 63272, L"Here-doc (Single quoted, q)", L"fore:#008080", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_TCL = { +// TCL Keywords +"after append array auto_execok auto_import auto_load auto_load_index auto_qualify beep " +"bgerror binary break case catch cd clock close concat continue dde default echo else " +"elseif encoding eof error eval exec exit expr fblocked fconfigure fcopy file fileevent " +"flush for foreach format gets glob global history http if incr info interp join lappend " +"lindex linsert list llength load loadTk lrange lreplace lsearch lset lsort memory msgcat " +"namespace open package pid pkg::create pkg_mkIndex Platform-specific proc puts pwd " +"re_syntax read regexp registry regsub rename resource return scan seek set socket source " +"split string subst switch tclLog tclMacPkgSearch tclPkgSetup tclPkgUnknown tell time trace " +"unknown unset update uplevel upvar variable vwait while", +// TK Keywords +"bell bind bindtags bitmap button canvas checkbutton clipboard colors console cursors " +"destroy entry event focus font frame grab grid image Inter-client keysyms label labelframe " +"listbox lower menu menubutton message option options pack panedwindow photo place " +"radiobutton raise scale scrollbar selection send spinbox text tk tk_chooseColor " +"tk_chooseDirectory tk_dialog tk_focusNext tk_getOpenFile tk_messageBox tk_optionMenu " +"tk_popup tk_setPalette tkerror tkvars tkwait toplevel winfo wish wm", +// iTCL Keywords +"@scope body class code common component configbody constructor define destructor hull " +"import inherit itcl itk itk_component itk_initialize itk_interior itk_option iwidgets keep " +"method private protected public", +"", "", "", "", "", "" }; + + +#define SCE_TCL__MULTI_COMMENT MULTI_STYLE(SCE_TCL_COMMENT,SCE_TCL_COMMENTLINE,SCE_TCL_COMMENT_BOX,SCE_TCL_BLOCK_COMMENT) +#define SCE_TCL__MULTI_KEYWORD MULTI_STYLE(SCE_TCL_WORD,SCE_TCL_WORD2,SCE_TCL_WORD3,SCE_TCL_WORD_IN_QUOTE) +#define SCE_TCL__MULTI_SUBSTITUTION MULTI_STYLE(SCE_TCL_SUBSTITUTION,SCE_TCL_SUB_BRACE,0,0) + + +EDITLEXER lexTCL = { SCLEX_TCL, 63273, L"Tcl Script", L"tcl; itcl", L"", &KeyWords_TCL, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { SCE_TCL__MULTI_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_TCL__MULTI_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, + { SCE_TCL_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + { SCE_TCL_IN_QUOTE, 63131, L"String", L"fore:#008080", L"" }, + { SCE_TCL_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_TCL_IDENTIFIER, 63129, L"Identifier", L"fore:#800080", L"" }, + { SCE_TCL__MULTI_SUBSTITUTION, 63274, L"Substitution", L"fore:#CC0000", L"" }, + { SCE_TCL_MODIFIER, 63275, L"Modifier", L"fore:#FF00FF", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_AU3 = { +"and byref case const continuecase continueloop default dim do else elseif endfunc endif " +"endselect endswitch endwith enum exit exitloop false for func global if in local next not " +"or redim return select static step switch then to true until wend while with", +"abs acos adlibregister adlibunregister asc ascw asin assign atan autoitsetoption autoitwingettitle " +"autoitwinsettitle beep binary binarylen binarymid binarytostring bitand bitnot bitor bitrotate " +"bitshift bitxor blockinput break call cdtray ceiling chr chrw clipget clipput consoleread " +"consolewrite consolewriteerror controlclick controlcommand controldisable controlenable " +"controlfocus controlgetfocus controlgethandle controlgetpos controlgettext controlhide " +"controllistview controlmove controlsend controlsettext controlshow controltreeview cos dec " +"dircopy dircreate dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree dllcallbackgetptr " +"dllcallbackregister dllclose dllopen dllstructcreate dllstructgetdata dllstructgetptr " +"dllstructgetsize dllstructsetdata drivegetdrive drivegetfilesystem drivegetlabel drivegetserial " +"drivegettype drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree drivespacetotal " +"drivestatus envget envset envupdate eval execute exp filechangedir fileclose filecopy " +"filecreatentfslink filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile " +"fileflush filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut filegetshortname " +"filegetsize filegettime filegetversion fileinstall filemove fileopen fileopendialog fileread " +"filereadline filerecycle filerecycleempty filesavedialog fileselectfolder filesetattrib filesetpos " +"filesettime filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi guictrlcreatebutton " +"guictrlcreatecheckbox guictrlcreatecombo guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy " +"guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon guictrlcreateinput " +"guictrlcreatelabel guictrlcreatelist guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu " +"guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj guictrlcreatepic guictrlcreateprogress " +"guictrlcreateradio guictrlcreateslider guictrlcreatetab guictrlcreatetabitem guictrlcreatetreeview " +"guictrlcreatetreeviewitem guictrlcreateupdown guictrldelete guictrlgethandle guictrlgetstate " +"guictrlread guictrlrecvmsg guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy " +"guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata guictrlsetdefbkcolor " +"guictrlsetdefcolor guictrlsetfont guictrlsetgraphic guictrlsetimage guictrlsetlimit guictrlsetonevent " +"guictrlsetpos guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete " +"guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators guisetbkcolor guisetcoord " +"guisetcursor guisetfont guisethelp guiseticon guisetonevent guisetstate guisetstyle guistartgroup " +"guiswitch hex hotkeyset httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize " +"inetread inidelete iniread inireadsection inireadsectionnames inirenamesection iniwrite iniwritesection " +"inputbox int isadmin isarray isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword " +"isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor " +"mousegetpos mousemove mouseup mousewheel msgbox number objcreate objcreateinterface objevent objevent " +"objget objname onautoitexitregister onautoitexitunregister opt ping pixelchecksum pixelgetcolor " +"pixelsearch pluginclose pluginopen processclose processexists processgetstats processlist " +"processsetpriority processwait processwaitclose progressoff progresson progressset ptr random regdelete " +"regenumkey regenumval regread regwrite round run runas runaswait runwait send sendkeepactive " +"seterror setextended shellexecute shellexecutewait shutdown sin sleep soundplay soundsetwavevolume " +"splashimageon splashoff splashtexton sqrt srandom statusbargettext stderrread stdinwrite " +"stdioclose stdoutread string stringaddcr stringcompare stringformat stringfromasciiarray stringinstr " +"stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint stringislower " +"stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid " +"stringregexp stringregexpreplace stringreplace stringright stringsplit stringstripcr stringstripws " +"stringtoasciiarray stringtobinary stringtrimleft stringtrimright stringupper tan tcpaccept " +"tcpclosesocket tcpconnect tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup " +"timerdiff timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete " +"trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent trayitemsetstate " +"trayitemsettext traysetclick trayseticon traysetonevent traysetpauseicon traysetstate " +"traysettooltip traytip ubound udpbind udpclosesocket udpopen udprecv udpsend udpshutdown " +"udpstartup vargettype winactivate winactive winclose winexists winflash wingetcaretpos " +"wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess wingetstate " +"wingettext wingettitle winkill winlist winmenuselectitem winminimizeall winminimizeallundo " +"winmove winsetontop winsetstate winsettitle winsettrans winwait winwaitactive winwaitclose " +"winwaitnotactive", +"@appdatacommondir @appdatadir @autoitexe @autoitpid @autoitunicode @autoitversion @autoitx64 " +"@com_eventobj @commonfilesdir @compiled @computername @comspec @cpuarch @cr @crlf @desktopcommondir " +"@desktopdepth @desktopdir @desktopheight @desktoprefresh @desktopwidth @documentscommondir " +"@error @exitcode @exitmethod @extended @favoritescommondir @favoritesdir @gui_ctrlhandle " +"@gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid @gui_winhandle @homedrive @homepath @homeshare " +"@hotkeypressed @hour @inetgetactive @inetgetbytesread @ipaddress1 @ipaddress2 @ipaddress3 " +"@ipaddress4 @kblayout @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang " +"@mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir " +"@programscommondir @programsdir @scriptdir @scriptfullpath @scriptlinenumber @scriptname @sec " +"@startmenucommondir @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide @sw_lock " +"@sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault @sw_showmaximized @sw_showminimized " +"@sw_showminnoactive @sw_showna @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir " +"@tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday @windowsdir " +"@workingdir @yday @year", +"{!} {#} {^} {{} {}} {+} {alt} {altdown} {altup} {appskey} " +"{asc} {backspace} {break} {browser_back} {browser_favorites} {browser_forward} {browser_home} " +"{browser_refresh} {browser_search} {browser_stop} {bs} {capslock} {ctrldown} {ctrlup} " +"{del} {delete} {down} {end} {enter} {esc} {escape} {f1} {f10} {f11} {f12} {f2} {f3} " +"{f4} {f5} {f6} {f7} {f8} {f9} {home} {ins} {insert} {lalt} {launch_app1} {launch_app2} " +"{launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} {lwindown} {lwinup} {media_next} " +"{media_play_pause} {media_prev} {media_stop} {numlock} {numpad0} {numpad1} {numpad2} " +"{numpad3} {numpad4} {numpad5} {numpad6} {numpad7} {numpad8} {numpad9} {numpadadd} " +"{numpaddiv} {numpaddot} {numpadenter} {numpadmult} {numpadsub} {pause} {pgdn} {pgup} " +"{printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {rwinup} {scrolllock} " +"{shiftdown} {shiftup} {sleep} {space} {tab} {up} {volume_down} {volume_mute} {volume_up}", +"#ce #comments-end #comments-start #cs #include #include-once #noautoit3execute #notrayicon " +"#onautoitstartregister #requireadmin", +"#autoit3wrapper_au3check_parameters #autoit3wrapper_au3check_stop_onwarning " +"#autoit3wrapper_change2cui #autoit3wrapper_compression #autoit3wrapper_cvswrapper_parameters " +"#autoit3wrapper_icon #autoit3wrapper_outfile #autoit3wrapper_outfile_type #autoit3wrapper_plugin_funcs " +"#autoit3wrapper_res_comment #autoit3wrapper_res_description #autoit3wrapper_res_field " +"#autoit3wrapper_res_file_add #autoit3wrapper_res_fileversion #autoit3wrapper_res_fileversion_autoincrement " +"#autoit3wrapper_res_icon_add #autoit3wrapper_res_language #autoit3wrapper_res_legalcopyright " +"#autoit3wrapper_res_requestedexecutionlevel #autoit3wrapper_res_savesource #autoit3wrapper_run_after " +"#autoit3wrapper_run_au3check #autoit3wrapper_run_before #autoit3wrapper_run_cvswrapper " +"#autoit3wrapper_run_debug_mode #autoit3wrapper_run_obfuscator #autoit3wrapper_run_tidy " +"#autoit3wrapper_tidy_stop_onerror #autoit3wrapper_useansi #autoit3wrapper_useupx " +"#autoit3wrapper_usex64 #autoit3wrapper_version #endregion #forceref #obfuscator_ignore_funcs " +"#obfuscator_ignore_variables #obfuscator_parameters #region #tidy_parameters", +"", // Reserved for expand +"_arrayadd _arraybinarysearch _arraycombinations _arrayconcatenate _arraydelete _arraydisplay _arrayfindall " +"_arrayinsert _arraymax _arraymaxindex _arraymin _arrayminindex _arraypermute _arraypop _arraypush " +"_arrayreverse _arraysearch _arraysort _arrayswap _arraytoclip _arraytostring _arraytrim _arrayunique _assert " +"_choosecolor _choosefont _clipboard_changechain _clipboard_close _clipboard _countformats _clipboard_empty " +"_clipboard_enumformats _clipboard_formatstr _clipboard_getdata _clipboard_getdataex _clipboard_getformatname " +"_clipboard_getopenwindow _clipboard_getowner _clipboard_getpriorityformat _clipboard_getsequencenumber " +"_clipboard_getviewer _clipboard_isformatavailable _clipboard_open _clipboard_registerformat " +"_clipboard_setdata _clipboard_setdataex _clipboard_setviewer _clipputfile _colorconverthsltorgb " +"_colorconvertrgbtohsl _colorgetblue _colorgetcolorref _colorgetgreen _colorgetred _colorgetrgb " +"_colorsetcolorref _colorsetrgb _crypt_decryptdata _crypt_decryptfile _crypt_derivekey _crypt_destroykey " +"_crypt_encryptdata _crypt_encryptfile _crypt_hashdata _crypt_hashfile _crypt_shutdown _crypt_startup " +"_date_time_comparefiletime _date_time_dosdatetimetoarray _date_time_dosdatetimetofiletime " +"_date_time_dosdatetimetostr _date_time_dosdatetoarray _date_time_dosdatetostr _date_time_dostimetoarray " +"_date_time_dostimetostr _date_time_encodefiletime _date_time_encodesystemtime _date_time_filetimetoarray " +"_date_time_filetimetodosdatetime _date_time_filetimetolocalfiletime _date_time_filetimetostr " +"_date_time_filetimetosystemtime _date_time_getfiletime _date_time_getlocaltime _date_time_getsystemtime " +"_date_time_getsystemtimeadjustment _date_time_getsystemtimeasfiletime _date_time_getsystemtimes " +"_date_time_gettickcount _date_time_gettimezoneinformation _date_time_localfiletimetofiletime " +"_date_time_setfiletime _date_time_setlocaltime _date_time_setsystemtime _date_time_setsystemtimeadjustment " +"_date_time_settimezoneinformation _date_time_systemtimetoarray _date_time_systemtimetodatestr " +"_date_time_systemtimetodatetimestr _date_time_systemtimetofiletime _date_time_systemtimetotimestr " +"_date_time_systemtimetotzspecificlocaltime _date_time_tzspecificlocaltimetosystemtime _dateadd " +"_datedayofweek _datedaysinmonth _datediff _dateisleapyear _dateisvalid _datetimeformat _datetimesplit " +"_datetodayofweek _datetodayofweekiso _datetodayvalue _datetomonth _dayvaluetodate _debugbugreportenv " +"_debugout _debugreport _debugreportex _debugreportvar _debugsetup _degree _eventlog__backup _eventlog__clear " +"_eventlog__close _eventlog__count _eventlog__deregistersource _eventlog__full _eventlog__notify " +"_eventlog__oldest _eventlog__open _eventlog__openbackup _eventlog__read _eventlog__registersource " +"_eventlog__report _excelbookattach _excelbookclose _excelbooknew _excelbookopen _excelbooksave " +"_excelbooksaveas _excelcolumndelete _excelcolumninsert _excelfontsetproperties _excelhorizontalalignset " +"_excelhyperlinkinsert _excelnumberformat _excelreadarray _excelreadcell _excelreadsheettoarray " +"_excelrowdelete _excelrowinsert _excelsheetactivate _excelsheetaddnew _excelsheetdelete _excelsheetlist " +"_excelsheetmove _excelsheetnameget _excelsheetnameset _excelwritearray _excelwritecell _excelwriteformula " +"_excelwritesheetfromarray _filecountlines _filecreate _filelisttoarray _fileprint _filereadtoarray " +"_filewritefromarray _filewritelog _filewritetoline _ftp_close _ftp_command _ftp_connect " +"_ftp_decodeinternetstatus _ftp_dircreate _ftp_dirdelete _ftp_dirgetcurrent _ftp_dirputcontents " +"_ftp_dirsetcurrent _ftp_fileclose _ftp_filedelete _ftp_fileget _ftp_filegetsize _ftp_fileopen _ftp_fileput " +"_ftp_fileread _ftp_filerename _ftp_filetimelohitostr _ftp_findfileclose _ftp_findfilefirst _ftp_findfilenext " +"_ftp_getlastresponseinfo _ftp_listtoarray _ftp_listtoarray2d _ftp_listtoarrayex _ftp_open " +"_ftp_progressdownload _ftp_progressupload _ftp_setstatuscallback _gdiplus_arrowcapcreate " +"_gdiplus_arrowcapdispose _gdiplus_arrowcapgetfillstate _gdiplus_arrowcapgetheight " +"_gdiplus_arrowcapgetmiddleinset _gdiplus_arrowcapgetwidth _gdiplus_arrowcapsetfillstate " +"_gdiplus_arrowcapsetheight _gdiplus_arrowcapsetmiddleinset _gdiplus_arrowcapsetwidth " +"_gdiplus_bitmapclonearea _gdiplus_bitmapcreatefromfile _gdiplus_bitmapcreatefromgraphics " +"_gdiplus_bitmapcreatefromhbitmap _gdiplus_bitmapcreatehbitmapfrombitmap _gdiplus_bitmapdispose " +"_gdiplus_bitmaplockbits _gdiplus_bitmapunlockbits _gdiplus_brushclone _gdiplus_brushcreatesolid " +"_gdiplus_brushdispose _gdiplus_brushgetsolidcolor _gdiplus_brushgettype _gdiplus_brushsetsolidcolor " +"_gdiplus_customlinecapdispose _gdiplus_decoders _gdiplus_decodersgetcount _gdiplus_decodersgetsize " +"_gdiplus_drawimagepoints _gdiplus_encoders _gdiplus_encodersgetclsid _gdiplus_encodersgetcount " +"_gdiplus_encodersgetparamlist _gdiplus_encodersgetparamlistsize _gdiplus_encodersgetsize _gdiplus_fontcreate " +"_gdiplus_fontdispose _gdiplus_fontfamilycreate _gdiplus_fontfamilydispose _gdiplus_graphicsclear " +"_gdiplus_graphicscreatefromhdc _gdiplus_graphicscreatefromhwnd _gdiplus_graphicsdispose " +"_gdiplus_graphicsdrawarc _gdiplus_graphicsdrawbezier _gdiplus_graphicsdrawclosedcurve " +"_gdiplus_graphicsdrawcurve _gdiplus_graphicsdrawellipse _gdiplus_graphicsdrawimage " +"_gdiplus_graphicsdrawimagerect _gdiplus_graphicsdrawimagerectrect _gdiplus_graphicsdrawline " +"_gdiplus_graphicsdrawpie _gdiplus_graphicsdrawpolygon _gdiplus_graphicsdrawrect _gdiplus_graphicsdrawstring " +"_gdiplus_graphicsdrawstringex _gdiplus_graphicsfillclosedcurve _gdiplus_graphicsfillellipse " +"_gdiplus_graphicsfillpie _gdiplus_graphicsfillpolygon _gdiplus_graphicsfillrect _gdiplus_graphicsgetdc " +"_gdiplus_graphicsgetsmoothingmode _gdiplus_graphicsmeasurestring _gdiplus_graphicsreleasedc " +"_gdiplus_graphicssetsmoothingmode _gdiplus_graphicssettransform _gdiplus_imagedispose _gdiplus_imagegetflags " +"_gdiplus_imagegetgraphicscontext _gdiplus_imagegetheight _gdiplus_imagegethorizontalresolution " +"_gdiplus_imagegetpixelformat _gdiplus_imagegetrawformat _gdiplus_imagegettype " +"_gdiplus_imagegetverticalresolution _gdiplus_imagegetwidth _gdiplus_imageloadfromfile " +"_gdiplus_imagesavetofile _gdiplus_imagesavetofileex _gdiplus_matrixcreate _gdiplus_matrixdispose " +"_gdiplus_matrixrotate _gdiplus_matrixscale _gdiplus_matrixtranslate _gdiplus_paramadd _gdiplus_paraminit " +"_gdiplus_pencreate _gdiplus_pendispose _gdiplus_pengetalignment _gdiplus_pengetcolor " +"_gdiplus_pengetcustomendcap _gdiplus_pengetdashcap _gdiplus_pengetdashstyle _gdiplus_pengetendcap " +"_gdiplus_pengetwidth _gdiplus_pensetalignment _gdiplus_pensetcolor _gdiplus_pensetcustomendcap " +"_gdiplus_pensetdashcap _gdiplus_pensetdashstyle _gdiplus_pensetendcap _gdiplus_pensetwidth " +"_gdiplus_rectfcreate _gdiplus_shutdown _gdiplus_startup _gdiplus_stringformatcreate " +"_gdiplus_stringformatdispose _gdiplus_stringformatsetalign _getip _guictrlavi_close _guictrlavi_create " +"_guictrlavi_destroy _guictrlavi_isplaying _guictrlavi_open _guictrlavi_openex _guictrlavi_play " +"_guictrlavi_seek _guictrlavi_show _guictrlavi_stop _guictrlbutton_click _guictrlbutton_create " +"_guictrlbutton_destroy _guictrlbutton_enable _guictrlbutton_getcheck _guictrlbutton_getfocus " +"_guictrlbutton_getidealsize _guictrlbutton_getimage _guictrlbutton_getimagelist _guictrlbutton_getnote " +"_guictrlbutton_getnotelength _guictrlbutton_getsplitinfo _guictrlbutton_getstate _guictrlbutton_gettext " +"_guictrlbutton_gettextmargin _guictrlbutton_setcheck _guictrlbutton_setdontclick _guictrlbutton_setfocus " +"_guictrlbutton_setimage _guictrlbutton_setimagelist _guictrlbutton_setnote _guictrlbutton_setshield " +"_guictrlbutton_setsize _guictrlbutton_setsplitinfo _guictrlbutton_setstate _guictrlbutton_setstyle " +"_guictrlbutton_settext _guictrlbutton_settextmargin _guictrlbutton_show _guictrlcombobox_adddir " +"_guictrlcombobox_addstring _guictrlcombobox_autocomplete _guictrlcombobox_beginupdate " +"_guictrlcombobox_create _guictrlcombobox_deletestring _guictrlcombobox_destroy _guictrlcombobox_endupdate " +"_guictrlcombobox_findstring _guictrlcombobox_findstringexact _guictrlcombobox_getcomboboxinfo " +"_guictrlcombobox_getcount _guictrlcombobox_getcuebanner _guictrlcombobox_getcursel " +"_guictrlcombobox_getdroppedcontrolrect _guictrlcombobox_getdroppedcontrolrectex " +"_guictrlcombobox_getdroppedstate _guictrlcombobox_getdroppedwidth _guictrlcombobox_geteditsel " +"_guictrlcombobox_getedittext _guictrlcombobox_getextendedui _guictrlcombobox_gethorizontalextent " +"_guictrlcombobox_getitemheight _guictrlcombobox_getlbtext _guictrlcombobox_getlbtextlen " +"_guictrlcombobox_getlist _guictrlcombobox_getlistarray _guictrlcombobox_getlocale " +"_guictrlcombobox_getlocalecountry _guictrlcombobox_getlocalelang _guictrlcombobox_getlocaleprimlang " +"_guictrlcombobox_getlocalesublang _guictrlcombobox_getminvisible _guictrlcombobox_gettopindex " +"_guictrlcombobox_initstorage _guictrlcombobox_insertstring _guictrlcombobox_limittext " +"_guictrlcombobox_replaceeditsel _guictrlcombobox_resetcontent _guictrlcombobox_selectstring " +"_guictrlcombobox_setcuebanner _guictrlcombobox_setcursel _guictrlcombobox_setdroppedwidth " +"_guictrlcombobox_seteditsel _guictrlcombobox_setedittext _guictrlcombobox_setextendedui " +"_guictrlcombobox_sethorizontalextent _guictrlcombobox_setitemheight _guictrlcombobox_setminvisible " +"_guictrlcombobox_settopindex _guictrlcombobox_showdropdown _guictrlcomboboxex_adddir " +"_guictrlcomboboxex_addstring _guictrlcomboboxex_beginupdate _guictrlcomboboxex_create " +"_guictrlcomboboxex_createsolidbitmap _guictrlcomboboxex_deletestring _guictrlcomboboxex_destroy " +"_guictrlcomboboxex_endupdate _guictrlcomboboxex_findstringexact _guictrlcomboboxex_getcomboboxinfo " +"_guictrlcomboboxex_getcombocontrol _guictrlcomboboxex_getcount _guictrlcomboboxex_getcursel " +"_guictrlcomboboxex_getdroppedcontrolrect _guictrlcomboboxex_getdroppedcontrolrectex " +"_guictrlcomboboxex_getdroppedstate _guictrlcomboboxex_getdroppedwidth _guictrlcomboboxex_geteditcontrol " +"_guictrlcomboboxex_geteditsel _guictrlcomboboxex_getedittext _guictrlcomboboxex_getextendedstyle " +"_guictrlcomboboxex_getextendedui _guictrlcomboboxex_getimagelist _guictrlcomboboxex_getitem " +"_guictrlcomboboxex_getitemex _guictrlcomboboxex_getitemheight _guictrlcomboboxex_getitemimage " +"_guictrlcomboboxex_getitemindent _guictrlcomboboxex_getitemoverlayimage _guictrlcomboboxex_getitemparam " +"_guictrlcomboboxex_getitemselectedimage _guictrlcomboboxex_getitemtext _guictrlcomboboxex_getitemtextlen " +"_guictrlcomboboxex_getlist _guictrlcomboboxex_getlistarray _guictrlcomboboxex_getlocale " +"_guictrlcomboboxex_getlocalecountry _guictrlcomboboxex_getlocalelang _guictrlcomboboxex_getlocaleprimlang " +"_guictrlcomboboxex_getlocalesublang _guictrlcomboboxex_getminvisible _guictrlcomboboxex_gettopindex " +"_guictrlcomboboxex_getunicode _guictrlcomboboxex_initstorage _guictrlcomboboxex_insertstring " +"_guictrlcomboboxex_limittext _guictrlcomboboxex_replaceeditsel _guictrlcomboboxex_resetcontent " +"_guictrlcomboboxex_setcursel _guictrlcomboboxex_setdroppedwidth _guictrlcomboboxex_seteditsel " +"_guictrlcomboboxex_setedittext _guictrlcomboboxex_setextendedstyle _guictrlcomboboxex_setextendedui " +"_guictrlcomboboxex_setimagelist _guictrlcomboboxex_setitem _guictrlcomboboxex_setitemex " +"_guictrlcomboboxex_setitemheight _guictrlcomboboxex_setitemimage _guictrlcomboboxex_setitemindent " +"_guictrlcomboboxex_setitemoverlayimage _guictrlcomboboxex_setitemparam " +"_guictrlcomboboxex_setitemselectedimage _guictrlcomboboxex_setminvisible _guictrlcomboboxex_settopindex " +"_guictrlcomboboxex_setunicode _guictrlcomboboxex_showdropdown _guictrldtp_create _guictrldtp_destroy " +"_guictrldtp_getmccolor _guictrldtp_getmcfont _guictrldtp_getmonthcal _guictrldtp_getrange " +"_guictrldtp_getrangeex _guictrldtp_getsystemtime _guictrldtp_getsystemtimeex _guictrldtp_setformat " +"_guictrldtp_setmccolor _guictrldtp_setmcfont _guictrldtp_setrange _guictrldtp_setrangeex " +"_guictrldtp_setsystemtime _guictrldtp_setsystemtimeex _guictrledit_appendtext _guictrledit_beginupdate " +"_guictrledit_canundo _guictrledit_charfrompos _guictrledit_create _guictrledit_destroy " +"_guictrledit_emptyundobuffer _guictrledit_endupdate _guictrledit_find _guictrledit_fmtlines " +"_guictrledit_getfirstvisibleline _guictrledit_getlimittext _guictrledit_getline _guictrledit_getlinecount " +"_guictrledit_getmargins _guictrledit_getmodify _guictrledit_getpasswordchar _guictrledit_getrect " +"_guictrledit_getrectex _guictrledit_getsel _guictrledit_gettext _guictrledit_gettextlen " +"_guictrledit_hideballoontip _guictrledit_inserttext _guictrledit_linefromchar _guictrledit_lineindex " +"_guictrledit_linelength _guictrledit_linescroll _guictrledit_posfromchar _guictrledit_replacesel " +"_guictrledit_scroll _guictrledit_setlimittext _guictrledit_setmargins _guictrledit_setmodify " +"_guictrledit_setpasswordchar _guictrledit_setreadonly _guictrledit_setrect _guictrledit_setrectex " +"_guictrledit_setrectnp _guictrledit_setrectnpex _guictrledit_setsel _guictrledit_settabstops " +"_guictrledit_settext _guictrledit_showballoontip _guictrledit_undo _guictrlheader_additem " +"_guictrlheader_clearfilter _guictrlheader_clearfilterall _guictrlheader_create " +"_guictrlheader_createdragimage _guictrlheader_deleteitem _guictrlheader_destroy _guictrlheader_editfilter " +"_guictrlheader_getbitmapmargin _guictrlheader_getimagelist _guictrlheader_getitem " +"_guictrlheader_getitemalign _guictrlheader_getitembitmap _guictrlheader_getitemcount " +"_guictrlheader_getitemdisplay _guictrlheader_getitemflags _guictrlheader_getitemformat " +"_guictrlheader_getitemimage _guictrlheader_getitemorder _guictrlheader_getitemparam " +"_guictrlheader_getitemrect _guictrlheader_getitemrectex _guictrlheader_getitemtext " +"_guictrlheader_getitemwidth _guictrlheader_getorderarray _guictrlheader_getunicodeformat " +"_guictrlheader_hittest _guictrlheader_insertitem _guictrlheader_layout _guictrlheader_ordertoindex " +"_guictrlheader_setbitmapmargin _guictrlheader_setfilterchangetimeout _guictrlheader_sethotdivider " +"_guictrlheader_setimagelist _guictrlheader_setitem _guictrlheader_setitemalign " +"_guictrlheader_setitembitmap _guictrlheader_setitemdisplay _guictrlheader_setitemflags " +"_guictrlheader_setitemformat _guictrlheader_setitemimage _guictrlheader_setitemorder " +"_guictrlheader_setitemparam _guictrlheader_setitemtext _guictrlheader_setitemwidth " +"_guictrlheader_setorderarray _guictrlheader_setunicodeformat _guictrlipaddress_clearaddress " +"_guictrlipaddress_create _guictrlipaddress_destroy _guictrlipaddress_get _guictrlipaddress_getarray " +"_guictrlipaddress_getex _guictrlipaddress_isblank _guictrlipaddress_set _guictrlipaddress_setarray " +"_guictrlipaddress_setex _guictrlipaddress_setfocus _guictrlipaddress_setfont _guictrlipaddress_setrange " +"_guictrlipaddress_showhide _guictrllistbox_addfile _guictrllistbox_addstring _guictrllistbox_beginupdate " +"_guictrllistbox_clickitem _guictrllistbox_create _guictrllistbox_deletestring _guictrllistbox_destroy " +"_guictrllistbox_dir _guictrllistbox_endupdate _guictrllistbox_findintext _guictrllistbox_findstring " +"_guictrllistbox_getanchorindex _guictrllistbox_getcaretindex _guictrllistbox_getcount " +"_guictrllistbox_getcursel _guictrllistbox_gethorizontalextent _guictrllistbox_getitemdata " +"_guictrllistbox_getitemheight _guictrllistbox_getitemrect _guictrllistbox_getitemrectex " +"_guictrllistbox_getlistboxinfo _guictrllistbox_getlocale _guictrllistbox_getlocalecountry " +"_guictrllistbox_getlocalelang _guictrllistbox_getlocaleprimlang _guictrllistbox_getlocalesublang " +"_guictrllistbox_getsel _guictrllistbox_getselcount _guictrllistbox_getselitems " +"_guictrllistbox_getselitemstext _guictrllistbox_gettext _guictrllistbox_gettextlen " +"_guictrllistbox_gettopindex _guictrllistbox_initstorage _guictrllistbox_insertstring " +"_guictrllistbox_itemfrompoint _guictrllistbox_replacestring _guictrllistbox_resetcontent " +"_guictrllistbox_selectstring _guictrllistbox_selitemrange _guictrllistbox_selitemrangeex " +"_guictrllistbox_setanchorindex _guictrllistbox_setcaretindex _guictrllistbox_setcolumnwidth " +"_guictrllistbox_setcursel _guictrllistbox_sethorizontalextent _guictrllistbox_setitemdata " +"_guictrllistbox_setitemheight _guictrllistbox_setlocale _guictrllistbox_setsel _guictrllistbox_settabstops " +"_guictrllistbox_settopindex _guictrllistbox_sort _guictrllistbox_swapstring _guictrllistbox_updatehscroll " +"_guictrllistview_addarray _guictrllistview_addcolumn _guictrllistview_additem _guictrllistview_addsubitem " +"_guictrllistview_approximateviewheight _guictrllistview_approximateviewrect " +"_guictrllistview_approximateviewwidth _guictrllistview_arrange _guictrllistview_beginupdate " +"_guictrllistview_canceleditlabel _guictrllistview_clickitem _guictrllistview_copyitems " +"_guictrllistview_create _guictrllistview_createdragimage _guictrllistview_createsolidbitmap " +"_guictrllistview_deleteallitems _guictrllistview_deletecolumn _guictrllistview_deleteitem " +"_guictrllistview_deleteitemsselected _guictrllistview_destroy _guictrllistview_drawdragimage " +"_guictrllistview_editlabel _guictrllistview_enablegroupview _guictrllistview_endupdate " +"_guictrllistview_ensurevisible _guictrllistview_findintext _guictrllistview_finditem " +"_guictrllistview_findnearest _guictrllistview_findparam _guictrllistview_findtext " +"_guictrllistview_getbkcolor _guictrllistview_getbkimage _guictrllistview_getcallbackmask " +"_guictrllistview_getcolumn _guictrllistview_getcolumncount _guictrllistview_getcolumnorder " +"_guictrllistview_getcolumnorderarray _guictrllistview_getcolumnwidth _guictrllistview_getcounterpage " +"_guictrllistview_geteditcontrol _guictrllistview_getextendedlistviewstyle _guictrllistview_getfocusedgroup " +"_guictrllistview_getgroupcount _guictrllistview_getgroupinfo _guictrllistview_getgroupinfobyindex " +"_guictrllistview_getgrouprect _guictrllistview_getgroupviewenabled _guictrllistview_getheader " +"_guictrllistview_gethotcursor _guictrllistview_gethotitem _guictrllistview_gethovertime " +"_guictrllistview_getimagelist _guictrllistview_getisearchstring _guictrllistview_getitem " +"_guictrllistview_getitemchecked _guictrllistview_getitemcount _guictrllistview_getitemcut " +"_guictrllistview_getitemdrophilited _guictrllistview_getitemex _guictrllistview_getitemfocused " +"_guictrllistview_getitemgroupid _guictrllistview_getitemimage _guictrllistview_getitemindent " +"_guictrllistview_getitemparam _guictrllistview_getitemposition _guictrllistview_getitempositionx " +"_guictrllistview_getitempositiony _guictrllistview_getitemrect _guictrllistview_getitemrectex " +"_guictrllistview_getitemselected _guictrllistview_getitemspacing _guictrllistview_getitemspacingx " +"_guictrllistview_getitemspacingy _guictrllistview_getitemstate _guictrllistview_getitemstateimage " +"_guictrllistview_getitemtext _guictrllistview_getitemtextarray _guictrllistview_getitemtextstring " +"_guictrllistview_getnextitem _guictrllistview_getnumberofworkareas _guictrllistview_getorigin " +"_guictrllistview_getoriginx _guictrllistview_getoriginy _guictrllistview_getoutlinecolor " +"_guictrllistview_getselectedcolumn _guictrllistview_getselectedcount _guictrllistview_getselectedindices " +"_guictrllistview_getselectionmark _guictrllistview_getstringwidth _guictrllistview_getsubitemrect " +"_guictrllistview_gettextbkcolor _guictrllistview_gettextcolor _guictrllistview_gettooltips " +"_guictrllistview_gettopindex _guictrllistview_getunicodeformat _guictrllistview_getview " +"_guictrllistview_getviewdetails _guictrllistview_getviewlarge _guictrllistview_getviewlist " +"_guictrllistview_getviewrect _guictrllistview_getviewsmall _guictrllistview_getviewtile " +"_guictrllistview_hidecolumn _guictrllistview_hittest _guictrllistview_insertcolumn " +"_guictrllistview_insertgroup _guictrllistview_insertitem _guictrllistview_justifycolumn " +"_guictrllistview_mapidtoindex _guictrllistview_mapindextoid _guictrllistview_redrawitems " +"_guictrllistview_registersortcallback _guictrllistview_removeallgroups _guictrllistview_removegroup " +"_guictrllistview_scroll _guictrllistview_setbkcolor _guictrllistview_setbkimage " +"_guictrllistview_setcallbackmask _guictrllistview_setcolumn _guictrllistview_setcolumnorder " +"_guictrllistview_setcolumnorderarray _guictrllistview_setcolumnwidth " +"_guictrllistview_setextendedlistviewstyle _guictrllistview_setgroupinfo _guictrllistview_sethotitem " +"_guictrllistview_sethovertime _guictrllistview_seticonspacing _guictrllistview_setimagelist " +"_guictrllistview_setitem _guictrllistview_setitemchecked _guictrllistview_setitemcount " +"_guictrllistview_setitemcut _guictrllistview_setitemdrophilited _guictrllistview_setitemex " +"_guictrllistview_setitemfocused _guictrllistview_setitemgroupid _guictrllistview_setitemimage " +"_guictrllistview_setitemindent _guictrllistview_setitemparam _guictrllistview_setitemposition " +"_guictrllistview_setitemposition32 _guictrllistview_setitemselected _guictrllistview_setitemstate " +"_guictrllistview_setitemstateimage _guictrllistview_setitemtext _guictrllistview_setoutlinecolor " +"_guictrllistview_setselectedcolumn _guictrllistview_setselectionmark _guictrllistview_settextbkcolor " +"_guictrllistview_settextcolor _guictrllistview_settooltips _guictrllistview_setunicodeformat " +"_guictrllistview_setview _guictrllistview_setworkareas _guictrllistview_simplesort " +"_guictrllistview_sortitems _guictrllistview_subitemhittest _guictrllistview_unregistersortcallback " +"_guictrlmenu_addmenuitem _guictrlmenu_appendmenu _guictrlmenu_checkmenuitem _guictrlmenu_checkradioitem " +"_guictrlmenu_createmenu _guictrlmenu_createpopup _guictrlmenu_deletemenu _guictrlmenu_destroymenu " +"_guictrlmenu_drawmenubar _guictrlmenu_enablemenuitem _guictrlmenu_finditem _guictrlmenu_findparent " +"_guictrlmenu_getitembmp _guictrlmenu_getitembmpchecked _guictrlmenu_getitembmpunchecked " +"_guictrlmenu_getitemchecked _guictrlmenu_getitemcount _guictrlmenu_getitemdata _guictrlmenu_getitemdefault " +"_guictrlmenu_getitemdisabled _guictrlmenu_getitemenabled _guictrlmenu_getitemgrayed " +"_guictrlmenu_getitemhighlighted _guictrlmenu_getitemid _guictrlmenu_getiteminfo _guictrlmenu_getitemrect " +"_guictrlmenu_getitemrectex _guictrlmenu_getitemstate _guictrlmenu_getitemstateex " +"_guictrlmenu_getitemsubmenu _guictrlmenu_getitemtext _guictrlmenu_getitemtype _guictrlmenu_getmenu " +"_guictrlmenu_getmenubackground _guictrlmenu_getmenubarinfo _guictrlmenu_getmenucontexthelpid " +"_guictrlmenu_getmenudata _guictrlmenu_getmenudefaultitem _guictrlmenu_getmenuheight " +"_guictrlmenu_getmenuinfo _guictrlmenu_getmenustyle _guictrlmenu_getsystemmenu _guictrlmenu_insertmenuitem " +"_guictrlmenu_insertmenuitemex _guictrlmenu_ismenu _guictrlmenu_loadmenu _guictrlmenu_mapaccelerator " +"_guictrlmenu_menuitemfrompoint _guictrlmenu_removemenu _guictrlmenu_setitembitmaps _guictrlmenu_setitembmp " +"_guictrlmenu_setitembmpchecked _guictrlmenu_setitembmpunchecked _guictrlmenu_setitemchecked " +"_guictrlmenu_setitemdata _guictrlmenu_setitemdefault _guictrlmenu_setitemdisabled " +"_guictrlmenu_setitemenabled _guictrlmenu_setitemgrayed _guictrlmenu_setitemhighlighted " +"_guictrlmenu_setitemid _guictrlmenu_setiteminfo _guictrlmenu_setitemstate _guictrlmenu_setitemsubmenu " +"_guictrlmenu_setitemtext _guictrlmenu_setitemtype _guictrlmenu_setmenu _guictrlmenu_setmenubackground " +"_guictrlmenu_setmenucontexthelpid _guictrlmenu_setmenudata _guictrlmenu_setmenudefaultitem " +"_guictrlmenu_setmenuheight _guictrlmenu_setmenuinfo _guictrlmenu_setmenustyle _guictrlmenu_trackpopupmenu " +"_guictrlmonthcal_create _guictrlmonthcal_destroy _guictrlmonthcal_getcalendarborder " +"_guictrlmonthcal_getcalendarcount _guictrlmonthcal_getcolor _guictrlmonthcal_getcolorarray " +"_guictrlmonthcal_getcursel _guictrlmonthcal_getcurselstr _guictrlmonthcal_getfirstdow " +"_guictrlmonthcal_getfirstdowstr _guictrlmonthcal_getmaxselcount _guictrlmonthcal_getmaxtodaywidth " +"_guictrlmonthcal_getminreqheight _guictrlmonthcal_getminreqrect _guictrlmonthcal_getminreqrectarray " +"_guictrlmonthcal_getminreqwidth _guictrlmonthcal_getmonthdelta _guictrlmonthcal_getmonthrange " +"_guictrlmonthcal_getmonthrangemax _guictrlmonthcal_getmonthrangemaxstr _guictrlmonthcal_getmonthrangemin " +"_guictrlmonthcal_getmonthrangeminstr _guictrlmonthcal_getmonthrangespan _guictrlmonthcal_getrange " +"_guictrlmonthcal_getrangemax _guictrlmonthcal_getrangemaxstr _guictrlmonthcal_getrangemin " +"_guictrlmonthcal_getrangeminstr _guictrlmonthcal_getselrange _guictrlmonthcal_getselrangemax " +"_guictrlmonthcal_getselrangemaxstr _guictrlmonthcal_getselrangemin _guictrlmonthcal_getselrangeminstr " +"_guictrlmonthcal_gettoday _guictrlmonthcal_gettodaystr _guictrlmonthcal_getunicodeformat " +"_guictrlmonthcal_hittest _guictrlmonthcal_setcalendarborder _guictrlmonthcal_setcolor " +"_guictrlmonthcal_setcursel _guictrlmonthcal_setdaystate _guictrlmonthcal_setfirstdow " +"_guictrlmonthcal_setmaxselcount _guictrlmonthcal_setmonthdelta _guictrlmonthcal_setrange " +"_guictrlmonthcal_setselrange _guictrlmonthcal_settoday _guictrlmonthcal_setunicodeformat " +"_guictrlrebar_addband _guictrlrebar_addtoolbarband _guictrlrebar_begindrag _guictrlrebar_create " +"_guictrlrebar_deleteband _guictrlrebar_destroy _guictrlrebar_dragmove _guictrlrebar_enddrag " +"_guictrlrebar_getbandbackcolor _guictrlrebar_getbandborders _guictrlrebar_getbandbordersex " +"_guictrlrebar_getbandchildhandle _guictrlrebar_getbandchildsize _guictrlrebar_getbandcount " +"_guictrlrebar_getbandforecolor _guictrlrebar_getbandheadersize _guictrlrebar_getbandid " +"_guictrlrebar_getbandidealsize _guictrlrebar_getbandlength _guictrlrebar_getbandlparam " +"_guictrlrebar_getbandmargins _guictrlrebar_getbandmarginsex _guictrlrebar_getbandrect " +"_guictrlrebar_getbandrectex _guictrlrebar_getbandstyle _guictrlrebar_getbandstylebreak " +"_guictrlrebar_getbandstylechildedge _guictrlrebar_getbandstylefixedbmp _guictrlrebar_getbandstylefixedsize " +"_guictrlrebar_getbandstylegripperalways _guictrlrebar_getbandstylehidden " +"_guictrlrebar_getbandstylehidetitle _guictrlrebar_getbandstylenogripper _guictrlrebar_getbandstyletopalign " +"_guictrlrebar_getbandstyleusechevron _guictrlrebar_getbandstylevariableheight _guictrlrebar_getbandtext " +"_guictrlrebar_getbarheight _guictrlrebar_getbarinfo _guictrlrebar_getbkcolor _guictrlrebar_getcolorscheme " +"_guictrlrebar_getrowcount _guictrlrebar_getrowheight _guictrlrebar_gettextcolor _guictrlrebar_gettooltips " +"_guictrlrebar_getunicodeformat _guictrlrebar_hittest _guictrlrebar_idtoindex _guictrlrebar_maximizeband " +"_guictrlrebar_minimizeband _guictrlrebar_moveband _guictrlrebar_setbandbackcolor " +"_guictrlrebar_setbandforecolor _guictrlrebar_setbandheadersize _guictrlrebar_setbandid " +"_guictrlrebar_setbandidealsize _guictrlrebar_setbandlength _guictrlrebar_setbandlparam " +"_guictrlrebar_setbandstyle _guictrlrebar_setbandstylebreak _guictrlrebar_setbandstylechildedge " +"_guictrlrebar_setbandstylefixedbmp _guictrlrebar_setbandstylefixedsize " +"_guictrlrebar_setbandstylegripperalways _guictrlrebar_setbandstylehidden " +"_guictrlrebar_setbandstylehidetitle _guictrlrebar_setbandstylenogripper _guictrlrebar_setbandstyletopalign " +"_guictrlrebar_setbandstyleusechevron _guictrlrebar_setbandstylevariableheight _guictrlrebar_setbandtext " +"_guictrlrebar_setbarinfo _guictrlrebar_setbkcolor _guictrlrebar_setcolorscheme _guictrlrebar_settextcolor " +"_guictrlrebar_settooltips _guictrlrebar_setunicodeformat _guictrlrebar_showband " +"_guictrlrichedit_appendtext _guictrlrichedit_autodetecturl _guictrlrichedit_canpaste " +"_guictrlrichedit_canpastespecial _guictrlrichedit_canredo _guictrlrichedit_canundo " +"_guictrlrichedit_changefontsize _guictrlrichedit_copy _guictrlrichedit_create _guictrlrichedit_cut " +"_guictrlrichedit_deselect _guictrlrichedit_destroy _guictrlrichedit_emptyundobuffer " +"_guictrlrichedit_findtext _guictrlrichedit_findtextinrange _guictrlrichedit_getbkcolor " +"_guictrlrichedit_getcharattributes _guictrlrichedit_getcharbkcolor _guictrlrichedit_getcharcolor " +"_guictrlrichedit_getcharposfromxy _guictrlrichedit_getcharposofnextword " +"_guictrlrichedit_getcharposofpreviousword _guictrlrichedit_getcharwordbreakinfo " +"_guictrlrichedit_getfirstcharposonline _guictrlrichedit_getfont _guictrlrichedit_getlinecount " +"_guictrlrichedit_getlinelength _guictrlrichedit_getlinenumberfromcharpos _guictrlrichedit_getnextredo " +"_guictrlrichedit_getnextundo _guictrlrichedit_getnumberoffirstvisibleline " +"_guictrlrichedit_getparaalignment _guictrlrichedit_getparaattributes _guictrlrichedit_getparaborder " +"_guictrlrichedit_getparaindents _guictrlrichedit_getparanumbering _guictrlrichedit_getparashading " +"_guictrlrichedit_getparaspacing _guictrlrichedit_getparatabstops _guictrlrichedit_getpasswordchar " +"_guictrlrichedit_getrect _guictrlrichedit_getscrollpos _guictrlrichedit_getsel _guictrlrichedit_getselaa " +"_guictrlrichedit_getseltext _guictrlrichedit_getspaceunit _guictrlrichedit_gettext " +"_guictrlrichedit_gettextinline _guictrlrichedit_gettextinrange _guictrlrichedit_gettextlength " +"_guictrlrichedit_getversion _guictrlrichedit_getxyfromcharpos _guictrlrichedit_getzoom " +"_guictrlrichedit_gotocharpos _guictrlrichedit_hideselection _guictrlrichedit_inserttext " +"_guictrlrichedit_ismodified _guictrlrichedit_istextselected _guictrlrichedit_paste " +"_guictrlrichedit_pastespecial _guictrlrichedit_pauseredraw _guictrlrichedit_redo " +"_guictrlrichedit_replacetext _guictrlrichedit_resumeredraw _guictrlrichedit_scrolllineorpage " +"_guictrlrichedit_scrolllines _guictrlrichedit_scrolltocaret _guictrlrichedit_setbkcolor " +"_guictrlrichedit_setcharattributes _guictrlrichedit_setcharbkcolor _guictrlrichedit_setcharcolor " +"_guictrlrichedit_seteventmask _guictrlrichedit_setfont _guictrlrichedit_setlimitontext " +"_guictrlrichedit_setmodified _guictrlrichedit_setparaalignment _guictrlrichedit_setparaattributes " +"_guictrlrichedit_setparaborder _guictrlrichedit_setparaindents _guictrlrichedit_setparanumbering " +"_guictrlrichedit_setparashading _guictrlrichedit_setparaspacing _guictrlrichedit_setparatabstops " +"_guictrlrichedit_setpasswordchar _guictrlrichedit_setreadonly _guictrlrichedit_setrect " +"_guictrlrichedit_setscrollpos _guictrlrichedit_setsel _guictrlrichedit_setspaceunit " +"_guictrlrichedit_settabstops _guictrlrichedit_settext _guictrlrichedit_setundolimit " +"_guictrlrichedit_setzoom _guictrlrichedit_streamfromfile _guictrlrichedit_streamfromvar " +"_guictrlrichedit_streamtofile _guictrlrichedit_streamtovar _guictrlrichedit_undo _guictrlslider_clearsel " +"_guictrlslider_cleartics _guictrlslider_create _guictrlslider_destroy _guictrlslider_getbuddy " +"_guictrlslider_getchannelrect _guictrlslider_getchannelrectex _guictrlslider_getlinesize " +"_guictrlslider_getlogicaltics _guictrlslider_getnumtics _guictrlslider_getpagesize _guictrlslider_getpos " +"_guictrlslider_getrange _guictrlslider_getrangemax _guictrlslider_getrangemin _guictrlslider_getsel " +"_guictrlslider_getselend _guictrlslider_getselstart _guictrlslider_getthumblength " +"_guictrlslider_getthumbrect _guictrlslider_getthumbrectex _guictrlslider_gettic _guictrlslider_getticpos " +"_guictrlslider_gettooltips _guictrlslider_getunicodeformat _guictrlslider_setbuddy " +"_guictrlslider_setlinesize _guictrlslider_setpagesize _guictrlslider_setpos _guictrlslider_setrange " +"_guictrlslider_setrangemax _guictrlslider_setrangemin _guictrlslider_setsel _guictrlslider_setselend " +"_guictrlslider_setselstart _guictrlslider_setthumblength _guictrlslider_settic _guictrlslider_setticfreq " +"_guictrlslider_settipside _guictrlslider_settooltips _guictrlslider_setunicodeformat " +"_guictrlstatusbar_create _guictrlstatusbar_destroy _guictrlstatusbar_embedcontrol " +"_guictrlstatusbar_getborders _guictrlstatusbar_getbordershorz _guictrlstatusbar_getbordersrect " +"_guictrlstatusbar_getbordersvert _guictrlstatusbar_getcount _guictrlstatusbar_getheight " +"_guictrlstatusbar_geticon _guictrlstatusbar_getparts _guictrlstatusbar_getrect _guictrlstatusbar_getrectex " +"_guictrlstatusbar_gettext _guictrlstatusbar_gettextflags _guictrlstatusbar_gettextlength " +"_guictrlstatusbar_gettextlengthex _guictrlstatusbar_gettiptext _guictrlstatusbar_getunicodeformat " +"_guictrlstatusbar_getwidth _guictrlstatusbar_issimple _guictrlstatusbar_resize " +"_guictrlstatusbar_setbkcolor _guictrlstatusbar_seticon _guictrlstatusbar_setminheight " +"_guictrlstatusbar_setparts _guictrlstatusbar_setsimple _guictrlstatusbar_settext " +"_guictrlstatusbar_settiptext _guictrlstatusbar_setunicodeformat _guictrlstatusbar_showhide " +"_guictrltab_activatetab _guictrltab_clicktab _guictrltab_create _guictrltab_deleteallitems " +"_guictrltab_deleteitem _guictrltab_deselectall _guictrltab_destroy _guictrltab_findtab " +"_guictrltab_getcurfocus _guictrltab_getcursel _guictrltab_getdisplayrect _guictrltab_getdisplayrectex " +"_guictrltab_getextendedstyle _guictrltab_getimagelist _guictrltab_getitem _guictrltab_getitemcount " +"_guictrltab_getitemimage _guictrltab_getitemparam _guictrltab_getitemrect _guictrltab_getitemrectex " +"_guictrltab_getitemstate _guictrltab_getitemtext _guictrltab_getrowcount _guictrltab_gettooltips " +"_guictrltab_getunicodeformat _guictrltab_highlightitem _guictrltab_hittest _guictrltab_insertitem " +"_guictrltab_removeimage _guictrltab_setcurfocus _guictrltab_setcursel _guictrltab_setextendedstyle " +"_guictrltab_setimagelist _guictrltab_setitem _guictrltab_setitemimage _guictrltab_setitemparam " +"_guictrltab_setitemsize _guictrltab_setitemstate _guictrltab_setitemtext _guictrltab_setmintabwidth " +"_guictrltab_setpadding _guictrltab_settooltips _guictrltab_setunicodeformat _guictrltoolbar_addbitmap " +"_guictrltoolbar_addbutton _guictrltoolbar_addbuttonsep _guictrltoolbar_addstring " +"_guictrltoolbar_buttoncount _guictrltoolbar_checkbutton _guictrltoolbar_clickaccel " +"_guictrltoolbar_clickbutton _guictrltoolbar_clickindex _guictrltoolbar_commandtoindex " +"_guictrltoolbar_create _guictrltoolbar_customize _guictrltoolbar_deletebutton _guictrltoolbar_destroy " +"_guictrltoolbar_enablebutton _guictrltoolbar_findtoolbar _guictrltoolbar_getanchorhighlight " +"_guictrltoolbar_getbitmapflags _guictrltoolbar_getbuttonbitmap _guictrltoolbar_getbuttoninfo " +"_guictrltoolbar_getbuttoninfoex _guictrltoolbar_getbuttonparam _guictrltoolbar_getbuttonrect " +"_guictrltoolbar_getbuttonrectex _guictrltoolbar_getbuttonsize _guictrltoolbar_getbuttonstate " +"_guictrltoolbar_getbuttonstyle _guictrltoolbar_getbuttontext _guictrltoolbar_getcolorscheme " +"_guictrltoolbar_getdisabledimagelist _guictrltoolbar_getextendedstyle _guictrltoolbar_gethotimagelist " +"_guictrltoolbar_gethotitem _guictrltoolbar_getimagelist _guictrltoolbar_getinsertmark " +"_guictrltoolbar_getinsertmarkcolor _guictrltoolbar_getmaxsize _guictrltoolbar_getmetrics " +"_guictrltoolbar_getpadding _guictrltoolbar_getrows _guictrltoolbar_getstring _guictrltoolbar_getstyle " +"_guictrltoolbar_getstylealtdrag _guictrltoolbar_getstylecustomerase _guictrltoolbar_getstyleflat " +"_guictrltoolbar_getstylelist _guictrltoolbar_getstyleregisterdrop _guictrltoolbar_getstyletooltips " +"_guictrltoolbar_getstyletransparent _guictrltoolbar_getstylewrapable _guictrltoolbar_gettextrows " +"_guictrltoolbar_gettooltips _guictrltoolbar_getunicodeformat _guictrltoolbar_hidebutton " +"_guictrltoolbar_highlightbutton _guictrltoolbar_hittest _guictrltoolbar_indextocommand " +"_guictrltoolbar_insertbutton _guictrltoolbar_insertmarkhittest _guictrltoolbar_isbuttonchecked " +"_guictrltoolbar_isbuttonenabled _guictrltoolbar_isbuttonhidden _guictrltoolbar_isbuttonhighlighted " +"_guictrltoolbar_isbuttonindeterminate _guictrltoolbar_isbuttonpressed _guictrltoolbar_loadbitmap " +"_guictrltoolbar_loadimages _guictrltoolbar_mapaccelerator _guictrltoolbar_movebutton " +"_guictrltoolbar_pressbutton _guictrltoolbar_setanchorhighlight _guictrltoolbar_setbitmapsize " +"_guictrltoolbar_setbuttonbitmap _guictrltoolbar_setbuttoninfo _guictrltoolbar_setbuttoninfoex " +"_guictrltoolbar_setbuttonparam _guictrltoolbar_setbuttonsize _guictrltoolbar_setbuttonstate " +"_guictrltoolbar_setbuttonstyle _guictrltoolbar_setbuttontext _guictrltoolbar_setbuttonwidth " +"_guictrltoolbar_setcmdid _guictrltoolbar_setcolorscheme _guictrltoolbar_setdisabledimagelist " +"_guictrltoolbar_setdrawtextflags _guictrltoolbar_setextendedstyle _guictrltoolbar_sethotimagelist " +"_guictrltoolbar_sethotitem _guictrltoolbar_setimagelist _guictrltoolbar_setindent " +"_guictrltoolbar_setindeterminate _guictrltoolbar_setinsertmark _guictrltoolbar_setinsertmarkcolor " +"_guictrltoolbar_setmaxtextrows _guictrltoolbar_setmetrics _guictrltoolbar_setpadding " +"_guictrltoolbar_setparent _guictrltoolbar_setrows _guictrltoolbar_setstyle _guictrltoolbar_setstylealtdrag " +"_guictrltoolbar_setstylecustomerase _guictrltoolbar_setstyleflat _guictrltoolbar_setstylelist " +"_guictrltoolbar_setstyleregisterdrop _guictrltoolbar_setstyletooltips _guictrltoolbar_setstyletransparent " +"_guictrltoolbar_setstylewrapable _guictrltoolbar_settooltips _guictrltoolbar_setunicodeformat " +"_guictrltoolbar_setwindowtheme _guictrltreeview_add _guictrltreeview_addchild " +"_guictrltreeview_addchildfirst _guictrltreeview_addfirst _guictrltreeview_beginupdate " +"_guictrltreeview_clickitem _guictrltreeview_create _guictrltreeview_createdragimage " +"_guictrltreeview_createsolidbitmap _guictrltreeview_delete _guictrltreeview_deleteall " +"_guictrltreeview_deletechildren _guictrltreeview_destroy _guictrltreeview_displayrect " +"_guictrltreeview_displayrectex _guictrltreeview_edittext _guictrltreeview_endedit " +"_guictrltreeview_endupdate _guictrltreeview_ensurevisible _guictrltreeview_expand " +"_guictrltreeview_expandedonce _guictrltreeview_finditem _guictrltreeview_finditemex " +"_guictrltreeview_getbkcolor _guictrltreeview_getbold _guictrltreeview_getchecked " +"_guictrltreeview_getchildcount _guictrltreeview_getchildren _guictrltreeview_getcount " +"_guictrltreeview_getcut _guictrltreeview_getdroptarget _guictrltreeview_geteditcontrol " +"_guictrltreeview_getexpanded _guictrltreeview_getfirstchild _guictrltreeview_getfirstitem " +"_guictrltreeview_getfirstvisible _guictrltreeview_getfocused _guictrltreeview_getheight " +"_guictrltreeview_getimageindex _guictrltreeview_getimagelisticonhandle _guictrltreeview_getindent " +"_guictrltreeview_getinsertmarkcolor _guictrltreeview_getisearchstring _guictrltreeview_getitembyindex " +"_guictrltreeview_getitemhandle _guictrltreeview_getitemparam _guictrltreeview_getlastchild " +"_guictrltreeview_getlinecolor _guictrltreeview_getnext _guictrltreeview_getnextchild " +"_guictrltreeview_getnextsibling _guictrltreeview_getnextvisible _guictrltreeview_getnormalimagelist " +"_guictrltreeview_getparenthandle _guictrltreeview_getparentparam _guictrltreeview_getprev " +"_guictrltreeview_getprevchild _guictrltreeview_getprevsibling _guictrltreeview_getprevvisible " +"_guictrltreeview_getscrolltime _guictrltreeview_getselected _guictrltreeview_getselectedimageindex " +"_guictrltreeview_getselection _guictrltreeview_getsiblingcount _guictrltreeview_getstate " +"_guictrltreeview_getstateimageindex _guictrltreeview_getstateimagelist _guictrltreeview_gettext " +"_guictrltreeview_gettextcolor _guictrltreeview_gettooltips _guictrltreeview_gettree " +"_guictrltreeview_getunicodeformat _guictrltreeview_getvisible _guictrltreeview_getvisiblecount " +"_guictrltreeview_hittest _guictrltreeview_hittestex _guictrltreeview_hittestitem _guictrltreeview_index " +"_guictrltreeview_insertitem _guictrltreeview_isfirstitem _guictrltreeview_isparent _guictrltreeview_level " +"_guictrltreeview_selectitem _guictrltreeview_selectitembyindex _guictrltreeview_setbkcolor " +"_guictrltreeview_setbold _guictrltreeview_setchecked _guictrltreeview_setcheckedbyindex " +"_guictrltreeview_setchildren _guictrltreeview_setcut _guictrltreeview_setdroptarget " +"_guictrltreeview_setfocused _guictrltreeview_setheight _guictrltreeview_seticon " +"_guictrltreeview_setimageindex _guictrltreeview_setindent _guictrltreeview_setinsertmark " +"_guictrltreeview_setinsertmarkcolor _guictrltreeview_setitemheight _guictrltreeview_setitemparam " +"_guictrltreeview_setlinecolor _guictrltreeview_setnormalimagelist _guictrltreeview_setscrolltime " +"_guictrltreeview_setselected _guictrltreeview_setselectedimageindex _guictrltreeview_setstate " +"_guictrltreeview_setstateimageindex _guictrltreeview_setstateimagelist _guictrltreeview_settext " +"_guictrltreeview_settextcolor _guictrltreeview_settooltips _guictrltreeview_setunicodeformat " +"_guictrltreeview_sort _guiimagelist_add _guiimagelist_addbitmap _guiimagelist_addicon " +"_guiimagelist_addmasked _guiimagelist_begindrag _guiimagelist_copy _guiimagelist_create " +"_guiimagelist_destroy _guiimagelist_destroyicon _guiimagelist_dragenter _guiimagelist_dragleave " +"_guiimagelist_dragmove _guiimagelist_draw _guiimagelist_drawex _guiimagelist_duplicate " +"_guiimagelist_enddrag _guiimagelist_getbkcolor _guiimagelist_geticon _guiimagelist_geticonheight " +"_guiimagelist_geticonsize _guiimagelist_geticonsizeex _guiimagelist_geticonwidth " +"_guiimagelist_getimagecount _guiimagelist_getimageinfoex _guiimagelist_remove _guiimagelist_replaceicon " +"_guiimagelist_setbkcolor _guiimagelist_seticonsize _guiimagelist_setimagecount _guiimagelist_swap " +"_guiscrollbars_enablescrollbar _guiscrollbars_getscrollbarinfoex _guiscrollbars_getscrollbarrect " +"_guiscrollbars_getscrollbarrgstate _guiscrollbars_getscrollbarxylinebutton " +"_guiscrollbars_getscrollbarxythumbbottom _guiscrollbars_getscrollbarxythumbtop " +"_guiscrollbars_getscrollinfo _guiscrollbars_getscrollinfoex _guiscrollbars_getscrollinfomax " +"_guiscrollbars_getscrollinfomin _guiscrollbars_getscrollinfopage _guiscrollbars_getscrollinfopos " +"_guiscrollbars_getscrollinfotrackpos _guiscrollbars_getscrollpos _guiscrollbars_getscrollrange " +"_guiscrollbars_init _guiscrollbars_scrollwindow _guiscrollbars_setscrollinfo " +"_guiscrollbars_setscrollinfomax _guiscrollbars_setscrollinfomin _guiscrollbars_setscrollinfopage " +"_guiscrollbars_setscrollinfopos _guiscrollbars_setscrollrange _guiscrollbars_showscrollbar " +"_guitooltip_activate _guitooltip_addtool _guitooltip_adjustrect _guitooltip_bitstottf _guitooltip_create " +"_guitooltip_deltool _guitooltip_destroy _guitooltip_enumtools _guitooltip_getbubbleheight " +"_guitooltip_getbubblesize _guitooltip_getbubblewidth _guitooltip_getcurrenttool _guitooltip_getdelaytime " +"_guitooltip_getmargin _guitooltip_getmarginex _guitooltip_getmaxtipwidth _guitooltip_gettext " +"_guitooltip_gettipbkcolor _guitooltip_gettiptextcolor _guitooltip_gettitlebitmap _guitooltip_gettitletext " +"_guitooltip_gettoolcount _guitooltip_gettoolinfo _guitooltip_hittest _guitooltip_newtoolrect " +"_guitooltip_pop _guitooltip_popup _guitooltip_setdelaytime _guitooltip_setmargin " +"_guitooltip_setmaxtipwidth _guitooltip_settipbkcolor _guitooltip_settiptextcolor _guitooltip_settitle " +"_guitooltip_settoolinfo _guitooltip_setwindowtheme _guitooltip_toolexists _guitooltip_tooltoarray " +"_guitooltip_trackactivate _guitooltip_trackposition _guitooltip_ttftobits _guitooltip_update " +"_guitooltip_updatetiptext _hextostring _ie_example _ie_introduction _ie_versioninfo _ieaction _ieattach " +"_iebodyreadhtml _iebodyreadtext _iebodywritehtml _iecreate _iecreateembedded _iedocgetobj _iedocinserthtml " +"_iedocinserttext _iedocreadhtml _iedocwritehtml _ieerrorhandlerderegister _ieerrorhandlerregister " +"_ieerrornotify _ieformelementcheckboxselect _ieformelementgetcollection _ieformelementgetobjbyname " +"_ieformelementgetvalue _ieformelementoptionselect _ieformelementradioselect _ieformelementsetvalue " +"_ieformgetcollection _ieformgetobjbyname _ieformimageclick _ieformreset _ieformsubmit " +"_ieframegetcollection _ieframegetobjbyname _iegetobjbyid _iegetobjbyname _ieheadinserteventscript " +"_ieimgclick _ieimggetcollection _ieisframeset _ielinkclickbyindex _ielinkclickbytext _ielinkgetcollection " +"_ieloadwait _ieloadwaittimeout _ienavigate _iepropertyget _iepropertyset _iequit _ietablegetcollection " +"_ietablewritetoarray _ietagnameallgetcollection _ietagnamegetcollection _iif _inetexplorercapable " +"_inetgetsource _inetmail _inetsmtpmail _ispressed _mathcheckdiv _max _memglobalalloc _memglobalfree " +"_memgloballock _memglobalsize _memglobalunlock _memmovememory _memvirtualalloc _memvirtualallocex " +"_memvirtualfree _memvirtualfreeex _min _mousetrap _namedpipes_callnamedpipe _namedpipes_connectnamedpipe " +"_namedpipes_createnamedpipe _namedpipes_createpipe _namedpipes_disconnectnamedpipe " +"_namedpipes_getnamedpipehandlestate _namedpipes_getnamedpipeinfo _namedpipes_peeknamedpipe " +"_namedpipes_setnamedpipehandlestate _namedpipes_transactnamedpipe _namedpipes_waitnamedpipe " +"_net_share_connectionenum _net_share_fileclose _net_share_fileenum _net_share_filegetinfo " +"_net_share_permstr _net_share_resourcestr _net_share_sessiondel _net_share_sessionenum " +"_net_share_sessiongetinfo _net_share_shareadd _net_share_sharecheck _net_share_sharedel " +"_net_share_shareenum _net_share_sharegetinfo _net_share_sharesetinfo _net_share_statisticsgetsvr " +"_net_share_statisticsgetwrk _now _nowcalc _nowcalcdate _nowdate _nowtime _pathfull _pathgetrelative " +"_pathmake _pathsplit _processgetname _processgetpriority _radian _replacestringinfile _rundos " +"_screencapture_capture _screencapture_capturewnd _screencapture_saveimage _screencapture_setbmpformat " +"_screencapture_setjpgquality _screencapture_settifcolordepth _screencapture_settifcompression " +"_security__adjusttokenprivileges _security__createprocesswithtoken _security__duplicatetokenex " +"_security__getaccountsid _security__getlengthsid _security__gettokeninformation _security__impersonateself " +"_security__isvalidsid _security__lookupaccountname _security__lookupaccountsid " +"_security__lookupprivilegevalue _security__openprocesstoken _security__openthreadtoken " +"_security__openthreadtokenex _security__setprivilege _security__settokeninformation " +"_security__sidtostringsid _security__sidtypestr _security__stringsidtosid _sendmessage _sendmessagea " +"_setdate _settime _singleton _soundclose _soundlength _soundopen _soundpause _soundplay _soundpos " +"_soundresume _soundseek _soundstatus _soundstop _sqlite_changes _sqlite_close _sqlite_display2dresult " +"_sqlite_encode _sqlite_errcode _sqlite_errmsg _sqlite_escape _sqlite_exec _sqlite_fastencode " +"_sqlite_fastescape _sqlite_fetchdata _sqlite_fetchnames _sqlite_gettable _sqlite_gettable2d " +"_sqlite_lastinsertrowid _sqlite_libversion _sqlite_open _sqlite_query _sqlite_queryfinalize " +"_sqlite_queryreset _sqlite_querysinglerow _sqlite_safemode _sqlite_settimeout _sqlite_shutdown " +"_sqlite_sqliteexe _sqlite_startup _sqlite_totalchanges _stringbetween _stringencrypt _stringexplode " +"_stringinsert _stringproper _stringrepeat _stringreverse _stringtohex _tcpiptoname _tempfile _tickstotime " +"_timer_diff _timer_getidletime _timer_gettimerid _timer_init _timer_killalltimers _timer_killtimer " +"_timer_settimer _timetoticks _versioncompare _viclose _viexeccommand _vifindgpib _vigpibbusreset _vigtl " +"_viinteractivecontrol _viopen _visetattribute _visettimeout _weeknumberiso _winapi_attachconsole " +"_winapi_attachthreadinput _winapi_beep _winapi_bitblt _winapi_callnexthookex _winapi_callwindowproc " +"_winapi_clienttoscreen _winapi_closehandle _winapi_combinergn _winapi_commdlgextendederror " +"_winapi_copyicon _winapi_createbitmap _winapi_createcompatiblebitmap _winapi_createcompatibledc " +"_winapi_createevent _winapi_createfile _winapi_createfont _winapi_createfontindirect _winapi_createpen " +"_winapi_createprocess _winapi_createrectrgn _winapi_createroundrectrgn _winapi_createsolidbitmap " +"_winapi_createsolidbrush _winapi_createwindowex _winapi_defwindowproc _winapi_deletedc " +"_winapi_deleteobject _winapi_destroyicon _winapi_destroywindow _winapi_drawedge _winapi_drawframecontrol " +"_winapi_drawicon _winapi_drawiconex _winapi_drawline _winapi_drawtext _winapi_duplicatehandle " +"_winapi_enablewindow _winapi_enumdisplaydevices _winapi_enumwindows _winapi_enumwindowspopup " +"_winapi_enumwindowstop _winapi_expandenvironmentstrings _winapi_extracticonex _winapi_fatalappexit " +"_winapi_fillrect _winapi_findexecutable _winapi_findwindow _winapi_flashwindow _winapi_flashwindowex " +"_winapi_floattoint _winapi_flushfilebuffers _winapi_formatmessage _winapi_framerect _winapi_freelibrary " +"_winapi_getancestor _winapi_getasynckeystate _winapi_getbkmode _winapi_getclassname " +"_winapi_getclientheight _winapi_getclientrect _winapi_getclientwidth _winapi_getcurrentprocess " +"_winapi_getcurrentprocessid _winapi_getcurrentthread _winapi_getcurrentthreadid _winapi_getcursorinfo " +"_winapi_getdc _winapi_getdesktopwindow _winapi_getdevicecaps _winapi_getdibits _winapi_getdlgctrlid " +"_winapi_getdlgitem _winapi_getfilesizeex _winapi_getfocus _winapi_getforegroundwindow " +"_winapi_getguiresources _winapi_geticoninfo _winapi_getlasterror _winapi_getlasterrormessage " +"_winapi_getlayeredwindowattributes _winapi_getmodulehandle _winapi_getmousepos _winapi_getmouseposx " +"_winapi_getmouseposy _winapi_getobject _winapi_getopenfilename _winapi_getoverlappedresult " +"_winapi_getparent _winapi_getprocessaffinitymask _winapi_getsavefilename _winapi_getstdhandle " +"_winapi_getstockobject _winapi_getsyscolor _winapi_getsyscolorbrush _winapi_getsystemmetrics " +"_winapi_gettextextentpoint32 _winapi_gettextmetrics _winapi_getwindow _winapi_getwindowdc " +"_winapi_getwindowheight _winapi_getwindowlong _winapi_getwindowplacement _winapi_getwindowrect " +"_winapi_getwindowrgn _winapi_getwindowtext _winapi_getwindowthreadprocessid _winapi_getwindowwidth " +"_winapi_getxyfrompoint _winapi_globalmemorystatus _winapi_guidfromstring _winapi_guidfromstringex " +"_winapi_hiword _winapi_inprocess _winapi_inttofloat _winapi_invalidaterect _winapi_isclassname " +"_winapi_iswindow _winapi_iswindowvisible _winapi_lineto _winapi_loadbitmap _winapi_loadimage " +"_winapi_loadlibrary _winapi_loadlibraryex _winapi_loadshell32icon _winapi_loadstring _winapi_localfree " +"_winapi_loword _winapi_makelangid _winapi_makelcid _winapi_makelong _winapi_makeqword _winapi_messagebeep " +"_winapi_mouse_event _winapi_moveto _winapi_movewindow _winapi_msgbox _winapi_muldiv " +"_winapi_multibytetowidechar _winapi_multibytetowidecharex _winapi_openprocess _winapi_pathfindonpath " +"_winapi_pointfromrect _winapi_postmessage _winapi_primarylangid _winapi_ptinrect _winapi_readfile " +"_winapi_readprocessmemory _winapi_rectisempty _winapi_redrawwindow _winapi_registerwindowmessage " +"_winapi_releasecapture _winapi_releasedc _winapi_screentoclient _winapi_selectobject _winapi_setbkcolor " +"_winapi_setbkmode _winapi_setcapture _winapi_setcursor _winapi_setdefaultprinter _winapi_setdibits " +"_winapi_setendoffile _winapi_setevent _winapi_setfilepointer _winapi_setfocus _winapi_setfont " +"_winapi_sethandleinformation _winapi_setlasterror _winapi_setlayeredwindowattributes _winapi_setparent " +"_winapi_setprocessaffinitymask _winapi_setsyscolors _winapi_settextcolor _winapi_setwindowlong " +"_winapi_setwindowplacement _winapi_setwindowpos _winapi_setwindowrgn _winapi_setwindowshookex " +"_winapi_setwindowtext _winapi_showcursor _winapi_showerror _winapi_showmsg _winapi_showwindow " +"_winapi_stringfromguid _winapi_stringlena _winapi_stringlenw _winapi_sublangid " +"_winapi_systemparametersinfo _winapi_twipsperpixelx _winapi_twipsperpixely _winapi_unhookwindowshookex " +"_winapi_updatelayeredwindow _winapi_updatewindow _winapi_waitforinputidle _winapi_waitformultipleobjects " +"_winapi_waitforsingleobject _winapi_widechartomultibyte _winapi_windowfrompoint _winapi_writeconsole " +"_winapi_writefile _winapi_writeprocessmemory _winnet_addconnection _winnet_addconnection2 " +"_winnet_addconnection3 _winnet_cancelconnection _winnet_cancelconnection2 _winnet_closeenum " +"_winnet_connectiondialog _winnet_connectiondialog1 _winnet_disconnectdialog _winnet_disconnectdialog1 " +"_winnet_enumresource _winnet_getconnection _winnet_getconnectionperformance _winnet_getlasterror " +"_winnet_getnetworkinformation _winnet_getprovidername _winnet_getresourceinformation " +"_winnet_getresourceparent _winnet_getuniversalname _winnet_getuser _winnet_openenum " +"_winnet_restoreconnection _winnet_useconnection _word_versioninfo _wordattach _wordcreate _worddocadd " +"_worddocaddlink _worddocaddpicture _worddocclose _worddocfindreplace _worddocgetcollection " +"_worddoclinkgetcollection _worddocopen _worddocprint _worddocpropertyget _worddocpropertyset _worddocsave " +"_worddocsaveas _worderrorhandlerderegister _worderrorhandlerregister _worderrornotify _wordmacrorun " +"_wordpropertyget _wordpropertyset _wordquit", +"" }; + + +EDITLEXER lexAU3 = { SCLEX_AU3, 63276, L"AutoIt3 Script", L"au3", L"", &KeyWords_AU3, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_AU3_COMMENT,SCE_AU3_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_AU3_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + { SCE_AU3_FUNCTION, 63277, L"Function", L"fore:#0000FF", L"" }, + { SCE_AU3_UDF, 63360, L"User-Defined Function", L"fore:#0000FF", L"" }, + { SCE_AU3_KEYWORD, 63128, L"Keyword", L"fore:#0000FF", L"" }, + { SCE_AU3_MACRO, 63278, L"Macro", L"fore:#0080FF", L"" }, + { SCE_AU3_STRING, 63131, L"String", L"fore:#008080", L"" }, + { SCE_AU3_OPERATOR, 63132, L"Operator", L"fore:#C000C0", L"" }, + { SCE_AU3_VARIABLE, 63249, L"Variable", L"fore:#808000", L"" }, + { SCE_AU3_SENT, 63279, L"Send Key", L"fore:#FF0000", L"" }, + { SCE_AU3_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + { SCE_AU3_SPECIAL, 63280, L"Special", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +EDITLEXER lexLATEX = { SCLEX_LATEX, 63281, L"LaTeX Files", L"tex; latex; sty", L"", &KeyWords_NULL, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_L_COMMAND,SCE_L_SHORTCMD,SCE_L_CMDOPT,0), 63236, L"Command", L"fore:#0000FF", L"" }, + { MULTI_STYLE(SCE_L_COMMENT,SCE_L_COMMENT2,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_L_MATH,SCE_L_MATH2,0,0), 63283, L"Math", L"fore:#FF0000", L"" }, + { SCE_L_SPECIAL, 63330, L"Special Char", L"fore:#AAAA00", L"" }, + { MULTI_STYLE(SCE_L_TAG,SCE_L_TAG2,0,0), 63282, L"Tag", L"fore:#0000FF", L"" }, + { SCE_L_VERBATIM, 63331, L"Verbatim Segment", L"fore:#666666", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +EDITLEXER lexANSI = { SCLEX_NULL, 63258, L"ANSI Art", L"nfo; diz", L"", &KeyWords_NULL, { + { STYLE_DEFAULT, 63126, L"Default", L"font:Lucida Console", L"" }, + { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" }, + { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+0", L"" }, + { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+0", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_AHK = { +"break continue else exit exitapp gosub goto if ifequal ifexist ifgreater ifgreaterorequal " +"ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist ifnotinstring ifwinactive " +"ifwinexist ifwinnotactive ifwinnotexist loop onexit pause repeat return settimer sleep " +"suspend static global local var byref while until for class try catch throw", +"autotrim blockinput clipwait control controlclick controlfocus controlget controlgetfocus " +"controlgetpos controlgettext controlmove controlsend controlsendraw controlsettext coordmode " +"critical detecthiddentext detecthiddenwindows drive driveget drivespacefree edit endrepeat " +"envadd envdiv envget envmult envset envsub envupdate fileappend filecopy filecopydir filecreatedir " +"filecreateshortcut filedelete filegetattrib filegetshortcut filegetsize filegettime filegetversion " +"fileinstall filemove filemovedir fileread filereadline filerecycle filerecycleempty fileremovedir " +"fileselectfile fileselectfolder filesetattrib filesettime formattime getkeystate groupactivate " +"groupadd groupclose groupdeactivategui guicontrol guicontrolget hideautoitwin hotkey imagesearch " +"inidelete iniread iniwrite input inputbox keyhistory keywait listhotkeys listlines listvars menu " +"mouseclick mouseclickdrag mousegetpos mousemove msgbox outputdebug pixelgetcolor pixelsearch " +"postmessage process progress random regdelete regread regwrite reload run runas runwait send " +"sendevent sendinput sendmessage sendmode sendplay sendraw setbatchlines setcapslockstate " +"setcontroldelay setdefaultmousespeed setenv setformat setkeydelay setmousedelay setnumlockstate " +"setscrolllockstate setstorecapslockmode settitlematchmode setwindelay setworkingdir shutdown sort " +"soundbeep soundget soundgetwavevolume soundplay soundset soundsetwavevolume splashimage splashtextoff " +"splashtexton splitpath statusbargettext statusbarwait stringcasesense stringgetpos stringleft stringlen " +"stringlower stringmid stringreplace stringright stringsplit stringtrimleft stringtrimright stringupper " +"sysget thread tooltip transform traytip urldownloadtofile winactivate winactivatebottom winclose winget " +"wingetactivestats wingetactivetitle wingetclass wingetpos wingettext wingettitle winhide winkill " +"winmaximize winmenuselectitem winminimize winminimizeall winminimizeallundo winmove winrestore winset " +"winsettitle winshow winwait winwaitactive winwaitclose winwaitnotactive fileencoding", +"abs acos asc asin atan ceil chr cos dllcall exp fileexist floor getkeystate numget numput " +"registercallback il_add il_create il_destroy instr islabel isfunc ln log lv_add lv_delete " +"lv_deletecol lv_getcount lv_getnext lv_gettext lv_insert lv_insertcol lv_modify lv_modifycol " +"lv_setimagelist mod onmessage round regexmatch regexreplace sb_seticon sb_setparts sb_settext " +"sin sqrt strlen substr tan tv_add tv_delete tv_getchild tv_getcount tv_getnext tv_get tv_getparent " +"tv_getprev tv_getselection tv_gettext tv_modify tv_setimagelist varsetcapacity winactive winexist " +"trim ltrim rtrim fileopen strget strput object array isobject objinsert objremove objminindex " +"objmaxindex objsetcapacity objgetcapacity objgetaddress objnewenum objaddref objrelease objhaskey " +"objclone _insert _remove _minindex _maxindex _setcapacity _getcapacity _getaddress _newenum _addref " +"_release _haskey _clone comobjcreate comobjget comobjconnect comobjerror comobjactive comobjenwrap " +"comobjunwrap comobjparameter comobjmissing comobjtype comobjvalue comobjarray comobjquery comobjflags " +"func getkeyname getkeyvk getkeysc isbyref exception", +"allowsamelinecomments clipboardtimeout commentflag errorstdout escapechar hotkeyinterval " +"hotkeymodifiertimeout hotstring if iftimeout ifwinactive ifwinexist include includeagain " +"installkeybdhook installmousehook keyhistory ltrim maxhotkeysperinterval maxmem maxthreads " +"maxthreadsbuffer maxthreadsperhotkey menumaskkey noenv notrayicon persistent singleinstance " +"usehook warn winactivateforce", +"shift lshift rshift alt lalt ralt control lcontrol rcontrol ctrl lctrl rctrl lwin rwin appskey " +"altdown altup shiftdown shiftup ctrldown ctrlup lwindown lwinup rwindown rwinup lbutton rbutton " +"mbutton wheelup wheeldown xbutton1 xbutton2 joy1 joy2 joy3 joy4 joy5 joy6 joy7 joy8 joy9 joy10 " +"joy11 joy12 joy13 joy14 joy15 joy16 joy17 joy18 joy19 joy20 joy21 joy22 joy23 joy24 joy25 joy26 " +"joy27 joy28 joy29 joy30 joy31 joy32 joyx joyy joyz joyr joyu joyv joypov joyname joybuttons " +"joyaxes joyinfo space tab enter escape esc backspace bs delete del insert ins pgup pgdn home end " +"up down left right printscreen ctrlbreak pause scrolllock capslock numlock numpad0 numpad1 numpad2 " +"numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9 numpadmult numpadadd numpadsub numpaddiv " +"numpaddot numpaddel numpadins numpadclear numpadup numpaddown numpadleft numpadright numpadhome " +"numpadend numpadpgup numpadpgdn numpadenter f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 " +"f16 f17 f18 f19 f20 f21 f22 f23 f24 browser_back browser_forward browser_refresh browser_stop " +"browser_search browser_favorites browser_home volume_mute volume_down volume_up media_next " +"media_prev media_stop media_play_pause launch_mail launch_media launch_app1 launch_app2 blind " +"click raw wheelleft wheelright", +"a_ahkpath a_ahkversion a_appdata a_appdatacommon a_autotrim a_batchlines a_caretx a_carety " +"a_computername a_controldelay a_cursor a_dd a_ddd a_dddd a_defaultmousespeed a_desktop " +"a_desktopcommon a_detecthiddentext a_detecthiddenwindows a_endchar a_eventinfo a_exitreason " +"a_formatfloat a_formatinteger a_gui a_guievent a_guicontrol a_guicontrolevent a_guiheight " +"a_guiwidth a_guix a_guiy a_hour a_iconfile a_iconhidden a_iconnumber a_icontip a_index " +"a_ipaddress1 a_ipaddress2 a_ipaddress3 a_ipaddress4 a_isadmin a_iscompiled a_issuspended " +"a_keydelay a_language a_lasterror a_linefile a_linenumber a_loopfield a_loopfileattrib " +"a_loopfiledir a_loopfileext a_loopfilefullpath a_loopfilelongpath a_loopfilename " +"a_loopfileshortname a_loopfileshortpath a_loopfilesize a_loopfilesizekb a_loopfilesizemb " +"a_loopfiletimeaccessed a_loopfiletimecreated a_loopfiletimemodified a_loopreadline a_loopregkey " +"a_loopregname a_loopregsubkey a_loopregtimemodified a_loopregtype a_mday a_min a_mm a_mmm " +"a_mmmm a_mon a_mousedelay a_msec a_mydocuments a_now a_nowutc a_numbatchlines a_ostype " +"a_osversion a_priorhotkey a_programfiles a_programs a_programscommon a_screenheight " +"a_screenwidth a_scriptdir a_scriptfullpath a_scriptname a_sec a_space a_startmenu " +"a_startmenucommon a_startup a_startupcommon a_stringcasesense a_tab a_temp a_thishotkey " +"a_thismenu a_thismenuitem a_thismenuitempos a_tickcount a_timeidle a_timeidlephysical " +"a_timesincepriorhotkey a_timesincethishotkey a_titlematchmode a_titlematchmodespeed " +"a_username a_wday a_windelay a_windir a_workingdir a_yday a_year a_yweek a_yyyy " +"clipboard clipboardall comspec errorlevel programfiles true false a_thisfunc a_thislabel " +"a_ispaused a_iscritical a_isunicode a_ptrsize a_scripthwnd a_priorkey", +"ltrim rtrim join ahk_id ahk_pid ahk_class ahk_group ahk_exe processname processpath minmax " +"controllist statuscd filesystem setlabel alwaysontop mainwindow nomainwindow useerrorlevel " +"altsubmit hscroll vscroll imagelist wantctrla wantf2 vis visfirst wantreturn backgroundtrans " +"minimizebox maximizebox sysmenu toolwindow exstyle check3 checkedgray readonly notab lastfound " +"lastfoundexist alttab shiftalttab alttabmenu alttabandmenu alttabmenudismiss controllisthwnd " +"hwnd deref pow bitnot bitand bitor bitxor bitshiftleft bitshiftright sendandmouse mousemove " +"mousemoveoff hkey_local_machine hkey_users hkey_current_user hkey_classes_root hkey_current_config " +"hklm hku hkcu hkcr hkcc reg_sz reg_expand_sz reg_multi_sz reg_dword reg_qword reg_binary reg_link " +"reg_resource_list reg_full_resource_descriptor reg_resource_requirements_list reg_dword_big_endian " +"regex pixel mouse screen relative rgb low belownormal normal abovenormal high realtime between " +"contains in is integer float number digit xdigit integerfast floatfast alpha upper lower alnum " +"time date not or and topmost top bottom transparent transcolor redraw region id idlast count " +"list capacity eject lock unlock label serial type status seconds minutes hours days read parse " +"logoff close error single shutdown menu exit reload tray add rename check uncheck togglecheck " +"enable disable toggleenable default nodefault standard nostandard color delete deleteall icon " +"noicon tip click show edit progress hotkey text picture pic groupbox button checkbox radio " +"dropdownlist ddl combobox statusbar treeview listbox listview datetime monthcal updown slider " +"tab tab2 activex iconsmall tile report sortdesc nosort nosorthdr grid hdr autosize range xm ym " +"ys xs xp yp font resize owner submit nohide minimize maximize restore noactivate na cancel " +"destroy center margin owndialogs guiescape guiclose guisize guicontextmenu guidropfiles tabstop " +"section wrap border top bottom buttons expand first lines number uppercase lowercase limit " +"password multi group background bold italic strike underline norm theme caption delimiter flash " +"style checked password hidden left right center section move focus hide choose choosestring text " +"pos enabled disabled visible notimers interrupt priority waitclose unicode tocodepage fromcodepage " +"yes no ok cancel abort retry ignore force on off all send wanttab monitorcount monitorprimary " +"monitorname monitorworkarea pid this base extends __get __set __call __delete __new new " +"useunsetlocal useunsetglobal useenv localsameasglobal", +"", "" }; + + +EDITLEXER lexAHK = { SCLEX_AHK, 63305, L"AutoHotkey Script", L"ahk; ia; scriptlet", L"", &KeyWords_AHK, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_AHK_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_AHK_COMMENTLINE,SCE_AHK_COMMENTBLOCK,0,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_AHK_ESCAPE, 63306, L"Escape", L"fore:#FF8000", L"" }, + { SCE_AHK_SYNOPERATOR, 63307, L"Syntax Operator", L"fore:#7F200F", L"" }, + { SCE_AHK_EXPOPERATOR, 63308, L"Expression operator", L"fore:#FF4F00", L"" }, + { SCE_AHK_STRING, 63131, L"String", L"fore:#404040", L"" }, + { SCE_AHK_NUMBER, 63130, L"Number", L"fore:#2F4F7F", L"" }, + { SCE_AHK_IDENTIFIER, 63129, L"Identifier", L"fore:#CF2F0F", L"" }, + { SCE_AHK_VARREF, 63309, L"Variable dereferencing", L"fore:#CF2F0F; back:#E4FFE4", L"" }, + { SCE_AHK_LABEL, 63235, L"Label", L"fore:#000000; back:#FFFFA1", L"" }, + { SCE_AHK_WORD_CF, 63310, L"Flow of control", L"fore:#480048; bold", L"" }, + { SCE_AHK_WORD_CMD, 63236, L"Command", L"fore:#004080", L"" }, + { SCE_AHK_WORD_FN, 63277, L"Function", L"fore:#0F707F; italics", L"" }, + { SCE_AHK_WORD_DIR, 63203, L"Directive", L"fore:#F04020; italics", L"" }, + { SCE_AHK_WORD_KB, 63311, L"Keys & buttons", L"fore:#FF00FF; bold", L"" }, + { SCE_AHK_WORD_VAR, 63312, L"Built-in Variables", L"fore:#CF00CF; italics", L"" }, + { SCE_AHK_WORD_SP, 63280, L"Special", L"fore:#0000FF; italics", L"" }, + //{ SCE_AHK_WORD_UD, 63106, L"User Defined", L"fore:#800020", L"" }, + { SCE_AHK_VARREFKW, 63313, L"Variable keyword", L"fore:#CF00CF; italics; back:#F9F9FF", L"" }, + { SCE_AHK_ERROR, 63260, L"Error", L"back:#FFC0C0", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_CMAKE = { +"add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library " +"add_subdirectory add_test aux_source_directory build_command build_name cmake_minimum_required " +"configure_file create_test_sourcelist else elseif enable_language enable_testing endforeach endif " +"endmacro endwhile exec_program execute_process export_library_dependencies file find_file find_library " +"find_package find_path find_program fltk_wrap_ui foreach get_cmake_property get_directory_property " +"get_filename_component get_source_file_property get_target_property get_test_property if include " +"include_directories include_external_msproject include_regular_expression install install_files " +"install_programs install_targets link_directories link_libraries list load_cache load_command " +"macro make_directory mark_as_advanced math message option output_required_files project qt_wrap_cpp " +"qt_wrap_ui remove remove_definitions separate_arguments set set_directory_properties set_source_files_properties " +"set_target_properties set_tests_properties site_name source_group string subdir_depends subdirs " +"target_link_libraries try_compile try_run use_mangled_mesa utility_source variable_requires vtk_make_instantiator " +"vtk_wrap_java vtk_wrap_python vtk_wrap_tcl while write_file", +"ABSOLUTE ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ALL AND APPEND ARGS ASCII BEFORE CACHE CACHE_VARIABLES " +"CLEAR COMMAND COMMANDS COMMAND_NAME COMMENT COMPARE COMPILE_FLAGS COPYONLY DEFINED DEFINE_SYMBOL " +"DEPENDS DOC EQUAL ESCAPE_QUOTES EXCLUDE EXCLUDE_FROM_ALL EXISTS EXPORT_MACRO EXT EXTRA_INCLUDE " +"FATAL_ERROR FILE FILES FORCE FUNCTION GENERATED GLOB GLOB_RECURSE GREATER GROUP_SIZE HEADER_FILE_ONLY " +"HEADER_LOCATION IMMEDIATE INCLUDES INCLUDE_DIRECTORIES INCLUDE_INTERNALS INCLUDE_REGULAR_EXPRESSION " +"LESS LINK_DIRECTORIES LINK_FLAGS LOCATION MACOSX_BUNDLE MACROS MAIN_DEPENDENCY MAKE_DIRECTORY MATCH " +"MATCHALL MATCHES MODULE NAME NAME_WE NOT NOTEQUAL NO_SYSTEM_PATH OBJECT_DEPENDS OPTIONAL OR OUTPUT " +"OUTPUT_VARIABLE PATH PATHS POST_BUILD POST_INSTALL_SCRIPT PREFIX PREORDER PRE_BUILD PRE_INSTALL_SCRIPT " +"PRE_LINK PROGRAM PROGRAM_ARGS PROPERTIES QUIET RANGE READ REGEX REGULAR_EXPRESSION REPLACE REQUIRED " +"RETURN_VALUE RUNTIME_DIRECTORY SEND_ERROR SHARED SOURCES STATIC STATUS STREQUAL STRGREATER STRLESS " +"SUFFIX TARGET TOLOWER TOUPPER VAR VARIABLES VERSION WIN32 WRAP_EXCLUDE WRITE APPLE MINGW MSYS CYGWIN " +"BORLAND WATCOM MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 OFF ON", +"", "", "", "", "", "", "" }; + + +EDITLEXER lexCmake = { SCLEX_CMAKE, 63324, L"Cmake Script", L"cmake; ctest", L"", &KeyWords_CMAKE, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_CMAKE_DEFAULT, L"Default", L"", L"" }, + { SCE_CMAKE_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { MULTI_STYLE(SCE_CMAKE_STRINGDQ,SCE_CMAKE_STRINGLQ,SCE_CMAKE_STRINGRQ,0), 63131, L"String", L"back:#EEEEEE; fore:#7F007F", L"" }, + { SCE_CMAKE_COMMANDS, 63277, L"Function", L"fore:#00007F", L"" }, + { SCE_CMAKE_PARAMETERS, 63294, L"Parameter", L"fore:#7F200F", L"" }, + { SCE_CMAKE_VARIABLE, 63249, L"Variable", L"fore:#CC3300", L"" }, + { SCE_CMAKE_WHILEDEF, 63325, L"While def", L"fore:#00007F", L"" }, + { SCE_CMAKE_FOREACHDEF, 63326, L"For each def", L"fore:#00007F", L"" }, + { SCE_CMAKE_IFDEFINEDEF, 63327, L"If def", L"fore:#00007F", L"" }, + { SCE_CMAKE_MACRODEF, 63328, L"Macro def", L"fore:#00007F", L"" }, + { SCE_CMAKE_STRINGVAR, 63329, L"Variable within string", L"back:#EEEEEE; fore:#CC3300", L"" }, + { SCE_CMAKE_NUMBER, 63130, L"Number", L"fore:#008080", L"" }, + //{ SCE_CMAKE_USERDEFINED, 63106, L"User Defined", L"fore:#800020", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_AVS = { +"true false return global", +"addborders alignedsplice amplify amplifydb animate applyrange assumebff assumefieldbased assumefps " +"assumeframebased assumesamplerate assumescaledfps assumetff audiodub audiodubex avifilesource " +"avisource bicubicresize bilinearresize blackmanresize blackness blankclip blur bob cache changefps " +"colorbars colorkeymask coloryuv compare complementparity conditionalfilter conditionalreader " +"convertaudio convertaudioto16bit convertaudioto24bit convertaudioto32bit convertaudioto8bit " +"convertaudiotofloat convertbacktoyuy2 convertfps converttobackyuy2 converttomono converttorgb " +"converttorgb24 converttorgb32 converttoy8 converttoyv16 converttoyv24 converttoyv411 converttoyuy2 " +"converttoyv12 crop cropbottom delayaudio deleteframe dissolve distributor doubleweave duplicateframe " +"ensurevbrmp3sync fadein fadein0 fadein2 fadeio fadeio0 fadeio2 fadeout fadeout0 fadeout2 fixbrokenchromaupsampling " +"fixluminance fliphorizontal flipvertical frameevaluate freezeframe gaussresize generalconvolution " +"getchannel getchannels getmtmode getparity grayscale greyscale histogram horizontalreduceby2 " +"imagereader imagesource imagewriter info interleave internalcache internalcachemt invert killaudio " +"killvideo lanczos4resize lanczosresize layer letterbox levels limiter loop mask maskhs max merge " +"mergeargb mergechannels mergechroma mergeluma mergergb messageclip min mixaudio monotostereo normalize " +"null opendmlsource overlay peculiarblend pointresize pulldown reduceby2 resampleaudio resetmask reverse " +"rgbadjust scriptclip segmentedavisource segmenteddirectshowsource selecteven selectevery selectodd " +"selectrangeevery separatefields setmtmode sharpen showalpha showblue showfiveversions showframenumber " +"showgreen showred showsmpte showtime sincresize skewrows spatialsoften spline16resize spline36resize " +"spline64resize ssrc stackhorizontal stackvertical subtitle subtract supereq swapfields swapuv " +"temporalsoften timestretch tone trim turn180 turnleft turnright tweak unalignedsplice utoy utoy8 " +"version verticalreduceby2 vtoy vtoy8 wavsource weave writefile writefileend writefileif writefilestart " +"ytouv", +"addgrain addgrainc agc_hdragc analyzelogo animeivtc asharp audiograph autocrop autoyuy2 avsrecursion " +"awarpsharp bassaudiosource bicublinresize bifrost binarize blendfields blindpp blockbuster bordercontrol " +"cfielddiff cframediff chromashift cnr2 colormatrix combmask contra convolution3d convolution3dyv12 " +"dctfilter ddcc deblendlogo deblock deblock_qed decimate decomb dedup deen deflate degrainmedian depan " +"depanestimate depaninterleave depanscenes depanstabilize descratch despot dfttest dgbob dgdecode_mpeg2source " +"dgsource directshowsource distancefunction dss2 dup dupmc edeen edgemask ediupsizer eedi2 eedi3 eedi3_rpow2 " +"expand faerydust fastbicubicresize fastbilinearresize fastediupsizer dedgemask fdecimate ffaudiosource " +"ffdshow ffindex ffmpegsource ffmpegsource2 fft3dfilter fft3dgpu ffvideosource fielddeinterlace fielddiff " +"fillmargins fity2uv fity2u fity2v fitu2y fitv2y fluxsmooth fluxsmoothst fluxsmootht framediff framenumber " +"frfun3b frfun7 gicocu golddust gradfun2db grapesmoother greedyhma grid guavacomb hqdn3d hybridfupp " +"hysteresymask ibob improvesceneswitch inflate inpand inpaintlogo interframe interlacedresize " +"interlacedwarpedresize interleaved2planar iscombed iscombedt iscombedtivtc kerneldeint leakkernelbob " +"leakkerneldeint limitedsharpen limitedsharpenfaster logic lsfmod lumafilter lumayv12 manalyse " +"maskeddeinterlace maskedmerge maskedmix mblockfps mcompensate mctemporaldenoise mctemporaldenoisepp " +"mdegrain1 mdegrain2 mdegrain3 mdepan medianblur mergehints mflow mflowblur mflowfps mflowinter minblur " +"mipsmooth mmask moderatesharpen monitorfilter motionmask mpasource mpeg2source mrecalculate mscdetection " +"msharpen mshow msmooth msu_fieldshiftfixer msu_frc msuper mt mt_adddiff mt_average mt_binarize mt_circle " +"mt_clamp mt_convolution mt_deflate mt_diamond mt_edge mt_ellipse mt_expand mt_freeellipse mt_freelosange " +"mt_freerectangle mt_hysteresis mt_infix mt_inflate mt_inpand mt_invert mt_logic mt_losange mt_lut mt_lutf " +"mt_luts mt_lutspa mt_lutsx mt_lutxy mt_lutxyz mt_makediff mt_mappedblur mt_merge mt_motion mt_polish " +"mt_rectangle mt_square mti mtsource multidecimate mvanalyse mvblockfps mvchangecompensate mvcompensate " +"mvdegrain1 mvdegrain2 mvdegrain3 mvdenoise mvdepan mvflow mvflowblur mvflowfps mvflowfps2 mvflowinter " +"mvincrease mvmask mvrecalculate mvscdetection mvshow nicac3source nicdtssource niclpcmsource nicmpasource " +"nicmpg123source nnedi nnedi2 nnedi2_rpow2 nnedi3 nnedi3_rpow2 nomosmooth overlaymask peachsmoother pixiedust " +"planar2interleaved qtgmc qtinput rawavsource rawsource reduceflicker reinterpolate411 removedirt removedust " +"removegrain removegrainhd removetemporalgrain repair requestlinear reversefielddominance rgb3dlut rgdeinterlace " +"rgsdeinterlace rgblut rotate sangnom seesaw sharpen2 showchannels showcombedtivtc smartdecimate smartdeinterlace " +"smdegrain smoothdeinterlace smoothuv soothess soxfilter spacedust sshiq ssim ssiq stmedianfilter t3dlut tanisotropic " +"tbilateral tcanny tcomb tcombmask tcpserver tcpsource tdecimate tdeint tedgemask telecide temporalcleaner " +"temporalrepair temporalsmoother tfieldblank tfm tisophote tivtc tmaskblank tmaskedmerge tmaskedmerge3 tmm " +"tmonitor tnlmeans tomsmocomp toon textsub ttempsmooth ttempsmoothf tunsharp unblock uncomb undot unfilter " +"unsharpmask vaguedenoiser variableblur verticalcleaner videoscope vinverse vobsub vqmcalc warpedresize warpsharp " +"xsharpen yadif yadifmod yuy2lut yv12convolution yv12interlacedreduceby2 yv12interlacedselecttopfields " +"yv12layer yv12lut yv12lutxy yv12substract yv12torgb24 yv12toyuy2", +"abs apply assert bool ceil chr clip continueddenominator continuednumerator cos default defined eval " +"averagechromau averagechromav averageluma chromaudifference chromavdifference lumadifference " +"exist exp findstr float floor frac hexvalue import int isbool isclip isfloat isint isstring lcase leftstr " +"load_stdcall_plugin loadcplugin loadplugin loadvfapiplugin loadvirtualdubplugin log midstr muldiv nop " +"opt_allowfloataudio opt_avipadscanlines opt_dwchannelmask opt_usewaveextensible opt_vdubplanarhack " +"pi pow rand revstr rightstr round scriptdir scriptfile scriptname select setmemorymax setplanarlegacyalignment " +"rgbdifference rgbdifferencefromprevious rgbdifferencetonext udifferencefromprevious udifferencetonext " +"setworkingdir sign sin spline sqrt string strlen time ucase undefined value versionnumber versionstring " +"uplanemax uplanemedian uplanemin uplaneminmaxdifference vdifferencefromprevious vdifferencetonext " +"vplanemax vplanemedian vplanemin vplaneminmaxdifference ydifferencefromprevious ydifferencetonext " +"yplanemax yplanemedian yplanemin yplaneminmaxdifference", +"audiobits audiochannels audiolength audiolengthf audiorate framecount framerate frameratedenominator " +"frameratenumerator getleftchannel getrightchannel hasaudio hasvideo height isaudiofloat isaudioint " +"isfieldbased isframebased isinterleaved isplanar isrgb isrgb24 isrgb32 isyuv isyuy2 isyv12 width", +"", "", "", "" }; + + +EDITLEXER lexAVS = { SCLEX_AVS, 63332, L"AviSynth Script", L"avs; avsi", L"", &KeyWords_AVS, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_AVS_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_AVS_COMMENTLINE,SCE_AVS_COMMENTBLOCK,SCE_AVS_COMMENTBLOCKN,0), 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_AVS_OPERATOR, 63132, L"Operator", L"", L"" }, + { MULTI_STYLE(SCE_AVS_STRING,SCE_AVS_TRIPLESTRING,0,0), 63131, L"String", L"fore:#7F007F", L"" }, + { SCE_AVS_NUMBER, 63130, L"Number", L"fore:#007F7F", L"" }, + { SCE_AVS_KEYWORD, 63128, L"Keyword", L"fore:#00007F; bold", L"" }, + { SCE_AVS_FILTER, 63333, L"Filter", L"fore:#00007F; bold", L"" }, + { SCE_AVS_PLUGIN, 63334, L"Plugin", L"fore:#0080C0; bold", L"" }, + { SCE_AVS_FUNCTION, 63277, L"Function", L"fore:#007F7F", L"" }, + { SCE_AVS_CLIPPROP, 63335, L"Clip property", L"fore:#00007F", L"" }, + //{ SCE_AVS_USERDFN, 63106, L"User Defined", L"fore:#8000FF", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_MARKDOWN = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexMARKDOWN = { SCLEX_MARKDOWN, 63336, L"Markdown", L"md; markdown; mdown; mkdn; mkd", L"", &KeyWords_MARKDOWN, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_MARKDOWN_DEFAULT, L"Default", L"", L"" }, + { SCE_MARKDOWN_LINE_BEGIN, 63338, L"Line Begin", L"", L"" }, + { MULTI_STYLE(SCE_MARKDOWN_STRONG1,SCE_MARKDOWN_STRONG2,0,0), 63339, L"Strong", L"bold", L"" }, + { MULTI_STYLE(SCE_MARKDOWN_EM1,SCE_MARKDOWN_EM2,0,0), 63340, L"Emphasis", L"italic", L"" }, + { SCE_MARKDOWN_HEADER1, 63341, L"Header 1", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_HEADER2, 63342, L"Header 2", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_HEADER3, 63343, L"Header 3", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_HEADER4, 63344, L"Header 4", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_HEADER5, 63345, L"Header 5", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_HEADER6, 63346, L"Header 6", L"fore:#FF0088; bold", L"" }, + { SCE_MARKDOWN_PRECHAR, 63347, L"Pre char", L"fore:#00007F", L"" }, + { SCE_MARKDOWN_ULIST_ITEM, 63348, L"Unordered list", L"fore:#0080FF; bold", L"" }, + { SCE_MARKDOWN_OLIST_ITEM, 63349, L"Ordered list", L"fore:#0080FF; bold", L"" }, + { SCE_MARKDOWN_BLOCKQUOTE, 63350, L"Block quote", L"fore:#00007F", L"" }, + { SCE_MARKDOWN_STRIKEOUT, 63351, L"Strikeout", L"", L"" }, + { SCE_MARKDOWN_HRULE, 63352, L"Horizontal rule", L"bold", L"" }, + { SCE_MARKDOWN_LINK, 63353, L"Link", L"fore:#0000FF", L"" }, + { MULTI_STYLE(SCE_MARKDOWN_CODE,SCE_MARKDOWN_CODE2,SCE_MARKDOWN_CODEBK,0), 63354, L"Code", L"fore:#00007F; back:#EBEBEB", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_YAML = { +"y n yes no on off true false", "", "", "", "", "", "", "", "" }; + +EDITLEXER lexYAML = { SCLEX_YAML, 63355, L"YAML", L"yaml; yml", L"", &KeyWords_YAML, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_YAML_DEFAULT, L"Default", L"", L"" }, + { SCE_YAML_COMMENT, 63127, L"Comment", L"fore:#008800", L"" }, + { SCE_YAML_IDENTIFIER, 63129, L"Identifier", L"bold; fore:#0A246A", L"" }, + { SCE_YAML_KEYWORD, 63128, L"Keyword", L"fore:#880088", L"" }, + { SCE_YAML_NUMBER, 63130, L"Number", L"fore:#FF8000", L"" }, + { SCE_YAML_REFERENCE, 63356, L"Reference", L"fore:#008888", L"" }, + { SCE_YAML_DOCUMENT, 63357, L"Document", L"fore:#FFFFFF; bold; back:#000088; eolfilled", L"" }, + { SCE_YAML_TEXT, 63358, L"Text", L"fore:#404040", L"" }, + { SCE_YAML_ERROR, 63359, L"Error", L"fore:#FFFFFF; bold; italic; back:#FF0000; eolfilled", L"" }, + { SCE_YAML_OPERATOR, 63132, L"Operator", L"fore:#333366", L"" }, + { -1, 00000, L"", L"", L"" } } }; + +KEYWORDLIST KeyWords_VHDL = { +"access after alias all architecture array assert attribute begin block body buffer bus case component configuration " +"constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in " +"inertial inout is label library linkage literal loop map new next null of on open others out package port postponed " +"procedure process pure range record register reject report return select severity shared signal subtype then " +"to transport type unaffected units until use variable wait when while with", +"abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor", +"left right low high ascending image value pos val succ pred leftof rightof base range reverse_range length delayed stable " +"quiet transaction event active last_event last_active last_value driving driving_value simple_name path_name instance_name", +"now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector to_stdulogicvector " +"to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left rotate_right resize to_integer " +"to_unsigned to_signed std_match to_01", +"std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed std_logic_textio std_logic_unsigned " +"numeric_bit numeric_std math_complex math_real vital_primitives vital_timing", +"boolean bit character severity_level integer real time delay_length natural positive string bit_vector file_open_kind " +"file_open_status line text side width std_ulogic std_ulogic_vector std_logic std_logic_vector X01 X01Z UX01 UX01Z unsigned signed", +"", "", "" }; + +EDITLEXER lexVHDL = { SCLEX_VHDL, 63370, L"VHDL", L"vhdl; vhd", L"", &KeyWords_VHDL, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_VHDL_COMMENTLINEBANG, SCE_VHDL_COMMENT, SCE_VHDL_BLOCK_COMMENT, 0), 63127, L"Comment", L"fore:#008800", L"" }, + { SCE_VHDL_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + { MULTI_STYLE(SCE_VHDL_STRING, SCE_VHDL_STRINGEOL, 0, 0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_VHDL_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { SCE_VHDL_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_VHDL_KEYWORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, + { SCE_VHDL_STDOPERATOR, 63371, L"Standard operator", L"bold; fore:#0A246A", L"" }, + { SCE_VHDL_ATTRIBUTE, 63372, L"Attribute", L"", L"" }, + { SCE_VHDL_STDFUNCTION, 63373, L"Standard function", L"", L"" }, + { SCE_VHDL_STDPACKAGE, 63374, L"Standard package", L"", L"" }, + { SCE_VHDL_STDTYPE, 63375, L"Standard type", L"fore:#FF8000", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +KEYWORDLIST KeyWords_COFFEESCRIPT = { +"", "", "", "", "", "", "", "", "" }; + + +EDITLEXER lexCOFFEESCRIPT = { SCLEX_COFFEESCRIPT, 63362, L"Coffeescript", L"coffee; Cakefile", L"", &KeyWords_COFFEESCRIPT, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_COFFEESCRIPT_DEFAULT, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_COMMENT,SCE_COFFEESCRIPT_COMMENTLINE,SCE_COFFEESCRIPT_COMMENTDOC,SCE_COFFEESCRIPT_COMMENTBLOCK), 63127, L"Comment", L"fore:#646464", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_STRING,SCE_COFFEESCRIPT_STRINGEOL,SCE_COFFEESCRIPT_STRINGRAW,0), 63131, L"String", L"fore:#008000", L"" }, + { SCE_COFFEESCRIPT_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" }, + { SCE_COFFEESCRIPT_IDENTIFIER, 63129, L"Identifier", L"bold; fore:#0A246A", L"" }, + { SCE_COFFEESCRIPT_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, + { SCE_COFFEESCRIPT_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, + //{ SCE_COFFEESCRIPT_CHARACTER, 63376, L"Character", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT,0), 63315, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_COFFEESCRIPT_GLOBALCLASS, 63378, L"Global Class", L"", L"" }, + //{ MULTI_STYLE(SCE_COFFEESCRIPT_COMMENTLINEDOC,SCE_COFFEESCRIPT_COMMENTDOCKEYWORD,SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR,0), 63379, L"Comment line", L"fore:#646464", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_WORD,SCE_COFFEESCRIPT_WORD2,0,0), 63380, L"Word", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_VERBATIM,SCE_COFFEESCRIPT_TRIPLEVERBATIM,0,0), 63381, L"Verbatim", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + +// This array holds all the lexers... +// Don't forget to change the number of the lexer for HTML and XML +// in Notepad2.c ParseCommandLine() if you change this array! +PEDITLEXER pLexArray[NUMLEXERS] = +{ + &lexDefault, + &lexANSI, + &lexAVS, + &lexCONF, //Apache Config Scripts + &lexASM, + &lexAHK, + &lexAU3, + &lexBAT, + &lexCOFFEESCRIPT, + &lexINI, + &lexCPP, + &lexCS, + &lexCmake, + &lexCSS, + &lexDIFF, + &lexINNO, + &lexJAVA, + &lexJS, + &lexMAK, + &lexMARKDOWN, + &lexLATEX, + &lexLUA, + &lexNSIS, + &lexPAS, + &lexPL, + &lexPS, + &lexPY, + &lexRC, + &lexRUBY, + &lexBASH, + &lexSQL, + &lexTCL, + &lexVBS, + &lexVB, + &lexHTML, + &lexXML, + &lexYAML, + &lexVHDL +}; + + +// Currently used lexer +PEDITLEXER pLexCurrent = &lexDefault; +COLORREF crCustom[16]; +BOOL bUse2ndDefaultStyle; +BOOL fStylesModified = FALSE; +BOOL fWarnedNoIniFile = FALSE; +BOOL fIsConsolasAvailable = FALSE; +int iBaseFontSize = 10; +int iDefaultLexer; +BOOL bAutoSelect; +int cxStyleSelectDlg; +int cyStyleSelectDlg; +extern int iDefaultCodePage; +extern int iDefaultCharSet; +extern BOOL bHiliteCurrentLine; + +// Only the active values are exposed to the legacy renderer/dialog. Original +// owns non-color preferences; each palette owns fore/back/alpha independently. +typedef struct { + WCHAR original[128]; + WCHAR dark[128]; +} THEME_STYLE; +static THEME_STYLE *themeStyles; +static int themeStyleCount; +static BOOL darkTheme; + +static void Theme_Append(LPWSTR out,LPCWSTR token) +{ + if (lstrlen(out) + lstrlen(token) + 2 < 128) { + if (*out) lstrcat(out,L"; "); + lstrcat(out,token); + } +} + +static void Theme_Filter(LPCWSTR input,LPWSTR out,BOOL colors) +{ + WCHAR copy[128],*token,*end; + out[0] = 0; + lstrcpyn(copy,input,COUNTOF(copy)); + token = copy; + while (*token) { + BOOL color; + end = StrChr(token,L';'); + if (end) *end = 0; + TrimString(token); + color = StrCmpNI(token,L"fore:",5) == 0 || + StrCmpNI(token,L"back:",5) == 0 || + StrCmpNI(token,L"alpha:",6) == 0; + if (color == colors && *token) Theme_Append(out,token); + if (!end) break; + token = end + 1; + } +} + +static BOOL Theme_Compose(LPWSTR out,LPCWSTR preferences,LPCWSTR colors) +{ + Theme_Filter(preferences,out,FALSE); + if (lstrlen(out) + lstrlen(colors) + 2 >= 128) return FALSE; + if (*colors) Theme_Append(out,colors); + return TRUE; +} + +static void Theme_Capture(void) +{ + int lex,i,n = 0; + if (!themeStyles) return; + for (lex = 0; lex < NUMLEXERS; ++lex) { + for (i = 0; pLexArray[lex]->Styles[i].iStyle != -1; ++i,++n) { + WCHAR colors[128],value[128]; + LPCWSTR active = pLexArray[lex]->Styles[i].szValue; + if (darkTheme) { + Theme_Filter(active,themeStyles[n].dark,TRUE); + Theme_Filter(themeStyles[n].original,colors,TRUE); + if (Theme_Compose(value,active,colors)) lstrcpy(themeStyles[n].original,value); + } else lstrcpy(themeStyles[n].original,active); + } + } +} + +static BOOL Theme_Apply(void) +{ + int lex,i,n = 0; + WCHAR value[128]; + if (!themeStyles) return FALSE; + // Validate every combined value before touching the active palette. + if (darkTheme) { + for (n = 0; n < themeStyleCount; ++n) + if (!Theme_Compose(value,themeStyles[n].original,themeStyles[n].dark)) return FALSE; + } + n = 0; + for (lex = 0; lex < NUMLEXERS; ++lex) { + for (i = 0; pLexArray[lex]->Styles[i].iStyle != -1; ++i,++n) { + LPWSTR active = pLexArray[lex]->Styles[i].szValue; + if (darkTheme) Theme_Compose(active,themeStyles[n].original,themeStyles[n].dark); + else lstrcpy(active,themeStyles[n].original); + } + } + return TRUE; +} + +static LPCWSTR Theme_DefaultColor(PEDITSTYLE style,int lex,int index) +{ + LPCWSTR name = style->pszName; + if (lex == 0) { + static LPCWSTR global[] = { + L"fore:#D4D4D4; back:#1E1E1E", L"fore:#858585; back:#252526", + L"fore:#FFFFFF; back:#515C6A", L"fore:#FFFFFF; back:#A1260D", + L"fore:#D4D4D4", L"fore:#505050", L"back:#264F78; alpha:200", + L"fore:#707070", L"back:#2A2D2E; alpha:255", L"fore:#FFFFFF", + L"fore:#505050; back:#303030", L"" + }; + return global[index % 12]; + } + if (index == 0) return L""; // Inherit the global theme default. + if (StrStrI(name,L"error") || StrStrI(name,L"unknown")) return L"fore:#F48771"; + if (StrStrI(name,L"comment")) return L"fore:#85B875"; + if (StrStrI(name,L"string") || StrStrI(name,L"character")) return L"fore:#D69D85"; + if (StrStrI(name,L"number") || StrStrI(name,L"value")) return L"fore:#B5CEA8"; + if (StrStrI(name,L"keyword") || StrStrI(name,L"directive")) return L"fore:#86B9E8"; + if (StrStrI(name,L"function") || StrStrI(name,L"command")) return L"fore:#DCDCAA"; + if (StrStrI(name,L"tag") || StrStrI(name,L"type")) return L"fore:#4EC9B0"; + if (StrStrI(name,L"variable") || StrStrI(name,L"attribute")) return L"fore:#9CDCFE"; + return L"fore:#D4D4D4"; +} + +static void Theme_Load(BOOL selected) +{ + int lex,i,n = 0; + WCHAR section[128]; + WCHAR *data = LocalAlloc(LPTR,64*1024); + LocalFree(themeStyles); + themeStyleCount = 0; + for (lex = 0; lex < NUMLEXERS; ++lex) + for (i = 0; pLexArray[lex]->Styles[i].iStyle != -1; ++i) ++themeStyleCount; + themeStyles = LocalAlloc(LPTR,themeStyleCount*sizeof(THEME_STYLE)); + darkTheme = FALSE; + if (!themeStyles || !data) { + LocalFree(themeStyles); + themeStyles = NULL; + LocalFree(data); + return; + } + for (lex = 0; lex < NUMLEXERS; ++lex) { + wsprintf(section,L"Theme.Dark.%s",pLexArray[lex]->pszName); + LoadIniSection(section,data,32*1024); + for (i = 0; pLexArray[lex]->Styles[i].iStyle != -1; ++i,++n) { + WCHAR value[128]; + PEDITSTYLE style = &pLexArray[lex]->Styles[i]; + lstrcpy(themeStyles[n].original,style->szValue); + IniSectionGetString(data,style->pszName,Theme_DefaultColor(style,lex,i),value,COUNTOF(value)); + Theme_Filter(value,themeStyles[n].dark,TRUE); + // A damaged saved color must not restore a light system background. + { + int color; + if ((StrStrI(themeStyles[n].dark,L"fore:") && !Style_StrGetColor(TRUE,themeStyles[n].dark,&color)) || + (StrStrI(themeStyles[n].dark,L"back:") && !Style_StrGetColor(FALSE,themeStyles[n].dark,&color))) + lstrcpy(themeStyles[n].dark,Theme_DefaultColor(style,lex,i)); + if (lex == 0 && i % 12 == 0) { + if (!Style_StrGetColor(TRUE,themeStyles[n].dark,&color)) Theme_Append(themeStyles[n].dark,L"fore:#D4D4D4"); + if (!Style_StrGetColor(FALSE,themeStyles[n].dark,&color)) Theme_Append(themeStyles[n].dark,L"back:#1E1E1E"); + } + } + } + } + LocalFree(data); + darkTheme = selected; + if (!Theme_Apply()) { darkTheme = FALSE; Theme_Apply(); } +} + +BOOL Style_IsDarkTheme(void) { return darkTheme; } + +void Style_SetTheme(HWND hwnd,BOOL dark) +{ + if (!themeStyles || dark == darkTheme) return; + Theme_Capture(); + darkTheme = dark; + if (!Theme_Apply()) { + darkTheme = !dark; + MessageBox(hwnd,L"A style is too long to combine with theme colors. Shorten it in Customize Schemes and try again.", + L"Editor Theme",MB_OK | MB_ICONWARNING); + return; + } + Style_SetLexer(hwnd,pLexCurrent); + SendMessage(hwnd,SCI_MARKERSETBACK,0,Style_GetBookmarkColor()); + SendMessage(hwnd,SCI_MARKERSETALPHA,0,darkTheme ? 60 : 20); + // Refresh the existing occurrence indicator without repeating its search. + { + extern int iMarkOccurrences; + SendMessage(hwnd,SCI_INDICSETFORE,1,Style_GetOccurrenceColor(iMarkOccurrences)); + } +} + +COLORREF Style_GetOccurrenceColor(int index) +{ + static const COLORREF dark[] = { RGB(100,160,230),RGB(100,200,140),RGB(230,140,120) }; + index = max(1,min(index,3)); + return darkTheme ? dark[index-1] : (0xff << ((index-1) << 3)); +} + +COLORREF Style_GetBookmarkColor(void) +{ + return darkTheme ? RGB(80,180,140) : RGB(0,255,0); +} + + +//============================================================================= +// +// Style_Load() +// +void Style_Load() +{ + int i,iLexer; + BOOL selectedTheme; + WCHAR tch[32]; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + // Custom colors + crCustom [0] = RGB(0x00,0x00,0x00); + crCustom [1] = RGB(0x0A,0x24,0x6A); + crCustom [2] = RGB(0x3A,0x6E,0xA5); + crCustom [3] = RGB(0x00,0x3C,0xE6); + crCustom [4] = RGB(0x00,0x66,0x33); + crCustom [5] = RGB(0x60,0x80,0x20); + crCustom [6] = RGB(0x64,0x80,0x00); + crCustom [7] = RGB(0xA4,0x60,0x00); + crCustom [8] = RGB(0xFF,0xFF,0xFF); + crCustom [9] = RGB(0xFF,0xFF,0xE2); + crCustom[10] = RGB(0xFF,0xF1,0xA8); + crCustom[11] = RGB(0xFF,0xC0,0x00); + crCustom[12] = RGB(0xFF,0x40,0x00); + crCustom[13] = RGB(0xC8,0x00,0x00); + crCustom[14] = RGB(0xB0,0x00,0xB0); + crCustom[15] = RGB(0xB2,0x8B,0x40); + + LoadIniSection(L"Custom Colors",pIniSection,cchIniSection); + for (i = 0; i < 16; i++) { + int itok; + int irgb; + WCHAR wch[32]; + wsprintf(tch,L"%02i",i+1); + if (IniSectionGetString(pIniSection,tch,L"",wch,COUNTOF(wch))) { + if (wch[0] == L'#') { + itok = swscanf(CharNext(wch),L"%x",&irgb); + if (itok == 1) + crCustom[i] = RGB((irgb&0xFF0000) >> 16,(irgb&0xFF00) >> 8,irgb&0xFF); + } + } + } + + LoadIniSection(L"Styles",pIniSection,cchIniSection); + // 2nd default + bUse2ndDefaultStyle = (IniSectionGetInt(pIniSection,L"Use2ndDefaultStyle",0)) ? 1 : 0; + selectedTheme = IniSectionGetInt(pIniSection,L"EditorTheme",0) == 1; + + // default scheme + iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0); + iDefaultLexer = min(max(iDefaultLexer,0),NUMLEXERS-1); + + // auto select + bAutoSelect = (IniSectionGetInt(pIniSection,L"AutoSelect",1)) ? 1 : 0; + + // scheme select dlg dimensions + cxStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeX",304); + cxStyleSelectDlg = max(cxStyleSelectDlg,0); + + cyStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeY",0); + cyStyleSelectDlg = max(cyStyleSelectDlg,324); + + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + LoadIniSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection); + if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, + pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) + lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt, + COUNTOF(pLexArray[iLexer]->szExtensions)); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName, + pLexArray[iLexer]->Styles[i].pszDefault, + pLexArray[iLexer]->Styles[i].szValue, + COUNTOF(pLexArray[iLexer]->Styles[i].szValue)); + i++; + } + } + LocalFree(pIniSection); + Theme_Load(selectedTheme); +} + + +//============================================================================= +// +// Style_Save() +// +void Style_Save() +{ + int i,iLexer; + int themeIndex = 0; + WCHAR tch[32]; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + // Custom colors + for (i = 0; i < 16; i++) { + WCHAR wch[32]; + wsprintf(tch,L"%02i",i+1); + wsprintf(wch,L"#%02X%02X%02X", + (int)GetRValue(crCustom[i]),(int)GetGValue(crCustom[i]),(int)GetBValue(crCustom[i])); + IniSectionSetString(pIniSection,tch,wch); + } + SaveIniSection(L"Custom Colors",pIniSection); + ZeroMemory(pIniSection,cchIniSection); + + // auto select + IniSectionSetInt(pIniSection,L"Use2ndDefaultStyle",bUse2ndDefaultStyle); + IniSectionSetInt(pIniSection,L"EditorTheme",darkTheme); + + // default scheme + IniSectionSetInt(pIniSection,L"DefaultScheme",iDefaultLexer); + + // auto select + IniSectionSetInt(pIniSection,L"AutoSelect",bAutoSelect); + + // scheme select dlg dimensions + IniSectionSetInt(pIniSection,L"SelectDlgSizeX",cxStyleSelectDlg); + IniSectionSetInt(pIniSection,L"SelectDlgSizeY",cyStyleSelectDlg); + + SaveIniSection(L"Styles",pIniSection); + + if (!fStylesModified) { + LocalFree(pIniSection); + return; + } + + ZeroMemory(pIniSection,cchIniSection); + Theme_Capture(); + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName, + themeStyles ? themeStyles[themeIndex++].original : pLexArray[iLexer]->Styles[i].szValue); + i++; + } + SaveIniSection(pLexArray[iLexer]->pszName,pIniSection); + ZeroMemory(pIniSection,cchIniSection); + } + if (themeStyles) { + themeIndex = 0; + for (iLexer = 0; iLexer < NUMLEXERS; ++iLexer) { + WCHAR section[128]; + wsprintf(section,L"Theme.Dark.%s",pLexArray[iLexer]->pszName); + for (i = 0; pLexArray[iLexer]->Styles[i].iStyle != -1; ++i) + IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,themeStyles[themeIndex++].dark); + SaveIniSection(section,pIniSection); + ZeroMemory(pIniSection,cchIniSection); + } + } + LocalFree(pIniSection); +} + + +//============================================================================= +// +// Style_Import() +// +BOOL Style_Import(HWND hwnd) +{ + WCHAR szFile[MAX_PATH * 2] = L""; + WCHAR szFilter[256]; + OPENFILENAME ofn; + + ZeroMemory(&ofn,sizeof(OPENFILENAME)); + GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter)); + PrepareFilterStr(szFilter); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = szFilter; + ofn.lpstrFile = szFile; + ofn.lpstrDefExt = L"ini"; + ofn.nMaxFile = COUNTOF(szFile); + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT + | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/; + + if (GetOpenFileName(&ofn)) { + + int i,iLexer; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + if (GetPrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection,szFile)) { + if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, + pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) + lstrcpyn(pLexArray[iLexer]->szExtensions,pLexArray[iLexer]->pszDefExt, + COUNTOF(pLexArray[iLexer]->szExtensions)); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + IniSectionGetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName, + pLexArray[iLexer]->Styles[i].pszDefault, + pLexArray[iLexer]->Styles[i].szValue, + COUNTOF(pLexArray[iLexer]->Styles[i].szValue)); + i++; + } + } + } + LocalFree(pIniSection); + return(TRUE); + } + return(FALSE); +} + +//============================================================================= +// +// Style_Export() +// +BOOL Style_Export(HWND hwnd) +{ + WCHAR szFile[MAX_PATH * 2] = L""; + WCHAR szFilter[256]; + OPENFILENAME ofn; + DWORD dwError = ERROR_SUCCESS; + + ZeroMemory(&ofn,sizeof(OPENFILENAME)); + GetString(IDS_FILTER_INI,szFilter,COUNTOF(szFilter)); + PrepareFilterStr(szFilter); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = szFilter; + ofn.lpstrFile = szFile; + ofn.lpstrDefExt = L"ini"; + ofn.nMaxFile = COUNTOF(szFile); + ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT + | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/ | OFN_OVERWRITEPROMPT; + + if (GetSaveFileName(&ofn)) { + + int i,iLexer; + WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); + int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); + + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + IniSectionSetString(pIniSection,pLexArray[iLexer]->Styles[i].pszName,pLexArray[iLexer]->Styles[i].szValue); + i++; + } + if (!WritePrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,szFile)) + dwError = GetLastError(); + ZeroMemory(pIniSection,cchIniSection); + } + LocalFree(pIniSection); + + if (dwError != ERROR_SUCCESS) { + MsgBox(MBINFO,IDS_EXPORT_FAIL,szFile); + } + return(TRUE); + } + return(FALSE); +} + + +//============================================================================= +// +// Style_SetLexer() +// +void Style_SetLexer(HWND hwnd,PEDITLEXER pLexNew) +{ + int i; + //WCHAR *p; + int rgb; + int iValue; + int iIdx; + int iStyleBits; + WCHAR wchCaretStyle[64] = L""; + + // Select default if NULL is specified + if (!pLexNew) + pLexNew = pLexArray[iDefaultLexer]; + + // Lexer + SendMessage(hwnd,SCI_SETLEXER,pLexNew->iLexer,0); + + iStyleBits = (int)SendMessage(hwnd,SCI_GETSTYLEBITSNEEDED,0,0); + SendMessage(hwnd,SCI_SETSTYLEBITS,(WPARAM)iStyleBits,0); + + if (pLexNew->iLexer == SCLEX_XML) + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.xml.allow.scripts",(LPARAM)"1"); + if (pLexNew->iLexer == SCLEX_CPP) { + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"styling.within.preprocessor",(LPARAM)"1"); + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.cpp.track.preprocessor",(LPARAM)"0"); + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.cpp.update.preprocessor",(LPARAM)"0"); + } + else if (pLexNew->iLexer == SCLEX_PASCAL) + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.pascal.smart.highlighting",(LPARAM)"1"); + else if (pLexNew->iLexer == SCLEX_SQL) { + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"sql.backslash.escapes",(LPARAM)"1"); + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.sql.backticks.identifier",(LPARAM)"1"); + SendMessage(hwnd,SCI_SETPROPERTY,(WPARAM)"lexer.sql.numbersign.comment",(LPARAM)"1"); + } + else if (pLexNew->iLexer == SCLEX_NSIS) + SciCall_SetProperty("nsis.ignorecase", "1"); + + // Code folding + SciCall_SetProperty("fold", "1"); + SciCall_SetProperty("fold.compact", "0"); + SciCall_SetProperty("fold.comment", "1"); + SciCall_SetProperty("fold.html", "1"); + SciCall_SetProperty("fold.preprocessor", "1"); + SciCall_SetProperty("fold.cpp.comment.explicit", "0"); + + // Add KeyWord Lists + for (i = 0; i < 9; i++) + SendMessage(hwnd,SCI_SETKEYWORDS,i,(LPARAM)pLexNew->pKeyWords->pszKeyWords[i]); + + // Use 2nd default style + iIdx = (bUse2ndDefaultStyle) ? 12 : 0; + + // Font quality setup, check availability of Consolas + Style_SetFontQuality(hwnd,lexDefault.Styles[0+iIdx].szValue); + fIsConsolasAvailable = IsFontAvailable(L"Consolas"); + + // Clear + SendMessage(hwnd,SCI_CLEARDOCUMENTSTYLE,0,0); + + // Default Values are always set + SendMessage(hwnd,SCI_STYLERESETDEFAULT,0,0); + SendMessage(hwnd,SCI_STYLESETCHARACTERSET,STYLE_DEFAULT,(LPARAM)DEFAULT_CHARSET); + iBaseFontSize = 10; + Style_SetStyles(hwnd,lexDefault.Styles[0+iIdx].iStyle,lexDefault.Styles[0+iIdx].szValue); // default + Style_StrGetSize(lexDefault.Styles[0+iIdx].szValue,&iBaseFontSize); // base size + + // Auto-select codepage according to charset + //Style_SetACPfromCharSet(hwnd); + + if (!Style_StrGetColor(TRUE,lexDefault.Styles[0+iIdx].szValue,&iValue)) + SendMessage(hwnd,SCI_STYLESETFORE,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color + if (!Style_StrGetColor(FALSE,lexDefault.Styles[0+iIdx].szValue,&iValue)) + SendMessage(hwnd,SCI_STYLESETBACK,STYLE_DEFAULT,(LPARAM)GetSysColor(COLOR_WINDOW)); // default window color + + if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) + Style_SetStyles(hwnd,pLexNew->Styles[0].iStyle,pLexNew->Styles[0].szValue); // lexer default + SendMessage(hwnd,SCI_STYLECLEARALL,0,0); + + Style_SetStyles(hwnd,lexDefault.Styles[1+iIdx].iStyle,lexDefault.Styles[1+iIdx].szValue); // linenumber + Style_SetStyles(hwnd,lexDefault.Styles[2+iIdx].iStyle,lexDefault.Styles[2+iIdx].szValue); // brace light + Style_SetStyles(hwnd,lexDefault.Styles[3+iIdx].iStyle,lexDefault.Styles[3+iIdx].szValue); // brace bad + if (pLexNew != &lexANSI) + Style_SetStyles(hwnd,lexDefault.Styles[4+iIdx].iStyle,lexDefault.Styles[4+iIdx].szValue); // control char + Style_SetStyles(hwnd,lexDefault.Styles[5+iIdx].iStyle,lexDefault.Styles[5+iIdx].szValue); // indent guide + + // More default values... + if (Style_StrGetColor(TRUE,lexDefault.Styles[6+iIdx].szValue,&rgb)) { // selection fore + SendMessage(hwnd,SCI_SETSELFORE,TRUE,rgb); + SendMessage(hwnd,SCI_SETADDITIONALSELFORE,rgb,0); + } + else { + SendMessage(hwnd,SCI_SETSELFORE,0,0); + SendMessage(hwnd,SCI_SETADDITIONALSELFORE,0,0); + } + + if (Style_StrGetColor(FALSE,lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection back + SendMessage(hwnd,SCI_SETSELBACK,TRUE,iValue); + SendMessage(hwnd,SCI_SETADDITIONALSELBACK,iValue,0); + } + else { + SendMessage(hwnd,SCI_SETSELBACK,TRUE,RGB(0xC0,0xC0,0xC0)); // use a default value... + SendMessage(hwnd,SCI_SETADDITIONALSELBACK,RGB(0xC0,0xC0,0xC0),0); + } + + if (Style_StrGetAlpha(lexDefault.Styles[6+iIdx].szValue,&iValue)) { // selection alpha + SendMessage(hwnd,SCI_SETSELALPHA,iValue,0); + SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,iValue,0); + } + else { + SendMessage(hwnd,SCI_SETSELALPHA,SC_ALPHA_NOALPHA,0); + SendMessage(hwnd,SCI_SETADDITIONALSELALPHA,SC_ALPHA_NOALPHA,0); + } + + if (StrStrI(lexDefault.Styles[6+iIdx].szValue,L"eolfilled")) // selection eolfilled + SendMessage(hwnd,SCI_SETSELEOLFILLED,1,0); + else + SendMessage(hwnd,SCI_SETSELEOLFILLED,0,0); + + if (Style_StrGetColor(TRUE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace fore + SendMessage(hwnd,SCI_SETWHITESPACEFORE,TRUE,rgb); + else + SendMessage(hwnd,SCI_SETWHITESPACEFORE,0,0); + + if (Style_StrGetColor(FALSE,lexDefault.Styles[7+iIdx].szValue,&rgb)) // whitespace back + SendMessage(hwnd,SCI_SETWHITESPACEBACK,TRUE,rgb); + else + SendMessage(hwnd,SCI_SETWHITESPACEBACK,0,0); // use a default value... + + // whitespace dot size + iValue = 1; + if (Style_StrGetSize(lexDefault.Styles[7+iIdx].szValue,&iValue)) { + + WCHAR tch[32]; + WCHAR wchStyle[COUNTOF(lexDefault.Styles[0].szValue)]; + lstrcpyn(wchStyle,lexDefault.Styles[7+iIdx].szValue,COUNTOF(lexDefault.Styles[0].szValue)); + + iValue = max(min(iValue,5),0); + wsprintf(lexDefault.Styles[7+iIdx].szValue,L"size:%i",iValue); + + if (Style_StrGetColor(TRUE,wchStyle,&rgb)) { + wsprintf(tch,L"; fore:#%02X%02X%02X", + (int)GetRValue(rgb), + (int)GetGValue(rgb), + (int)GetBValue(rgb)); + lstrcat(lexDefault.Styles[7+iIdx].szValue,tch); + } + + if (Style_StrGetColor(FALSE,wchStyle,&rgb)) { + wsprintf(tch,L"; back:#%02X%02X%02X", + (int)GetRValue(rgb), + (int)GetGValue(rgb), + (int)GetBValue(rgb)); + lstrcat(lexDefault.Styles[7+iIdx].szValue,tch); + } + } + SendMessage(hwnd,SCI_SETWHITESPACESIZE,iValue,0); + + if (bHiliteCurrentLine) { + + if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back + { + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0); + SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0); + + if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue)) + SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0); + else + SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0); + } + else + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); + } + else + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); + + // caret style and width + if (StrStr(lexDefault.Styles[9+iIdx].szValue,L"block")) { + SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_BLOCK,0); + lstrcpy(wchCaretStyle,L"block"); + } + else { + WCHAR wch[32]; + iValue = 1; + if (Style_StrGetSize(lexDefault.Styles[9+iIdx].szValue,&iValue)) { + iValue = max(min(iValue,3),1); + wsprintf(wch,L"size:%i",iValue); + lstrcat(wchCaretStyle,wch); + } + SendMessage(hwnd,SCI_SETCARETSTYLE,CARETSTYLE_LINE,0); + SendMessage(hwnd,SCI_SETCARETWIDTH,iValue,0); + } + if (StrStr(lexDefault.Styles[9+iIdx].szValue,L"noblink")) { + SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)0,0); + if (lstrlen(wchCaretStyle)) + lstrcat(wchCaretStyle,L"; "); + lstrcat(wchCaretStyle,L"noblink"); + } + else + SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)GetCaretBlinkTime(),0); + + // caret fore + if (!Style_StrGetColor(TRUE,lexDefault.Styles[9+iIdx].szValue,&rgb)) + rgb = GetSysColor(COLOR_WINDOWTEXT); + else { + WCHAR wch[32]; + wsprintf(wch,L"fore:#%02X%02X%02X", + (int)GetRValue(rgb), + (int)GetGValue(rgb), + (int)GetBValue(rgb)); + if (lstrlen(wchCaretStyle)) + lstrcat(wchCaretStyle,L"; "); + lstrcat(wchCaretStyle,wch); + } + if (!VerifyContrast(rgb,(COLORREF)SendMessage(hwnd,SCI_STYLEGETBACK,0,0))) + rgb = (int)SendMessage(hwnd,SCI_STYLEGETFORE,0,0); + SendMessage(hwnd,SCI_SETCARETFORE,rgb,0); + SendMessage(hwnd,SCI_SETADDITIONALCARETFORE,rgb,0); + lstrcpy(lexDefault.Styles[9+iIdx].szValue,wchCaretStyle); + + if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) { + if (Style_StrGetColor(TRUE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge fore + SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); + else + SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); + } + else { + if (Style_StrGetColor(FALSE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge back + SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); + else + SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); + } + + // Extra Line Spacing + if (Style_StrGetSize(lexDefault.Styles[11+iIdx].szValue,&iValue) && pLexNew != &lexANSI) { + int iAscent = 0; + int iDescent = 0; + iValue = min(max(iValue,0),64); + wsprintf(lexDefault.Styles[11+iIdx].szValue,L"size:%i",iValue); + if (iValue % 2) { + iAscent++; + iValue--; + } + iAscent += iValue / 2; + iDescent += iValue / 2; + SendMessage(hwnd,SCI_SETEXTRAASCENT,(WPARAM)iAscent,0); + SendMessage(hwnd,SCI_SETEXTRADESCENT,(WPARAM)iDescent,0); + } + else { + SendMessage(hwnd,SCI_SETEXTRAASCENT,0,0); + SendMessage(hwnd,SCI_SETEXTRADESCENT,0,0); + //wsprintf(lexDefault.Styles[11+iIdx].szValue,L"size:0"); + } + + { // set folding style; braces are for scoping only + static const int iMarkerIDs[] = + { + SC_MARKNUM_FOLDEROPEN, + SC_MARKNUM_FOLDER, + SC_MARKNUM_FOLDERSUB, + SC_MARKNUM_FOLDERTAIL, + SC_MARKNUM_FOLDEREND, + SC_MARKNUM_FOLDEROPENMID, + SC_MARKNUM_FOLDERMIDTAIL + }; + + int i; + + COLORREF clrFore = SciCall_StyleGetFore(STYLE_DEFAULT); + COLORREF clrBack = SciCall_StyleGetBack(STYLE_DEFAULT); + + SciCall_SetFoldMarginColour(TRUE, clrBack); + SciCall_SetFoldMarginHiColour(TRUE, clrBack); + + // Set marker color to the average of clrFore and clrBack + clrFore = (((clrFore & 0xFF0000) + (clrBack & 0xFF0000)) >> 1 & 0xFF0000) | + (((clrFore & 0x00FF00) + (clrBack & 0x00FF00)) >> 1 & 0x00FF00) | + (((clrFore & 0x0000FF) + (clrBack & 0x0000FF)) >> 1 & 0x0000FF); + + // Rounding hack for pure white against pure black + if (clrFore == 0x7F7F7F) clrFore = 0x808080; + + for (i = 0; i < COUNTOF(iMarkerIDs); ++i) + { + SciCall_MarkerSetBack(iMarkerIDs[i], clrFore); + SciCall_MarkerSetFore(iMarkerIDs[i], clrBack); + } + } // end set folding style + + if (SendMessage(hwnd,SCI_GETINDENTATIONGUIDES,0,0) != SC_IV_NONE) + Style_SetIndentGuides(hwnd,TRUE); + + if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) + { + int j; + i = 1; + while (pLexNew->Styles[i].iStyle != -1) { + + for (j = 0; j < 4 && (pLexNew->Styles[i].iStyle8[j] != 0 || j == 0); ++j) + Style_SetStyles(hwnd,pLexNew->Styles[i].iStyle8[j],pLexNew->Styles[i].szValue); + + if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { + int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, + SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { + int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, SCE_HJ_DOUBLESTRING, + SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, SCE_HJ_SYMBOLS }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { + int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, + SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { + int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { + int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { + int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING, SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR, + SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY, SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { + int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, + SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, + SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, + SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, + SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, + SCE_HPA_IDENTIFIER }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_XML && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { + int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION, + SCE_HPHP_DEFAULT, SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, + SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, + SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE, SCE_HJ_START, SCE_HJ_DEFAULT, + SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, + SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, + SCE_HJ_SYMBOLS, SCE_HJA_START, SCE_HJA_DEFAULT, SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, + SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, + SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS, SCE_HB_START, SCE_HB_DEFAULT, + SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, + SCE_HB_NUMBER, SCE_HBA_START, SCE_HBA_DEFAULT, SCE_HBA_COMMENTLINE, SCE_HBA_WORD, + SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER, SCE_HP_START, + SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD, + SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR, + SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, + SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, + SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew->iLexer == SCLEX_CPP && pLexNew->Styles[i].iStyle8[0] == SCE_C_COMMENT) { + int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + + if (pLexNew -> iLexer == SCLEX_SQL && pLexNew->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { + int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR }; + for (j = 0; j < COUNTOF(iRelated); j++) + Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + } + i++; + } + } + + SendMessage(hwnd,SCI_COLOURISE,0,(LPARAM)-1); + + // Save current lexer + pLexCurrent = pLexNew; +} + + +//============================================================================= +// +// Style_SetLongLineColors() +// +void Style_SetLongLineColors(HWND hwnd) +{ + int rgb; + + // Use 2nd default style + int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; + + if (SendMessage(hwnd,SCI_GETEDGEMODE,0,0) == EDGE_LINE) { + if (Style_StrGetColor(TRUE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge fore + SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); + else + SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); + } + else { + if (Style_StrGetColor(FALSE,lexDefault.Styles[10+iIdx].szValue,&rgb)) // edge back + SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0); + else + SendMessage(hwnd,SCI_SETEDGECOLOUR,GetSysColor(COLOR_3DLIGHT),0); + } +} + + +//============================================================================= +// +// Style_SetCurrentLineBackground() +// +void Style_SetCurrentLineBackground(HWND hwnd) +{ + int rgb, iValue; + + // Use 2nd default style + int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; + + if (bHiliteCurrentLine) { + + if (Style_StrGetColor(FALSE,lexDefault.Styles[8+iIdx].szValue,&rgb)) // caret line back + { + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,TRUE,0); + SendMessage(hwnd,SCI_SETCARETLINEBACK,rgb,0); + + if (Style_StrGetAlpha(lexDefault.Styles[8+iIdx].szValue,&iValue)) + SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,iValue,0); + else + SendMessage(hwnd,SCI_SETCARETLINEBACKALPHA,SC_ALPHA_NOALPHA,0); + } + else + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); + } + else + SendMessage(hwnd,SCI_SETCARETLINEVISIBLE,FALSE,0); +} + + +//============================================================================= +// +// Style_SniffShebang() +// +PEDITLEXER __fastcall Style_SniffShebang(char *pchText) +{ + if (StrCmpNA(pchText,"#!",2) == 0) { + char *pch = pchText + 2; + while (*pch == ' ' || *pch == '\t') + pch++; + while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') + pch++; + if ((pch - pchText) >= 3 && StrCmpNA(pch-3,"env",3) == 0) { + while (*pch == ' ') + pch++; + while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') + pch++; + } + if ((pch - pchText) >= 3 && StrCmpNIA(pch-3,"php",3) == 0) + return(&lexHTML); + else if ((pch - pchText) >= 4 && StrCmpNIA(pch-4,"perl",4) == 0) + return(&lexPL); + else if ((pch - pchText) >= 6 && StrCmpNIA(pch-6,"python",6) == 0) + return(&lexPY); + else if ((pch - pchText) >= 3 && StrCmpNA(pch-3,"tcl",3) == 0) + return(&lexTCL); + else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"wish",4) == 0) + return(&lexTCL); + else if ((pch - pchText) >= 5 && StrCmpNA(pch-5,"tclsh",5) == 0) + return(&lexTCL); + else if ((pch - pchText) >= 2 && StrCmpNA(pch-2,"sh",2) == 0) + return(&lexBASH); + else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"ruby",4) == 0) + return(&lexRUBY); + else if ((pch - pchText) >= 4 && StrCmpNA(pch-4,"node",4) == 0) + return(&lexJS); + } + + return(NULL); +} + + +//============================================================================= +// +// Style_MatchLexer() +// +PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames) +{ + int i; + WCHAR tch[256+16]; + WCHAR *p1,*p2; + + if (!bCheckNames) { + + for (i = 0; i < NUMLEXERS; i++) { + + ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch)); + lstrcpy(tch,pLexArray[i]->szExtensions); + p1 = tch; + while (*p1) { + if (p2 = StrChr(p1,L';')) + *p2 = L'\0'; + else + p2 = StrEnd(p1); + StrTrim(p1,L" ."); + if (lstrcmpi(p1,lpszMatch) == 0) + return(pLexArray[i]); + p1 = p2+1; + } + } + } + + else { + + int cch = lstrlen(lpszMatch); + if (cch >= 3) { + + for (i = 0; i < NUMLEXERS; i++) { + if (StrCmpNI(pLexArray[i]->pszName,lpszMatch,cch) == 0) + return(pLexArray[i]); + } + } + } + return(NULL); +} + + +//============================================================================= +// +// Style_SetLexerFromFile() +// +extern int fNoHTMLGuess; +extern int fNoCGIGuess; +extern FILEVARS fvCurFile; + +void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) +{ + LPWSTR lpszExt = PathFindExtension(lpszFile); + BOOL bFound = FALSE; + PEDITLEXER pLexNew = pLexArray[iDefaultLexer]; + PEDITLEXER pLexSniffed; + + if ((fvCurFile.mask & FV_MODE) && fvCurFile.tchMode[0]) { + + WCHAR wchMode[32]; + PEDITLEXER pLexMode; + UINT cp = (UINT)SendMessage(hwnd,SCI_GETCODEPAGE,0,0); + MultiByteToWideChar(cp,0,fvCurFile.tchMode,-1,wchMode,COUNTOF(wchMode)); + + if (!fNoCGIGuess && (lstrcmpi(wchMode,L"cgi") == 0 || lstrcmpi(wchMode,L"fcgi") == 0)) { + char tchText[256]; + SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); + StrTrimA(tchText," \t\n\r"); + if (pLexSniffed = Style_SniffShebang(tchText)) { + if (iEncoding != g_DOSEncoding || pLexSniffed != &lexDefault || ( + lstrcmpi(lpszExt,L"nfo") && lstrcmpi(lpszExt,L"diz"))) { + // Although .nfo and .diz were removed from the default lexer's + // default extensions list, they may still presist in the user's INI + pLexNew = pLexSniffed; + bFound = TRUE; + } + } + } + + if (!bFound) { + if (pLexMode = Style_MatchLexer(wchMode,FALSE)) { + pLexNew = pLexMode; + bFound = TRUE; + } + else if (pLexMode = Style_MatchLexer(wchMode,TRUE)) { + pLexNew = pLexMode; + bFound = TRUE; + } + } + } + + if (!bFound && bAutoSelect && /* bAutoSelect == FALSE skips lexer search */ + (lpszFile && lstrlen(lpszFile) > 0 && *lpszExt)) { + + if (*lpszExt == L'.') + lpszExt++; + + if (!fNoCGIGuess && (lstrcmpi(lpszExt,L"cgi") == 0 || lstrcmpi(lpszExt,L"fcgi") == 0)) { + char tchText[256]; + SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); + StrTrimA(tchText," \t\n\r"); + if (pLexSniffed = Style_SniffShebang(tchText)) { + pLexNew = pLexSniffed; + bFound = TRUE; + } + } + + if (!bFound && lstrcmpi(PathFindFileName(lpszFile),L"cmakelists.txt") == 0) { + pLexNew = &lexCmake; + bFound = TRUE; + } + + // check associated extensions + if (!bFound) { + if (pLexSniffed = Style_MatchLexer(lpszExt,FALSE)) { + pLexNew = pLexSniffed; + bFound = TRUE; + } + } + } + + if (!bFound && bAutoSelect && + lstrcmpi(PathFindFileName(lpszFile),L"makefile") == 0) { + pLexNew = &lexMAK; + bFound = TRUE; + } + + if (!bFound && bAutoSelect && + lstrcmpi(PathFindFileName(lpszFile),L"rakefile") == 0) { + pLexNew = &lexRUBY; + bFound = TRUE; + } + + if (!bFound && bAutoSelect && + lstrcmpi(PathFindFileName(lpszFile),L"mozconfig") == 0) { + pLexNew = &lexBASH; + bFound = TRUE; + } + + if (!bFound && bAutoSelect && (!fNoHTMLGuess || !fNoCGIGuess)) { + char tchText[512]; + SendMessage(hwnd,SCI_GETTEXT,(WPARAM)COUNTOF(tchText)-1,(LPARAM)tchText); + StrTrimA(tchText," \t\n\r"); + if (!fNoHTMLGuess && tchText[0] == '<') { + if (StrStrIA(tchText,"= 0 && id < NUMLEXERS) { + Style_SetLexer(hwnd,pLexArray[id]); + } +} + + +//============================================================================= +// +// Style_ToggleUse2ndDefault() +// +void Style_ToggleUse2ndDefault(HWND hwnd) +{ + bUse2ndDefaultStyle = (bUse2ndDefaultStyle) ? 0 : 1; + Style_SetLexer(hwnd,pLexCurrent); +} + + +//============================================================================= +// +// Style_SetDefaultFont() +// +void Style_SetDefaultFont(HWND hwnd) +{ + int iIdx = (bUse2ndDefaultStyle) ? 12 : 0; + if (Style_SelectFont(hwnd, + lexDefault.Styles[0+iIdx].szValue, + COUNTOF(lexDefault.Styles[0].szValue), + TRUE)) { + fStylesModified = TRUE; + Style_SetLexer(hwnd,pLexCurrent); + } +} + + +//============================================================================= +// +// Style_GetUse2ndDefault() +// +BOOL Style_GetUse2ndDefault(HWND hwnd) +{ + return (bUse2ndDefaultStyle); +} + + +//============================================================================= +// +// Style_SetIndentGuides() +// +extern int flagSimpleIndentGuides; + +void Style_SetIndentGuides(HWND hwnd,BOOL bShow) +{ + int iIndentView = SC_IV_NONE; + if (bShow) { + if (!flagSimpleIndentGuides) { + if (SendMessage(hwnd,SCI_GETLEXER,0,0) == SCLEX_PYTHON) + iIndentView = SC_IV_LOOKFORWARD; + else + iIndentView = SC_IV_LOOKBOTH; + } + else + iIndentView = SC_IV_REAL; + } + SendMessage(hwnd,SCI_SETINDENTATIONGUIDES,iIndentView,0); +} + + +//============================================================================= +// +// Style_GetFileOpenDlgFilter() +// +extern WCHAR tchFileDlgFilters[5*1024]; + +BOOL Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter) +{ + if (lstrlen(tchFileDlgFilters) == 0) + GetString(IDS_FILTER_ALL,lpszFilter,cchFilter); + else { + lstrcpyn(lpszFilter,tchFileDlgFilters,cchFilter-2); + lstrcat(lpszFilter,L"||"); + } + PrepareFilterStr(lpszFilter); + return TRUE; +} + + +//============================================================================= +// +// Style_StrGetFont() +// +BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont) +{ + WCHAR tch[256]; + WCHAR *p; + + if (p = StrStrI(lpszStyle,L"font:")) + { + lstrcpy(tch,p + CSTRLEN(L"font:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + + if (lstrcmpi(tch,L"Default") == 0) + { + if (fIsConsolasAvailable) + lstrcpyn(lpszFont,L"Consolas",cchFont); + else + lstrcpyn(lpszFont,L"Lucida Console",cchFont); + } + else + { + lstrcpyn(lpszFont,tch,cchFont); + } + + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetFontQuality() +// +BOOL Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality) +{ + WCHAR tch[256]; + WCHAR *p; + + if (p = StrStrI(lpszStyle,L"smoothing:")) + { + lstrcpy(tch,p + CSTRLEN(L"smoothing:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + if (lstrcmpi(tch,L"none") == 0 || + lstrcmpi(tch,L"standard") == 0 || + lstrcmpi(tch,L"cleartype") == 0 || + lstrcmpi(tch,L"default") == 0) { + lstrcpyn(lpszQuality,tch,cchQuality); + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetCharSet() +// +BOOL Style_StrGetCharSet(LPCWSTR lpszStyle,int *i) +{ + WCHAR tch[256]; + WCHAR *p; + int iValue; + int itok; + + if (p = StrStrI(lpszStyle,L"charset:")) + { + lstrcpy(tch,p + CSTRLEN(L"charset:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + itok = swscanf(tch,L"%i",&iValue); + if (itok == 1) + { + *i = iValue; + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetSize() +// +BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i) +{ + WCHAR tch[256]; + WCHAR *p; + int iValue; + int iSign = 0; + int itok; + + if (p = StrStrI(lpszStyle,L"size:")) + { + lstrcpy(tch,p + CSTRLEN(L"size:")); + if (tch[0] == L'+') + { + iSign = 1; + tch[0] = L' '; + } + else if (tch[0] == L'-') + { + iSign = -1; + tch[0] = L' '; + } + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + itok = swscanf(tch,L"%i",&iValue); + if (itok == 1) + { + if (iSign == 0) + *i = iValue; + else + *i = max(0,iBaseFontSize + iValue * iSign); // size must be + + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetSizeStr() +// +BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize) +{ + WCHAR tch[256]; + WCHAR *p; + + if (p = StrStrI(lpszStyle,L"size:")) + { + lstrcpy(tch,p + CSTRLEN(L"size:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + lstrcpyn(lpszSize,tch,cchSize); + return TRUE; + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetColor() +// +BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb) +{ + WCHAR tch[256]; + WCHAR *p; + int iValue; + int itok; + WCHAR *pItem = (bFore) ? L"fore:" : L"back:"; + + if (p = StrStrI(lpszStyle,pItem)) + { + lstrcpy(tch,p + lstrlen(pItem)); + if (tch[0] == L'#') + tch[0] = L' '; + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + itok = swscanf(tch,L"%x",&iValue); + if (itok == 1) + { + *rgb = RGB((iValue&0xFF0000) >> 16,(iValue&0xFF00) >> 8,iValue&0xFF); + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetCase() +// +BOOL Style_StrGetCase(LPCWSTR lpszStyle,int *i) +{ + WCHAR tch[256]; + WCHAR *p; + + if (p = StrStrI(lpszStyle,L"case:")) + { + lstrcpy(tch,p + CSTRLEN(L"case:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + if (tch[0] == L'u' || tch[0] == L'U') { + *i = SC_CASE_UPPER; + return TRUE; + } + else if (tch[0] == L'l' || tch[0] == L'L') { + *i = SC_CASE_LOWER; + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_StrGetAlpha() +// +BOOL Style_StrGetAlpha(LPCWSTR lpszStyle,int *i) +{ + WCHAR tch[256]; + WCHAR *p; + int iValue; + int itok; + + if (p = StrStrI(lpszStyle,L"alpha:")) + { + lstrcpy(tch,p + CSTRLEN(L"alpha:")); + if (p = StrChr(tch,L';')) + *p = L'\0'; + TrimString(tch); + itok = swscanf(tch,L"%i",&iValue); + if (itok == 1) + { + *i = min(max(SC_ALPHA_TRANSPARENT,iValue),SC_ALPHA_OPAQUE); + return TRUE; + } + } + return FALSE; +} + + +//============================================================================= +// +// Style_SelectFont() +// +BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle) +{ + CHOOSEFONT cf; + LOGFONT lf; + WCHAR szNewStyle[512]; + int iValue; + WCHAR tch[32]; + HDC hdc; + + ZeroMemory(&cf,sizeof(CHOOSEFONT)); + ZeroMemory(&lf,sizeof(LOGFONT)); + + // Map lpszStyle to LOGFONT + if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) + lstrcpyn(lf.lfFaceName,tch,COUNTOF(lf.lfFaceName)); + if (Style_StrGetCharSet(lpszStyle,&iValue)) + lf.lfCharSet = iValue; + if (Style_StrGetSize(lpszStyle,&iValue)) { + hdc = GetDC(hwnd); + lf.lfHeight = -MulDiv(iValue,GetDeviceCaps(hdc,LOGPIXELSY),72); + ReleaseDC(hwnd,hdc); + } + lf.lfWeight = (StrStrI(lpszStyle,L"bold")) ? FW_BOLD : FW_NORMAL; + lf.lfItalic = (StrStrI(lpszStyle,L"italic")) ? 1 : 0; + + // Init cf + cf.lStructSize = sizeof(CHOOSEFONT); + cf.hwndOwner = hwnd; + cf.lpLogFont = &lf; + cf.Flags = CF_INITTOLOGFONTSTRUCT /*| CF_NOSCRIPTSEL*/ | CF_SCREENFONTS; + + if (HIBYTE(GetKeyState(VK_SHIFT))) + cf.Flags |= CF_FIXEDPITCHONLY; + + if (!ChooseFont(&cf) || !lstrlen(lf.lfFaceName)) + return FALSE; + + // Map back to lpszStyle + lstrcpy(szNewStyle,L"font:"); + lstrcat(szNewStyle,lf.lfFaceName); + if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) + { + lstrcat(szNewStyle,L"; smoothing:"); + lstrcat(szNewStyle,tch); + } + if (bDefaultStyle && + lf.lfCharSet != DEFAULT_CHARSET && + lf.lfCharSet != ANSI_CHARSET && + lf.lfCharSet != iDefaultCharSet) { + lstrcat(szNewStyle,L"; charset:"); + wsprintf(tch,L"%i",lf.lfCharSet); + lstrcat(szNewStyle,tch); + } + lstrcat(szNewStyle,L"; size:"); + wsprintf(tch,L"%i",cf.iPointSize/10); + lstrcat(szNewStyle,tch); + if (cf.nFontType & BOLD_FONTTYPE) + lstrcat(szNewStyle,L"; bold"); + if (cf.nFontType & ITALIC_FONTTYPE) + lstrcat(szNewStyle,L"; italic"); + + if (StrStrI(lpszStyle,L"underline")) + lstrcat(szNewStyle,L"; underline"); + + // save colors + if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) + { + wsprintf(tch,L"; fore:#%02X%02X%02X", + (int)GetRValue(iValue), + (int)GetGValue(iValue), + (int)GetBValue(iValue)); + lstrcat(szNewStyle,tch); + } + if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) + { + wsprintf(tch,L"; back:#%02X%02X%02X", + (int)GetRValue(iValue), + (int)GetGValue(iValue), + (int)GetBValue(iValue)); + lstrcat(szNewStyle,tch); + } + + if (StrStrI(lpszStyle,L"eolfilled")) + lstrcat(szNewStyle,L"; eolfilled"); + + if (Style_StrGetCase(lpszStyle,&iValue)) { + lstrcat(szNewStyle,L"; case:"); + lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L""); + } + + if (Style_StrGetAlpha(lpszStyle,&iValue)) { + lstrcat(szNewStyle,L"; alpha:"); + wsprintf(tch,L"%i",iValue); + lstrcat(szNewStyle,tch); + } + + lstrcpyn(lpszStyle,szNewStyle,cchStyle); + return TRUE; +} + + +//============================================================================= +// +// Style_SelectColor() +// +BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle) +{ + CHOOSECOLOR cc; + WCHAR szNewStyle[512]; + int iRGBResult; + int iValue; + WCHAR tch[32]; + + ZeroMemory(&cc,sizeof(CHOOSECOLOR)); + + iRGBResult = (bFore) ? GetSysColor(COLOR_WINDOWTEXT) : GetSysColor(COLOR_WINDOW); + Style_StrGetColor(bFore,lpszStyle,&iRGBResult); + + cc.lStructSize = sizeof(CHOOSECOLOR); + cc.hwndOwner = hwnd; + cc.rgbResult = iRGBResult; + cc.lpCustColors = crCustom; + cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR; + + if (!ChooseColor(&cc)) + return FALSE; + + iRGBResult = cc.rgbResult; + + // Rebuild style string + lstrcpy(szNewStyle,L""); + if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) + { + lstrcat(szNewStyle,L"font:"); + lstrcat(szNewStyle,tch); + } + if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + lstrcat(szNewStyle,L"smoothing:"); + lstrcat(szNewStyle,tch); + } + if (Style_StrGetCharSet(lpszStyle,&iValue)) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + wsprintf(tch,L"charset:%i",iValue); + lstrcat(szNewStyle,tch); + } + if (Style_StrGetSizeStr(lpszStyle,tch,COUNTOF(tch))) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + lstrcat(szNewStyle,L"size:"); + lstrcat(szNewStyle,tch); + } + + if (StrStrI(lpszStyle,L"bold")) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + lstrcat(szNewStyle,L"bold"); + } + if (StrStrI(lpszStyle,L"italic")) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + lstrcat(szNewStyle,L"italic"); + } + if (StrStrI(lpszStyle,L"underline")) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + lstrcat(szNewStyle,L"underline"); + } + + if (bFore) + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + wsprintf(tch,L"fore:#%02X%02X%02X", + (int)GetRValue(iRGBResult), + (int)GetGValue(iRGBResult), + (int)GetBValue(iRGBResult)); + lstrcat(szNewStyle,tch); + if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) + { + wsprintf(tch,L"; back:#%02X%02X%02X", + (int)GetRValue(iValue), + (int)GetGValue(iValue), + (int)GetBValue(iValue)); + lstrcat(szNewStyle,tch); + } + } + else + { + if (lstrlen(szNewStyle)) + lstrcat(szNewStyle,L"; "); + if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) + { + wsprintf(tch,L"fore:#%02X%02X%02X; ", + (int)GetRValue(iValue), + (int)GetGValue(iValue), + (int)GetBValue(iValue)); + lstrcat(szNewStyle,tch); + } + wsprintf(tch,L"back:#%02X%02X%02X", + (int)GetRValue(iRGBResult), + (int)GetGValue(iRGBResult), + (int)GetBValue(iRGBResult)); + lstrcat(szNewStyle,tch); + } + + if (StrStrI(lpszStyle,L"eolfilled")) + lstrcat(szNewStyle,L"; eolfilled"); + + if (Style_StrGetCase(lpszStyle,&iValue)) { + lstrcat(szNewStyle,L"; case:"); + lstrcat(szNewStyle,(iValue == SC_CASE_UPPER) ? L"u" : L""); + } + + if (Style_StrGetAlpha(lpszStyle,&iValue)) { + lstrcat(szNewStyle,L"; alpha:"); + wsprintf(tch,L"%i",iValue); + lstrcat(szNewStyle,tch); + } + + if (StrStrI(lpszStyle,L"block")) + lstrcat(szNewStyle,L"; block"); + + if (StrStrI(lpszStyle,L"noblink")) + lstrcat(szNewStyle,L"; noblink"); + + lstrcpyn(lpszStyle,szNewStyle,cchStyle); + return TRUE; +} + + +//============================================================================= +// +// Style_SetStyles() +// +void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) +{ + + WCHAR tch[256]; + WCHAR *p; + int iValue; + + // Font + if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { + char mch[256]; + WideCharToMultiByte(CP_UTF8,0,tch,-1,mch,COUNTOF(mch),NULL,NULL); + SendMessage(hwnd,SCI_STYLESETFONT,iStyle,(LPARAM)mch); + } + + // Size + if (Style_StrGetSize(lpszStyle,&iValue)) + SendMessage(hwnd,SCI_STYLESETSIZE,iStyle,(LPARAM)iValue); + + // Fore + if (Style_StrGetColor(TRUE,lpszStyle,&iValue)) + SendMessage(hwnd,SCI_STYLESETFORE,iStyle,(LPARAM)iValue); + + // Back + if (Style_StrGetColor(FALSE,lpszStyle,&iValue)) + SendMessage(hwnd,SCI_STYLESETBACK,iStyle,(LPARAM)iValue); + + // Bold + if (p = StrStrI(lpszStyle,L"bold")) + SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)TRUE); + else + SendMessage(hwnd,SCI_STYLESETBOLD,iStyle,(LPARAM)FALSE); + + // Italic + if (p = StrStrI(lpszStyle,L"italic")) + SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)TRUE); + else + SendMessage(hwnd,SCI_STYLESETITALIC,iStyle,(LPARAM)FALSE); + + // Underline + if (p = StrStrI(lpszStyle,L"underline")) + SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)TRUE); + else + SendMessage(hwnd,SCI_STYLESETUNDERLINE,iStyle,(LPARAM)FALSE); + + // EOL Filled + if (p = StrStrI(lpszStyle,L"eolfilled")) + SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)TRUE); + else + SendMessage(hwnd,SCI_STYLESETEOLFILLED,iStyle,(LPARAM)FALSE); + + // Case + if (Style_StrGetCase(lpszStyle,&iValue)) + SendMessage(hwnd,SCI_STYLESETCASE,iStyle,(LPARAM)iValue); + + // Character Set + if (Style_StrGetCharSet(lpszStyle,&iValue)) + SendMessage(hwnd,SCI_STYLESETCHARACTERSET,iStyle,(LPARAM)iValue); + +} + + +//============================================================================= +// +// Style_SetFontQuality() +// +void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { + + WPARAM wQuality = SC_EFF_QUALITY_DEFAULT; + WCHAR tch[32]; + + if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) { + if (lstrcmpi(tch,L"none") == 0) + wQuality = SC_EFF_QUALITY_NON_ANTIALIASED; + else if (lstrcmpi(tch,L"standard") == 0) + wQuality = SC_EFF_QUALITY_ANTIALIASED; + else if (lstrcmpi(tch,L"cleartype") == 0) + wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; + else + wQuality = SC_EFF_QUALITY_DEFAULT; + } + else { + WCHAR tch[32]; + if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { + if (lstrcmpi(tch,L"Calibri") == 0 || + lstrcmpi(tch,L"Cambria") == 0 || + lstrcmpi(tch,L"Candara") == 0 || + lstrcmpi(tch,L"Consolas") == 0 || + lstrcmpi(tch,L"Constantia") == 0 || + lstrcmpi(tch,L"Corbel") == 0 || + lstrcmpi(tch,L"Segoe UI") == 0) + wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; + } + else + wQuality = SC_EFF_QUALITY_DEFAULT; + } + SendMessage(hwnd,SCI_SETFONTQUALITY,wQuality,0); +} + + +//============================================================================= +// +// Style_GetCurrentLexerName() +// +void Style_GetCurrentLexerName(LPWSTR lpszName,int cchName) +{ + if (!GetString(pLexCurrent->rid,lpszName,cchName)) + lstrcpyn(lpszName,pLexCurrent->pszName,cchName); +} + + +//============================================================================= +// +// Style_GetLexerIconId() +// +int Style_GetLexerIconId(PEDITLEXER plex) +{ + WCHAR *p; + WCHAR *pszExtensions; + WCHAR *pszFile; + + SHFILEINFO shfi; + + if (lstrlen(plex->szExtensions)) + pszExtensions = plex->szExtensions; + else + pszExtensions = plex->pszDefExt; + + pszFile = GlobalAlloc(GPTR,sizeof(WCHAR)*(lstrlen(pszExtensions) + CSTRLEN(L"*.txt") + 16)); + lstrcpy(pszFile,L"*."); + lstrcat(pszFile,pszExtensions); + if (p = StrChr(pszFile,L';')) + *p = L'\0'; + + // check for ; at beginning + if (lstrlen(pszFile) < 3) + lstrcat(pszFile,L"txt"); + + SHGetFileInfo(pszFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); + + GlobalFree(pszFile); + + return (shfi.iIcon); +} + + +//============================================================================= +// +// Style_AddLexerToTreeView() +// +HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) +{ + int i = 0; + WCHAR tch[128]; + + HTREEITEM hTreeNode; + + TVINSERTSTRUCT tvis; + ZeroMemory(&tvis,sizeof(TVINSERTSTRUCT)); + + tvis.hInsertAfter = TVI_LAST; + + tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; + if (GetString(plex->rid,tch,COUNTOF(tch))) + tvis.item.pszText = tch; + else + tvis.item.pszText = plex->pszName; + tvis.item.iImage = Style_GetLexerIconId(plex); + tvis.item.iSelectedImage = tvis.item.iImage; + tvis.item.lParam = (LPARAM)plex; + + hTreeNode = (HTREEITEM)TreeView_InsertItem(hwnd,&tvis); + + tvis.hParent = hTreeNode; + + tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; + //tvis.item.iImage = -1; + //tvis.item.iSelectedImage = -1; + + while (plex->Styles[i].iStyle != -1) { + + if (GetString(plex->Styles[i].rid,tch,COUNTOF(tch))) + tvis.item.pszText = tch; + else + tvis.item.pszText = plex->Styles[i].pszName; + tvis.item.lParam = (LPARAM)(&plex->Styles[i]); + TreeView_InsertItem(hwnd,&tvis); + i++; + } + + return hTreeNode; +} + + +//============================================================================= +// +// Style_AddLexerToListView() +// +void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex) +{ + WCHAR tch[128]; + LVITEM lvi; + ZeroMemory(&lvi,sizeof(LVITEM)); + + lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; + lvi.iItem = ListView_GetItemCount(hwnd); + if (GetString(plex->rid,tch,COUNTOF(tch))) + lvi.pszText = tch; + else + lvi.pszText = plex->pszName; + lvi.iImage = Style_GetLexerIconId(plex); + lvi.lParam = (LPARAM)plex; + + ListView_InsertItem(hwnd,&lvi); +} + + +//============================================================================= +// +// Style_ConfigDlgProc() +// +INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static HWND hwndTV; + static BOOL fDragging; + static PEDITLEXER pCurrentLexer; + static PEDITSTYLE pCurrentStyle; + static HFONT hFontTitle; + static HBRUSH hbrFore; + static HBRUSH hbrBack; + + switch(umsg) + { + + case WM_INITDIALOG: + { + int i; + SHFILEINFO shfi; + LOGFONT lf; + HTREEITEM currentLex = { 0 }; + int found = 0; + + hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); + fDragging = FALSE; + + TreeView_SetImageList(hwndTV, + (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL); + + // Add lexers + for (i = 0; i < NUMLEXERS; i++) + { + if (!found && lstrcmp(pLexArray[i]->pszName,pLexCurrent->pszName) == 0) + { + found = 1; + currentLex = Style_AddLexerToTreeView(hwndTV,pLexArray[i]); + } + else + Style_AddLexerToTreeView(hwndTV,pLexArray[i]); + } + + pCurrentStyle = 0; + + //SetExplorerTheme(hwndTV); + //TreeView_Expand(hwndTV,TreeView_GetRoot(hwndTV),TVE_EXPAND); + TreeView_Select(hwndTV,currentLex,TVGN_CARET); + + SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT,COUNTOF(lexDefault.Styles[0].szValue)-1,0); + + MakeBitmapButton(hwnd,IDC_PREVSTYLE,g_hInstance,IDB_PREV); + MakeBitmapButton(hwnd,IDC_NEXTSTYLE,g_hInstance,IDB_NEXT); + + // Setup title font + if (hFontTitle) + DeleteObject(hFontTitle); + if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_TITLE,WM_GETFONT,0,0))) + hFontTitle = GetStockObject(DEFAULT_GUI_FONT); + GetObject(hFontTitle,sizeof(LOGFONT),&lf); + lf.lfHeight += lf.lfHeight / 5; + lf.lfWeight = FW_BOLD; + hFontTitle = CreateFontIndirect(&lf); + SendDlgItemMessage(hwnd,IDC_TITLE,WM_SETFONT,(WPARAM)hFontTitle,TRUE); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + DeleteBitmapButton(hwnd,IDC_STYLEFORE); + DeleteBitmapButton(hwnd,IDC_STYLEBACK); + DeleteBitmapButton(hwnd,IDC_PREVSTYLE); + DeleteBitmapButton(hwnd,IDC_NEXTSTYLE); + return FALSE; + + + case WM_NOTIFY: + + if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) + { + LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; + + switch (lpnmtv->hdr.code) + { + + case TVN_SELCHANGED: + { + if (pCurrentStyle) + GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + + else if (pCurrentLexer) { + if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + } + + // a lexer has been selected + if (!TreeView_GetParent(hwndTV,lpnmtv->itemNew.hItem)) + { + WCHAR wch[128]; + + GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); + if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; + + pCurrentStyle = 0; + if (pCurrentLexer = (PEDITLEXER)lpnmtv->itemNew.lParam) + { + SetDlgItemText(hwnd,IDC_STYLELABEL,wch); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); + } + else + { + SetDlgItemText(hwnd,IDC_STYLELABEL,L""); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); + SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); + } + } + + // a style has been selected + else + { + WCHAR wch[128]; + + GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); + if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; + + + pCurrentLexer = 0; + if (pCurrentStyle = (PEDITSTYLE)lpnmtv->itemNew.lParam) + { + SetDlgItemText(hwnd,IDC_STYLELABEL,StrEnd(wch)+1); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),TRUE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),TRUE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),TRUE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),TRUE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),TRUE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),TRUE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),TRUE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),TRUE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),TRUE); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); + } + else + { + SetDlgItemText(hwnd,IDC_STYLELABEL,L""); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEEDIT),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFONT),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEFORE),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEBACK),FALSE); + EnableWindow(GetDlgItem(hwnd,IDC_STYLEDEFAULT),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEBOLD),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEITALIC),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEUNDERLINE),FALSE); + //EnableWindow(GetDlgItem(hwnd,IDC_STYLEEOLFILLED),FALSE); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); + SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); + } + } + } + break; + + case TVN_BEGINDRAG: + { + //HIMAGELIST himl; + + //if (pCurrentStyle) + // GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + TreeView_Select(hwndTV,lpnmtv->itemNew.hItem,TVGN_CARET); + + //himl = TreeView_CreateDragImage(hwndTV,lpnmtv->itemNew.hItem); + //ImageList_BeginDrag(himl,0,0,0); + //ImageList_DragEnter(hwndTV,lpnmtv->ptDrag.x,lpnmtv->ptDrag.y); + if (pCurrentStyle) + DestroyCursor(SetCursor(LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_COPY)))); + else + DestroyCursor(SetCursor(LoadCursor(NULL,IDC_NO))); + + SetCapture(hwnd); + fDragging = TRUE; + } + + } + } + + break; + + + case WM_MOUSEMOVE: + { + HTREEITEM htiTarget; + TVHITTESTINFO tvht; + + if (fDragging && pCurrentStyle) + { + LONG xCur = LOWORD(lParam); + LONG yCur = HIWORD(lParam); + + //ImageList_DragMove(xCur,yCur); + //ImageList_DragShowNolock(FALSE); + + tvht.pt.x = xCur; + tvht.pt.y = yCur; + + //ClientToScreen(hwnd,&tvht.pt); + //ScreenToClient(hwndTV,&tvht.pt); + MapWindowPoints(hwnd,hwndTV,&tvht.pt,1); + + if ((htiTarget = TreeView_HitTest(hwndTV,&tvht)) != NULL && + TreeView_GetParent(hwndTV,htiTarget) != NULL) + { + TreeView_SelectDropTarget(hwndTV,htiTarget); + //TreeView_Expand(hwndTV,htiTarget,TVE_EXPAND); + TreeView_EnsureVisible(hwndTV,htiTarget); + } + else + TreeView_SelectDropTarget(hwndTV,NULL); + + //ImageList_DragShowNolock(TRUE); + } + } + break; + + + case WM_LBUTTONUP: + { + if (fDragging) + { + HTREEITEM htiTarget; + + //ImageList_EndDrag(); + + if (htiTarget = TreeView_GetDropHilight(hwndTV)) + { + WCHAR tchCopy[256]; + TreeView_SelectDropTarget(hwndTV,NULL); + GetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy,COUNTOF(tchCopy)); + TreeView_Select(hwndTV,htiTarget,TVGN_CARET); + + // after select, this is new current item + if (pCurrentStyle) + { + lstrcpy(pCurrentStyle->szValue,tchCopy); + SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tchCopy,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tchCopy,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tchCopy,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tchCopy,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + } + } + ReleaseCapture(); + DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); + fDragging = FALSE; + } + } + break; + + + case WM_CANCELMODE: + { + if (fDragging) + { + //ImageList_EndDrag(); + TreeView_SelectDropTarget(hwndTV,NULL); + ReleaseCapture(); + DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); + fDragging = FALSE; + } + } + break; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_PREVSTYLE: + if (TreeView_GetSelection(hwndTV)) + TreeView_Select(hwndTV,TreeView_GetPrevVisible(hwndTV, + TreeView_GetSelection(hwndTV)),TVGN_CARET); + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + case IDC_NEXTSTYLE: + if (TreeView_GetSelection(hwndTV)) + TreeView_Select(hwndTV,TreeView_GetNextVisible(hwndTV, + TreeView_GetSelection(hwndTV)),TVGN_CARET); + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + case IDC_STYLEFONT: + if (pCurrentStyle) + { + WCHAR tch[256]; + GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + if (Style_SelectFont(hwnd,tch,COUNTOF(tch), + lstrcmpi(pCurrentStyle->pszName,L"Default Style") == 0 || + lstrcmpi(pCurrentStyle->pszName,L"2nd Default Style") == 0)) { + SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + } + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + case IDC_STYLEFORE: + if (pCurrentStyle) + { + WCHAR tch[256]; + GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch))) { + SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + } + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + case IDC_STYLEBACK: + if (pCurrentStyle) + { + WCHAR tch[256]; + GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch))) { + SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(tch,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(tch,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(tch,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(tch,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + } + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + case IDC_STYLEDEFAULT: + if (pCurrentStyle) + { + lstrcpy(pCurrentStyle->szValue,pCurrentStyle->pszDefault); + if (darkTheme) { + int lex,i; + for (lex = 0; lex < NUMLEXERS; ++lex) + for (i = 0; pLexArray[lex]->Styles[i].iStyle != -1; ++i) + if (&pLexArray[lex]->Styles[i] == pCurrentStyle) + Theme_Compose(pCurrentStyle->szValue,pCurrentStyle->pszDefault, + Theme_DefaultColor(pCurrentStyle,lex,i)); + } + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); + //CheckDlgButton(hwnd,IDC_STYLEBOLD,(Style_StrGetAttribute(pCurrentStyle->szValue,L"bold") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEITALIC,(Style_StrGetAttribute(pCurrentStyle->szValue,L"italic") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,(Style_StrGetAttribute(pCurrentStyle->szValue,L"underline") ? BST_CHECKED : BST_UNCHECKED)); + //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,(Style_StrGetAttribute(pCurrentStyle->szValue,L"eolfilled") ? BST_CHECKED : BST_UNCHECKED)); + } + else if (pCurrentLexer) { + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); + } + PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + break; + + //case IDC_STYLEBOLD: + // if (pCurrentStyle) + // { + // WCHAR tch[256]; + // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + // Style_StrSetAttribute(tch,COUNTOF(tch),L"bold",IsDlgButtonChecked(hwnd,IDC_STYLEBOLD)); + // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + // } + // break; + + //case IDC_STYLEITALIC: + // if (pCurrentStyle) + // { + // WCHAR tch[256]; + // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + // Style_StrSetAttribute(tch,COUNTOF(tch),L"italic",IsDlgButtonChecked(hwnd,IDC_STYLEITALIC)); + // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + // } + // break; + + //case IDC_STYLEUNDERLINE: + // if (pCurrentStyle) + // { + // WCHAR tch[256]; + // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + // Style_StrSetAttribute(tch,COUNTOF(tch),L"underline",IsDlgButtonChecked(hwnd,IDC_STYLEUNDERLINE)); + // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + // } + // break; + + //case IDC_STYLEEOLFILLED: + // if (pCurrentStyle) + // { + // WCHAR tch[256]; + // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + // Style_StrSetAttribute(tch,COUNTOF(tch),L"eolfilled",IsDlgButtonChecked(hwnd,IDC_STYLEEOLFILLED)); + // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + // } + // break; + + case IDC_STYLEEDIT: + { + if (HIWORD(wParam) == EN_CHANGE) { + int cr; + WCHAR tch[256]; + + GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); + + cr = -1; + Style_StrGetColor(TRUE,tch,&cr); + MakeColorPickButton(hwnd,IDC_STYLEFORE,g_hInstance,cr); + + cr = -1; + Style_StrGetColor(FALSE,tch,&cr); + MakeColorPickButton(hwnd,IDC_STYLEBACK,g_hInstance,cr); + } + } + break; + + case IDC_IMPORT: + { + HWND hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); + + if (pCurrentStyle) + GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + else if (pCurrentLexer) { + if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + } + + if (Style_Import(hwnd)) { + + if (pCurrentStyle) + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); + else if (pCurrentLexer) + SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); + + TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET); + } + } + break; + + case IDC_EXPORT: + { + if (pCurrentStyle) + GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + else if (pCurrentLexer) { + if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + } + + Style_Export(hwnd); + } + break; + + case IDC_PREVIEW: + { + // Hack from outside + extern HWND hwndEdit; + extern void UpdateLineNumerWidth(); + + if (pCurrentStyle) + GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + else if (pCurrentLexer) { + if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + } + + Style_SetLexer(hwndEdit,pLexCurrent); + UpdateLineNumberWidth(); + } + break; + + case IDOK: + if (pCurrentStyle) + GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); + else if (pCurrentLexer) { + if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) + lstrcpy(pCurrentLexer->szExtensions,pCurrentLexer->pszDefExt); + } + EndDialog(hwnd,IDOK); + break; + + case IDCANCEL: + if (fDragging) + SendMessage(hwnd,WM_CANCELMODE,0,0); + else + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// Style_ConfigDlg() +// +void Style_ConfigDlg(HWND hwnd) +{ + + WCHAR *StyleBackup[1024]; + int c,cItems,i,iLexer; + + // Backup Styles + c = 0; + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + StyleBackup[c++] = StrDup(pLexArray[iLexer]->Styles[i].szValue); + i++; + } + } + cItems = c; + + if (IDCANCEL == ThemedDialogBoxParam(g_hInstance, + MAKEINTRESOURCE(IDD_STYLECONFIG), + GetParent(hwnd),Style_ConfigDlgProc, + (LPARAM)&StyleBackup)) + { + // Restore Styles + c = 0; + for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + lstrcpy(pLexArray[iLexer]->szExtensions,StyleBackup[c++]); + i = 0; + while (pLexArray[iLexer]->Styles[i].iStyle != -1) { + lstrcpy(pLexArray[iLexer]->Styles[i].szValue,StyleBackup[c++]); + i++; + } + } + } + + else { + fStylesModified = TRUE; + if (lstrlen(szIniFile) == 0 && !fWarnedNoIniFile) { + MsgBox(MBWARN,IDS_SETTINGSNOTSAVED); + fWarnedNoIniFile = TRUE; + } + } + + for (c = 0; c < cItems; c++) + LocalFree(StyleBackup[c]); + + // Apply new (or previous) Styles + Style_SetLexer(hwnd,pLexCurrent); +} + + +//============================================================================= +// +// Style_SelectLexerDlgProc() +// +INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +{ + + static int cxClient; + static int cyClient; + static int mmiPtMaxY; + static int mmiPtMinX; + + static HWND hwndLV; + static int iInternalDefault; + + switch(umsg) + { + + case WM_INITDIALOG: + { + int i; + int lvItems; + LVITEM lvi; + SHFILEINFO shfi; + LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; + + RECT rc; + WCHAR tch[MAX_PATH]; + int cGrip; + + GetClientRect(hwnd,&rc); + cxClient = rc.right - rc.left; + cyClient = rc.bottom - rc.top; + + AdjustWindowRectEx(&rc,GetWindowLong(hwnd,GWL_STYLE)|WS_THICKFRAME,FALSE,0); + mmiPtMinX = rc.right-rc.left; + mmiPtMaxY = rc.bottom-rc.top; + + if (cxStyleSelectDlg < (rc.right-rc.left)) + cxStyleSelectDlg = rc.right-rc.left; + if (cyStyleSelectDlg < (rc.bottom-rc.top)) + cyStyleSelectDlg = rc.bottom-rc.top; + SetWindowPos(hwnd,NULL,rc.left,rc.top,cxStyleSelectDlg,cyStyleSelectDlg,SWP_NOZORDER); + + SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); + SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + + GetMenuString(GetSystemMenu(GetParent(hwnd),FALSE),SC_SIZE,tch,COUNTOF(tch),MF_BYCOMMAND); + InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_STRING|MF_ENABLED,SC_SIZE,tch); + InsertMenu(GetSystemMenu(hwnd,FALSE),SC_CLOSE,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); + + SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE, + GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP3),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS); + + cGrip = GetSystemMetrics(SM_CXHTHUMB); + SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,cxClient-cGrip, + cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER); + + hwndLV = GetDlgItem(hwnd,IDC_STYLELIST); + + ListView_SetImageList(hwndLV, + (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), + LVSIL_SMALL); + + ListView_SetImageList(hwndLV, + (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), + LVSIL_NORMAL); + + //SetExplorerTheme(hwndLV); + ListView_SetExtendedListViewStyle(hwndLV,/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); + ListView_InsertColumn(hwndLV,0,&lvc); + + // Add lexers + for (i = 0; i < NUMLEXERS; i++) + Style_AddLexerToListView(hwndLV,pLexArray[i]); + + ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); + + // Select current lexer + lvItems = ListView_GetItemCount(hwndLV); + lvi.mask = LVIF_PARAM; + for (i = 0; i < lvItems; i++) { + lvi.iItem = i; + ListView_GetItem(hwndLV,&lvi);; + if (lstrcmp(((PEDITLEXER)lvi.lParam)->pszName,pLexCurrent->pszName) == 0) { + ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); + ListView_EnsureVisible(hwndLV,i,FALSE); + if (iDefaultLexer == i) { + CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED); + } + } + } + + iInternalDefault = iDefaultLexer; + + if (bAutoSelect) + CheckDlgButton(hwnd,IDC_AUTOSELECT,BST_CHECKED); + + CenterDlgInParent(hwnd); + } + return TRUE; + + + case WM_DESTROY: + { + RECT rc; + + GetWindowRect(hwnd,&rc); + cxStyleSelectDlg = rc.right-rc.left; + cyStyleSelectDlg = rc.bottom-rc.top; + } + return FALSE; + + + case WM_SIZE: + { + RECT rc; + + int dxClient = LOWORD(lParam) - cxClient; + int dyClient = HIWORD(lParam) - cyClient; + cxClient = LOWORD(lParam); + cyClient = HIWORD(lParam); + + GetWindowRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); + InvalidateRect(GetDlgItem(hwnd,IDC_RESIZEGRIP3),NULL,TRUE); + + GetWindowRect(GetDlgItem(hwnd,IDOK),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDOK),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); + InvalidateRect(GetDlgItem(hwnd,IDOK),NULL,TRUE); + + GetWindowRect(GetDlgItem(hwnd,IDCANCEL),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDCANCEL),NULL,rc.left+dxClient,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); + InvalidateRect(GetDlgItem(hwnd,IDCANCEL),NULL,TRUE); + + GetWindowRect(GetDlgItem(hwnd,IDC_STYLELIST),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDC_STYLELIST),NULL,0,0,rc.right-rc.left+dxClient,rc.bottom-rc.top+dyClient,SWP_NOZORDER|SWP_NOMOVE); + ListView_SetColumnWidth(GetDlgItem(hwnd,IDC_STYLELIST),0,LVSCW_AUTOSIZE_USEHEADER); + InvalidateRect(GetDlgItem(hwnd,IDC_STYLELIST),NULL,TRUE); + + GetWindowRect(GetDlgItem(hwnd,IDC_AUTOSELECT),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); + InvalidateRect(GetDlgItem(hwnd,IDC_AUTOSELECT),NULL,TRUE); + + GetWindowRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),&rc); + MapWindowPoints(NULL,hwnd,(LPPOINT)&rc,2); + SetWindowPos(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,rc.left,rc.top+dyClient,0,0,SWP_NOZORDER|SWP_NOSIZE); + InvalidateRect(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),NULL,TRUE); + } + return TRUE; + + + case WM_GETMINMAXINFO: + { + LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; + lpmmi->ptMinTrackSize.x = mmiPtMinX; + lpmmi->ptMinTrackSize.y = mmiPtMaxY; + //lpmmi->ptMaxTrackSize.y = mmiPtMaxY; + } + return TRUE; + + + case WM_NOTIFY: { + if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) { + + switch (((LPNMHDR)(lParam))->code) { + + case NM_DBLCLK: + SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); + break; + + case LVN_ITEMCHANGED: + case LVN_DELETEITEM: { + int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); + if (iInternalDefault == i) + CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED); + else + CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_UNCHECKED); + EnableWindow(GetDlgItem(hwnd,IDC_DEFAULTSCHEME),i != -1); + EnableWindow(GetDlgItem(hwnd,IDOK),i != -1); + } + break; + } + } + } + + return TRUE; + + + case WM_COMMAND: + + switch(LOWORD(wParam)) + { + + case IDC_DEFAULTSCHEME: + if (IsDlgButtonChecked(hwnd,IDC_DEFAULTSCHEME) == BST_CHECKED) + iInternalDefault = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); + else + iInternalDefault = 0; + break; + + + case IDOK: + { + LVITEM lvi; + + lvi.mask = LVIF_PARAM; + lvi.iItem = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); + if (ListView_GetItem(hwndLV,&lvi)) { + pLexCurrent = (PEDITLEXER)lvi.lParam; + iDefaultLexer = iInternalDefault; + bAutoSelect = (IsDlgButtonChecked(hwnd,IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; + EndDialog(hwnd,IDOK); + } + } + break; + + + case IDCANCEL: + EndDialog(hwnd,IDCANCEL); + break; + + } + + return TRUE; + + } + + return FALSE; + +} + + +//============================================================================= +// +// Style_SelectLexerDlg() +// +void Style_SelectLexerDlg(HWND hwnd) +{ + if (IDOK == ThemedDialogBoxParam(g_hInstance, + MAKEINTRESOURCE(IDD_STYLESELECT), + GetParent(hwnd),Style_SelectLexerDlgProc,0)) + + Style_SetLexer(hwnd,pLexCurrent); +} + + +// End of Styles.c diff --git a/src/Styles.h b/src/Styles.h index 0347a217..f55f9603 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -1,100 +1,104 @@ -/****************************************************************************** -* -* -* Notepad2 -* -* Styles.h -* Scintilla Style Management -* -* See Readme.txt for more information about this source code. -* Please send me your comments to this work. -* -* See License.txt for details about distribution and modification. -* -* (c) Florian Balmer 1996-2011 -* florian.balmer@gmail.com -* http://www.flos-freeware.ch -* -* -******************************************************************************/ - - -typedef struct _editstyle -{ - union - { - INT32 iStyle; - UINT8 iStyle8[4]; - }; - int rid; - WCHAR* pszName; - WCHAR* pszDefault; - WCHAR szValue[128]; - -} EDITSTYLE, *PEDITSTYLE; - - -typedef struct _keywordlist -{ - char *pszKeyWords[KEYWORDSET_MAX + 1]; - -} KEYWORDLIST, *PKEYWORDLIST; - - -typedef struct _editlexer -{ - int iLexer; - int rid; - WCHAR* pszName; - WCHAR* pszDefExt; - WCHAR szExtensions[128]; - PKEYWORDLIST pKeyWords; - EDITSTYLE Styles[]; - -} EDITLEXER, *PEDITLEXER; - - -// Number of Lexers in pLexArray -#define NUMLEXERS 38 - - -void Style_Load(); -void Style_Save(); -BOOL Style_Import(HWND); -BOOL Style_Export(HWND); -void Style_SetLexer(HWND,PEDITLEXER); -void Style_SetLongLineColors(HWND); -void Style_SetCurrentLineBackground(HWND); -void Style_SetLexerFromFile(HWND,LPCWSTR); -void Style_SetLexerFromName(HWND,LPCWSTR,LPCWSTR); -void Style_SetDefaultLexer(HWND); -void Style_SetHTMLLexer(HWND); -void Style_SetXMLLexer(HWND); -void Style_SetLexerFromID(HWND,int); -void Style_SetDefaultFont(HWND); -void Style_ToggleUse2ndDefault(HWND); -BOOL Style_GetUse2ndDefault(HWND); -void Style_SetIndentGuides(HWND,BOOL); -BOOL Style_GetOpenDlgFilterStr(LPWSTR,int); -BOOL Style_StrGetFont(LPCWSTR,LPWSTR,int); -BOOL Style_StrGetFontQuality(LPCWSTR,LPWSTR,int); -BOOL Style_StrGetCharSet(LPCWSTR,int*); -BOOL Style_StrGetSize(LPCWSTR,int*); -BOOL Style_StrGetSizeStr(LPCWSTR,LPWSTR,int); -BOOL Style_StrGetColor(BOOL,LPCWSTR,int*); -BOOL Style_StrGetCase(LPCWSTR,int*); -BOOL Style_StrGetAlpha(LPCWSTR,int*); -BOOL Style_SelectFont(HWND,LPWSTR,int,BOOL); -BOOL Style_SelectColor(HWND,BOOL,LPWSTR,int); -void Style_SetStyles(HWND,int,LPCWSTR); -void Style_SetFontQuality(HWND,LPCWSTR); -void Style_GetCurrentLexerName(LPWSTR,int); -int Style_GetLexerIconId(PEDITLEXER); -HTREEITEM Style_AddLexerToTreeView(HWND,PEDITLEXER); -INT_PTR CALLBACK Styles_ConfigDlgProc(HWND,UINT,WPARAM,LPARAM); -void Style_ConfigDlg(HWND); -INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND,UINT,WPARAM,LPARAM); -void Style_SelectLexerDlg(HWND); - - -// End of Style.h +/****************************************************************************** +* +* +* Notepad2 +* +* Styles.h +* Scintilla Style Management +* +* See Readme.txt for more information about this source code. +* Please send me your comments to this work. +* +* See License.txt for details about distribution and modification. +* +* (c) Florian Balmer 1996-2011 +* florian.balmer@gmail.com +* http://www.flos-freeware.ch +* +* +******************************************************************************/ + + +typedef struct _editstyle +{ + union + { + INT32 iStyle; + UINT8 iStyle8[4]; + }; + int rid; + WCHAR* pszName; + WCHAR* pszDefault; + WCHAR szValue[128]; + +} EDITSTYLE, *PEDITSTYLE; + + +typedef struct _keywordlist +{ + char *pszKeyWords[KEYWORDSET_MAX + 1]; + +} KEYWORDLIST, *PKEYWORDLIST; + + +typedef struct _editlexer +{ + int iLexer; + int rid; + WCHAR* pszName; + WCHAR* pszDefExt; + WCHAR szExtensions[128]; + PKEYWORDLIST pKeyWords; + EDITSTYLE Styles[]; + +} EDITLEXER, *PEDITLEXER; + + +// Number of Lexers in pLexArray +#define NUMLEXERS 38 + + +void Style_Load(); +BOOL Style_IsDarkTheme(void); +void Style_SetTheme(HWND,BOOL); +COLORREF Style_GetOccurrenceColor(int); +COLORREF Style_GetBookmarkColor(void); +void Style_Save(); +BOOL Style_Import(HWND); +BOOL Style_Export(HWND); +void Style_SetLexer(HWND,PEDITLEXER); +void Style_SetLongLineColors(HWND); +void Style_SetCurrentLineBackground(HWND); +void Style_SetLexerFromFile(HWND,LPCWSTR); +void Style_SetLexerFromName(HWND,LPCWSTR,LPCWSTR); +void Style_SetDefaultLexer(HWND); +void Style_SetHTMLLexer(HWND); +void Style_SetXMLLexer(HWND); +void Style_SetLexerFromID(HWND,int); +void Style_SetDefaultFont(HWND); +void Style_ToggleUse2ndDefault(HWND); +BOOL Style_GetUse2ndDefault(HWND); +void Style_SetIndentGuides(HWND,BOOL); +BOOL Style_GetOpenDlgFilterStr(LPWSTR,int); +BOOL Style_StrGetFont(LPCWSTR,LPWSTR,int); +BOOL Style_StrGetFontQuality(LPCWSTR,LPWSTR,int); +BOOL Style_StrGetCharSet(LPCWSTR,int*); +BOOL Style_StrGetSize(LPCWSTR,int*); +BOOL Style_StrGetSizeStr(LPCWSTR,LPWSTR,int); +BOOL Style_StrGetColor(BOOL,LPCWSTR,int*); +BOOL Style_StrGetCase(LPCWSTR,int*); +BOOL Style_StrGetAlpha(LPCWSTR,int*); +BOOL Style_SelectFont(HWND,LPWSTR,int,BOOL); +BOOL Style_SelectColor(HWND,BOOL,LPWSTR,int); +void Style_SetStyles(HWND,int,LPCWSTR); +void Style_SetFontQuality(HWND,LPCWSTR); +void Style_GetCurrentLexerName(LPWSTR,int); +int Style_GetLexerIconId(PEDITLEXER); +HTREEITEM Style_AddLexerToTreeView(HWND,PEDITLEXER); +INT_PTR CALLBACK Styles_ConfigDlgProc(HWND,UINT,WPARAM,LPARAM); +void Style_ConfigDlg(HWND); +INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND,UINT,WPARAM,LPARAM); +void Style_SelectLexerDlg(HWND); + + +// End of Style.h diff --git a/src/Version.h b/src/Version.h index 9219adee..381e8677 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1,71 +1,73 @@ -/****************************************************************************** -* -* Notepad2-mod -* -* Version.h -* -* See License.txt for details about distribution and modification. -* -* (c) XhmikosR 2010-2017 -* https://github.com/XhmikosR/notepad2-mod -* -* -******************************************************************************/ - - -#ifndef NOTEPAD2_VERSION_H -#define NOTEPAD2_VERSION_H - -#include "VersionRev.h" - -#ifndef _T -#if !defined(ISPP_INVOKED) && (defined(UNICODE) || defined(_UNICODE)) -#define _T(text) L##text -#else -#define _T(text) text -#endif -#endif - -#define DO_STRINGIFY(x) _T(#x) -#define STRINGIFY(x) DO_STRINGIFY(x) - -#define VERSION_MAJOR 4 -#define VERSION_MINOR 2 -#define VERSION_BUILD 25 - -#define MY_APPNAME L"Notepad2-mod" -#define VERSION_FILEVERSION_NUM VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD,VERSION_REV -#define VERSION_FILEVERSION STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." \ - STRINGIFY(VERSION_BUILD) "." STRINGIFY(VERSION_REV) -#define VERSION_LEGALCOPYRIGHT_SHORT L"Copyright © 2004-2017" -#define VERSION_LEGALCOPYRIGHT_LONG L"© Florian Balmer 2004-2017" -#define VERSION_AUTHORNAME L"Florian Balmer" -#define VERSION_WEBPAGEDISPLAY L"flo's freeware - http://www.flos-freeware.ch" -#define VERSION_EMAILDISPLAY L"florian.balmer@gmail.com" -#define VERSION_COMPANYNAME L"Florian Balmer et al." -#define VERSION_MODPAGEDISPLAY L"https://xhmikosr.github.io/notepad2-mod/" - -#if defined(_WIN64) - #define VERSION_FILEVERSION_LONG L"Notepad2-mod (64-bit) " STRINGIFY(VERSION_MAJOR) L"." \ - STRINGIFY(VERSION_MINOR) L"." STRINGIFY(VERSION_BUILD) \ - L" r" STRINGIFY(VERSION_REV) L" (" VERSION_HASH L")" -#else - #define VERSION_FILEVERSION_LONG L"Notepad2-mod " STRINGIFY(VERSION_MAJOR) L"." \ - STRINGIFY(VERSION_MINOR) L"." STRINGIFY(VERSION_BUILD) \ - L" r" STRINGIFY(VERSION_REV) L" (" VERSION_HASH L")" -#endif - -// Compiler specific -#if defined(_MSC_VER) - #if _MSC_VER == 1910 - #if (_MSC_FULL_VER >= 191025017 && _MSC_FULL_VER <= 191025019) - #define VERSION_COMPILER L"MSVC 2017" - #endif - #else - #define VERSION_COMPILER L"MSVC (version unknown)" - #endif -#else - #define VERSION_COMPILER L"(Unknown compiler)" -#endif - -#endif // NOTEPAD2_VERSION_H +/****************************************************************************** +* +* Notepad2-mod +* +* Version.h +* +* See License.txt for details about distribution and modification. +* +* (c) XhmikosR 2010-2017 +* https://github.com/XhmikosR/notepad2-mod +* +* +******************************************************************************/ + + +#ifndef NOTEPAD2_VERSION_H +#define NOTEPAD2_VERSION_H + +#include "VersionRev.h" + +#ifndef _T +#if !defined(ISPP_INVOKED) && (defined(UNICODE) || defined(_UNICODE)) +#define _T(text) L##text +#else +#define _T(text) text +#endif +#endif + +#define DO_STRINGIFY(x) _T(#x) +#define STRINGIFY(x) DO_STRINGIFY(x) + +#define VERSION_MAJOR 4 +#define VERSION_MINOR 2 +#define VERSION_BUILD 25 + +#define MY_APPNAME L"Notepad2-mod" +#define VERSION_FILEVERSION_NUM VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD,VERSION_REV +#define VERSION_FILEVERSION STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." \ + STRINGIFY(VERSION_BUILD) "." STRINGIFY(VERSION_REV) +#define VERSION_LEGALCOPYRIGHT_SHORT L"Copyright © 2004-2017" +#define VERSION_LEGALCOPYRIGHT_LONG L"© Florian Balmer 2004-2017" +#define VERSION_AUTHORNAME L"Florian Balmer" +#define VERSION_WEBPAGEDISPLAY L"flo's freeware - http://www.flos-freeware.ch" +#define VERSION_EMAILDISPLAY L"florian.balmer@gmail.com" +#define VERSION_COMPANYNAME L"Florian Balmer et al." +#define VERSION_MODPAGEDISPLAY L"https://xhmikosr.github.io/notepad2-mod/" + +#if defined(_WIN64) + #define VERSION_FILEVERSION_LONG L"Notepad2-mod (64-bit) " STRINGIFY(VERSION_MAJOR) L"." \ + STRINGIFY(VERSION_MINOR) L"." STRINGIFY(VERSION_BUILD) \ + L" r" STRINGIFY(VERSION_REV) L" (" VERSION_HASH L")" +#else + #define VERSION_FILEVERSION_LONG L"Notepad2-mod " STRINGIFY(VERSION_MAJOR) L"." \ + STRINGIFY(VERSION_MINOR) L"." STRINGIFY(VERSION_BUILD) \ + L" r" STRINGIFY(VERSION_REV) L" (" VERSION_HASH L")" +#endif + +// Compiler specific +#if defined(_MSC_VER) + #if _MSC_VER >= 1930 && _MSC_VER < 1950 + #define VERSION_COMPILER L"MSVC 2022" + #elif _MSC_VER == 1910 + #if (_MSC_FULL_VER >= 191025017 && _MSC_FULL_VER <= 191025019) + #define VERSION_COMPILER L"MSVC 2017" + #endif + #else + #define VERSION_COMPILER L"MSVC (version unknown)" + #endif +#else + #define VERSION_COMPILER L"(Unknown compiler)" +#endif + +#endif // NOTEPAD2_VERSION_H diff --git a/src/resource.h b/src/resource.h index 74a84a04..0ee90cce 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,439 +1,441 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Notepad2.rc -// -#define IDC_STATIC -1 -#define IDR_MAINWND 100 -#define IDC_FINDTEXT 100 -#define IDC_LINENUM 100 -#define IDC_COMMANDLINE 100 -#define IDD_ABOUT 100 -#define IDC_VERSION 100 -#define IDC_OPENWITHDIR 100 -#define IDC_FILEMRU 100 -#define IDC_STYLELIST 100 -#define IDC_FAVORITESDIR 100 -#define IDC_COLUMNWRAP 100 -#define IDC_INFOBOXICON 100 -#define IDC_COPY 100 -#define IDC_ENCODINGLIST 100 -#define IDC_SEARCHEXE 101 -#define IDR_POPUPMENU 101 -#define IDC_GETOPENWITHDIR 101 -#define IDC_RESIZEGRIP 101 -#define IDD_OPENWITH 101 -#define IDC_REPLACETEXT 101 -#define IDI_RUN 101 -#define IDC_COLNUM 101 -#define IDC_DEFAULTSCHEME 101 -#define IDC_GETFAVORITESDIR 101 -#define IDC_INFOBOXTEXT 101 -#define IDB_OPEN 101 -#define IDR_ACCFINDREPLACE 101 -#define IDC_STYLELABEL 101 -#define IDC_RESIZEGRIP4 101 -#define IDC_NOUNICODEDETECTION 101 -#define IDC_COPYRIGHT 101 -#define IDC_MOD_PAGE 112 -#define IDC_STYLEEDIT 102 -#define IDC_FINDCASE 102 -#define IDC_OPENWITHDESCR 102 -#define IDC_SAVEMRU 102 -#define IDD_RUN 102 -#define IDC_AUTOSELECT 102 -#define IDC_FAVORITESDESCR 102 -#define IDC_INFOBOXCHECK 102 -#define IDC_CONSISTENTEOLS 102 -#define IDB_PREV 102 -#define IDI_STYLES 102 -#define IDC_ASCIIASUTF8 102 -#define IDC_WEBPAGE 102 -#define IDD_DEFENCODING 103 -#define IDC_FINDWORD 103 -#define IDC_RESIZEGRIP3 103 -#define IDB_NEXT 103 -#define IDC_STYLEFORE 103 -#define IDC_AUTOSTRIPBLANKS 103 -#define IDC_ENCODINGFROMFILEVARS 103 -#define IDC_WEBPAGE2 103 -#define IDD_ENCODING 104 -#define IDC_MOD_PAGE2 104 -#define IDC_FINDSTART 104 -#define IDB_PICK 104 -#define IDC_STYLEBACK 104 -#define IDC_AUTHORNAME 104 -#define IDD_RECODE 105 -#define IDC_FINDREGEXP 105 -#define IDC_STYLEFONT 105 -#define IDB_ENCODING 105 -#define IDC_EMAIL 105 -#define IDD_DEFEOLMODE 106 -#define IDC_FINDTRANSFORMBS 106 -#define IDC_PREVIEW 106 -#define IDC_EMAIL2 106 -#define IDD_FAVORITES 107 -#define IDC_NOWRAP 107 -#define IDC_STYLEDEFAULT 107 -#define IDD_ADDTOFAV 108 -#define IDC_PREVSTYLE 108 -#define IDC_FINDCLOSE 108 -#define IDD_FILEMRU 109 -#define IDC_FINDPREV 109 -#define IDC_NEXTSTYLE 109 -#define IDD_CHANGENOTIFY 110 -#define IDC_IMPORT 110 -#define IDD_MODIFYLINES 111 -#define IDC_EXPORT 111 -#define IDC_REPLACE 112 -#define IDC_TITLE 112 -#define IDD_ALIGN 112 -#define IDD_ENCLOSESELECTION 113 -#define IDC_REPLACEALL 113 -#define IDC_STYLELABELS 113 -#define IDD_INSERTTAG 114 -#define IDC_REPLACEINSEL 114 -#define IDD_SORT 115 -#define IDC_TOGGLEFINDREPLACE 115 -#define IDD_COLUMNWRAP 116 -#define IDD_LINENUM 117 -#define IDD_FIND 118 -#define IDD_REPLACE 119 -#define IDD_STYLESELECT 120 -#define IDD_STYLECONFIG 121 -#define IDD_WORDWRAP 122 -#define IDD_LONGLINES 123 -#define IDD_TABSETTINGS 124 -#define IDD_PAGESETUP 125 -#define IDD_INFOBOX 126 -#define IDD_INFOBOX2 127 -#define IDD_INFOBOX3 128 -#define IDC_BACKSLASHHELP 151 -#define IDC_REGEXPHELP 152 -#define IDC_WILDCARDHELP 153 -#define IDC_WILDCARDSEARCH 154 -#define IDACC_FIND 200 -#define IDACC_REPLACE 201 -#define IDACC_SAVEPOS 202 -#define IDACC_RESETPOS 203 -#define IDACC_FINDNEXT 204 -#define IDACC_FINDPREV 205 -#define IDACC_REPLACENEXT 206 -#define IDACC_SAVEFIND 207 -#define IDACC_SELTONEXT 208 -#define IDACC_SELTOPREV 209 -#define IDC_NFOASOEM 300 -#define IDC_COMPILER 301 -#define IDC_COMPILER2 302 -#define IDS_APPTITLE 10000 -#define IDS_APPTITLE_ELEVATED 10001 -#define IDS_APPTITLE_PASTEBOARD 10002 -#define IDS_UNTITLED 10003 -#define IDS_TITLEEXCERPT 10004 -#define IDS_READONLY 10005 -#define IDS_DOCPOS 10006 -#define IDS_DOCPOS2 10007 -#define IDS_DOCSIZE 10008 -#define IDS_LOADFILE 10009 -#define IDS_SAVEFILE 10010 -#define IDS_PRINTFILE 10011 -#define IDS_SAVINGSETTINGS 10012 -#define IDS_LINKDESCRIPTION 10013 -#define IDS_FILTER_ALL 10014 -#define IDS_FILTER_EXE 10015 -#define IDS_FILTER_INI 10016 -#define IDS_OPENWITH 10017 -#define IDS_FAVORITES 10018 -#define IDS_BACKSLASHHELP 10019 -#define IDS_REGEXPHELP 10020 -#define IDS_WILDCARDHELP 10021 -#define CMD_ESCAPE 20000 -#define CMD_SHIFTESC 20001 -#define CMD_CTRLENTER 20002 -#define CMD_CTRLBACK 20003 -#define CMD_CTRLDEL 20004 -#define CMD_CTRLTAB 20005 -#define CMD_RECODEDEFAULT 20006 -#define CMD_RELOADANSI 20007 -#define CMD_RELOADOEM 20008 -#define CMD_RELOADASCIIASUTF8 20009 -#define CMD_RELOADNOFILEVARS 20010 -#define CMD_LEXDEFAULT 20011 -#define CMD_LEXHTML 20012 -#define CMD_LEXXML 20013 -#define CMD_TIMESTAMPS 20014 -#define CMD_WEBACTION1 20015 -#define CMD_WEBACTION2 20016 -#define CMD_FINDNEXTSEL 20017 -#define CMD_FINDPREVSEL 20018 -#define CMD_INCLINELIMIT 20019 -#define CMD_DECLINELIMIT 20020 -#define CMD_STRINGIFY 20021 -#define CMD_STRINGIFY2 20022 -#define CMD_EMBRACE 20023 -#define CMD_EMBRACE2 20024 -#define CMD_EMBRACE3 20025 -#define CMD_EMBRACE4 20026 -#define CMD_INCREASENUM 20027 -#define CMD_DECREASENUM 20028 -#define CMD_TOGGLETITLE 20029 -#define CMD_JUMP2SELSTART 20030 -#define CMD_JUMP2SELEND 20031 -#define CMD_COPYPATHNAME 20032 -#define CMD_COPYWINPOS 20033 -#define CMD_DEFAULTWINPOS 20034 -#define CMD_OPENINIFILE 20035 -#define IDM_FILE_NEW 40000 -#define IDM_FILE_OPEN 40001 -#define IDM_FILE_REVERT 40002 -#define IDM_FILE_BROWSE 40003 -#define IDM_FILE_SAVE 40004 -#define IDM_FILE_SAVEAS 40005 -#define IDM_FILE_SAVECOPY 40006 -#define IDM_FILE_READONLY 40007 -#define IDM_FILE_LAUNCH 40008 -#define IDM_FILE_OPENWITH 40009 -#define IDM_FILE_RUN 40010 -#define IDM_FILE_NEWWINDOW 40011 -#define IDM_FILE_NEWWINDOW2 40012 -#define IDM_FILE_PAGESETUP 40013 -#define IDM_FILE_PRINT 40014 -#define IDM_FILE_PROPERTIES 40015 -#define IDM_FILE_CREATELINK 40016 -#define IDM_FILE_OPENFAV 40017 -#define IDM_FILE_ADDTOFAV 40018 -#define IDM_FILE_MANAGEFAV 40019 -#define IDM_FILE_RECENT 40020 -#define IDM_FILE_EXIT 40021 -#define IDM_ENCODING_ANSI 40100 -#define IDM_ENCODING_UNICODE 40101 -#define IDM_ENCODING_UNICODEREV 40102 -#define IDM_ENCODING_UTF8 40103 -#define IDM_ENCODING_UTF8SIGN 40104 -#define IDM_ENCODING_SELECT 40105 -#define IDM_ENCODING_RECODE 40106 -#define IDM_ENCODING_SETDEFAULT 40107 -#define IDM_LINEENDINGS_CRLF 40200 -#define IDM_LINEENDINGS_LF 40201 -#define IDM_LINEENDINGS_CR 40202 -#define IDM_LINEENDINGS_SETDEFAULT 40203 -#define IDM_EDIT_BOOKMARKTOGGLE 40250 -#define IDM_EDIT_BOOKMARKNEXT 40251 -#define IDM_EDIT_BOOKMARKCLEAR 40252 -#define IDM_EDIT_BOOKMARKPREV 40253 -#define BME_EDIT_BOOKMARKTOGGLE 40254 -#define BME_EDIT_BOOKMARKNEXT 40255 -#define BME_EDIT_BOOKMARKCLEAR 40256 -#define BME_EDIT_BOOKMARKPREV 40257 -#define IDM_EDIT_UNDO 40300 -#define IDM_EDIT_REDO 40301 -#define IDM_EDIT_CUT 40302 -#define IDM_EDIT_COPY 40303 -#define IDM_EDIT_COPYALL 40304 -#define IDM_EDIT_COPYADD 40305 -#define IDM_EDIT_PASTE 40306 -#define IDM_EDIT_SWAP 40307 -#define IDM_EDIT_CLEAR 40308 -#define IDM_EDIT_CLEARCLIPBOARD 40309 -#define IDM_EDIT_SELECTALL 40310 -#define IDM_EDIT_SELECTWORD 40311 -#define IDM_EDIT_SELECTLINE 40312 -#define IDM_EDIT_MOVELINEUP 40313 -#define IDM_EDIT_MOVELINEDOWN 40314 -#define IDM_EDIT_DUPLICATELINE 40315 -#define IDM_EDIT_CUTLINE 40316 -#define IDM_EDIT_COPYLINE 40317 -#define IDM_EDIT_DELETELINE 40318 -#define IDM_EDIT_DELETELINELEFT 40319 -#define IDM_EDIT_DELETELINERIGHT 40320 -#define IDM_EDIT_COLUMNWRAP 40321 -#define IDM_EDIT_SPLITLINES 40322 -#define IDM_EDIT_JOINLINES 40323 -#define IDM_EDIT_JOINLINESEX 40324 -#define IDM_EDIT_INDENT 40325 -#define IDM_EDIT_UNINDENT 40326 -#define IDM_EDIT_ENCLOSESELECTION 40327 -#define IDM_EDIT_SELECTIONDUPLICATE 40328 -#define IDM_EDIT_PADWITHSPACES 40329 -#define IDM_EDIT_STRIP1STCHAR 40330 -#define IDM_EDIT_STRIPLASTCHAR 40331 -#define IDM_EDIT_TRIMLINES 40332 -#define IDM_EDIT_COMPRESSWS 40333 -#define IDM_EDIT_MERGEBLANKLINES 40334 -#define IDM_EDIT_REMOVEBLANKLINES 40335 -#define IDM_EDIT_MODIFYLINES 40336 -#define IDM_EDIT_SORTLINES 40337 -#define IDM_EDIT_ALIGN 40338 -#define IDM_EDIT_CONVERTUPPERCASE 40339 -#define IDM_EDIT_CONVERTLOWERCASE 40340 -#define IDM_EDIT_INVERTCASE 40341 -#define IDM_EDIT_TITLECASE 40342 -#define IDM_EDIT_SENTENCECASE 40343 -#define IDM_EDIT_CONVERTTABS 40344 -#define IDM_EDIT_CONVERTSPACES 40345 -#define IDM_EDIT_CONVERTTABS2 40346 -#define IDM_EDIT_CONVERTSPACES2 40347 -#define IDM_EDIT_INSERT_TAG 40348 -#define IDM_EDIT_INSERT_ENCODING 40349 -#define IDM_EDIT_INSERT_SHORTDATE 40350 -#define IDM_EDIT_INSERT_LONGDATE 40351 -#define IDM_EDIT_INSERT_FILENAME 40352 -#define IDM_EDIT_INSERT_PATHNAME 40353 -#define IDM_EDIT_LINECOMMENT 40354 -#define IDM_EDIT_STREAMCOMMENT 40355 -#define IDM_EDIT_URLENCODE 40356 -#define IDM_EDIT_URLDECODE 40357 -#define IDM_EDIT_ESCAPECCHARS 40358 -#define IDM_EDIT_UNESCAPECCHARS 40359 -#define IDM_EDIT_CHAR2HEX 40360 -#define IDM_EDIT_HEX2CHAR 40361 -#define IDM_EDIT_FINDMATCHINGBRACE 40362 -#define IDM_EDIT_SELTOMATCHINGBRACE 40363 -#define IDM_EDIT_FIND 40364 -#define IDM_EDIT_SAVEFIND 40365 -#define IDM_EDIT_FINDNEXT 40366 -#define IDM_EDIT_FINDPREV 40367 -#define IDM_EDIT_REPLACE 40368 -#define IDM_EDIT_REPLACENEXT 40369 -#define IDM_EDIT_GOTOLINE 40370 -#define IDM_EDIT_SELTONEXT 40371 -#define IDM_EDIT_SELTOPREV 40372 -#define IDM_EDIT_COMPLETEWORD 40373 -#define IDM_VIEW_SCHEME 40400 -#define IDM_VIEW_USE2NDDEFAULT 40401 -#define IDM_VIEW_SCHEMECONFIG 40402 -#define IDM_VIEW_FONT 40403 -#define IDM_VIEW_WORDWRAP 40404 -#define IDM_VIEW_LONGLINEMARKER 40405 -#define IDM_VIEW_SHOWINDENTGUIDES 40406 -#define IDM_VIEW_SHOWWHITESPACE 40407 -#define IDM_VIEW_SHOWEOLS 40408 -#define IDM_VIEW_WORDWRAPSYMBOLS 40409 -#define IDM_VIEW_MATCHBRACES 40410 -#define IDM_VIEW_HILITECURRENTLINE 40411 -#define IDM_VIEW_LINENUMBERS 40412 -#define IDM_VIEW_MARGIN 40413 -#define IDM_VIEW_ZOOMIN 40414 -#define IDM_VIEW_ZOOMOUT 40415 -#define IDM_VIEW_RESETZOOM 40416 -#define IDM_VIEW_TABSASSPACES 40417 -#define IDM_VIEW_TABSETTINGS 40418 -#define IDM_VIEW_WORDWRAPSETTINGS 40419 -#define IDM_VIEW_LONGLINESETTINGS 40420 -#define IDM_VIEW_AUTOINDENTTEXT 40421 -#define IDM_VIEW_AUTOCLOSETAGS 40422 -#define IDM_VIEW_REUSEWINDOW 40423 -#define IDM_VIEW_STICKYWINPOS 40424 -#define IDM_VIEW_ALWAYSONTOP 40425 -#define IDM_VIEW_MINTOTRAY 40426 -#define IDM_VIEW_TRANSPARENT 40427 -#define IDM_VIEW_SINGLEFILEINSTANCE 40428 -#define IDM_VIEW_CHANGENOTIFY 40429 -#define IDM_VIEW_SHOWFILENAMEONLY 40430 -#define IDM_VIEW_SHOWFILENAMEFIRST 40431 -#define IDM_VIEW_SHOWFULLPATH 40432 -#define IDM_VIEW_SHOWEXCERPT 40433 -#define IDM_VIEW_NOESCFUNC 40434 -#define IDM_VIEW_ESCMINIMIZE 40435 -#define IDM_VIEW_ESCEXIT 40436 -#define IDM_VIEW_SAVEBEFORERUNNINGTOOLS 40437 -#define IDM_VIEW_NOSAVERECENT 40438 -#define IDM_VIEW_NOSAVEFINDREPL 40439 -#define IDM_VIEW_TOOLBAR 40440 -#define IDM_VIEW_CUSTOMIZETB 40441 -#define IDM_VIEW_STATUSBAR 40442 -#define IDM_VIEW_SAVESETTINGS 40443 -#define IDM_VIEW_SAVESETTINGSNOW 40444 -#define IDM_VIEW_FOLDING 40445 -#define IDM_VIEW_TOGGLEFOLDS 40446 -#define IDM_VIEW_MARKOCCURRENCES_OFF 40447 -#define IDM_VIEW_MARKOCCURRENCES_BLUE 40448 -#define IDM_VIEW_MARKOCCURRENCES_GREEN 40449 -#define IDM_VIEW_MARKOCCURRENCES_RED 40450 -#define IDM_VIEW_MARKOCCURRENCES_CASE 40451 -#define IDM_VIEW_MARKOCCURRENCES_WORD 40452 -#define IDM_VIEW_AUTOCOMPLETEWORDS 40453 -#define IDM_HELP_ABOUT 40500 -#define IDM_CMDLINE_HELP 40501 -#define IDM_TRAY_RESTORE 40600 -#define IDM_TRAY_EXIT 40601 -#define IDT_FILE_NEW 40700 -#define IDT_FILE_OPEN 40701 -#define IDT_FILE_BROWSE 40702 -#define IDT_FILE_SAVE 40703 -#define IDT_EDIT_UNDO 40704 -#define IDT_EDIT_REDO 40705 -#define IDT_EDIT_CUT 40706 -#define IDT_EDIT_COPY 40707 -#define IDT_EDIT_PASTE 40708 -#define IDT_EDIT_FIND 40709 -#define IDT_EDIT_REPLACE 40710 -#define IDT_VIEW_WORDWRAP 40711 -#define IDT_VIEW_ZOOMIN 40712 -#define IDT_VIEW_ZOOMOUT 40713 -#define IDT_VIEW_SCHEME 40714 -#define IDT_VIEW_SCHEMECONFIG 40715 -#define IDT_FILE_EXIT 40716 -#define IDT_FILE_SAVEAS 40717 -#define IDT_FILE_SAVECOPY 40718 -#define IDT_EDIT_CLEAR 40719 -#define IDT_FILE_PRINT 40720 -#define IDT_FILE_OPENFAV 40721 -#define IDT_FILE_ADDTOFAV 40722 -#define IDT_VIEW_TOGGLEFOLDS 40723 -#define IDT_FILE_LAUNCH 40724 -#define SC_SAVEPOS 40800 -#define SC_RESETPOS 40801 -#define IDS_ERR_LOADFILE 50000 -#define IDS_ERR_SAVEFILE 50001 -#define IDS_ERR_BROWSE 50002 -#define IDS_ERR_MRUDLG 50003 -#define IDS_ERR_CREATELINK 50004 -#define IDS_ERR_PREVWINDISABLED 50005 -#define IDS_SELRECT 50006 -#define IDS_BUFFERTOOSMALL 50007 -#define IDS_FIND_WRAPFW 50008 -#define IDS_FIND_WRAPRE 50009 -#define IDS_NOTFOUND 50010 -#define IDS_REPLCOUNT 50011 -#define IDS_ASK_ENCODING 50012 -#define IDS_ASK_ENCODING2 50013 -#define IDS_ERR_ENCODINGNA 50014 -#define IDS_ERR_UNICODE 50015 -#define IDS_ERR_UNICODE2 50016 -#define IDS_WARNLOADBIGFILE 50017 -#define IDS_ERR_DROP 50018 -#define IDS_ASK_SAVE 50019 -#define IDS_ASK_REVERT 50020 -#define IDS_ASK_RECODE 50021 -#define IDS_ASK_CREATE 50022 -#define IDS_PRINT_HEADER 50023 -#define IDS_PRINT_FOOTER 50024 -#define IDS_PRINT_COLOR 50025 -#define IDS_PRINT_PAGENUM 50026 -#define IDS_PRINT_EMPTY 50027 -#define IDS_PRINT_ERROR 50028 -#define IDS_FAV_SUCCESS 50029 -#define IDS_FAV_FAILURE 50030 -#define IDS_READONLY_MODIFY 50031 -#define IDS_READONLY_SAVE 50032 -#define IDS_FILECHANGENOTIFY 50033 -#define IDS_FILECHANGENOTIFY2 50034 -#define IDS_STICKYWINPOS 50035 -#define IDS_SAVEDSETTINGS 50036 -#define IDS_CREATEINI_FAIL 50037 -#define IDS_WRITEINI_FAIL 50038 -#define IDS_SETTINGSNOTSAVED 50039 -#define IDS_EXPORT_FAIL 50040 -#define IDS_CMDLINEHELP 60000 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 0 -#define _APS_NEXT_COMMAND_VALUE 0 -#define _APS_NEXT_CONTROL_VALUE 0 -#define _APS_NEXT_SYMED_VALUE 0 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Notepad2.rc +// +#define IDC_STATIC -1 +#define IDR_MAINWND 100 +#define IDC_FINDTEXT 100 +#define IDC_LINENUM 100 +#define IDC_COMMANDLINE 100 +#define IDD_ABOUT 100 +#define IDC_VERSION 100 +#define IDC_OPENWITHDIR 100 +#define IDC_FILEMRU 100 +#define IDC_STYLELIST 100 +#define IDC_FAVORITESDIR 100 +#define IDC_COLUMNWRAP 100 +#define IDC_INFOBOXICON 100 +#define IDC_COPY 100 +#define IDC_ENCODINGLIST 100 +#define IDC_SEARCHEXE 101 +#define IDR_POPUPMENU 101 +#define IDC_GETOPENWITHDIR 101 +#define IDC_RESIZEGRIP 101 +#define IDD_OPENWITH 101 +#define IDC_REPLACETEXT 101 +#define IDI_RUN 101 +#define IDC_COLNUM 101 +#define IDC_DEFAULTSCHEME 101 +#define IDC_GETFAVORITESDIR 101 +#define IDC_INFOBOXTEXT 101 +#define IDB_OPEN 101 +#define IDR_ACCFINDREPLACE 101 +#define IDC_STYLELABEL 101 +#define IDC_RESIZEGRIP4 101 +#define IDC_NOUNICODEDETECTION 101 +#define IDC_COPYRIGHT 101 +#define IDC_MOD_PAGE 112 +#define IDC_STYLEEDIT 102 +#define IDC_FINDCASE 102 +#define IDC_OPENWITHDESCR 102 +#define IDC_SAVEMRU 102 +#define IDD_RUN 102 +#define IDC_AUTOSELECT 102 +#define IDC_FAVORITESDESCR 102 +#define IDC_INFOBOXCHECK 102 +#define IDC_CONSISTENTEOLS 102 +#define IDB_PREV 102 +#define IDI_STYLES 102 +#define IDC_ASCIIASUTF8 102 +#define IDC_WEBPAGE 102 +#define IDD_DEFENCODING 103 +#define IDC_FINDWORD 103 +#define IDC_RESIZEGRIP3 103 +#define IDB_NEXT 103 +#define IDC_STYLEFORE 103 +#define IDC_AUTOSTRIPBLANKS 103 +#define IDC_ENCODINGFROMFILEVARS 103 +#define IDC_WEBPAGE2 103 +#define IDD_ENCODING 104 +#define IDC_MOD_PAGE2 104 +#define IDC_FINDSTART 104 +#define IDB_PICK 104 +#define IDC_STYLEBACK 104 +#define IDC_AUTHORNAME 104 +#define IDD_RECODE 105 +#define IDC_FINDREGEXP 105 +#define IDC_STYLEFONT 105 +#define IDB_ENCODING 105 +#define IDC_EMAIL 105 +#define IDD_DEFEOLMODE 106 +#define IDC_FINDTRANSFORMBS 106 +#define IDC_PREVIEW 106 +#define IDC_EMAIL2 106 +#define IDD_FAVORITES 107 +#define IDC_NOWRAP 107 +#define IDC_STYLEDEFAULT 107 +#define IDD_ADDTOFAV 108 +#define IDC_PREVSTYLE 108 +#define IDC_FINDCLOSE 108 +#define IDD_FILEMRU 109 +#define IDC_FINDPREV 109 +#define IDC_NEXTSTYLE 109 +#define IDD_CHANGENOTIFY 110 +#define IDC_IMPORT 110 +#define IDD_MODIFYLINES 111 +#define IDC_EXPORT 111 +#define IDC_REPLACE 112 +#define IDC_TITLE 112 +#define IDD_ALIGN 112 +#define IDD_ENCLOSESELECTION 113 +#define IDC_REPLACEALL 113 +#define IDC_STYLELABELS 113 +#define IDD_INSERTTAG 114 +#define IDC_REPLACEINSEL 114 +#define IDD_SORT 115 +#define IDC_TOGGLEFINDREPLACE 115 +#define IDD_COLUMNWRAP 116 +#define IDD_LINENUM 117 +#define IDD_FIND 118 +#define IDD_REPLACE 119 +#define IDD_STYLESELECT 120 +#define IDD_STYLECONFIG 121 +#define IDD_WORDWRAP 122 +#define IDD_LONGLINES 123 +#define IDD_TABSETTINGS 124 +#define IDD_PAGESETUP 125 +#define IDD_INFOBOX 126 +#define IDD_INFOBOX2 127 +#define IDD_INFOBOX3 128 +#define IDC_BACKSLASHHELP 151 +#define IDC_REGEXPHELP 152 +#define IDC_WILDCARDHELP 153 +#define IDC_WILDCARDSEARCH 154 +#define IDACC_FIND 200 +#define IDACC_REPLACE 201 +#define IDACC_SAVEPOS 202 +#define IDACC_RESETPOS 203 +#define IDACC_FINDNEXT 204 +#define IDACC_FINDPREV 205 +#define IDACC_REPLACENEXT 206 +#define IDACC_SAVEFIND 207 +#define IDACC_SELTONEXT 208 +#define IDACC_SELTOPREV 209 +#define IDC_NFOASOEM 300 +#define IDC_COMPILER 301 +#define IDC_COMPILER2 302 +#define IDS_APPTITLE 10000 +#define IDS_APPTITLE_ELEVATED 10001 +#define IDS_APPTITLE_PASTEBOARD 10002 +#define IDS_UNTITLED 10003 +#define IDS_TITLEEXCERPT 10004 +#define IDS_READONLY 10005 +#define IDS_DOCPOS 10006 +#define IDS_DOCPOS2 10007 +#define IDS_DOCSIZE 10008 +#define IDS_LOADFILE 10009 +#define IDS_SAVEFILE 10010 +#define IDS_PRINTFILE 10011 +#define IDS_SAVINGSETTINGS 10012 +#define IDS_LINKDESCRIPTION 10013 +#define IDS_FILTER_ALL 10014 +#define IDS_FILTER_EXE 10015 +#define IDS_FILTER_INI 10016 +#define IDS_OPENWITH 10017 +#define IDS_FAVORITES 10018 +#define IDS_BACKSLASHHELP 10019 +#define IDS_REGEXPHELP 10020 +#define IDS_WILDCARDHELP 10021 +#define CMD_ESCAPE 20000 +#define CMD_SHIFTESC 20001 +#define CMD_CTRLENTER 20002 +#define CMD_CTRLBACK 20003 +#define CMD_CTRLDEL 20004 +#define CMD_CTRLTAB 20005 +#define CMD_RECODEDEFAULT 20006 +#define CMD_RELOADANSI 20007 +#define CMD_RELOADOEM 20008 +#define CMD_RELOADASCIIASUTF8 20009 +#define CMD_RELOADNOFILEVARS 20010 +#define CMD_LEXDEFAULT 20011 +#define CMD_LEXHTML 20012 +#define CMD_LEXXML 20013 +#define CMD_TIMESTAMPS 20014 +#define CMD_WEBACTION1 20015 +#define CMD_WEBACTION2 20016 +#define CMD_FINDNEXTSEL 20017 +#define CMD_FINDPREVSEL 20018 +#define CMD_INCLINELIMIT 20019 +#define CMD_DECLINELIMIT 20020 +#define CMD_STRINGIFY 20021 +#define CMD_STRINGIFY2 20022 +#define CMD_EMBRACE 20023 +#define CMD_EMBRACE2 20024 +#define CMD_EMBRACE3 20025 +#define CMD_EMBRACE4 20026 +#define CMD_INCREASENUM 20027 +#define CMD_DECREASENUM 20028 +#define CMD_TOGGLETITLE 20029 +#define CMD_JUMP2SELSTART 20030 +#define CMD_JUMP2SELEND 20031 +#define CMD_COPYPATHNAME 20032 +#define CMD_COPYWINPOS 20033 +#define CMD_DEFAULTWINPOS 20034 +#define CMD_OPENINIFILE 20035 +#define IDM_FILE_NEW 40000 +#define IDM_FILE_OPEN 40001 +#define IDM_FILE_REVERT 40002 +#define IDM_FILE_BROWSE 40003 +#define IDM_FILE_SAVE 40004 +#define IDM_FILE_SAVEAS 40005 +#define IDM_FILE_SAVECOPY 40006 +#define IDM_FILE_READONLY 40007 +#define IDM_FILE_LAUNCH 40008 +#define IDM_FILE_OPENWITH 40009 +#define IDM_FILE_RUN 40010 +#define IDM_FILE_NEWWINDOW 40011 +#define IDM_FILE_NEWWINDOW2 40012 +#define IDM_FILE_PAGESETUP 40013 +#define IDM_FILE_PRINT 40014 +#define IDM_FILE_PROPERTIES 40015 +#define IDM_FILE_CREATELINK 40016 +#define IDM_FILE_OPENFAV 40017 +#define IDM_FILE_ADDTOFAV 40018 +#define IDM_FILE_MANAGEFAV 40019 +#define IDM_FILE_RECENT 40020 +#define IDM_FILE_EXIT 40021 +#define IDM_ENCODING_ANSI 40100 +#define IDM_ENCODING_UNICODE 40101 +#define IDM_ENCODING_UNICODEREV 40102 +#define IDM_ENCODING_UTF8 40103 +#define IDM_ENCODING_UTF8SIGN 40104 +#define IDM_ENCODING_SELECT 40105 +#define IDM_ENCODING_RECODE 40106 +#define IDM_ENCODING_SETDEFAULT 40107 +#define IDM_LINEENDINGS_CRLF 40200 +#define IDM_LINEENDINGS_LF 40201 +#define IDM_LINEENDINGS_CR 40202 +#define IDM_LINEENDINGS_SETDEFAULT 40203 +#define IDM_EDIT_BOOKMARKTOGGLE 40250 +#define IDM_EDIT_BOOKMARKNEXT 40251 +#define IDM_EDIT_BOOKMARKCLEAR 40252 +#define IDM_EDIT_BOOKMARKPREV 40253 +#define BME_EDIT_BOOKMARKTOGGLE 40254 +#define BME_EDIT_BOOKMARKNEXT 40255 +#define BME_EDIT_BOOKMARKCLEAR 40256 +#define BME_EDIT_BOOKMARKPREV 40257 +#define IDM_EDIT_UNDO 40300 +#define IDM_EDIT_REDO 40301 +#define IDM_EDIT_CUT 40302 +#define IDM_EDIT_COPY 40303 +#define IDM_EDIT_COPYALL 40304 +#define IDM_EDIT_COPYADD 40305 +#define IDM_EDIT_PASTE 40306 +#define IDM_EDIT_SWAP 40307 +#define IDM_EDIT_CLEAR 40308 +#define IDM_EDIT_CLEARCLIPBOARD 40309 +#define IDM_EDIT_SELECTALL 40310 +#define IDM_EDIT_SELECTWORD 40311 +#define IDM_EDIT_SELECTLINE 40312 +#define IDM_EDIT_MOVELINEUP 40313 +#define IDM_EDIT_MOVELINEDOWN 40314 +#define IDM_EDIT_DUPLICATELINE 40315 +#define IDM_EDIT_CUTLINE 40316 +#define IDM_EDIT_COPYLINE 40317 +#define IDM_EDIT_DELETELINE 40318 +#define IDM_EDIT_DELETELINELEFT 40319 +#define IDM_EDIT_DELETELINERIGHT 40320 +#define IDM_EDIT_COLUMNWRAP 40321 +#define IDM_EDIT_SPLITLINES 40322 +#define IDM_EDIT_JOINLINES 40323 +#define IDM_EDIT_JOINLINESEX 40324 +#define IDM_EDIT_INDENT 40325 +#define IDM_EDIT_UNINDENT 40326 +#define IDM_EDIT_ENCLOSESELECTION 40327 +#define IDM_EDIT_SELECTIONDUPLICATE 40328 +#define IDM_EDIT_PADWITHSPACES 40329 +#define IDM_EDIT_STRIP1STCHAR 40330 +#define IDM_EDIT_STRIPLASTCHAR 40331 +#define IDM_EDIT_TRIMLINES 40332 +#define IDM_EDIT_COMPRESSWS 40333 +#define IDM_EDIT_MERGEBLANKLINES 40334 +#define IDM_EDIT_REMOVEBLANKLINES 40335 +#define IDM_EDIT_MODIFYLINES 40336 +#define IDM_EDIT_SORTLINES 40337 +#define IDM_EDIT_ALIGN 40338 +#define IDM_EDIT_CONVERTUPPERCASE 40339 +#define IDM_EDIT_CONVERTLOWERCASE 40340 +#define IDM_EDIT_INVERTCASE 40341 +#define IDM_EDIT_TITLECASE 40342 +#define IDM_EDIT_SENTENCECASE 40343 +#define IDM_EDIT_CONVERTTABS 40344 +#define IDM_EDIT_CONVERTSPACES 40345 +#define IDM_EDIT_CONVERTTABS2 40346 +#define IDM_EDIT_CONVERTSPACES2 40347 +#define IDM_EDIT_INSERT_TAG 40348 +#define IDM_EDIT_INSERT_ENCODING 40349 +#define IDM_EDIT_INSERT_SHORTDATE 40350 +#define IDM_EDIT_INSERT_LONGDATE 40351 +#define IDM_EDIT_INSERT_FILENAME 40352 +#define IDM_EDIT_INSERT_PATHNAME 40353 +#define IDM_EDIT_LINECOMMENT 40354 +#define IDM_EDIT_STREAMCOMMENT 40355 +#define IDM_EDIT_URLENCODE 40356 +#define IDM_EDIT_URLDECODE 40357 +#define IDM_EDIT_ESCAPECCHARS 40358 +#define IDM_EDIT_UNESCAPECCHARS 40359 +#define IDM_EDIT_CHAR2HEX 40360 +#define IDM_EDIT_HEX2CHAR 40361 +#define IDM_EDIT_FINDMATCHINGBRACE 40362 +#define IDM_EDIT_SELTOMATCHINGBRACE 40363 +#define IDM_EDIT_FIND 40364 +#define IDM_EDIT_SAVEFIND 40365 +#define IDM_EDIT_FINDNEXT 40366 +#define IDM_EDIT_FINDPREV 40367 +#define IDM_EDIT_REPLACE 40368 +#define IDM_EDIT_REPLACENEXT 40369 +#define IDM_EDIT_GOTOLINE 40370 +#define IDM_EDIT_SELTONEXT 40371 +#define IDM_EDIT_SELTOPREV 40372 +#define IDM_EDIT_COMPLETEWORD 40373 +#define IDM_VIEW_SCHEME 40400 +#define IDM_VIEW_USE2NDDEFAULT 40401 +#define IDM_VIEW_THEME_ORIGINAL 40980 +#define IDM_VIEW_THEME_DARK 40981 +#define IDM_VIEW_SCHEMECONFIG 40402 +#define IDM_VIEW_FONT 40403 +#define IDM_VIEW_WORDWRAP 40404 +#define IDM_VIEW_LONGLINEMARKER 40405 +#define IDM_VIEW_SHOWINDENTGUIDES 40406 +#define IDM_VIEW_SHOWWHITESPACE 40407 +#define IDM_VIEW_SHOWEOLS 40408 +#define IDM_VIEW_WORDWRAPSYMBOLS 40409 +#define IDM_VIEW_MATCHBRACES 40410 +#define IDM_VIEW_HILITECURRENTLINE 40411 +#define IDM_VIEW_LINENUMBERS 40412 +#define IDM_VIEW_MARGIN 40413 +#define IDM_VIEW_ZOOMIN 40414 +#define IDM_VIEW_ZOOMOUT 40415 +#define IDM_VIEW_RESETZOOM 40416 +#define IDM_VIEW_TABSASSPACES 40417 +#define IDM_VIEW_TABSETTINGS 40418 +#define IDM_VIEW_WORDWRAPSETTINGS 40419 +#define IDM_VIEW_LONGLINESETTINGS 40420 +#define IDM_VIEW_AUTOINDENTTEXT 40421 +#define IDM_VIEW_AUTOCLOSETAGS 40422 +#define IDM_VIEW_REUSEWINDOW 40423 +#define IDM_VIEW_STICKYWINPOS 40424 +#define IDM_VIEW_ALWAYSONTOP 40425 +#define IDM_VIEW_MINTOTRAY 40426 +#define IDM_VIEW_TRANSPARENT 40427 +#define IDM_VIEW_SINGLEFILEINSTANCE 40428 +#define IDM_VIEW_CHANGENOTIFY 40429 +#define IDM_VIEW_SHOWFILENAMEONLY 40430 +#define IDM_VIEW_SHOWFILENAMEFIRST 40431 +#define IDM_VIEW_SHOWFULLPATH 40432 +#define IDM_VIEW_SHOWEXCERPT 40433 +#define IDM_VIEW_NOESCFUNC 40434 +#define IDM_VIEW_ESCMINIMIZE 40435 +#define IDM_VIEW_ESCEXIT 40436 +#define IDM_VIEW_SAVEBEFORERUNNINGTOOLS 40437 +#define IDM_VIEW_NOSAVERECENT 40438 +#define IDM_VIEW_NOSAVEFINDREPL 40439 +#define IDM_VIEW_TOOLBAR 40440 +#define IDM_VIEW_CUSTOMIZETB 40441 +#define IDM_VIEW_STATUSBAR 40442 +#define IDM_VIEW_SAVESETTINGS 40443 +#define IDM_VIEW_SAVESETTINGSNOW 40444 +#define IDM_VIEW_FOLDING 40445 +#define IDM_VIEW_TOGGLEFOLDS 40446 +#define IDM_VIEW_MARKOCCURRENCES_OFF 40447 +#define IDM_VIEW_MARKOCCURRENCES_BLUE 40448 +#define IDM_VIEW_MARKOCCURRENCES_GREEN 40449 +#define IDM_VIEW_MARKOCCURRENCES_RED 40450 +#define IDM_VIEW_MARKOCCURRENCES_CASE 40451 +#define IDM_VIEW_MARKOCCURRENCES_WORD 40452 +#define IDM_VIEW_AUTOCOMPLETEWORDS 40453 +#define IDM_HELP_ABOUT 40500 +#define IDM_CMDLINE_HELP 40501 +#define IDM_TRAY_RESTORE 40600 +#define IDM_TRAY_EXIT 40601 +#define IDT_FILE_NEW 40700 +#define IDT_FILE_OPEN 40701 +#define IDT_FILE_BROWSE 40702 +#define IDT_FILE_SAVE 40703 +#define IDT_EDIT_UNDO 40704 +#define IDT_EDIT_REDO 40705 +#define IDT_EDIT_CUT 40706 +#define IDT_EDIT_COPY 40707 +#define IDT_EDIT_PASTE 40708 +#define IDT_EDIT_FIND 40709 +#define IDT_EDIT_REPLACE 40710 +#define IDT_VIEW_WORDWRAP 40711 +#define IDT_VIEW_ZOOMIN 40712 +#define IDT_VIEW_ZOOMOUT 40713 +#define IDT_VIEW_SCHEME 40714 +#define IDT_VIEW_SCHEMECONFIG 40715 +#define IDT_FILE_EXIT 40716 +#define IDT_FILE_SAVEAS 40717 +#define IDT_FILE_SAVECOPY 40718 +#define IDT_EDIT_CLEAR 40719 +#define IDT_FILE_PRINT 40720 +#define IDT_FILE_OPENFAV 40721 +#define IDT_FILE_ADDTOFAV 40722 +#define IDT_VIEW_TOGGLEFOLDS 40723 +#define IDT_FILE_LAUNCH 40724 +#define SC_SAVEPOS 40800 +#define SC_RESETPOS 40801 +#define IDS_ERR_LOADFILE 50000 +#define IDS_ERR_SAVEFILE 50001 +#define IDS_ERR_BROWSE 50002 +#define IDS_ERR_MRUDLG 50003 +#define IDS_ERR_CREATELINK 50004 +#define IDS_ERR_PREVWINDISABLED 50005 +#define IDS_SELRECT 50006 +#define IDS_BUFFERTOOSMALL 50007 +#define IDS_FIND_WRAPFW 50008 +#define IDS_FIND_WRAPRE 50009 +#define IDS_NOTFOUND 50010 +#define IDS_REPLCOUNT 50011 +#define IDS_ASK_ENCODING 50012 +#define IDS_ASK_ENCODING2 50013 +#define IDS_ERR_ENCODINGNA 50014 +#define IDS_ERR_UNICODE 50015 +#define IDS_ERR_UNICODE2 50016 +#define IDS_WARNLOADBIGFILE 50017 +#define IDS_ERR_DROP 50018 +#define IDS_ASK_SAVE 50019 +#define IDS_ASK_REVERT 50020 +#define IDS_ASK_RECODE 50021 +#define IDS_ASK_CREATE 50022 +#define IDS_PRINT_HEADER 50023 +#define IDS_PRINT_FOOTER 50024 +#define IDS_PRINT_COLOR 50025 +#define IDS_PRINT_PAGENUM 50026 +#define IDS_PRINT_EMPTY 50027 +#define IDS_PRINT_ERROR 50028 +#define IDS_FAV_SUCCESS 50029 +#define IDS_FAV_FAILURE 50030 +#define IDS_READONLY_MODIFY 50031 +#define IDS_READONLY_SAVE 50032 +#define IDS_FILECHANGENOTIFY 50033 +#define IDS_FILECHANGENOTIFY2 50034 +#define IDS_STICKYWINPOS 50035 +#define IDS_SAVEDSETTINGS 50036 +#define IDS_CREATEINI_FAIL 50037 +#define IDS_WRITEINI_FAIL 50038 +#define IDS_SETTINGSNOTSAVED 50039 +#define IDS_EXPORT_FAIL 50040 +#define IDS_CMDLINEHELP 60000 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 0 +#define _APS_NEXT_COMMAND_VALUE 0 +#define _APS_NEXT_CONTROL_VALUE 0 +#define _APS_NEXT_SYMED_VALUE 0 +#endif +#endif diff --git a/update_rev.bat b/update_rev.bat index c49077ca..da27add0 100644 --- a/update_rev.bat +++ b/update_rev.bat @@ -1,32 +1,41 @@ -@ECHO OFF -SETLOCAL - -PUSHD %~dp0 - -IF EXIST "build.user.bat" (CALL "build.user.bat") - -SET PATH=%MSYS%\bin;%PATH% - -FOR %%G IN (bash.exe) DO (SET FOUND=%%~$PATH:G) -IF NOT DEFINED FOUND GOTO MissingVar - -bash.exe ./version.sh - - -:END -POPD -ENDLOCAL -EXIT /B - - -:MissingVar -COLOR 0C -TITLE ERROR -ECHO MSYS (bash.exe) wasn't found. Create a file build.user.bat and set the variable there. -ECHO. -ECHO SET "MSYS=H:\progs\MSYS" -ECHO. & ECHO. -ECHO Press any key to exit... -PAUSE >NUL -ENDLOCAL -EXIT /B +@ECHO OFF +SETLOCAL + +PUSHD "%~dp0" + +IF EXIST "build.user.bat" (CALL "build.user.bat") + +IF DEFINED MSYS SET "PATH=%MSYS%\bin;%PATH%" + +rem Prefer Git for Windows Bash over a possible WSL bash.exe on PATH. +FOR /F "delims=" %%G IN ('where git.exe 2^>NUL') DO IF EXIST "%%~dpG..\bin\bash.exe" SET "GIT_BASH=%%~dpG..\bin\bash.exe" +IF DEFINED GIT_BASH GOTO GitBash + +GOTO FindBash + +:GitBash +"%GIT_BASH%" ./version.sh +SET "BUILD_RESULT=%ERRORLEVEL%" +GOTO END + +:FindBash +FOR %%G IN (bash.exe) DO (SET FOUND=%%~$PATH:G) +IF NOT DEFINED FOUND GOTO MissingVar + +bash.exe ./version.sh +SET "BUILD_RESULT=%ERRORLEVEL%" +GOTO END + + +:END +POPD +ENDLOCAL & EXIT /B %BUILD_RESULT% + + +:MissingVar +ECHO Git for Windows Bash wasn't found. Install Git for Windows or set MSYS in build.user.bat. +ECHO. +ECHO SET "MSYS=H:\progs\MSYS" +ECHO. & ECHO. +SET "BUILD_RESULT=1" +GOTO END diff --git a/version.sh b/version.sh index 0d92dd58..5a2b42e8 100644 --- a/version.sh +++ b/version.sh @@ -30,12 +30,12 @@ if ! git rev-parse --git-dir > /dev/null 2>&1; then ver=0 else # Get the current branch name - branch=$(git symbolic-ref -q HEAD) && branch=${branch##refs/heads/} || branch="no branch" + branch=$(git symbolic-ref -q HEAD) && branch=${branch##refs/heads/} || branch="" # If we are on another branch that isn't master, we want extra info like on # which commit from master it is based on and what its hash is. This assumes we # won't ever branch from a changeset from before the move to git - if [[ "$branch" != "master" ]]; then + if [[ -n "$branch" && "$branch" != "master" ]]; then version_info="#define BRANCH _T(\"$branch\")"$'\n' if git show-ref --verify --quiet refs/heads/master; then # Get where the branch is based on master