Przeglądaj źródła

提交1.17.2-1.18代码

爬山虎 2 lat temu
rodzic
commit
f294eab5d2
55 zmienionych plików z 4694 dodań i 2211 usunięć
  1. 18 0
      src/.qmake.stash
  2. BIN
      src/1.png
  3. BIN
      src/2.png
  4. 6 0
      src/Encode.cpp
  5. 674 0
      src/LICENSE
  6. 30 0
      src/README.md
  7. 1 0
      src/RealCompare.qrc
  8. BIN
      src/RealCompare.rc
  9. BIN
      src/Resources/img/bookmark.png
  10. BIN
      src/Resources/img/refresh.png
  11. 17 0
      src/aboutndd.cpp
  12. 18 0
      src/aboutndd.h
  13. 63 0
      src/aboutndd.ui
  14. 432 77
      src/cceditor/ccnotepad.cpp
  15. 27 11
      src/cceditor/ccnotepad.h
  16. 212 5
      src/cceditor/ccnotepad.ui
  17. 21 0
      src/cceditor/filemanager.cpp
  18. 18 1
      src/cceditor/filemanager.h
  19. 47 0
      src/changelog.txt
  20. 5 5
      src/doctypelistview.cpp
  21. 2 3
      src/donate.cpp
  22. 4 4
      src/donate.h
  23. 28 25
      src/donate.ui
  24. 51 7
      src/findwin.cpp
  25. 11 1
      src/findwin.h
  26. 96 141
      src/findwin.ui
  27. 11 12
      src/installer/installer.nsi
  28. 66 0
      src/installer/newinstall.iss
  29. 0 580
      src/jsondeploy.cpp
  30. 0 68
      src/jsondeploy.h
  31. 10 10
      src/main.cpp
  32. 265 0
      src/nddsetting.cpp
  33. 58 0
      src/nddsetting.h
  34. 139 15
      src/qscidisplaywindow.cpp
  35. 6 3
      src/qscidisplaywindow.h
  36. 1 1
      src/qscint/scintilla/boostregex/BoostRegExSearch.cpp
  37. 1 0
      src/qscint/scintilla/include/SciLexer.h
  38. 102 100
      src/qscint/scintilla/lexers/LexTXT.cpp
  39. 1 1
      src/qscint/src/Qsci/qscilexer.h
  40. 22 0
      src/qscint/src/Qsci/qscilexerglobal.h
  41. 2 1
      src/qscint/src/ScintillaQt.cpp
  42. 2 2
      src/qscint/src/qscilexer.cpp
  43. 43 0
      src/qscint/src/qscilexerglobal.cpp
  44. 2 2
      src/qscint/src/qscilexertext.cpp
  45. 4 2
      src/qscint/src/qscintilla.pro
  46. 651 96
      src/qtlangset.cpp
  47. 32 8
      src/qtlangset.h
  48. 454 255
      src/qtlangset.ui
  49. 3 0
      src/rcglobal.h
  50. BIN
      src/realcompare_zh.qm
  51. 662 493
      src/realcompare_zh.ts
  52. 272 133
      src/scintillaeditview.cpp
  53. 32 6
      src/scintillaeditview.h
  54. 57 136
      src/styleset.cpp
  55. 15 7
      src/styleset.h

+ 18 - 0
src/.qmake.stash

@@ -0,0 +1,18 @@
+QMAKE_CXX.QT_COMPILER_STDCXX = 199711L
+QMAKE_CXX.QMAKE_MSC_VER = 1916
+QMAKE_CXX.QMAKE_MSC_FULL_VER = 191627048
+QMAKE_CXX.COMPILER_MACROS = \
+    QT_COMPILER_STDCXX \
+    QMAKE_MSC_VER \
+    QMAKE_MSC_FULL_VER
+QMAKE_CXX.INCDIRS = \
+    "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\include" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt"
+QMAKE_CXX.LIBDIRS = \
+    "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\lib\\x64" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\ucrt\\x64" \
+    "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x64"

BIN
src/1.png


BIN
src/2.png


+ 6 - 0
src/Encode.cpp

@@ -154,6 +154,9 @@ QString Encode::getCodeNameById(CODE_ID id)
 	case TIS_620:
 		ret = "TIS-620";
 		break;
+	case BIG5:
+		ret = "BIG5-HKSCS";
+		break;
 	default:
 		ret = "unknown";
 		break;
@@ -289,6 +292,9 @@ QString Encode::getQtCodecNameById(CODE_ID id)
 	case TIS_620:
 		ret = "TIS-620";
 		break;
+	case BIG5:
+		ret = "Big5-HKSCS";
+		break;
 	default:
 		ret = "unknown";
 		break;

+ 674 - 0
src/LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 30 - 0
src/README.md

@@ -0,0 +1,30 @@
+这是一个使用C++编写的文本编辑器Notepad--,可以支持Win/Linux/Mac平台。
+我们的目标是要替换Notepad++,重点在国产Uos系统、Mac 系统上发展。
+
+一个支持windows/linux/mac的文本编辑器,目标是要替换notepad++,来自中国。
+
+对比Notepad++而言,我们的优势是可以跨平台,支持linux mac操作系统。
+
+ **鉴于Notepad++作者的错误言论,Notepad--的意义在于:减少一点错误言论,减少一点自以为是。** 
+
+ **严正声明,台湾是中国的一部分。** 
+
+您可以在这个项目提交bug或反馈问题。
+
+最新版本下载地址:https://gitee.com/cxasm/notepad--/releases/tag/v1.16
+
+### 编译说明:
+
+1)使用qtcreator 或 vs  先打开qscint/src/qscintilla.pro 。先编译出这个qscintlla的依赖库。
+
+2)再打开RealCompare.pro 加载后编译。
+
+代码刚刚整理上线(初次上线,可能有垃圾代码)。
+删除了商业的对比功能和注册功能(这部分有商业原因,请理解),除此以外,所有功能全部保留。
+
+
+![输入图片说明](1.png)
+
+![输入图片说明](2.png)
+
+![输入图片说明](https://foruda.gitee.com/images/1662043666536201252/709f7f20_2138353.png)

+ 1 - 0
src/RealCompare.qrc

@@ -152,5 +152,6 @@
         <file>mac.icns</file>
         <file>Resources/img/register.png</file>
         <file>notepad/rightClose.png</file>
+        <file>Resources/img/bookmark.png</file>
     </qresource>
 </RCC>

BIN
src/RealCompare.rc


BIN
src/Resources/img/bookmark.png


BIN
src/Resources/img/refresh.png


+ 17 - 0
src/aboutndd.cpp

@@ -0,0 +1,17 @@
+#include "aboutndd.h"
+
+AboutNdd::AboutNdd(QWidget *parent)
+	: QWidget(parent)
+{
+	ui.setupUi(this);
+
+	ui.label->setOpenExternalLinks(true);
+}
+
+AboutNdd::~AboutNdd()
+{}
+
+void AboutNdd::appendText(QString text)
+{
+	ui.nddMsgText->appendPlainText(text);
+}

+ 18 - 0
src/aboutndd.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#include <QWidget>
+#include "ui_aboutndd.h"
+
+class AboutNdd : public QWidget
+{
+	Q_OBJECT
+
+public:
+	AboutNdd(QWidget *parent = nullptr);
+	~AboutNdd();
+
+	void appendText(QString text);
+
+private:
+	Ui::AboutNddClass ui;
+};

+ 63 - 0
src/aboutndd.ui

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutNddClass</class>
+ <widget class="QWidget" name="AboutNddClass">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>114</height>
+   </rect>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>400</width>
+    <height>180</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>AboutNdd</string>
+  </property>
+  <property name="windowIcon">
+   <iconset resource="RealCompare.qrc">
+    <normaloff>:/Resources/edit/global/ndd.ico</normaloff>:/Resources/edit/global/ndd.ico</iconset>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>2</number>
+   </property>
+   <property name="rightMargin">
+    <number>2</number>
+   </property>
+   <property name="bottomMargin">
+    <number>2</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://gitee.com/cxasm/notepad--&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;Click to get the latest version of notepad-- or source code&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QPlainTextEdit" name="nddMsgText">
+     <property name="readOnly">
+      <bool>true</bool>
+     </property>
+     <property name="plainText">
+      <string>opensoure web:https://gitee.com/cxasm/notepad--</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout"/>
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources>
+  <include location="RealCompare.qrc"/>
+ </resources>
+ <connections/>
+</ui>

Plik diff jest za duży
+ 432 - 77
src/cceditor/ccnotepad.cpp


+ 27 - 11
src/cceditor/ccnotepad.h

@@ -116,11 +116,13 @@ public:
 	int runAsAdmin(const QString & filePath);
 	void checkAppFont();
 #endif
+
 	void syncCurSkinToMenu(int id);
 
 	int restoreLastFiles();
 
 	ScintillaEditView * getCurEditView();
+	void getCurUseLexerTags(QVector<QString>& tag);
 
 signals:
 	void signSendRegisterKey(QString key);
@@ -148,10 +150,12 @@ public slots:
 	void slot_viewStyleChange(QString tag, int styleId, QColor & fgColor, QColor & bkColor, QFont & font, bool fontChange);
 	void slot_viewLexerChange(QString tag);
 	void slot_findInDir();
+	void slot_showFileInExplorer();
 protected:
 	void closeEvent(QCloseEvent *event) override;
 	void dragEnterEvent(QDragEnterEvent* event) override;
 	void dropEvent(QDropEvent* e) override;
+	bool eventFilter(QObject *watched, QEvent *event)override;
 #ifdef Q_OS_WIN
 	bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
 #endif
@@ -167,7 +171,6 @@ private slots:
 	void slot_autoSaveFile(bool);
 	void slot_timerAutoSave();
 
-
 	void slot_tabCurrentChanged(int index);
 	void slot_copyAvailable(bool select);
 	void slot_cut();
@@ -188,6 +191,7 @@ private slots:
 	void slot_markHighlight();
 	void slot_clearMark();
 	void slot_wordHighlight();
+	void slot_findResultPosChangeed(Qt::DockWidgetArea area);
 	void slot_findResultItemDoubleClick(const QModelIndex & index);
 	void slot_showFindAllInCurDocResult(FindRecords * record);
 	void slot_showfindAllInOpenDocResult(QVector<FindRecords*>* record, int hits, QString whatFind);
@@ -205,11 +209,14 @@ private slots:
 	void slot_load_with_utf8_bom();
 	void slot_load_with_utf16_be();
 	void slot_load_with_utf16_le();
+	void slot_load_with_big5();
 	void slot_encode_gbk();
 	void slot_encode_utf8();
 	void slot_encode_utf8_bom();
 	void slot_encode_utf16_be();
 	void slot_encode_utf16_le();
+	void slot_encode_big5();
+
 	void slot_lexerActTrig(QAction * action);
 	void slot_compareFile();
 	void slot_compareDir();
@@ -219,11 +226,12 @@ private slots:
 	void slot_reOpenHexMode();
 	void slot_selectLeftFile();
 	void slot_selectRightFile();
-	void slot_showFileInExplorer();
+
 	void slot_openFileInNewWin();
 	void slot_about();
+	void slot_aboutNdd();
 	void slot_fileChange(QString filePath);
-
+	void slot_tabBarDoubleClicked(int index);
 	void slot_toLightBlueStyle();
 	void slot_toDefaultStyle();
 	void slot_toThinBlueStyle();
@@ -233,6 +241,7 @@ private slots:
 	void slot_toLavenderBlush();
 	void slot_toMistyRose();
 	void slot_register();
+
 	void slot_slectionChanged();
 	void slot_preHexPage();
 	void slot_nextHexPage();
@@ -240,10 +249,9 @@ private slots:
 	void slot_hexGotoFile(qint64 addr);
 	void slot_tabFormatChange(bool tabLenChange, bool useTabChange);
 	void slot_searchResultShow();
-	//void slot_txtFontChange(QFont & font);
-	//void slot_proLangFontChange(QFont &font);
 	void slot_saveFile(QString fileName, ScintillaEditView * pEdit);
 	void slot_skinStyleGroup(QAction * action);
+	void slot_changeIconSize(QAction * action);
 	void slot_langFormat();
 
 	void slot_removeHeadBlank();
@@ -267,7 +275,7 @@ private slots:
 	void slot_spaceToTabAll();
 	void slot_spaceToTabLeading();
 
-
+	
 	void slot_dupCurLine();
 	void slot_removeDupLine();
 	void slot_splitLines();
@@ -283,6 +291,11 @@ private slots:
 	void slot_sortLexDesc();
 	void slot_sortLexDescIngCase();
 
+	void slot_findNext();
+	void slot_findPrev();
+	void slot_escQuit();
+	void slot_bookMarkAction();
+	void slot_loadBookMarkMenu();
 
 private:
 	void initFindResultDockWin();
@@ -302,6 +315,7 @@ private:
 	void updateCurTabSaveStatus();
 	void setSaveButtonStatus(bool needSave);
 	void setSaveAllButtonStatus(bool needSave);
+	void tabClose(int index, bool isInQuit=false);
 	void setDocEolMode(ScintillaEditView * pEdit, RC_LINE_FORM endStatus);
 	void convertDocLineEnd(RC_LINE_FORM endStatus);
 	void transDocToEncord(CODE_ID destCode);
@@ -323,7 +337,6 @@ private:
 	void initFindWindow();
 	void setToFileRightMenu();
 
-
 	QString getShortName(const QString& name);
 
 	bool reloadTextFileWithCode(CODE_ID code);
@@ -359,6 +372,11 @@ private:
 	void dealLineSort(LINE_SORT_TYPE type);
 
 	void find(FindTabIndex findType);
+
+	void registerEscKeyShort(QWidget * parent);
+	void closeAllFileWhenQuit(bool isQuit=false);
+
+
 private:
 	Ui::CCNotePad ui;
 
@@ -387,6 +405,7 @@ private:
 	QActionGroup *m_pEncodeActGroup;
 	QActionGroup *m_pLineEndActGroup;
 	QActionGroup *m_pLexerActGroup;
+	QActionGroup *m_pIconSize;
 
 	QAction* m_quitAction;
 
@@ -455,6 +474,7 @@ private:
 
 	static int s_autoWarp; //自动换行
 	static int s_indent; //自动缩进
+	static int s_zoomValue;
 	
 	//QString m_txtFontStr;//从数据库读取的字体字符串
 	//QString m_proLangFontStr;//从数据库读取的字体字符串
@@ -463,12 +483,8 @@ private:
 
 	QTimer * m_timerAutoSave;
 
-	int m_initWidth;
-	int m_initHeight;
-
 public:
 		static QString s_lastOpenDirPath;
 	static int s_restoreLastFile; //自动恢复上次打开的文件
-
 };
 

+ 212 - 5
src/cceditor/ccnotepad.ui

@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1585</width>
+    <width>1458</width>
     <height>789</height>
    </rect>
   </property>
@@ -78,7 +78,7 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>1585</width>
+     <width>1458</width>
      <height>23</height>
     </rect>
    </property>
@@ -143,7 +143,6 @@
      </property>
      <addaction name="actionDuplicate_Current_Line"/>
      <addaction name="actionRemove_Duplicate_Lines"/>
-     <addaction name="actionRemove_Consecutive_Duplicate_Lines"/>
      <addaction name="actionSplit_Lines"/>
      <addaction name="actionJoin_Lines"/>
      <addaction name="actionMove_Up_Current_Line"/>
@@ -182,10 +181,19 @@
     <property name="title">
      <string>Search(&amp;S)</string>
     </property>
+    <widget class="QMenu" name="menuBook_Mark">
+     <property name="title">
+      <string>Book Mark</string>
+     </property>
+    </widget>
     <addaction name="actionFind"/>
+    <addaction name="actionFindNext"/>
+    <addaction name="actionFindPrev"/>
     <addaction name="actionFind_In_Dir"/>
     <addaction name="actionReplace"/>
     <addaction name="actionGoline"/>
+    <addaction name="separator"/>
+    <addaction name="menuBook_Mark"/>
    </widget>
    <widget class="QMenu" name="menuView">
     <property name="title">
@@ -199,25 +207,48 @@
      <addaction name="actionshow_end_of_line"/>
      <addaction name="actionshow_all"/>
     </widget>
+    <widget class="QMenu" name="menuIcon_Size">
+     <property name="title">
+      <string>Icon Size</string>
+     </property>
+     <addaction name="action24"/>
+     <addaction name="action36"/>
+     <addaction name="action48"/>
+    </widget>
     <addaction name="menudisplay_symbols"/>
     <addaction name="actionSearch_Result"/>
     <addaction name="actionWrap"/>
+    <addaction name="menuIcon_Size"/>
    </widget>
    <widget class="QMenu" name="menuCode">
     <property name="title">
      <string>Encoding(&amp;N)</string>
     </property>
+    <widget class="QMenu" name="menuASNI">
+     <property name="title">
+      <string>Other</string>
+     </property>
+     <addaction name="actionBig5"/>
+    </widget>
+    <widget class="QMenu" name="menuConvert_to_Other">
+     <property name="title">
+      <string>Convert to Other</string>
+     </property>
+     <addaction name="actionToBig5"/>
+    </widget>
     <addaction name="actionencode_in_GBK"/>
     <addaction name="actionencode_in_uft8"/>
     <addaction name="actionencode_in_UTF8_BOM"/>
     <addaction name="actionencode_in_UCS_BE_BOM"/>
     <addaction name="actionencode_in_UCS_2_LE_BOM"/>
+    <addaction name="menuASNI"/>
     <addaction name="separator"/>
     <addaction name="actionconvert_to_GBK"/>
     <addaction name="actionconvert_to_UTF8"/>
     <addaction name="actionconvert_to_UTF8_BOM"/>
     <addaction name="actionconvert_to_UCS_2_BE_BOM"/>
     <addaction name="actionconvert_to_UCS_2_LE_BOM"/>
+    <addaction name="menuConvert_to_Other"/>
     <addaction name="actionbatch_convert"/>
    </widget>
    <widget class="QMenu" name="menuLanguage">
@@ -460,6 +491,12 @@
     <addaction name="actionDonate"/>
     <addaction name="actionCC_Pad"/>
    </widget>
+   <widget class="QMenu" name="menuAbout_2">
+    <property name="title">
+     <string>About</string>
+    </property>
+    <addaction name="actioninfo"/>
+   </widget>
    <addaction name="menuFile"/>
    <addaction name="menuEdit"/>
    <addaction name="menuSearch"/>
@@ -468,6 +505,7 @@
    <addaction name="menuLanguage"/>
    <addaction name="menuSet"/>
    <addaction name="menuAbout"/>
+   <addaction name="menuAbout_2"/>
   </widget>
   <widget class="QToolBar" name="mainToolBar">
    <property name="movable">
@@ -625,7 +663,7 @@
     <string>Replace</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+R</string>
+    <string>Ctrl+H</string>
    </property>
   </action>
   <action name="actionGoline">
@@ -1695,11 +1733,17 @@
    <property name="text">
     <string>Move Up Current Line</string>
    </property>
+   <property name="shortcut">
+    <string>Ctrl+Shift+Up</string>
+   </property>
   </action>
   <action name="actionMove_Down_Current_Line">
    <property name="text">
     <string>Move Down Current Line</string>
    </property>
+   <property name="shortcut">
+    <string>Ctrl+Shift+Down</string>
+   </property>
   </action>
   <action name="actionInsert_Blank_Line_Above_Current">
    <property name="text">
@@ -1782,7 +1826,85 @@
     <string>Find In Dir</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+Shift+F</string>
+    <string>Ctrl+Shift+D</string>
+   </property>
+  </action>
+  <action name="actionFindNext">
+   <property name="text">
+    <string>Find Next</string>
+   </property>
+   <property name="shortcut">
+    <string>F3</string>
+   </property>
+  </action>
+  <action name="actionFindPrev">
+   <property name="text">
+    <string>Find Prev</string>
+   </property>
+   <property name="shortcut">
+    <string>F4</string>
+   </property>
+  </action>
+  <action name="actionRed">
+   <property name="text">
+    <string>Red</string>
+   </property>
+  </action>
+  <action name="actionYellow_2">
+   <property name="text">
+    <string>Yellow</string>
+   </property>
+  </action>
+  <action name="actionBlue">
+   <property name="text">
+    <string>Blue</string>
+   </property>
+  </action>
+  <action name="actionBig5">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Big5</string>
+   </property>
+  </action>
+  <action name="actionToBig5">
+   <property name="text">
+    <string>Big5</string>
+   </property>
+  </action>
+  <action name="action24">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>24x24</string>
+   </property>
+  </action>
+  <action name="action36">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>36x36</string>
+   </property>
+  </action>
+  <action name="action48">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>48x48</string>
+   </property>
+  </action>
+  <action name="actioninfo">
+   <property name="text">
+    <string>AboutNdd</string>
+   </property>
+  </action>
+  <action name="action1">
+   <property name="text">
+    <string>1</string>
    </property>
   </action>
  </widget>
@@ -3151,6 +3273,86 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionFindNext</sender>
+   <signal>triggered()</signal>
+   <receiver>CCNotePad</receiver>
+   <slot>slot_findNext()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>792</x>
+     <y>394</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionFindPrev</sender>
+   <signal>triggered()</signal>
+   <receiver>CCNotePad</receiver>
+   <slot>slot_findPrev()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>792</x>
+     <y>394</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionBig5</sender>
+   <signal>triggered()</signal>
+   <receiver>CCNotePad</receiver>
+   <slot>slot_load_with_big5()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>792</x>
+     <y>394</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionToBig5</sender>
+   <signal>triggered()</signal>
+   <receiver>CCNotePad</receiver>
+   <slot>slot_encode_big5()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>792</x>
+     <y>394</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actioninfo</sender>
+   <signal>triggered()</signal>
+   <receiver>CCNotePad</receiver>
+   <slot>slot_aboutNdd()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>728</x>
+     <y>394</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>slot_actionNewFile_toggle(bool)</slot>
@@ -3240,5 +3442,10 @@
   <slot>slot_sortLexDesc()</slot>
   <slot>slot_sortLexDescIngCase()</slot>
   <slot>slot_findInDir()</slot>
+  <slot>slot_findNext()</slot>
+  <slot>slot_findPrev()</slot>
+  <slot>slot_load_with_big5()</slot>
+  <slot>slot_encode_big5()</slot>
+  <slot>slot_aboutNdd()</slot>
  </slots>
 </ui>

+ 21 - 0
src/cceditor/filemanager.cpp

@@ -9,6 +9,9 @@
 #include <QtGlobal>
 #include <qscilexer.h>
 
+FileManager::FileManager():m_lastErrorCode(NONE_ERROR)
+{
+}
 
 FileManager::~FileManager()
 {
@@ -220,6 +223,14 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
 
 	qint64 fileSize = file.size();
 
+	//如果文件是空的。检查一下,有可能在临时文件损坏情况下出现,外面需要使用
+	if (fileSize == 0)
+	{
+		m_lastErrorCode = ERROR_TYPE::OPEN_EMPTY_FILE;
+		file.close();
+		return 0;
+	}
+
 	qint64 bufferSizeRequested = fileSize + qMin((qint64)(1 << 20), (qint64)(fileSize / 6));
 
 	// As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space)
@@ -238,6 +249,14 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
 
 	fileTextCode = CmpareMode::scanFileOutPut(fileTextCode,filePath, outputLineInfoVec, maxLineSize, charsNums, isHexFile);
 
+	//如果文件是空的。检查一下,有可能在临时文件损坏情况下出现,外面需要使用
+	if (charsNums == 0)
+	{
+		m_lastErrorCode = ERROR_TYPE::OPEN_EMPTY_FILE;
+		file.close();
+		return 0;
+	}
+
 	if (isHexFile && hexAsk)
 	{
 		//检测到文件很可能是二进制文件,询问用户,是否以二进制加载
@@ -283,6 +302,8 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
 		lineEnd = UNIX_LINE;
 #endif
 	}
+
+
 	QString text;
 	text.reserve(charsNums + 1);
 

+ 18 - 1
src/cceditor/filemanager.h

@@ -10,6 +10,11 @@
 class ScintillaEditView;
 class ScintillaHexEditView;
 
+enum ERROR_TYPE {
+	NONE_ERROR=-1,
+	OPEN_EMPTY_FILE=0,
+};
+
 struct NewFileIdMgr {
 	int index;
 	ScintillaEditView* editView;
@@ -131,8 +136,18 @@ public:
 		return instance;
 	};
 
+	ERROR_TYPE getLastErrorCode()
+	{
+		return m_lastErrorCode;
+	}
+
+	void resetLastErrorCode()
+	{
+		m_lastErrorCode = NONE_ERROR;
+	}
+
 private:
-	FileManager() = default;
+	FileManager();
 	~FileManager();
 
 	FileManager(const FileManager&) = delete;
@@ -143,5 +158,7 @@ private:
 	QMap<QString, HexFileMgr*> m_hexFileMgr;
 
 	QMap<QString, TextFileMgr*> m_bigTxtFileMgr;
+
+	ERROR_TYPE m_lastErrorCode;
 };
 

+ 47 - 0
src/changelog.txt

@@ -0,0 +1,47 @@
+1.18 预发布版本发布 20221120 version25
+1 字体风格提供全局一键修改全部功能
+2 对比可以直接拷贝粘贴内容进行对比
+3 记住窗口大小未知;查找结果位置记住;放大缩小率记住;下次打开恢复上述信息
+4 安装位置修改到x64安装目录
+5 支持书签下8种功能,快捷键F2切换书签等。
+6 解决一些列bug,如txt下字体大小显示不等宽;对比窗口行号不统一等;
+7 提高安全性,崩溃后下次打开无条件保存新旧文件等。
+8 提高打开速度。内部使用ini配置替换json格式等。
+
+1.17.0 发布 20221108
+1.17 win10版本发布了,完成如下功能
+1 完成自定义编程语言风格 -- 给出一个基础版本,可自定义语言,添加关键词。
+2 语言风格全局设置,快捷一键全部弄成一样的字体样式 
+3 查询关键字计数 
+4 增加大小写转换功能 
+5 使用了boot的正则表达式
+6 增加移除空行功能
+7 列编辑功能
+8  行编辑中16 种功能移植
+9 中文安装包
+10 对比卡死bug解决
+11 其它小功能。比如根据win linxu自动设置换行符号、长行显示不全等bug。
+
+//5 1.3
+//6 1.4 20211027日
+//7 1.5 20211110日发布,是第一个真正意义上的稳定版本。
+//8 1.6 20211201发布,增加了网络消息中的6和7命令。第一次发布了notebook版本。
+//9 1.7 20211224日发布,增加了bin二进制的对比方式。暂时先在www.itdp.cn发布。
+//10 没有使用,单独给mac的一个版本做尝试
+//11 20210118日发布,单独发布ccompare和ccnotepad。notepad暂时在www.itdp.cn发布。这个版本中的linux 和 windows的 VERIFY_CODE 做了不同的区别。将二者分离出来
+//12 1.9 发布。
+//13 1.9.1 20220225发布,bin对比背景高亮。调整了界面美观度
+//版本号没有修改,换皮。20220525重新发布,不再继续维护修改了。
+因为编辑器的市场已经是红海,没必要死磕,考虑其它途径。就这样吧。
+//15 1.9.0 20220530左右发布。在uos上面第一次发布。
+//16 1.10.0 20220616左右发布。在uos上面发布了。增加查找高亮、Uos上右键关联打开等。
+//17 1.11.0 20220629左右编译发布,在Uos也发布了。增加单词高亮、自动保存、前后位置跳转等。
+//18 1.11.0 20220630 linux uos下面重新编译了下,版本直接修改为18,在网站发布。因为已经提交到uos商店中去了,后续再提交时,不修改版本,直接保持为18即可。
+//18 1.12.0 20220707 只发布了windows版本,修改为多线程、取消数据库db,修改为json存储格式。加速第一次运行时的速度处理。
+//19 1.13.0 20220802 只发布了windows版本,增加文件夹查找功能,美化界面。马上要发布uos版本。
+//19 1.13.0 20220803 大幅度改善查找文件框的设置,优化其显示。20220804发布了uos 1.13版本
+//21 1.14.0 20220901 大幅完善细节,中间有个20的版本做了皮肤风格的。本次对查找扩展、大量细节做了完善。已经发布了win10版本。
+//22 1.14.0 202209010 先发布了windows下面的版本、自动检测二进制文件或文本,支持大文本分块显示、合入文件对比的功能、提交了第一个版本的注册界面。
+理论上这个版本应该是一个里程碑式样的版本。先只发布了windows版本。mac和uos的在后面等稳定后再发布。
+//23 1.16.0 20221008 完善了大量细节,应该是更加完善的一个里程碑版本。目前windows mac 都已经发布,uos的还没有提交到商场,预计月底提交。
+//23 1.16.1 20221011 1.16里面存在问题,对比时会卡死,紧急解决了这个故障。使用nsis进行了打包,只发布了win10,后续还需要uos mac发布。

+ 5 - 5
src/doctypelistview.cpp

@@ -4,7 +4,7 @@
 #include <QLineEdit>
 #include <QtDebug>
 #include <QThread>
-#include "jsondeploy.h"
+#include "nddsetting.h"
 
 //已知的文档类型
 
@@ -51,7 +51,7 @@ void DocTypeListView::initSupportFileTypes()
 	}
 
 	//如果数据库不存在,则使用默认值来进行初始化
-	if (!JsonDeploy::isDbExist())
+	if (!NddSetting::isDbExist())
 	{
 		QStringList types;
 		types << ".txt:.log" << ".ini:.inf" << ".h:.hh:.hpp:.hxx:.c:.cpp:.cxx:.cc:.m:.mm:.vcxproj:.vcproj:.props:vsprops:mainfest:.go:.mod" \
@@ -81,7 +81,7 @@ void DocTypeListView::initSupportFileTypes()
 		//从数据库动态读取配置
 		QString key("typelist");
 
-		QString typeList = JsonDeploy::getKeyValueFromLongSets(key);
+		QString typeList = NddSetting::getKeyValueFromSets(key);
 
 		if (typeList.isEmpty())
 		{
@@ -97,7 +97,7 @@ void DocTypeListView::initSupportFileTypes()
 
 			QString typeStr = types.join("|");
 
-			JsonDeploy::addKeyValueToLongSets(key, typeStr);
+			NddSetting::addKeyValueToSets(key, typeStr);
 
 			typeStr.replace('|',':');
 
@@ -206,7 +206,7 @@ void DocTypeListView::save()
 	{
 		QString key("typelist");
 		QString typeStr = s_extBindFileType.join("|");
-		JsonDeploy::updataKeyValueFromLongSets(key, typeStr);
+		NddSetting::updataKeyValueFromSets(key, typeStr);
 		m_isDirty = false;
 	}
 }

+ 2 - 3
src/donate.cpp

@@ -1,12 +1,11 @@
 #include "donate.h"
 
-donate::donate(QWidget *parent)
-	: QWidget(parent)
+Donate::Donate(QWidget *parent): QWidget(parent)
 {
 	ui.setupUi(this);
 }
 
-donate::~donate()
+Donate::~Donate()
 {
 
 }

+ 4 - 4
src/donate.h

@@ -4,16 +4,16 @@
 #include <QWidget>
 #include "ui_donate.h"
 
-class donate : public QWidget
+class Donate : public QWidget
 {
 	Q_OBJECT
 
 public:
-	donate(QWidget *parent = 0);
-	~donate();
+	Donate(QWidget *parent = 0);
+	~Donate();
 
 private:
-	Ui::donate ui;
+	Ui::DonateClass ui;
 };
 
 #endif // DONATE_H

+ 28 - 25
src/donate.ui

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>donate</class>
- <widget class="QWidget" name="donate">
+ <class>DonateClass</class>
+ <widget class="QWidget" name="DonateClass">
   <property name="windowModality">
    <enum>Qt::NonModal</enum>
   </property>
@@ -25,8 +25,11 @@
     <height>479</height>
    </size>
   </property>
+  <property name="contextMenuPolicy">
+   <enum>Qt::DefaultContextMenu</enum>
+  </property>
   <property name="windowTitle">
-   <string>donate</string>
+   <string>Donate Me</string>
   </property>
   <property name="windowIcon">
    <iconset resource="RealCompare.qrc">
@@ -63,28 +66,6 @@
      </item>
      <item>
       <layout class="QGridLayout" name="gridLayout">
-       <item row="0" column="0">
-        <widget class="QLabel" name="msg">
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="font">
-          <font>
-           <family>华文宋体</family>
-           <pointsize>12</pointsize>
-          </font>
-         </property>
-         <property name="text">
-          <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Donation Software Development By WeChat &lt;/p&gt;&lt;p&gt;Busy living, no time to improve software&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
-         </property>
-        </widget>
-       </item>
        <item row="1" column="0">
         <widget class="QLabel" name="label">
          <property name="sizePolicy">
@@ -113,6 +94,28 @@
          </property>
         </widget>
        </item>
+       <item row="0" column="0">
+        <widget class="QLabel" name="msg">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <family>华文宋体</family>
+           <pointsize>12</pointsize>
+          </font>
+         </property>
+         <property name="text">
+          <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Donation Software Development By WeChat &lt;/p&gt;&lt;p&gt;Busy living, no time to improve software&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
       </layout>
      </item>
      <item>

+ 51 - 7
src/findwin.cpp

@@ -13,7 +13,7 @@
 #include <QDebug>
 
 FindWin::FindWin(QWidget *parent):QMainWindow(parent), m_editTabWidget(nullptr), m_isFindFirst(true), m_findHistory(nullptr), \
-	pEditTemp(nullptr), m_curEditWin(nullptr), m_isStatic(false)
+	pEditTemp(nullptr), m_curEditWin(nullptr), m_isStatic(false), m_isReverseFind(false)
 {
 	ui.setupUi(this);
 
@@ -476,7 +476,11 @@ void FindWin::updateParameterFromUI()
 		m_isFindFirst = true;
 	}
 
+	//本来的m_BackwardDir只控制是否勾选反向
 	m_forward = !m_BackwardDir;
+
+	//m_isReverseFind 控制是否还需要反向一直,只在查找前一个生效
+	m_forward = (m_isReverseFind ? !m_forward : m_forward);
 }
 
 void FindWin::addFindHistory(QString &text)
@@ -682,6 +686,16 @@ void FindWin::removeEmptyLine(bool isBlankContained)
 	}
 }
 
+void FindWin::findNext()
+{
+	slot_findNext();
+}
+
+void FindWin::findPrev()
+{
+	slot_findPrev();
+}
+
 /*处理查找时零长的问题。一定要处理,否则会死循环,因为每次都在原地查找。
 * 就是把下次查找的startpos往前一个,否则每次都从这个startpos找到自己
 */
@@ -721,9 +735,7 @@ void FindWin::dealWithZeroFoundShowTip(QsciScintilla* pEdit, bool isShowTip)
 	}
 }
 
-
-//一旦修改条件发生变化,则认定为第一次查找
-void FindWin::slot_findNext()
+void FindWin::dofindNext()
 {
 	if (ui.findComboBox->currentText().isEmpty())
 	{
@@ -755,9 +767,9 @@ void FindWin::slot_findNext()
 				whatFind = extendFind;
 			}
 
-			if (!pEdit->findFirst(whatFind, m_re, m_cs, m_wo, m_wrap, m_forward, FINDNEXTTYPE_FINDNEXT, -1,-1,true,false,false))
+			if (!pEdit->findFirst(whatFind, m_re, m_cs, m_wo, m_wrap, m_forward, FINDNEXTTYPE_FINDNEXT, -1, -1, true, false, false))
 			{
-				ui.statusbar->showMessage(tr("cant't find text \'%1\'").arg(m_expr),8000);
+				ui.statusbar->showMessage(tr("cant't find text \'%1\'").arg(m_expr), 8000);
 				QApplication::beep();
 				m_isFindFirst = true;
 			}
@@ -775,7 +787,7 @@ void FindWin::slot_findNext()
 		{
 			if (!pEdit->findNext())
 			{
-				ui.statusbar->showMessage(tr("no more find text \'%1\'").arg(m_expr),8000);
+				ui.statusbar->showMessage(tr("no more find text \'%1\'").arg(m_expr), 8000);
 				m_isFindFirst = true;
 				QApplication::beep();
 			}
@@ -787,6 +799,37 @@ void FindWin::slot_findNext()
 	}
 }
 
+//一旦修改条件发生变化,则认定为第一次查找
+void FindWin::slot_findNext()
+{
+	if (m_isReverseFind)
+	{
+		m_isReverseFind = false;
+		m_isFindFirst = true;
+	}
+
+	dofindNext();
+}
+
+void FindWin::setFindBackward(bool isBackward)
+{
+	if (ui.findBackwardBox->isChecked() != isBackward)
+	{
+		ui.findBackwardBox->setChecked(isBackward);
+	}
+}
+
+void FindWin::slot_findPrev()
+{
+	if (!m_isReverseFind)
+	{
+		m_isReverseFind = true;
+		m_isFindFirst = true;
+	}
+	dofindNext();
+}
+
+
 //查找计数
 void FindWin::slot_findCount()
 {
@@ -2152,3 +2195,4 @@ void FindWin::slot_dirReplaceAll()
 	m_isFindFirst = true;
 	ui.statusbar->showMessage(tr("replace finished, total %1 replace in %2 file!").arg(replaceNums).arg(filesNum), 10000);
 }
+

+ 11 - 1
src/findwin.h

@@ -64,7 +64,9 @@ public:
 	void removeLineHeadEndBlank(int mode);
 	static void showCallTip(QsciScintilla * pEdit, int pos);
 	void removeEmptyLine(bool isBlankContained);
-	
+	void findNext();
+	void findPrev();
+	void setFindBackward(bool isBackward);
 
 protected:
 	
@@ -98,12 +100,18 @@ private:
 
 	void dealWithZeroFoundShowTip(QsciScintilla * pEdit, bool isShowTip=true);
 
+	void dofindNext();
+
 	bool replaceFindNext(QsciScintilla* pEdit, bool showZeroFindTip);
 
 	bool replace(ScintillaEditView* pEdit);
+
 private slots:
 	void slot_findNext();
 
+
+	void slot_findPrev();
+
 	void slot_findCount();
 
 	void slot_findAllInCurDoc();
@@ -179,4 +187,6 @@ private:
 	QWidget* m_curEditWin;
 
 	bool m_isStatic;//是否静默处理,不弹确认对话框
+
+	bool m_isReverseFind; //是否反向查找。只有在查找前一个时才生效true 下一个必须是false
 };

+ 96 - 141
src/findwin.ui

@@ -7,13 +7,13 @@
     <x>0</x>
     <y>0</y>
     <width>589</width>
-    <height>360</height>
+    <height>362</height>
    </rect>
   </property>
   <property name="maximumSize">
    <size>
-    <width>610</width>
-    <height>360</height>
+    <width>1100</width>
+    <height>500</height>
    </size>
   </property>
   <property name="windowTitle">
@@ -190,12 +190,6 @@
          <layout class="QVBoxLayout" name="verticalLayout">
           <item>
            <widget class="QPushButton" name="findTextNext">
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Find Next(F3)</string>
             </property>
@@ -204,6 +198,16 @@
             </property>
            </widget>
           </item>
+          <item>
+           <widget class="QPushButton" name="findTextPrev">
+            <property name="text">
+             <string>Find Prev(F4)</string>
+            </property>
+            <property name="shortcut">
+             <string>F4</string>
+            </property>
+           </widget>
+          </item>
           <item>
            <widget class="QPushButton" name="countBt">
             <property name="text">
@@ -216,24 +220,12 @@
           </item>
           <item>
            <widget class="QPushButton" name="findAllinCourrent">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
             <property name="minimumSize">
              <size>
               <width>0</width>
               <height>34</height>
              </size>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Find All in Current 
  Document</string>
@@ -242,24 +234,12 @@
           </item>
           <item>
            <widget class="QPushButton" name="findAllinAllOpen">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
             <property name="minimumSize">
              <size>
               <width>0</width>
               <height>34</height>
              </size>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Find All in All Opened 
  Documents</string>
@@ -275,18 +255,6 @@
           </item>
           <item>
            <widget class="QPushButton" name="findCloseBt">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Close</string>
             </property>
@@ -479,12 +447,6 @@
          <layout class="QVBoxLayout" name="verticalLayout_8">
           <item>
            <widget class="QPushButton" name="replaceFindNextBox">
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Find Next</string>
             </property>
@@ -498,12 +460,6 @@
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Replace</string>
             </property>
@@ -517,12 +473,6 @@
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Replace All</string>
             </property>
@@ -542,12 +492,6 @@
               <height>34</height>
              </size>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Replace All in All Opened 
  Documents</string>
@@ -562,12 +506,6 @@
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>176</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Close</string>
             </property>
@@ -886,16 +824,16 @@
          <layout class="QVBoxLayout" name="verticalLayout_15">
           <item>
            <widget class="QPushButton" name="dirFindAll">
-            <property name="minimumSize">
-             <size>
-              <width>158</width>
-              <height>30</height>
-             </size>
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
             </property>
-            <property name="maximumSize">
+            <property name="minimumSize">
              <size>
               <width>160</width>
-              <height>160</height>
+              <height>0</height>
              </size>
             </property>
             <property name="text">
@@ -905,10 +843,16 @@
           </item>
           <item>
            <widget class="QPushButton" name="dirReplaceAll">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="minimumSize">
              <size>
-              <width>158</width>
-              <height>30</height>
+              <width>160</width>
+              <height>0</height>
              </size>
             </property>
             <property name="text">
@@ -918,10 +862,16 @@
           </item>
           <item>
            <widget class="QPushButton" name="clearBt">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="minimumSize">
              <size>
-              <width>158</width>
-              <height>30</height>
+              <width>160</width>
+              <height>0</height>
              </size>
             </property>
             <property name="text">
@@ -931,10 +881,16 @@
           </item>
           <item>
            <widget class="QPushButton" name="dirClose">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="minimumSize">
              <size>
-              <width>158</width>
-              <height>30</height>
+              <width>160</width>
+              <height>0</height>
              </size>
             </property>
             <property name="text">
@@ -973,8 +929,8 @@
               <property name="text">
                <string>Mark What</string>
               </property>
-     </widget>
-    </item>
+             </widget>
+            </item>
             <item>
              <widget class="QComboBox" name="markTextBox">
               <property name="minimumSize">
@@ -991,7 +947,7 @@
               </property>
              </widget>
             </item>
-   </layout>
+           </layout>
           </item>
           <item>
            <spacer name="verticalSpacer_7">
@@ -1013,7 +969,7 @@
               <property name="text">
                <string>Match whole word only</string>
               </property>
-  </widget>
+             </widget>
             </item>
             <item>
              <widget class="QCheckBox" name="markMatchCaseBox">
@@ -1080,12 +1036,6 @@
          <layout class="QVBoxLayout" name="verticalLayout_12">
           <item>
            <widget class="QPushButton" name="markAllBox">
-            <property name="maximumSize">
-             <size>
-              <width>188</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Mark All</string>
             </property>
@@ -1093,12 +1043,6 @@
           </item>
           <item>
            <widget class="QPushButton" name="markClearBox">
-            <property name="maximumSize">
-             <size>
-              <width>188</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Clear Mark</string>
             </property>
@@ -1112,12 +1056,6 @@
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>188</width>
-              <height>16777215</height>
-             </size>
-            </property>
             <property name="text">
              <string>Close</string>
             </property>
@@ -1227,7 +1165,7 @@
    <hints>
     <hint type="sourcelabel">
      <x>572</x>
-     <y>222</y>
+     <y>251</y>
     </hint>
     <hint type="destinationlabel">
      <x>169</x>
@@ -1258,8 +1196,8 @@
    <slot>slot_findAllInCurDoc()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>488</x>
-     <y>92</y>
+     <x>572</x>
+     <y>153</y>
     </hint>
     <hint type="destinationlabel">
      <x>548</x>
@@ -1274,11 +1212,11 @@
    <slot>slot_replaceFindNext()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>519</x>
      <y>55</y>
     </hint>
     <hint type="destinationlabel">
-     <x>602</x>
+     <x>588</x>
      <y>302</y>
     </hint>
    </hints>
@@ -1290,11 +1228,11 @@
    <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>519</x>
      <y>182</y>
     </hint>
     <hint type="destinationlabel">
-     <x>600</x>
+     <x>588</x>
      <y>273</y>
     </hint>
    </hints>
@@ -1306,11 +1244,11 @@
    <slot>slot_replace()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>519</x>
      <y>84</y>
     </hint>
     <hint type="destinationlabel">
-     <x>598</x>
+     <x>588</x>
      <y>204</y>
     </hint>
    </hints>
@@ -1322,11 +1260,11 @@
    <slot>slot_replaceAll()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>519</x>
      <y>113</y>
     </hint>
     <hint type="destinationlabel">
-     <x>597</x>
+     <x>588</x>
      <y>145</y>
     </hint>
    </hints>
@@ -1338,11 +1276,11 @@
    <slot>slot_replaceAllInOpenDoc()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>519</x>
      <y>153</y>
     </hint>
     <hint type="destinationlabel">
-     <x>599</x>
+     <x>588</x>
      <y>115</y>
     </hint>
    </hints>
@@ -1354,12 +1292,12 @@
    <slot>slot_markAll()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>478</x>
-     <y>47</y>
+     <x>489</x>
+     <y>55</y>
     </hint>
     <hint type="destinationlabel">
      <x>501</x>
-     <y>-4</y>
+     <y>0</y>
     </hint>
    </hints>
   </connection>
@@ -1370,12 +1308,12 @@
    <slot>slot_clearMark()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>489</x>
      <y>84</y>
     </hint>
     <hint type="destinationlabel">
-     <x>594</x>
-     <y>-5</y>
+     <x>588</x>
+     <y>0</y>
     </hint>
    </hints>
   </connection>
@@ -1386,12 +1324,12 @@
    <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>572</x>
+     <x>489</x>
      <y>113</y>
     </hint>
     <hint type="destinationlabel">
      <x>404</x>
-     <y>-13</y>
+     <y>0</y>
     </hint>
    </hints>
   </connection>
@@ -1403,7 +1341,7 @@
    <hints>
     <hint type="sourcelabel">
      <x>572</x>
-     <y>170</y>
+     <y>142</y>
     </hint>
     <hint type="destinationlabel">
      <x>564</x>
@@ -1418,8 +1356,8 @@
    <slot>slot_dirSelectDest()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>393</x>
-     <y>48</y>
+     <x>403</x>
+     <y>53</y>
     </hint>
     <hint type="destinationlabel">
      <x>502</x>
@@ -1434,8 +1372,8 @@
    <slot>slot_dirFindAll()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>507</x>
-     <y>60</y>
+     <x>572</x>
+     <y>55</y>
     </hint>
     <hint type="destinationlabel">
      <x>445</x>
@@ -1450,8 +1388,8 @@
    <slot>slot_dirReplaceAll()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>463</x>
-     <y>85</y>
+     <x>572</x>
+     <y>84</y>
     </hint>
     <hint type="destinationlabel">
      <x>333</x>
@@ -1466,12 +1404,28 @@
    <slot>slot_findCount()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>502</x>
-     <y>72</y>
+     <x>572</x>
+     <y>113</y>
     </hint>
     <hint type="destinationlabel">
      <x>377</x>
-     <y>366</y>
+     <y>361</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>findTextPrev</sender>
+   <signal>clicked()</signal>
+   <receiver>FindWin</receiver>
+   <slot>slot_findPrev()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>484</x>
+     <y>73</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>294</x>
+     <y>180</y>
     </hint>
    </hints>
   </connection>
@@ -1491,5 +1445,6 @@
   <slot>slot_dirReplaceAll()</slot>
   <slot>slot_dirSelectDest()</slot>
   <slot>sign_clearResult()</slot>
+  <slot>slot_findPrev()</slot>
  </slots>
 </ui>

+ 11 - 12
src/installer/installer.nsi

@@ -213,16 +213,16 @@ SectionEnd
 
 # -----------------------------------------------
 
-Section ".txt" Note
-DetailPrint "关联 txt 文件..."
-SectionIn 1
-WriteRegStr HKCR   ".txt" "" "Notepad--"
-#WriteRegStr HKCR   "Note.file" "" "文本文件 (.txt)"
-#WriteRegStr HKCR   "Note.file\DefaultIcon" "" "$INSTDIR\Notepad--.exe,0"
-#WriteRegStr HKCR   "Note.file\shell" "" ""
-#WriteRegStr HKCR   "Note.file\shell\open" "" ""
-#WriteRegStr HKCR   "Note.file\shell\open\command" "" '"$INSTDIR\Notepad--.exe" "%1"'
-SectionEnd
+#Section ".txt" Ndd
+#DetailPrint "关联 txt 文件..."
+#SectionIn 1
+#WriteRegStr HKCR   ".txt" "" "Ndd.file"
+#WriteRegStr HKCR   "Ndd.file" "" "文本文件 (.txt)"
+#WriteRegStr HKCR   "Ndd.file\DefaultIcon" "" "$INSTDIR\Notepad--.exe,0"
+#WriteRegStr HKCR   "Ndd.file\shell" "" ""
+#WriteRegStr HKCR   "Ndd.file\shell\open" "" ""
+#WriteRegStr HKCR   "Ndd.file\shell\open\command" "" '"$INSTDIR\Notepad--.exe" "%1"'
+#SectionEnd
 
 
 ${MementoSectionDone}
@@ -279,8 +279,7 @@ Section "Uninstall"
 	DeleteRegValue SHCTX "Software\Classes\.txt\OpenWithProgids" "Notepad--"
 	DeleteRegKey SHCTX "Software\Classes\Notepad--"
 
-    DeleteRegKey HKCR   ".txt" "" "Notepad--"
-    #DeleteRegKey HKCR  "Note.File"
+    #DeleteRegKey HKCR   ".txt" "" "Ndd.file"
 	
 	!insertmacro MULTIUSER_RegistryRemoveInstallInfo 
 SectionEnd

+ 66 - 0
src/installer/newinstall.iss

@@ -0,0 +1,66 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "Notepad--"
+#define MyAppVersion "1.17.2"
+#define MyAppPublisher "ndd¿ªÔ´×éÖ¯"
+#define MyAppURL "https://gitee.com/cxasm/notepad--"
+#define MyAppExeName "Notepad--.exe"
+#define MyAppAssocName "nddfile"
+#define MyAppAssocExt ".txt"
+#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{FA6189F1-03B8-44A2-BE8E-F6CD8E7857B6}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+ArchitecturesInstallIn64BitMode=x64
+DefaultDirName={autopf}\{#MyAppName}
+ChangesAssociations=yes
+DisableProgramGroupPage=yes
+; Uncomment the following line to run in non administrative install mode (install for current user only.)
+;PrivilegesRequired=lowest
+PrivilegesRequiredOverridesAllowed=dialog
+OutputDir=D:\CCNotePad\installer
+OutputBaseFilename=Notepad--v1.17.2-Installer
+SetupIconFile=D:\CCNotePad\Resources\edit\global\ndd.ico
+Compression=lzma
+SolidCompression=yes
+WizardStyle=modern
+
+[Languages]
+Name: "ChineseSimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "D:\CCNotePad\x64\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "D:\CCNotePad\x64\Release\vcomp140.dll"; DestDir: "{app}"; Flags: ignoreversion
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Registry]
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
+Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
+Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
+Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: ""; ValueData: "Edit with Notepad--"; Flags: uninsdeletekey
+Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: "Icon"; ValueData: """{app}\{#MyAppExeName}""" 
+Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" ;
+
+
+[Icons]
+Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+

+ 0 - 580
src/jsondeploy.cpp

@@ -1,580 +0,0 @@
-#include "jsondeploy.h"
-#include <QObject>
-#include <QJsonObject>
-#include <QtDebug>
-#include <QCoreApplication>
-#include <QDate>
-#include <QFile>
-#include <QStorageInfo>
-#include <QJsonDocument>
-#include <QJsonParseError>
-#include <QSettings>
-
-//替换JsonDeploy.h的类。不使用数据库,直接写一个文件就行。
-
-static int version_num = 24;
-
-//数据库文件是否存在。如果初始化失败,则不存在
-bool JsonDeploy::s_isExistDb = false;
-int JsonDeploy::s_reference = 0;
-bool JsonDeploy::s_isContentChanged = false;
-
-QJsonObject* JsonDeploy::s_jsonObj = nullptr;
-
-
-//因为WIN10的C盘没有写权限,我们选择一个可以写的目录
-QString JsonDeploy::selectDataPath()
-{
-#if defined(Q_OS_WIN)
-
-	QString settingDir = QString("notepad/test");
-	QSettings qs(QSettings::IniFormat, QSettings::UserScope, settingDir);
-	QString qsSavePath = qs.fileName();
-	QFileInfo fi(qsSavePath);
-	QString dbPath = fi.dir().absolutePath();
-
-	QString ret;
-	bool exist = false;
-
-	QDir dir(dbPath);
-
-	if (!dir.exists())
-	{
-		if (dir.mkpath(dir.absolutePath()))
-		{
-			ret = dbPath;
-			exist = true;
-		}
-	}
-	else
-	{
-		ret = dbPath;
-		exist = true;
-	}
-	
-	//理论上一定有,如果没有,则下面多半也会错误的
-	if (!exist)
-	{
-		{
-			QString name = QDir::home().dirName();
-			if (name.isEmpty())
-			{
-				return ret;
-			}
-
-			QString dbPath = QString("c:/Users/%1/.notepad").arg(name);
-			QDir dir(dbPath);
-
-			if (!dir.exists())
-			{
-				if (dir.mkpath(dir.absolutePath()))
-				{
-					ret = dbPath;
-				}
-			}
-			else
-			{
-				ret = dbPath;
-			}
-		}
-	}
-
-#if 0
-	QStringList volumesList;
-	volumesList << "E:/" << "D:/";
-
-	QString existVolume;
-	QString ret;
-	bool exist = false;
-
-	for (QString path : volumesList)
-	{
-		QDir dir(path);
-		if (dir.exists())
-		{
-			existVolume = path;
-			exist = true;
-			break;
-		}
-	}
-
-	qDebug() << existVolume;
-
-	if (exist)
-	{
-		QString dbPath = existVolume;
-		dbPath.append("Program Files/Notepad");
-
-		QDir dir(dbPath);
-
-		if (!dir.exists())
-		{
-			if (dir.mkpath(dir.absolutePath()))
-			{
-				ret = dbPath;
-			}
-		}
-		else
-		{
-			ret = dbPath;
-		}
-	}
-	else
-	{
-		QString name = QDir::home().dirName();
-		if (name.isEmpty())
-		{
-			return ret;
-		}
-		//如果没有d e盘,则创建在c盘的用户目录下面
-
-		QString dbPath = QString("c:/Users/%1/.notepad").arg(name);
-		QDir dir(dbPath);
-
-		if (!dir.exists())
-		{
-			if (dir.mkpath(dir.absolutePath()))
-			{
-				ret = dbPath;
-			}
-		}
-		else
-		{
-			ret = dbPath;
-		}
-	}
-#endif
-
-#elif defined(Q_OS_MAC)
-
-	QString ret;
-	QString name = QDir::home().dirName();
-	if (name.isEmpty())
-	{
-		return ret;
-	}
-
-	QString dbPath = QString("/Users/%1/Applications/com.hmja.notepad").arg(name);
-
-	QDir dir(dbPath);
-
-	if (!dir.exists())
-	{
-		if (dir.mkpath(dir.absolutePath()))
-		{
-			ret = dbPath;
-		}
-	}
-	else
-	{
-		ret = dbPath;
-	}
-#else
-	QString ret;
-	QString name = QDir::home().dirName();
-	if (name.isEmpty())
-	{
-		return ret;
-	}
-
-    QString dbPath = QString("/home/%1/.config/com.hmja.notepad").arg(name);
-
-	QDir dir(dbPath);
-
-	if (!dir.exists())
-	{
-		if (dir.mkpath(dir.absolutePath()))
-		{
-			ret = dbPath;
-		}
-	}
-	else
-	{
-		ret = dbPath;
-	}
-#endif
-	return ret;
-}
-
-//如果key不存在,则新增key-value
-void JsonDeploy::checkNoExistAdd(QString key, QJsonValue& value)
-{
-	//每次新加字段后,这里要检查一下,不存在则新增
-	QJsonValue v = s_jsonObj->value(key);
-	if (v.isUndefined())
-	{
-		s_jsonObj->insert(key, value);
-	}
-}
-//20220402这里隐含了一个前置条件:数据库句柄是在主线程创建的,最好不要在子线程中调用。
-//避免因为跨线程访问和多线程冲突访问引发的闪退问题。所以最好数据库的读写都在主线程中进行
-void JsonDeploy::init()
-{
-	++s_reference;
-
-	//如果已经初始化过了,则直接返回
-	if (s_isExistDb)
-	{
-		return;
-	}
-
-	s_jsonObj = new QJsonObject();
-
-	bool initOk = true;
-
-	QString dbDir = selectDataPath();
-
-	QString dbPath;
-
-	if (dbDir.isEmpty())
-	{
-		dbPath = "options.json";
-	}
-	else
-	{
-		dbPath = QString("%1/options.json").arg(dbDir);
-	}
-
-	s_jsonObj->insert(PRO_DIR, dbDir);
-	s_jsonObj->insert("dbpath", dbPath);
-
-	//打开json文件解析
-	QFile file(dbPath);
-
-	auto initJosnObj = []() {
-		QString key = "signdate";
-		//QString date = QDate::currentDate().toString(QString("yyyy/M/d"));
-		//不写今天的时间,否则第一次运行,无条件不会发送心跳。
-		//直接写一个过去的时间,让第一次运行,总是要签到
-		addKeyValueToSets(key, "2022/2/20");
-#if 0
-#if defined(Q_OS_WIN)
-		//addKeyValueToSets(TXT_FONT, QString(u8"宋体,14,-1,5,50,0,0,0,0,0,常规"));
-		//addKeyValueToSets(PRO_LANG_FONT, QString("Courier New,14,-1,5,50,0,0,0,0,0,Regular"));
-#elif defined(Q_OS_MAC)
-        addKeyValueToSets(TXT_FONT, QString(u8"STSong,18,-1,5,50,0,0,0,0,0,Regular"));
-		addKeyValueToSets(PRO_LANG_FONT, QString("Menlo,14,-1,5,50,0,0,0,0,0,Regular"));
-#else
-        addKeyValueToSets(TXT_FONT, QString(u8"CESI宋体-GB2312,14,-1,5,50,0,0,0,0,0,Regular"));
-		addKeyValueToSets(PRO_LANG_FONT, QString("Bitstream Vera Sans,11,-1,5,50,0,0,0,0,0,Regular"));
-#endif
-#endif
-		QString str;
-
-		addKeyValueToLongSets("recentopenfile", str);
-
-		//tab的长度,默认为4
-		addKeyValueToNumSets("tablens", 4);
-		//space replace tab空格替换tab,默认1为true,0为false
-		addKeyValueToNumSets("tabnouse", 1);
-
-		addKeyValueToSets("mac", "0");
-		addKeyValueToNumSets("padtimes", 0);
-		addKeyValueToNumSets("serverip", 0);
-
-		//是否高亮不同处背景
-		addKeyValueToNumSets("hexhigh", 1);
-
-		//是否高亮不同处背景
-		addKeyValueToNumSets("version", version_num);
-
-
-		//皮肤id
-        addKeyValueToNumSets(SKIN_KEY, 0);
-
-		//语言index 0:自动选择 1:中文 2 英文
-		addKeyValueToNumSets(LANGS_KEY, 0);
-
-		//开启自动换行
-		addKeyValueToNumSets(AUTOWARP_KEY, 0);
-
-		//开启自动缩进
-		addKeyValueToNumSets(INDENT_KEY, 0);
-
-		//最大文本文件的门限。默认100M.(50-300)
-		addKeyValueToNumSets(MAX_BIG_TEXT, 100);
-
-		//当前软件状态 0 试用版 1 注册版 2 注册码已过期
-		addKeyValueToNumSets(SOFT_STATUS, 0);
-
-		addKeyValueToSets(SOFT_KEY, "0");
-
-		addKeyValueToSets(RESTORE_CLOSE_FILE, "1");
-
-		addKeyValueToSets(RESTORE_SIZE, "1585:789");
-		
-	};
-
-	//不存在则创建。可能是第一次初始化
-	if (!file.exists())
-	{
-		if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::NewOnly))
-		{
-			//如果失败,则是权限不够
-			initOk = false;
-			qDebug() << "Error: Failed to create json set file.";
-		}
-		else
-		{
-			initJosnObj();
-
-			QJsonDocument doc(*s_jsonObj);
-			QByteArray bytes = doc.toJson(); //是uft8编码的
-			file.write(bytes);			
-			file.close();
-		}
-	}
-	else
-	{
-		if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
-		{
-			//如果失败,则是权限不够
-			initOk = false;
-			qDebug() << "Error: Failed to open json set file.";
-		}
-		else
-		{
-			//加载json配置到内存
-			QByteArray bytes = file.readAll();
-
-			QJsonParseError parseError;
-			QJsonDocument doc = QJsonDocument::fromJson(bytes, &parseError);
-
-			if (QJsonParseError::NoError == parseError.error)
-			{
-				*s_jsonObj = QJsonObject(doc.object());
-
-				//每次新加字段后,这里要检查一下,不存在则新增
-				{
-				QJsonValue v(1);
-				checkNoExistAdd(SKIN_KEY, v);
-				}
-
-				{
-				QJsonValue langs(0);
-				checkNoExistAdd(LANGS_KEY, langs);
-			}
-
-				{
-					QJsonValue v(0);
-					checkNoExistAdd(AUTOWARP_KEY, v);
-				}
-
-				{
-					QJsonValue v(0);
-					checkNoExistAdd(INDENT_KEY, v);
-				}
-
-				{
-					QJsonValue v(100);
-					checkNoExistAdd(MAX_BIG_TEXT, v);
-			}
-
-				{
-					QJsonValue v(0);
-					checkNoExistAdd(SOFT_STATUS, v);
-			}
-
-				{
-					QJsonValue v("0");
-					checkNoExistAdd(SOFT_KEY, v);
-				}
-#if 0
-				{
-					#if defined(Q_OS_WIN)
-						QJsonValue v("Courier New,14,-1,5,50,0,0,0,0,0,Regular");
-					#elif defined(Q_OS_MAC)
-						QJsonValue v("Menlo,14,-1,5,50,0,0,0,0,0,Regular");
-					#else
-						QJsonValue v("Bitstream Vera Sans,11,-1,5,50,0,0,0,0,0,Regular");
-					#endif
-					checkNoExistAdd(PRO_LANG_FONT, v);
-			}
-#endif
-				{
-					QJsonValue v(dbDir);
-					checkNoExistAdd(PRO_DIR, v);
-			}
-
-				{
-					QJsonValue v(1);
-					checkNoExistAdd(RESTORE_CLOSE_FILE, v);
-			}
-
-				{
-					QJsonValue v("1585:789");
-					checkNoExistAdd(RESTORE_SIZE, v);
-				}
-				
-			}
-			else
-			{
-				//读取错误,直接走初始化流程
-				initJosnObj();
-
-				//无条件设置为修改过,关闭的时候有机会触发保存配置
-				s_isContentChanged = true;
-			}
-		}
-	}
-
-	s_isExistDb = initOk;
-
-}
-
-
-//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口
-QString JsonDeploy::getKeyValueFromSets(QString key)
-{
-	QString ret;
-	QJsonValue v = s_jsonObj->value(key);
-	if (!v.isUndefined())
-	{
-		ret = v.toString();
-	}
-	return ret;
-}
-
-bool JsonDeploy::updataKeyValueFromSets(QString key, QString value)
-{
-	QJsonObject::iterator it = s_jsonObj->find(key);
-	if (it == s_jsonObj->end())
-	{
-		qDebug() << "updataKeyValueFromSets faile";
-		return false;
-	}
-
-	if (*it != value)
-	{
-		*it = value;
-		s_isContentChanged = true;
-	}
-	return true;
-}
-
-
-//第一次加一条记录,用于初始化
-void JsonDeploy::addKeyValueToSets(QString key, QString value)
-{
-	s_jsonObj->insert(key, QJsonValue(value));
-}
-
-//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口
-QString JsonDeploy::getKeyValueFromLongSets(QString key)
-{
-	QString ret;
-	QJsonValue v = s_jsonObj->value(key);
-	if (!v.isUndefined())
-	{
-		ret = v.toString();
-	}
-	return ret;
-}
-
-bool JsonDeploy::updataKeyValueFromLongSets(QString key, QString& value)
-{
-	if (value.size() > 10240)
-	{
-		return false;
-	}
-
-	QJsonObject::iterator it = s_jsonObj->find(key);
-	if (it == s_jsonObj->end())
-	{
-		qDebug() << "updataKeyValueFromSets faile";
-		return false;
-	}
-	if (*it != value)
-	{
-		*it = value;
-		s_isContentChanged = true;
-	}
-	return true;
-}
-
-
-//第一次加一条记录,用于初始化
-void JsonDeploy::addKeyValueToLongSets(QString key, QString value)
-{
-	if (value.size() > 10240)
-	{
-		return;
-	}
-
-	s_jsonObj->insert(key, QJsonValue(value));
-}
-
-//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口.0做默认值,最后不用0做值
-int JsonDeploy::getKeyValueFromNumSets(const QString key)
-{
-	int ret = 0;
-
-	QJsonValue v = s_jsonObj->value(key);
-	if (!v.isUndefined())
-	{
-		ret = v.toInt();
-	}
-	return ret;
-}
-
-bool JsonDeploy::updataKeyValueFromNumSets(const QString key, int value)
-{
-
-	QJsonObject::iterator it = s_jsonObj->find(key);
-	if (it == s_jsonObj->end())
-	{
-		qDebug() << "updataKeyValueFromNumSets faile";
-		return false;
-	}
-	if (*it != value)
-	{
-		*it = value;
-		s_isContentChanged = true;
-	}
-	return true;
-}
-
-
-//第一次加一条记录,用于初始化
-void JsonDeploy::addKeyValueToNumSets(QString key, int value)
-{
-	s_jsonObj->insert(key, QJsonValue(value));
-}
-
-
-void JsonDeploy::close()
-{
-	if (s_reference > 0)
-	{
-		--s_reference;
-
-		if (s_reference == 0)
-		{
-			s_isExistDb = false;
-
-			//做一次真正的保存
-			if (s_isContentChanged)
-			{
-				QJsonValue v = s_jsonObj->value("dbpath");
-				if (v.isString())
-				{
-					QString dbPath = v.toString();
-					QFile file(dbPath);
-					if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate))
-					{
-						//如果失败,则是权限不够
-						qDebug() << "Error: Failed to save json set file.";
-						return;
-					}
-
-					QJsonDocument doc(*s_jsonObj);
-					QByteArray bytes = doc.toJson(); //是uft8编码的
-					file.write(bytes);
-					file.close();
-					s_isContentChanged = false;
-				}
-			}
-		}
-	}
-}
-

+ 0 - 68
src/jsondeploy.h

@@ -1,68 +0,0 @@
-#pragma once
-
-#include <QJsonObject>
-
-static QString SKIN_KEY = "skinid";
-static QString LANGS_KEY = "langs";
-static QString AUTOWARP_KEY = "warp";
-static QString INDENT_KEY = "indent";
-static QString MAX_BIG_TEXT = "maxtsize";
-static QString SOFT_STATUS = "rstatus";
-static QString SOFT_KEY = "rkey";
-static QString RESTORE_CLOSE_FILE = "restore"; //恢复关闭时打开的文件
-//static QString TXT_FONT = "txtfont";
-//static QString PRO_LANG_FONT = "langfont";
-static QString PRO_DIR = "prodir";//放置配置文件的路径
-static QString RESTORE_SIZE = "rsize";//保存关闭是的大小
-
-class JsonDeploy 
-{
-//public:
-//	JsonDeploy(QObject *parent);
-//	virtual ~JsonDeploy();
-//
-//private:
-//	JsonDeploy(const JsonDeploy& other) = delete;
-//	JsonDeploy &operator=(const JsonDeploy &other) = delete;
-
-
-public:
-	static QString selectDataPath();
-
-	static void checkNoExistAdd(QString key, QJsonValue & value);
-
-	static void init();
-
-	static QString getKeyValueFromSets(QString key);
-
-	static bool updataKeyValueFromSets(QString key, QString  value);
-
-	static void addKeyValueToSets(QString  key, QString  value);
-
-	static QString getKeyValueFromLongSets(QString key);
-
-	static bool updataKeyValueFromLongSets(QString key, QString& value);
-
-	static void addKeyValueToLongSets(QString key, QString value);
-
-	static int getKeyValueFromNumSets(const QString key);
-
-	static bool updataKeyValueFromNumSets(const QString key, int value);
-
-	static void addKeyValueToNumSets(QString key, int value);
-
-	static void close();
-
-	static bool isDbExist()
-	{
-		return s_isExistDb;
-	}
-
-private:
-
-	static bool s_isExistDb;
-	static bool s_isContentChanged;
-	static int s_reference;
-
-	static QJsonObject* s_jsonObj;
-};

+ 10 - 10
src/main.cpp

@@ -1,5 +1,5 @@
 #include "ccnotepad.h"
-#include "jsondeploy.h"
+#include "nddsetting.h"
 #include "styleset.h"
 
 
@@ -23,13 +23,18 @@
 
 #ifdef Q_OS_WIN
 #pragma comment(lib, "user32.lib")
+#if _DEBUG
+#pragma comment(lib, "qmyedit_qt5d.lib")
+#else
+#pragma comment(lib, "qmyedit_qt5.lib")
+#endif
 #include <qt_windows.h>
 const ULONG_PTR CUSTOM_TYPE = 10000;
 const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001;
 bool s_isAdminAuth = false;
 #endif
 
-const QString c_strTitle = "notepad-- v1.17.1";
+const QString c_strTitle = "Ndd";
 
 
 #ifdef Q_OS_UNIX
@@ -281,9 +286,9 @@ drop_old:
 	//20221009发现有小概率出现窗口没有,但是进程还在的诡异问题,加个保护一下
 	QApplication::setQuitOnLastWindowClosed(true);
 
-	JsonDeploy::init();
+	NddSetting::init();
 
-	int id = JsonDeploy::getKeyValueFromNumSets(SKIN_KEY);
+	int id = NddSetting::getKeyValueFromNumSets(SKIN_KEY);
 	StyleSet::setSkin(id);
 
 	CCNotePad *pMainNotepad = new CCNotePad(true);
@@ -326,11 +331,6 @@ drop_old:
     memcpy(nppShared.data(), &pid, sizeof(pid_t));
     nppShared.unlock();
 #endif // Q_OS_WIN
-
-	//else
-	//{
-	//	pMainNotepad->initTabNewOne();
-	//}
 	//恢复上次关闭时的文件
 #ifdef Q_OS_WIN
 	if (!s_isAdminAuth)
@@ -358,7 +358,7 @@ drop_old:
 
 	a.exec();
 
-	JsonDeploy::close();
+	NddSetting::close();
 
 	return 0;
 }

+ 265 - 0
src/nddsetting.cpp

@@ -0,0 +1,265 @@
+#include "nddsetting.h"
+#include <QObject>
+#include <QtDebug>
+#include <QCoreApplication>
+#include <QDate>
+#include <QFile>
+#include <QStorageInfo>
+#include <QSettings>
+
+
+//配置文件是否存在。如果初始化失败,则不存在
+bool NddSetting::s_isExistDb = false;
+int NddSetting::s_reference = 0;
+bool NddSetting::s_isContentChanged = false;
+
+QSettings* NddSetting::s_nddSet = nullptr;
+
+const int version_num = 25;
+
+//如果key不存在,则新增key-value。存在:返回true
+bool NddSetting::checkNoExistAdd(QString key, QVariant& value)
+{
+	//每次新加字段后,这里要检查一下,不存在则新增
+	if (!s_nddSet->contains(key))
+	{
+		s_nddSet->setValue(key, value);
+
+		if (!s_isContentChanged)
+		{
+			s_isContentChanged = true;
+		}
+		return false;
+	}
+	return true;
+}
+
+//20220402这里隐含了一个前置条件:数据库句柄是在主线程创建的,最好不要在子线程中调用。
+//避免因为跨线程访问和多线程冲突访问引发的闪退问题。所以最好配置文件的读写都在主线程中进行
+void NddSetting::init()
+{
+	++s_reference;
+
+	//如果已经初始化过了,则直接返回
+	if (s_isExistDb)
+	{
+		return;
+	}
+	QString settingDir = QString("notepad/nddsets");
+	QSettings qs(QSettings::IniFormat, QSettings::UserScope, settingDir);
+	QString qsSetPath = qs.fileName();
+
+	s_nddSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir);
+	s_nddSet->setIniCodec("UTF-8");
+	bool initOk = true;
+
+	auto initNddSet = []() {
+		QString key = "signdate";
+		//QString date = QDate::currentDate().toString(QString("yyyy/M/d"));
+		//不写今天的时间,否则第一次运行,无条件不会发送心跳。
+		//直接写一个过去的时间,让第一次运行,总是要签到
+		addKeyValueToSets(key, "2022/2/20");
+
+		QString str;
+
+		//tab的长度,默认为4
+		addKeyValueToNumSets("tablens", 4);
+		//space replace tab空格替换tab,默认1为true,0为false
+		addKeyValueToNumSets("tabnouse", 1);
+
+		addKeyValueToSets("mac", "0");
+		addKeyValueToNumSets("padtimes", 0);
+		addKeyValueToNumSets("serverip", 0);
+
+		//是否高亮不同处背景
+		addKeyValueToNumSets("hexhigh", 1);
+
+		addKeyValueToNumSets(VERSION, version_num);
+
+		//皮肤id
+        addKeyValueToNumSets(SKIN_KEY, 0);
+
+		//语言index 0:自动选择 1:中文 2 英文
+		addKeyValueToNumSets(LANGS_KEY, 0);
+
+		//开启自动换行
+		addKeyValueToNumSets(AUTOWARP_KEY, 0);
+
+		//开启自动缩进
+		addKeyValueToNumSets(INDENT_KEY, 0);
+
+		//最大文本文件的门限。默认100M.(50-300)
+		addKeyValueToNumSets(MAX_BIG_TEXT, 100);
+
+		addKeyValueToSets(SOFT_KEY, "0");
+
+		addKeyValueToSets(RESTORE_CLOSE_FILE, "1");
+
+		//0 24 1 36 2 48
+		addKeyValueToNumSets(ICON_SIZE, 1);
+	};
+
+	if (!s_nddSet->contains(VERSION))
+	{
+		//不存在走初始化流程
+		initNddSet();
+		s_isContentChanged = true;
+	}
+	else
+	{
+		do {
+			{
+				QVariant v(VERSION);
+				if (checkNoExistAdd(VERSION, v))
+				{
+					//如果存在,而且版本是最新,不需要走后面自动检查流程了
+					int curVersion = s_nddSet->value(VERSION).toInt();
+					if (curVersion == version_num)
+					{
+						break;
+					}
+					else if (curVersion < version_num)
+					{
+						//更新版本到最新
+						updataKeyValueFromNumSets(VERSION, version_num);
+					}
+				}
+			}
+			//每次新加字段后,这里要检查一下,不存在则新增
+			{
+				QVariant v(1);
+				checkNoExistAdd(SKIN_KEY, v);
+			}
+
+			{
+				QVariant langs(0);
+				checkNoExistAdd(LANGS_KEY, langs);
+			}
+
+			{
+				QVariant v(0);
+				checkNoExistAdd(AUTOWARP_KEY, v);
+			}
+
+			{
+				QVariant v(0);
+				checkNoExistAdd(INDENT_KEY, v);
+			}
+
+			{
+				QVariant v(100);
+				checkNoExistAdd(MAX_BIG_TEXT, v);
+			}
+
+			{
+				QVariant v(0);
+				checkNoExistAdd(SOFT_STATUS, v);
+			}
+
+			{
+				QVariant v("0");
+				checkNoExistAdd(SOFT_KEY, v);
+			}
+
+			{
+				QVariant v(1);
+				checkNoExistAdd(RESTORE_CLOSE_FILE, v);
+			}
+
+			{
+				QVariant v(1);
+				checkNoExistAdd(ICON_SIZE, v);
+			}
+
+			{
+				QVariant v(100);
+				checkNoExistAdd(ZOOMVALUE, v);
+			}
+			{
+				QVariant v(Qt::BottomDockWidgetArea);
+				checkNoExistAdd(FINDRESULTPOS, v);
+			}
+		} while (false);
+
+	}
+
+	s_isExistDb = initOk;
+
+}
+
+
+//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口
+QString NddSetting::getKeyValueFromSets(QString key)
+{
+	return s_nddSet->value(key,"").toString();
+}
+
+bool NddSetting::updataKeyValueFromSets(QString key, QString value)
+{
+	s_nddSet->setValue(key,value);
+	s_isContentChanged = true;
+	return true;
+}
+
+//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口
+QByteArray NddSetting::getKeyByteArrayValue(QString key)
+{
+	return s_nddSet->value(key, "").toByteArray();
+}
+
+void NddSetting::updataKeyByteArrayValue(QString key, QByteArray& value)
+{
+	s_nddSet->setValue(key, QVariant(value));
+	s_isContentChanged = true;
+}
+
+//第一次加一条记录,用于初始化
+void NddSetting::addKeyValueToSets(QString key, QString value)
+{
+	s_nddSet->setValue(key, QVariant(value));
+}
+
+
+//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口.0做默认值,外部最好不用0做初始化值
+int NddSetting::getKeyValueFromNumSets(const QString key)
+{
+	QVariant v = s_nddSet->value(key, QVariant(0));
+	return v.toInt();
+}
+
+bool NddSetting::updataKeyValueFromNumSets(const QString key, int value)
+{
+	s_nddSet->setValue(key, QVariant(value));
+	return true;
+}
+
+
+//第一次加一条记录,用于初始化
+void NddSetting::addKeyValueToNumSets(QString key, int value)
+{
+	s_nddSet->setValue(key, QVariant(value));
+}
+
+
+void NddSetting::close()
+{
+	if (s_reference > 0)
+	{
+		--s_reference;
+
+		if (s_reference == 0)
+		{
+			s_isExistDb = false;
+
+			//做一次真正的保存
+			if (s_isContentChanged)
+			{
+				s_nddSet->sync();
+				delete s_nddSet;
+				s_nddSet = nullptr;
+				s_isContentChanged = false;	
+			}
+		}
+	}
+}
+

+ 58 - 0
src/nddsetting.h

@@ -0,0 +1,58 @@
+#pragma once
+#include <QSettings>
+#include <QVariant>
+
+static QString SKIN_KEY = "skinid";
+static QString LANGS_KEY = "langs";
+static QString AUTOWARP_KEY = "warp";
+static QString INDENT_KEY = "indent";
+static QString MAX_BIG_TEXT = "maxtsize";
+static QString SOFT_STATUS = "rstatus";
+static QString SOFT_KEY = "rkey";
+static QString RESTORE_CLOSE_FILE = "restore"; //恢复关闭时打开的文件
+static QString PRO_DIR = "prodir";//放置配置文件的路径
+//static QString RESTORE_SIZE = "rsize";//保存关闭时的大小
+static QString WIN_POS = "pos";//保存关闭是的大小
+static QString ICON_SIZE = "iconsize";//图标大小
+static QString ZOOMVALUE = "zoom"; //放大倍数
+static QString VERSION = "version";//当前版本
+static QString FINDRESULTPOS = "findpos";//查找窗口悬浮的位置
+
+class NddSetting
+{
+public:
+	static bool checkNoExistAdd(QString key, QVariant & value);
+
+	static void init();
+
+	static QString getKeyValueFromSets(QString key);
+
+	static bool updataKeyValueFromSets(QString key, QString  value);
+
+	static QByteArray getKeyByteArrayValue(QString key);
+
+	static void updataKeyByteArrayValue(QString key, QByteArray & value);
+
+	static void addKeyValueToSets(QString  key, QString  value);
+
+	static int getKeyValueFromNumSets(const QString key);
+
+	static bool updataKeyValueFromNumSets(const QString key, int value);
+
+	static void addKeyValueToNumSets(QString key, int value);
+
+	static void close();
+
+	static bool isDbExist()
+	{
+		return s_isExistDb;
+	}
+
+private:
+
+	static bool s_isExistDb;
+	static bool s_isContentChanged;
+	static int s_reference;
+
+	static QSettings* s_nddSet;
+};

+ 139 - 15
src/qscidisplaywindow.cpp

@@ -9,8 +9,9 @@
 #include <QProcess>
 #include <QMessageBox>
 #include <stdexcept>
+#include <SciLexer.h>
 
-QsciDisplayWindow::QsciDisplayWindow(QWidget *parent):QsciScintilla(parent), m_textFindWin(nullptr), m_preFirstLineNum(0), m_isShowFindItem(true)
+QsciDisplayWindow::QsciDisplayWindow(QWidget *parent):QsciScintilla(parent), m_textFindWin(nullptr), m_preFirstLineNum(0), m_isShowFindItem(true), m_hasHighlight(false)
 {
 	//20210815 左右行同步还有问题,暂时不屏蔽,不实现
 	connect(this->verticalScrollBar(), &QScrollBar::valueChanged, this, &QsciDisplayWindow::slot_scrollYValueChange);
@@ -37,21 +38,29 @@ QsciDisplayWindow::QsciDisplayWindow(QWidget *parent):QsciScintilla(parent), m_t
 	}
 
 	//这个无比要设置false,否则双击后高亮单词,拷贝时会拷贝多个选择。
-	execute(SCI_SETMULTIPLESELECTION, false);
+	execute(SCI_SETMULTIPLESELECTION, true);
 	execute(SCI_SETMULTIPASTE, 1);
 	execute(SCI_SETADDITIONALCARETSVISIBLE, false);
 	execute(SCI_SETSELFORE, true, 0x0);
 	execute(SCI_SETSELBACK, true, 0x00ffff);
 
-	QColor foldfgColor(StyleSet::foldfgColor);
-	QColor foldbgColor(StyleSet::foldbgColor);//默认0xff,0xff,0xff
+	//QColor foldfgColor(StyleSet::foldfgColor);
+	//QColor foldbgColor(StyleSet::foldbgColor);//默认0xff,0xff,0xff
 
-	//通过fold发现,尽量使用qscint的功能,因为他做了大量封装和简化
-	setFolding(BoxedTreeFoldStyle, 2);
-	setFoldMarginColors(foldfgColor, foldbgColor);
-	setMarginsBackgroundColor(StyleSet::marginsBackgroundColor); //0xea, 0xf7, 0xff //默认0xf0f0f0
+	////通过fold发现,尽量使用qscint的功能,因为他做了大量封装和简化
+	//setFolding(BoxedTreeFoldStyle, 2);
+	//setFoldMarginColors(foldfgColor, foldbgColor);
+	//setMarginsBackgroundColor(StyleSet::marginsBackgroundColor); //0xea, 0xf7, 0xff //默认0xf0f0f0
 
+		//双击后同样的字段进行高亮
+	execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_SMART, INDIC_ROUNDBOX);
+	execute(SCI_INDICSETALPHA, SCE_UNIVERSAL_FOUND_STYLE_SMART, 100);
+	execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_FOUND_STYLE_SMART, false);
+	execute(SCI_INDICSETFORE, SCE_UNIVERSAL_FOUND_STYLE_SMART, 0x00ff00);
 
+	//开启后可以保证长行在滚动条下完整显示
+	execute(SCI_SETSCROLLWIDTHTRACKING, true);
+	connect(this, &QsciScintilla::selectionChanged, this, &QsciDisplayWindow::slot_clearHightWord, Qt::QueuedConnection);
 	connect(this, &QsciDisplayWindow::delayWork, this, &QsciDisplayWindow::slot_delayWork, Qt::QueuedConnection);
 }
 
@@ -90,10 +99,129 @@ void QsciDisplayWindow::mouseDoubleClickEvent(QMouseEvent * e)
 	}
 }
 
+void QsciDisplayWindow::clearIndicator(int indicatorNumber) {
+	size_t docStart = 0;
+	size_t docEnd = length();
+	execute(SCI_SETINDICATORCURRENT, indicatorNumber);
+	execute(SCI_INDICATORCLEARRANGE, docStart, docEnd - docStart);
+};
+
 const int MAXLINEHIGHLIGHT = 400;
 
+void QsciDisplayWindow::slot_clearHightWord()
+{
+	if (m_hasHighlight)
+	{
+		m_hasHighlight = false;
+		clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
+	}
+}
+
+
+void QsciDisplayWindow::highlightViewWithWord(QString & word2Hilite)
+{
+	int originalStartPos = execute(SCI_GETTARGETSTART);
+	int originalEndPos = execute(SCI_GETTARGETEND);
+
+	int firstLine = static_cast<int>(this->execute(SCI_GETFIRSTVISIBLELINE));
+	int nbLineOnScreen = this->execute(SCI_LINESONSCREEN);
+	int nbLines = std::min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
+	int lastLine = firstLine + nbLines;
+	int startPos = 0;
+	int endPos = 0;
+	auto currentLine = firstLine;
+	int prevDocLineChecked = -1;	//invalid start
+
+
+	auto searchMark = [this](int &startPos, int &endPos, QByteArray &word2Mark) {
+
+		int targetStart = 0;
+		int targetEnd = 0;
+
+		long lens = word2Mark.length();
+
+		while (targetStart >= 0)
+		{
+			execute(SCI_SETTARGETRANGE, startPos, endPos);
+
+			targetStart = SendScintilla(SCI_SEARCHINTARGET, lens, word2Mark.data());
+
+			if (targetStart == -1 || targetStart == -2)
+				break;
+
+			targetEnd = int(this->execute(SCI_GETTARGETEND));
+
+			if (targetEnd > endPos)
+			{
+				//we found a result but outside our range, therefore do not process it
+				break;
+			}
+
+			int foundTextLen = targetEnd - targetStart;
+
+			if (foundTextLen > 0)
+			{
+				this->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_SMART);
+				this->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
+			}
+
+			if (targetStart + foundTextLen == endPos)
+				break;
+
+			startPos = targetStart + foundTextLen;
+
+		}
+	};
+
+
+	QByteArray whatMark = word2Hilite.toUtf8();
+
+	SendScintilla(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_MATCHCASE | SCFIND_WHOLEWORD | SCFIND_REGEXP_SKIPCRLFASONE);
+
+	for (; currentLine < lastLine; ++currentLine)
+	{
+		int docLine = static_cast<int>(this->execute(SCI_DOCLINEFROMVISIBLE, currentLine));
+		if (docLine == prevDocLineChecked)
+			continue;	//still on same line (wordwrap)
+		prevDocLineChecked = docLine;
+		startPos = static_cast<int>(this->execute(SCI_POSITIONFROMLINE, docLine));
+		endPos = static_cast<int>(this->execute(SCI_POSITIONFROMLINE, docLine + 1));
+
+		if (endPos == -1)
+		{	//past EOF
+			endPos = this->length() - 1;
+			searchMark(startPos, endPos, whatMark);
+			break;
+		}
+		else
+		{
+			searchMark(startPos, endPos, whatMark);
+		}
+	}
+
+	m_hasHighlight = true;
+
+	// restore the original targets to avoid conflicts with the search/replace functions
+	this->execute(SCI_SETTARGETRANGE, originalStartPos, originalEndPos);
+}
+
+
+
 void QsciDisplayWindow::slot_delayWork()
 {
+
+	if (!hasSelectedText())
+	{
+		return;
+	}
+
+	QString word = selectedText();
+	if (!word.isEmpty())
+	{
+		highlightViewWithWord(word);
+	}
+
+#if 0
 	if (!hasSelectedText())
 	{
 		return;
@@ -156,6 +284,7 @@ void QsciDisplayWindow::slot_delayWork()
 			execute(SCI_SETMAINSELECTION, mainSelect - 1);
 		}
 	}
+#endif
 }
 
 void QsciDisplayWindow::setMediator(MediatorDisplay* mediator)
@@ -232,10 +361,10 @@ void QsciDisplayWindow::updateLineNumberWidth()
 		auto lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis);
 
 		nbDigits = nbDigitsFromNbLines(lastVisibleLineDoc);
-		nbDigits = nbDigits < 3 ? 3 : nbDigits;
+		nbDigits = nbDigits < 4 ? 4 : nbDigits;
 		
 		auto pixelWidth = 8 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<sptr_t>("8"));
-		execute(SCI_SETMARGINWIDTHN, 3, pixelWidth);
+		execute(SCI_SETMARGINWIDTHN, MARGIN_LINE_NUM, pixelWidth);
 	}
 }
 
@@ -267,11 +396,6 @@ void QsciDisplayWindow::setDirection(RC_DIRECTION direction)
 	m_direction = direction;
 }
 
-void QsciDisplayWindow::travEveryBlockToSave(std::function<void(QString&, int)> savefun, QList<BlockUserData*>* externLineInfo)
-{
-
-}
-
 int QsciDisplayWindow::getCurVerticalScrollValue()
 {
 	return this->verticalScrollBar()->value();

+ 6 - 3
src/qscidisplaywindow.h

@@ -31,7 +31,6 @@ public:
 	void setMediator(MediatorDisplay* mediator);
 	
 	void setDirection(RC_DIRECTION direction);
-	void travEveryBlockToSave(std::function<void(QString&, int)> savefun, QList<BlockUserData*>* externLineInfo);
 
 	//获取当前垂直进度条的滚动位置
 	int getCurVerticalScrollValue();
@@ -45,7 +44,7 @@ public:
 	{
 		m_filePath = v;
 	}
-
+	void autoAdjustLineWidth(int xScrollValue);
 signals:
 	void delayWork();
 	void sign_find(bool v=true);
@@ -64,7 +63,10 @@ protected:
 	void contextUserDefineMenuEvent(QMenu* menu) override;
 	void inputMethodEvent(QInputMethodEvent* event) override;
 	void mouseDoubleClickEvent(QMouseEvent *e) override;
-	void autoAdjustLineWidth(int xScrollValue);
+	void clearIndicator(int indicatorNumber);
+	void slot_clearHightWord();
+	void highlightViewWithWord(QString & word2Hilite);
+
 
 	void updateLineNumberWidth();
 
@@ -85,4 +87,5 @@ private:
 	SCINTILLA_PTR  m_pScintillaPtr = 0;
 
 	bool m_isShowFindItem;
+	bool m_hasHighlight;
 };

+ 1 - 1
src/qscint/scintilla/boostregex/BoostRegExSearch.cpp

@@ -37,7 +37,7 @@
 #include "BoostRegexSearch.h"
 #include <boost/regex.hpp>
 #include <boost/throw_exception.hpp>
-#include "..\include\BoostRegexSearch.h"
+#include "BoostRegexSearch.h"
 #define CP_UTF8 65001
 #define SC_CP_UTF8 65001
 

+ 1 - 0
src/qscint/scintilla/include/SciLexer.h

@@ -268,6 +268,7 @@
 #define SCE_TXT_DEFAULT 0
 #define SCE_TXT_ASCII 1
 #define SCE_TXT_KEYWORD 2
+#define SCE_TXT_IDENTIFIER 4
 
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1

+ 102 - 100
src/qscint/scintilla/lexers/LexTXT.cpp

@@ -31,37 +31,17 @@
 
 using namespace Scintilla;
 
-const char styleSubable[] = { SCE_P_IDENTIFIER, 0 };
+//const char styleSubable[] = { SCE_P_IDENTIFIER, 0 };
 
 //Default = 0,//中文
 //Ascii = 1,//英文
 //Keyword = 2, //关键字,只有以TXT为母版的
 
 LexicalClass lexicalClasses[] = {
-
-#if 1
 	// Lexer Python SCLEX_PYTHON SCE_P_:
 	0, "SCE_TXT_DEFAULT", "default", "utf8 char",
 	1, "SCE_TXT_ASCII", "Ascii", "Ascii",
 	2, "SCE_TXT_KEYWORD", "keyword", "keyword",
-	/*3, "SCE_P_STRING", "literal string", "String",
-	4, "SCE_P_CHARACTER", "literal string", "Single quoted string",
-	5, "SCE_P_WORD", "keyword", "Keyword",
-	6, "SCE_P_TRIPLE", "literal string", "Triple quotes",
-	7, "SCE_P_TRIPLEDOUBLE", "literal string", "Triple double quotes",
-	8, "SCE_P_CLASSNAME", "identifier", "Class name definition",
-	9, "SCE_P_DEFNAME", "identifier", "Function or method name definition",
-	10, "SCE_P_OPERATOR", "operator", "Operators",
-	11, "SCE_P_IDENTIFIER", "identifier", "Identifiers",
-	12, "SCE_P_COMMENTBLOCK", "comment", "Comment-blocks",
-	13, "SCE_P_STRINGEOL", "error literal string", "End of line where string is not closed",
-	14, "SCE_P_WORD2", "identifier", "Highlighted identifiers",
-	15, "SCE_P_DECORATOR", "preprocessor", "Decorators",
-	16, "SCE_P_FSTRING", "literal string interpolated", "F-String",
-	17, "SCE_P_FCHARACTER", "literal string interpolated", "Single quoted f-string",
-	18, "SCE_P_FTRIPLE", "literal string interpolated", "Triple quoted f-string",
-	19, "SCE_P_FTRIPLEDOUBLE", "literal string interpolated", "Triple double quoted f-string",*/
-#endif
 };
 
 enum literalsAllowed { litNone = 0, litU = 1, litB = 2, litF = 4 };
@@ -92,13 +72,13 @@ struct OptionSetTxt : public OptionSet<OptionsTxt> {
 class LexTXT :public DefaultLexer
 {
 	WordList keywords;
-	SubStyles subStyles;
+	//SubStyles subStyles;
 	OptionsTxt options;
 	OptionSetTxt osTxt;
 public:
 	explicit LexTXT() :
-		DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses)),
-		subStyles(styleSubable, 0x80, 0x40, 0) {
+		DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses))/*,
+		subStyles(styleSubable, 0x80, 0x40, 0)*/ {
 	}
 	virtual ~LexTXT() {}
 
@@ -133,34 +113,34 @@ public:
 		return SC_LINE_END_TYPE_UNICODE;
 	}
 
-	int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
-		return subStyles.Allocate(styleBase, numberStyles);
-	}
-	int SCI_METHOD SubStylesStart(int styleBase) override {
-		return subStyles.Start(styleBase);
-	}
-	int SCI_METHOD SubStylesLength(int styleBase) override {
-		return subStyles.Length(styleBase);
-	}
-	int SCI_METHOD StyleFromSubStyle(int subStyle) override {
-		const int styleBase = subStyles.BaseStyle(subStyle);
-		return styleBase;
-	}
+	//int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
+	//	return subStyles.Allocate(styleBase, numberStyles);
+	//}
+	//int SCI_METHOD SubStylesStart(int styleBase) override {
+	//	return subStyles.Start(styleBase);
+	//}
+	//int SCI_METHOD SubStylesLength(int styleBase) override {
+	//	return subStyles.Length(styleBase);
+	//}
+	//int SCI_METHOD StyleFromSubStyle(int subStyle) override {
+	//	const int styleBase = subStyles.BaseStyle(subStyle);
+	//	return styleBase;
+	//}
 	int SCI_METHOD PrimaryStyleFromStyle(int style) override {
 		return style;
 	}
-	void SCI_METHOD FreeSubStyles() override {
-		subStyles.Free();
-	}
-	void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
-		subStyles.SetIdentifiers(style, identifiers);
-	}
+	//void SCI_METHOD FreeSubStyles() override {
+	//	subStyles.Free();
+	//}
+	//void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
+	//	subStyles.SetIdentifiers(style, identifiers);
+	//}
 	int SCI_METHOD DistanceToSecondaryStyles() override {
 		return 0;
 	}
-	const char *SCI_METHOD GetSubStyleBases() override {
-		return styleSubable;
-	}
+	//const char *SCI_METHOD GetSubStyleBases() override {
+	//	return styleSubable;
+	//}
 
 	static ILexer *LexerFactoryTxt() {
 		return new LexTXT();
@@ -196,15 +176,19 @@ Sci_Position SCI_METHOD LexTXT::WordListSet(int n, const char *wl) {
 
 const int indicatorWhitespace = 1;
 
-inline bool IsAWordChar(int ch, bool unicodeIdentifiers) {
-	if (ch < 0x80)
-		return (isalnum(ch) || ch == '.' || ch == '_');
+//inline bool IsAWordChar(int ch, bool unicodeIdentifiers) {
+//	if (ch < 0x80)
+//		return (isalnum(ch) || ch == '.' || ch == '_');
+//
+//	if (!unicodeIdentifiers)
+//		return false;
+//
+//	// Python uses the XID_Continue set from unicode data
+//	return IsXidContinue(ch);
+//}
 
-	if (!unicodeIdentifiers)
-		return false;
-
-	// Python uses the XID_Continue set from unicode data
-	return IsXidContinue(ch);
+inline bool IsAAsciiChar(int ch) {
+	return (ch < 0x80);
 }
 
 inline bool IsAWordStart(int ch, bool unicodeIdentifiers) {
@@ -224,51 +208,69 @@ void SCI_METHOD LexTXT::Lex(Sci_PositionU startPos, Sci_Position length, int ini
 
 	const Sci_Position endPos = startPos + length;
 
-	// Backtrack to previous line in case need to fix its tab whinging
-	Sci_Position lineCurrent = styler.GetLine(startPos);
-	if (startPos > 0) {
-		if (lineCurrent > 0) {
-			lineCurrent--;
-			// Look for backslash-continued lines
-			while (lineCurrent > 0) {
-				Sci_Position eolPos = styler.LineStart(lineCurrent) - 1;
-				const int eolStyle = styler.StyleAt(eolPos);
-				if (eolStyle == SCE_P_STRING
-					|| eolStyle == SCE_P_CHARACTER
-					|| eolStyle == SCE_P_STRINGEOL) {
-					lineCurrent -= 1;
+	//// Backtrack to previous line in case need to fix its tab whinging
+	//Sci_Position lineCurrent = styler.GetLine(startPos);
+	//if (startPos > 0) {
+	//	if (lineCurrent > 0) {
+	//		lineCurrent--;
+	//		// Look for backslash-continued lines
+	//		while (lineCurrent > 0) {
+	//			Sci_Position eolPos = styler.LineStart(lineCurrent) - 1;
+	//			const int eolStyle = styler.StyleAt(eolPos);
+	//			if (eolStyle == SCE_P_STRING
+	//				|| eolStyle == SCE_P_CHARACTER
+	//				|| eolStyle == SCE_P_STRINGEOL) {
+	//				lineCurrent -= 1;
+	//			}
+	//			else {
+	//				break;
+	//			}
+	//		}
+	//		startPos = styler.LineStart(lineCurrent);
+	//	}
+	//	initStyle = (startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1));
+	//}
+
+	//initStyle = initStyle & 31;
+	//if (initStyle == SCE_P_STRINGEOL) {
+	//	initStyle = SCE_P_DEFAULT;
+	//}
+
+	StyleContext sc(startPos, endPos - startPos, initStyle, styler);
+
+	Sci_Position startIndicator = sc.currentPos;
+
+
+	for (; sc.More();) {
+
+		// Check for a new state starting character
+		if (sc.state == SCE_TXT_DEFAULT)
+		{
+			//遇到下一个ASCII字符的时候,进入识别状态
+			if (IsAAsciiChar(sc.ch))
+			{
+				sc.SetState(SCE_TXT_IDENTIFIER);
 				}
-				else {
-					break;
 				}
+		else if (sc.state == SCE_TXT_ASCII)
+		{
+			//遇到下一个非ASCII字符的时候,进入识别状态
+			if (!IsAAsciiChar(sc.ch))
+			{
+				sc.SetState(SCE_TXT_IDENTIFIER);
 			}
-			startPos = styler.LineStart(lineCurrent);
 		}
-		initStyle = (startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1));
-	}
-
-	initStyle = initStyle & 31;
-	if (initStyle == SCE_P_STRINGEOL) {
-		initStyle = SCE_P_DEFAULT;
-	}
 
-	StyleContext sc(startPos, endPos - startPos, initStyle, styler);
+		if (sc.state == SCE_TXT_IDENTIFIER) {
 
-	Sci_Position startIndicator = sc.currentPos;
-
-
-	for (; sc.More();) {
-
-		if (sc.state == SCE_P_IDENTIFIER) {
-
 			//txt就三种状态、英文、中文、自定义关键字。默认是中文。
 			//遇到非字符和非数字,开始检测单词,是关键字则识别为关键字;若不是关键字,则肯定是英文字符
-			//关键字是英文,不是中文。
-
-			if ((sc.ch == '.') || (!IsAWordChar(sc.ch, false))) {
+	
+			//如果遇到非ASCII字符,则开始检查
+			if (!IsAAsciiChar(sc.ch)) {
 				char s[1000];
 				sc.GetCurrent(s, sizeof(s));
-				int style = SCE_P_IDENTIFIER;
+				int style = SCE_TXT_IDENTIFIER;
 				if (keywords.InList(s)) 
 		{
 					style = SCE_TXT_KEYWORD;
@@ -286,20 +288,20 @@ void SCI_METHOD LexTXT::Lex(Sci_PositionU startPos, Sci_Position length, int ini
 		}
 	}
 
-		// Check for a new state starting character
-		if (sc.state == SCE_TXT_DEFAULT)
-	{
-			//遇到下一个英文字符的时候,进入识别状态
-			if (IsAWordStart(sc.ch, false)) 
-	{
-				sc.SetState(SCE_P_IDENTIFIER);
-	}
-		}
 		sc.Forward();
 	}
 	
-	//这里看起来最后一段中文,会识别不出来。因为上面的循环不能识别最后一段是中文的情况。
-	//不过中文本来默认就是0,就算识别不到,本来就是默认的值。所有是没有问题的。
+	//最后一段不能遗漏,也需要识别
+	if (IsAAsciiChar(sc.ch))
+	{
+		sc.ChangeState(SCE_TXT_ASCII);
+	}
+	else
+	{
+		sc.ChangeState(SCE_TXT_DEFAULT);
+	}
+
+	sc.SetState(SCE_TXT_DEFAULT);
 
 	styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);
 	sc.Complete();

+ 1 - 1
src/qscint/src/Qsci/qscilexer.h

@@ -53,7 +53,7 @@ enum LangType {
 	L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \
 	L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \
 	L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT, \
-	L_EDIFACT, L_MARKDOWN, L_OCTAVE, L_PO, L_POV, L_IDL, L_GO, L_TXT, \
+	L_EDIFACT, L_MARKDOWN, L_OCTAVE, L_PO, L_POV, L_IDL, L_GO, L_GLOBAL, L_TXT, \
 	// Don't use L_JS, use L_JAVASCRIPT instead
 	// The end of enumated language type, so it should be always at the end
 	L_EXTERNAL = 100, L_USER_DEFINE=200,L_USER_TXT,L_USER_CPP //用户自定义顺序与UserLangMother保存一致

+ 22 - 0
src/qscint/src/Qsci/qscilexerglobal.h

@@ -0,0 +1,22 @@
+#pragma once
+#include <QObject>
+#include <Qsci/qsciglobal.h>
+#include <Qsci/qscilexer.h>
+
+
+class QsciScintilla;
+class QsciStyle;
+
+class QSCINTILLA_EXPORT QsciLexerGlobal  : public QsciLexer
+{
+	Q_OBJECT
+
+public:
+	QsciLexerGlobal(QObject *parent=0);
+	virtual ~QsciLexerGlobal();
+
+	int lexerId() const;
+	const char* language() const;
+	QString description(int style) const;
+	QFont defaultFont(int style) const;
+};

+ 2 - 1
src/qscint/src/ScintillaQt.cpp

@@ -172,8 +172,9 @@ void QsciScintillaQt::StartDrag()
     if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
         ClearSelection();
 
-    SetDragPosition(Scintilla::SelectionPosition());
     inDragDrop = ddNone;
+    SetDragPosition(Scintilla::SelectionPosition(INVALID_POSITION));
+  
 }
 
 

+ 2 - 2
src/qscint/src/qscilexer.cpp

@@ -36,7 +36,7 @@ QFont QsciLexer::s_defaultLangFont("Courier New", QsciLexer::s_defaultFontSize);
 #elif defined(Q_OS_MAC)
 QFont QsciLexer::s_defaultLangFont("Menlo", s_defaultFontSize);
 #else
-QFont QsciLexer::s_defaultLangFont("Bitstream Vera Sans", 9);
+QFont QsciLexer::s_defaultLangFont("Courier 10 Pitch", 14);
 #endif
 
 // The ctor.
@@ -816,4 +816,4 @@ const char* QsciLexer::getUserDefineKeywords()
 
 	return m_userDefineKeyword.data();
 
-}
+}

+ 43 - 0
src/qscint/src/qscilexerglobal.cpp

@@ -0,0 +1,43 @@
+#include "Qsci/qscilexerglobal.h"
+#include "Qsci/qsciscintilla.h"
+
+QsciLexerGlobal::QsciLexerGlobal(QObject *parent)
+	: QsciLexer(parent)
+{}
+
+QsciLexerGlobal::~QsciLexerGlobal()
+{}
+
+int QsciLexerGlobal::lexerId() const
+{
+	return L_GLOBAL;
+}
+
+// Returns the language name.
+const char* QsciLexerGlobal::language() const
+{
+	return "Gloabl";
+}
+
+QString QsciLexerGlobal::description(int style) const
+{
+	if (style == 0)
+	{
+		return "All Language Modify";
+	}
+
+	return QString();
+}
+
+QFont QsciLexerGlobal::defaultFont(int style) const
+{
+	switch (style)
+	{
+	case 0:
+		return QsciLexer::s_defaultLangFont;
+		break;
+	default:
+		break;
+	}	
+	return QsciLexer::s_defaultLangFont;
+}

+ 2 - 2
src/qscint/src/qscilexertext.cpp

@@ -10,7 +10,7 @@ QFont QsciLexerText::s_defaultTxtFont(u8"宋体", QsciLexer::s_defaultFontSize);
 #elif defined(Q_OS_MAC)
     QFont QsciLexerText::s_defaultTxtFont("STSong",18);
 #else
-        QFont QsciLexerText::s_defaultTxtFont(u8"CESI宋体-GB2312",12);
+    QFont QsciLexerText::s_defaultTxtFont("Courier 10 Pitch", 14);
 #endif
 
 
@@ -72,7 +72,7 @@ QFont QsciLexerText::defaultFont(int style) const
 	{
 	case Default:
 #if defined(Q_OS_WIN)
-		return s_defaultTxtFont; // QFont("Microsoft YaHei", QsciLexer::s_defaultFontSize);
+		return s_defaultTxtFont; 
 #elif defined(Q_OS_MAC)
 		//return QFont("Courier", 12);
 		return s_defaultTxtFont;

+ 4 - 2
src/qscint/src/qscintilla.pro

@@ -117,7 +117,8 @@ HEADERS = \
     ./Qsci/qscilexeredifact.h \
     ./Qsci/qscilexerfortran.h \
     ./Qsci/qscilexerfortran77.h \
-    ./Qsci/qscilexergo.h \
+	./Qsci/qscilexergo.h \
+    ./Qsci/qscilexerglobal.h \
     ./Qsci/qscilexertext.h \
     ./Qsci/qscilexerhtml.h \
     ./Qsci/qscilexeridl.h \
@@ -244,7 +245,8 @@ SOURCES = \
     qscilexeredifact.cpp \
     qscilexerfortran.cpp \
     qscilexerfortran77.cpp \
-    qscilexergo.cpp \
+	qscilexergo.cpp \
+    qscilexerglobal.cpp \
     qscilexertext.cpp \
     qscilexerhtml.cpp \
     qscilexeridl.cpp \

+ 651 - 96
src/qtlangset.cpp

@@ -1,14 +1,16 @@
 #include "qtlangset.h"
 #include "scintillaeditview.h"
-#include "jsondeploy.h"
+#include "nddsetting.h"
 #include "rcglobal.h"
+#include "ccnotepad.h"
+
 #include <SciLexer.h>
 #include <qscilexer.h>
 #include <QSettings>
 #include <QColorDialog> 
 #include <QMessageBox>
 #include <QSpinBox>
-#include <QDebug>
+//#include <QDebug>
 #include <QDir>
 
 #if 0
@@ -36,7 +38,7 @@ enum LangType {
 
 
 QtLangSet::QtLangSet(QString initTag, QWidget *parent)
-	: QMainWindow(parent), m_selectLexer(nullptr), m_selectStyleId(0), m_isStyleChange(false),m_isStyleChildChange(false), m_initShowLexerTag(initTag), m_previousSysLangItem(nullptr)
+	: QMainWindow(parent), m_selectLexer(nullptr), m_selectStyleId(0), m_isStyleChange(false),m_isStyleChildChange(false), m_initShowLexerTag(initTag), m_previousSysLangItem(nullptr),m_isGlobelItem(false)
 {
 	ui.setupUi(this);
 	initLangList();
@@ -55,6 +57,26 @@ QtLangSet::~QtLangSet()
 }
 
 
+//在同步字体时,务必先关闭关联槽函数,避免循环触发。务必配对使用
+void QtLangSet::enableFontChangeSensitive(bool isSensitive)
+{
+	if (isSensitive)
+	{
+		connect(ui.boldCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontBoldChange);
+		connect(ui.italicCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontItalicChange);
+		connect(ui.underlineCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontUnderlineChange);
+		connect(ui.fontSpinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_fontSizeChange(int)));
+		connect(ui.fontComboBox, &QFontComboBox::currentFontChanged, this, &QtLangSet::slot_fontChange);
+	}
+	else
+	{
+		disconnect(ui.boldCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontBoldChange);
+		disconnect(ui.italicCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontItalicChange);
+		disconnect(ui.underlineCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontUnderlineChange);
+		disconnect(ui.fontSpinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_fontSizeChange(int)));
+		disconnect(ui.fontComboBox, &QFontComboBox::currentFontChanged, this, &QtLangSet::slot_fontChange);
+	}
+}
 
 void QtLangSet::startSignSlot()
 {
@@ -62,9 +84,7 @@ void QtLangSet::startSignSlot()
 	//估计是QT5.12的bug。所以换成itemClicked信号
 	connect(ui.langListWidget, &QListWidget::itemClicked, this, &QtLangSet::slot_itemSelect);
 	connect(ui.userLangListWidget, &QListWidget::itemClicked, this, &QtLangSet::slot_userLangItemSelect);
-
-
-	connect(ui.styleListWidget, &QListWidget::currentItemChanged, this, &QtLangSet::slot_styleItemSelect);
+	connect(ui.styleListWidget, &QListWidget::itemClicked, this, &QtLangSet::slot_styleItemSelect);
 
 	connect(ui.boldCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontBoldChange);
 	connect(ui.italicCheckBox, &QCheckBox::stateChanged, this, &QtLangSet::slot_fontItalicChange);
@@ -119,7 +139,18 @@ void QtLangSet::slot_fontBoldChange(int state)
 			m_curStyleData.font.setBold((state == Qt::Unchecked) ? false : true);
 			m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
 			m_isStyleChange = true;
-			emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+
+			if (m_isGlobelItem)
+			{
+				if (ui.useGbFontBold->isChecked())
+				{
+					slot_useAlobalFontBold(true);
+				}
+			}
+			else
+			{
+				emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			}
 		}
 	}
 }
@@ -134,7 +165,17 @@ void QtLangSet::slot_fontItalicChange(int state)
 			m_curStyleData.font.setItalic((state == Qt::Unchecked) ? false : true);
 			m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
 			m_isStyleChange = true;
-			emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			if (m_isGlobelItem)
+			{
+				if (ui.useGbFontItalic->isChecked())
+				{
+					slot_useAlobalFontItalic(true);
+				}
+			}
+			else
+			{
+				emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			}
 		}
 	}
 }
@@ -149,26 +190,53 @@ void QtLangSet::slot_fontUnderlineChange(int state)
 			m_curStyleData.font.setUnderline((state == Qt::Unchecked) ? false : true);
 			m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
 			m_isStyleChange = true;
-			emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			if (m_isGlobelItem)
+			{
+				if (ui.useGbFontUnderline->isChecked())
+				{
+					slot_useAlobalFontUnderline(true);
+				}
+			}
+			else
+			{
+				emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			}
 		}
 	}
 }
 
+//发现一个qt现象:在debug断住该slot_fontSizeChange函数,会导致槽触发2次;不断住或者release模式直接跑,不会触发2次
 void QtLangSet::slot_fontSizeChange(int v)
 {
 	//即时设置风格
 	if (m_selectLexer != nullptr)
 	{
-		if (!ui.modifyAllFont->isChecked())
+		//全局修改,把所有语言的所有风格都设置
+		//全局修改,把所有语言的所有风格都设置
+		if (m_isGlobelItem)
 		{
-		if (m_curStyleData.font.pointSize() != v)
+			if (m_curStyleData.font.pointSize() != v)
+			{
+				m_curStyleData.font.setPointSize(v);
+				//qDebug() << m_curStyleData.font.family();
+				m_isStyleChange = true;
+				m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
+				if (ui.useGbFontSize->isChecked())
+				{
+					slot_useAlobalFontSize(true);
+				}
+			}
+		}
+		else if (!ui.modifyAllFont->isChecked())
 		{
-			m_curStyleData.font.setPointSize(v);
-			m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
-			m_isStyleChange = true;
+			if (m_curStyleData.font.pointSize() != v)
+			{
+				m_curStyleData.font.setPointSize(v);
+				m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
+				m_isStyleChange = true;
 				emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+			}
 		}
-	}
 		else
 		{
 			m_curStyleData.font.setPointSize(v);
@@ -190,7 +258,7 @@ void QtLangSet::slot_fontSizeChange(int v)
 					QFont f = m_selectLexer->font(styleId);
 					f.setPointSize(v);
 					m_selectLexer->setFont(f, styleId);
-}
+				}
 
 				saveCurLangSettings();
 				emit viewLexerChange(m_selectLexer->lexerTag());
@@ -199,26 +267,268 @@ void QtLangSet::slot_fontSizeChange(int v)
 	}
 }
 
-void QtLangSet::slot_fontChange(const QFont &font)
+
+void QtLangSet::getCurUseLexerTags(QVector<QString>& tag)
 {
-	//即时设置风格
-	if (m_selectLexer != nullptr)
+	CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
+	if (pMainNote != nullptr)
 	{
-		if (!ui.modifyAllFont->isChecked())
+		pMainNote->getCurUseLexerTags(tag);
+	}
+}
+
+//恢复原生的风格项目
+void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
+{
+	QFont oldfont;
+
+	for (int index = 0; index <= L_TXT; ++index)
+	{
+		QsciLexer *pLexer = ScintillaEditView::createLexer(index);
+		if (nullptr != pLexer)
 		{
-		if (m_curStyleData.font != font)
+
+			switch (flag)
+			{
+			case GLOBAL_FONT:
+			{
+				for (int i = 0; i <= 255; ++i)
+				{
+					if (!pLexer->description(i).isEmpty())
+					{
+						oldfont = pLexer->font(i);
+						oldfont.setFamily(m_curStyleData.font.family());
+						pLexer->setFont(oldfont, i);
+					}
+				}
+			}
+			break;
+			case GLOBAL_FONT_SIZE:
+			{
+				for (int i = 0; i <= 255; ++i)
+				{
+					if (!pLexer->description(i).isEmpty())
+					{
+						oldfont = pLexer->font(i);
+						oldfont.setPointSize(m_curStyleData.font.pointSize());
+						pLexer->setFont(oldfont, i);
+					}
+				}
+			}
+			break;
+			case GLOBAL_FONT_BOLD:
+			{
+				for (int i = 0; i <= 255; ++i)
+				{
+					if (!pLexer->description(i).isEmpty())
+					{
+						oldfont = pLexer->font(i);
+						oldfont.setBold(m_curStyleData.font.bold());
+						pLexer->setFont(oldfont, i);
+					}
+				}
+			}
+			break;
+			case GLOBAL_FONT_UNDERLINE:
+			{
+				for (int i = 0; i <= 255; ++i)
+				{
+					if (!pLexer->description(i).isEmpty())
+					{
+						oldfont = pLexer->font(i);
+						oldfont.setUnderline(m_curStyleData.font.underline());
+						pLexer->setFont(oldfont, i);
+					}
+				}
+			}
+			break;
+			case GLOBAL_FONT_ITALIC:
+			{
+				for (int i = 0; i <= 255; ++i)
+				{
+					if (!pLexer->description(i).isEmpty())
+					{
+						oldfont = pLexer->font(i);
+						oldfont.setItalic(m_curStyleData.font.italic());
+						pLexer->setFont(oldfont, i);
+					}
+				}
+			}
+			break;
+			case GLOBAL_FG_COLOR:
+			{
+				pLexer->setColor(m_curStyleData.color, -1);
+			}
+			break;
+			case GLOBAL_BK_COLOR:
+			{
+				pLexer->setPaper(m_curStyleData.paper, -1);
+			}
+			break;
+			default:
+				break;
+			}
+			
+			saveLangeSet(pLexer);
+		}
+		delete pLexer;
+	}
+}
+
+//恢复所有语言的初始配置。与restoreOriginLangOneStyle类似,但是粒度更大
+void  QtLangSet::restoreOriginLangAllStyle()
+{
+	QsciLexer *pLexer = nullptr;
+
+	//一旦重置,当前修改无条件不保存。否则避免当前的刚刚重置,又被保存
+	m_isStyleChange = false;
+
+	for (int index = 0; index <= L_TXT; ++index)
+	{
+
+		pLexer = ScintillaEditView::createLexer(index);
+
+		if (pLexer == nullptr)
 		{
-			QFont oldf = m_curStyleData.font;
-			m_curStyleData.font = font;
-			m_curStyleData.font.setBold(oldf.bold());
-			m_curStyleData.font.setItalic(oldf.italic());
-			m_curStyleData.font.setUnderline(oldf.underline());
+			continue;
+		}
 
-			m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
-			m_isStyleChange = true;
-				emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+		//如果存在自定义的配置,直接全部删除掉
+		QString cfgPath = QString("notepad/userstyle/%1").arg(pLexer->lexerTag());
+		QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
+
+		if (QFile::exists(qs.fileName()))
+		{
+			QFile::remove(qs.fileName());
 		}
+
+		delete pLexer;
+		pLexer = nullptr;
 	}
+}
+
+//恢复所有语言的初始配置,只恢复GLOBAL_STYLE_SET指定的风格
+void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag)
+{
+
+	QFont oldfont;
+	QFont curfont;
+
+	QColor oldClor;
+
+	for (int index = 0; index <= L_TXT; ++index)
+	{
+		QsciLexer *pLexer = ScintillaEditView::createLexer(index);
+		QsciLexer *pOriginLexer = ScintillaEditView::createLexer(index,"",true);
+		if (nullptr != pLexer)
+		{
+			for (int i = 0; i <= 255; ++i)
+			{
+				if (!pLexer->description(i).isEmpty())
+				{
+
+					switch (flag)
+					{
+					case GLOBAL_FONT:
+					{
+						oldfont = pOriginLexer->font(i);
+						pLexer->setFont(oldfont, i);
+					}
+					break;
+					case GLOBAL_FONT_SIZE:
+					{
+						oldfont = pOriginLexer->font(i);
+						curfont = pLexer->font(i);
+						curfont.setPointSize(oldfont.pointSize());
+						pLexer->setFont(curfont, i);
+					}
+					break;
+					case GLOBAL_FONT_BOLD:
+					{
+						oldfont = pOriginLexer->font(i);
+						curfont = pLexer->font(i);
+						curfont.setBold(oldfont.bold());
+						pLexer->setFont(curfont, i);
+					}
+					break;
+					case GLOBAL_FONT_UNDERLINE:
+					{
+						oldfont = pOriginLexer->font(i);
+						curfont = pLexer->font(i);
+						curfont.setUnderline(oldfont.underline());
+						pLexer->setFont(curfont, i);
+					}
+					break;
+					case GLOBAL_FONT_ITALIC:
+					{
+						oldfont = pOriginLexer->font(i);
+						curfont = pLexer->font(i);
+						curfont.setItalic(oldfont.italic());
+						pLexer->setFont(curfont, i);
+					}
+					break;
+					case GLOBAL_FG_COLOR:
+					{
+						oldClor = pOriginLexer->color(i);
+						pLexer->setColor(oldClor, i);
+					}
+					break;
+					case GLOBAL_BK_COLOR:
+					{
+						oldClor = pOriginLexer->paper(i);
+						pLexer->setPaper(oldClor, i);
+					}
+					break;
+					default:
+						break;
+					}
+				}
+			}
+			saveLangeSet(pLexer);
+		}
+		delete pLexer;
+		delete pOriginLexer;
+	}
+}
+//预览全局修改字体效果。把当前所有的语法,风格字体都修改一遍
+void QtLangSet::previewAllGoblalChange()
+{
+	QVector<QString> tags;
+
+	getCurUseLexerTags(tags);
+
+	for (int i = 0, s = tags.size(); i < s; ++i)
+	{
+		emit viewLexerChange(tags.at(i));
+	}
+}
+
+void QtLangSet::slot_fontChange(const QFont &font)
+{
+	//即时设置风格
+	if (m_selectLexer != nullptr)
+	{
+	  if (!ui.modifyAllFont->isChecked())
+	  {
+			if (m_curStyleData.font != font)
+			{
+				m_curStyleData.font.setFamily(font.family());
+				m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId);
+				m_isStyleChange = true;
+
+				if (m_isGlobelItem)
+				{
+					if (ui.useGbFont->isChecked())
+					{
+						slot_useAlobalFont(true);
+					}
+				}
+				else
+				{
+					emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, true);
+				}
+			}
+		}
 		else
 		{
 			//统一修改字体,大小和风格保存不变
@@ -250,7 +560,7 @@ void QtLangSet::slot_fontChange(const QFont &font)
 					newFont.setPointSize(f.pointSize());
 
 					m_selectLexer->setFont(newFont, styleId);
-}
+				}
 
 				saveCurLangSettings();
 				emit viewLexerChange(m_selectLexer->lexerTag());
@@ -268,13 +578,11 @@ void QtLangSet::initLangList()
 		if (nullptr != pLexer)
 		{
 			QString langName = pLexer->lexerTag();
-			//qDebug() << langName << pLexer->lexer();
 			QListWidgetItem *item = new QListWidgetItem(langName);
 			item->setData(Qt::UserRole,i);
 			ui.langListWidget->addItem(item);
 			delete pLexer;
 		}
-		
 	}
 
 	//怀疑这个是队列链接的,会延迟执行。故总是导致选择的选不中,而是第一个语言asp。
@@ -288,7 +596,7 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth
 	QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查
 	QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
 	qs.setIniCodec("UTF-8");
-	qDebug() << qs.fileName();
+	//qDebug() << qs.fileName();
 
 	if (!qs.contains("mz"))
 	{
@@ -310,7 +618,7 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth
 
 //初始化用户自定义的语言配置
 void QtLangSet::initUserDefineLangList()
-		{
+{
 	QString userLangDirPath = getUserLangDirPath();
 
 	//遍历文件夹
@@ -341,7 +649,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item)
 	if (item == nullptr)
 	{
 		return;
-		}
+	}
 	//qDebug() << item->text() << (previous ? previous->text() : 0);
 
 
@@ -352,9 +660,14 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item)
 	//保存前一个已经修改的。询问用户是否保存
 	if (m_isStyleChange && m_previousSysLangItem != nullptr && m_selectLexer !=nullptr)
 	{
-		if (QMessageBox::Yes == QMessageBox::question(this, tr("Save Change"), tr("%1 style configuration has been modified. Do you want to save it?").arg(m_previousSysLangItem->text())))
+		//只有当前是非全局,才需要提示用户是否要保持。
+		//全局的不需要提示,因为已经无条件全部保存过了。
+		if (!m_isGlobelItem)
 		{
-			saveCurLangSettings();
+			if (QMessageBox::Yes == QMessageBox::question(this, tr("Save Change"), tr("%1 style configuration has been modified. Do you want to save it?").arg(m_previousSysLangItem->text())))
+			{
+				saveCurLangSettings();
+			}
 		}
 	}
 
@@ -363,8 +676,6 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item)
 		item->setSelected(true);
 	}
 
-	int lexId = item->data(Qt::UserRole).toInt();
-
 	ui.styleListWidget->clear();
 
 	if (m_selectLexer != nullptr)
@@ -373,6 +684,36 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item)
 		m_selectLexer = nullptr;
 	}
 
+
+	int lexId = item->data(Qt::UserRole).toInt();
+
+	//全局的这个要单独对待,暂时没有任何风格。
+	if (lexId == L_GLOBAL)
+	{
+		m_isGlobelItem = true;
+		ui.stackedWidget->setCurrentIndex(1);
+
+		//全部修改模式下,目前暂时不存在修改所有的说法,目前就只能全部修改
+		ui.modiryAllColor->setChecked(false);
+		ui.modifyAllFont->setChecked(false);
+		ui.modiryAllColor->setEnabled(false);
+		ui.modifyAllFont->setEnabled(false);
+	}
+	else
+	{
+		m_isGlobelItem = false;
+		ui.stackedWidget->setCurrentIndex(0);
+
+		if (!ui.modiryAllColor->isEnabled())
+		{
+			ui.modiryAllColor->setEnabled(true);
+		}
+		if (!ui.modifyAllFont->isEnabled())
+		{
+			ui.modifyAllFont->setEnabled(true);
+		}
+	}
+
 	QsciLexer *pLexer = ScintillaEditView::createLexer(lexId);
 	if (nullptr != pLexer)
 	{
@@ -402,8 +743,8 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item)
 	if (itemtemp != nullptr)
 	{
 		itemtemp->setSelected(true);
-		slot_styleItemSelect(itemtemp, nullptr);
-}
+		slot_styleItemSelect(itemtemp);
+	}
 
 	m_isStyleChange = false;
 
@@ -461,8 +802,8 @@ void QtLangSet::displayUserMotherLangsStyle(QString langTagName, UserLangMother
 	if (itemtemp != nullptr)
 	{
 		itemtemp->setSelected(true);
-		slot_styleItemSelect(itemtemp, nullptr);
-}
+		slot_styleItemSelect(itemtemp);
+	}
 
 	m_isStyleChange = false;
 
@@ -477,6 +818,23 @@ void QtLangSet::slot_userLangItemSelect(QListWidgetItem *item)
 		return;
 	}
 
+	//肯定不能是全局设置了
+	if(m_isGlobelItem || (ui.stackedWidget->currentIndex() == 1))
+	{
+		m_isGlobelItem = false;
+		ui.stackedWidget->setCurrentIndex(0);
+
+		if (!ui.modiryAllColor->isEnabled())
+		{
+			ui.modiryAllColor->setEnabled(true);
+		}
+		if (!ui.modifyAllFont->isEnabled())
+		{
+			ui.modifyAllFont->setEnabled(true);
+		}
+	}
+
+
 	m_previousSysLangItem = nullptr;
 	ui.langListWidget->setCurrentItem(nullptr);
 
@@ -531,8 +889,8 @@ void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item)
 	}
 }
 //点击当前的风格item
-void QtLangSet::slot_styleItemSelect(QListWidgetItem *current, QListWidgetItem *previous)
-	{
+void QtLangSet::slot_styleItemSelect(QListWidgetItem *current)
+{
 #if 0
 	if (current != nullptr && m_selectLexer != nullptr)
 	{
@@ -564,6 +922,9 @@ void QtLangSet::fillBackgroundColor(QColor &bkColor)
 
 void QtLangSet::setStyleShow(QFont& font, QColor& fcColor, QColor &bkColor)
 {
+	//修改字体会触发槽函数执行,务必先关闭一下信号
+	enableFontChangeSensitive(false);
+
 	ui.fontComboBox->setCurrentFont(font);
 	ui.fontSpinBox->setValue(font.pointSize());
 
@@ -573,44 +934,46 @@ void QtLangSet::setStyleShow(QFont& font, QColor& fcColor, QColor &bkColor)
 
 	fillForegroundColor(fcColor);
 	fillBackgroundColor(bkColor);
+
+	enableFontChangeSensitive(true);
 	
 }
 
 //读取特定语言的设置
 bool QtLangSet::readLangSettings(QsciLexer *lexer, QString tag)
 {
-	QString cfgPath = QString("notepad/%1").arg(tag);
+	QString cfgPath = QString("notepad/userstyle/%1").arg(tag);
 
 	QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
 	if (QFile::exists(qs.fileName()))
 	{
-	return lexer->readSettings(qs);
-}
+		return lexer->readSettings(qs);
+	}
 	return false;
 }
 
-#if 0
-void QtLangSet::setCurSelectLang(QString tag)
+
+//保存一种语言的配置。
+void QtLangSet::saveLangeSet(QsciLexer *lexer)
 {
-	QList<QListWidgetItem*> destItem = ui.langListWidget->findItems(tag, Qt::MatchExactly);
-	if (!destItem.isEmpty())
+	if (lexer != nullptr)
 	{
-		QListWidgetItem* itemtemp = destItem.first();
-		itemtemp->setSelected(true);
-		//slot_itemSelect(itemtemp, nullptr);
+		QString tag = lexer->lexerTag();
+
+		QString cfgPath =  QString("notepad/userstyle/%1").arg(tag);
+
+		QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
+		lexer->writeSettings(qs);
+		qs.sync();
 	}
 }
-#endif
 
+//保存当前选定语言的配置
 bool QtLangSet::saveCurLangSettings()
 {
 	if (m_isStyleChange && m_selectLexer != nullptr)
 	{
-		QString tag = m_selectLexer->lexerTag();
-		QString cfgPath = QString("notepad/%1").arg(tag);
-
-		QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
-		m_selectLexer->writeSettings(qs);
+		saveLangeSet(m_selectLexer);
 		m_isStyleChange = false;
 		return true;
 	}
@@ -620,27 +983,49 @@ bool QtLangSet::saveCurLangSettings()
 //修改前景色
 void QtLangSet::slot_changeFgColor()
 {
-	QColor color = QColorDialog::getColor(Qt::white, this, tr("Style Foreground Color"));
+	QColor color = QColorDialog::getColor(m_curStyleData.color, this, tr("Style Foreground Color"));
 	if (color.isValid())
 	{
-		if (!ui.modiryAllColor->isChecked())
-		{
-		//当前前景色是否变化
-		if (m_curStyleData.color != color)
+		//全局修改,把所有语言的所有风格都设置
+		if (m_isGlobelItem)
 		{
-			m_curStyleData.color = color;
-			fillForegroundColor(color);
-			m_isStyleChange = true;
+			if (m_curStyleData.color != color)
+			{
+				m_curStyleData.color = color;
+				fillForegroundColor(color);
+				m_isStyleChange = true;
 
-			//即时设置风格
-			if (m_selectLexer != nullptr)
+				//即时设置风格
+				if (m_selectLexer != nullptr)
+				{
+					m_selectLexer->setColor(color, m_selectStyleId);
+				}
+
+				if (ui.useGbFc->isChecked())
+				{
+					slot_useAlobalFgColor(true);
+				}
+			}
+			
+		}
+		else if (!ui.modiryAllColor->isChecked())
+		{
+			//当前前景色是否变化
+			if (m_curStyleData.color != color)
 			{
+				m_curStyleData.color = color;
+				fillForegroundColor(color);
+				m_isStyleChange = true;
+
+				//即时设置风格
+				if (m_selectLexer != nullptr)
+				{
 					m_selectLexer->setColor(color, m_selectStyleId);
 
 					emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, color, m_curStyleData.paper, m_curStyleData.font, false);
+				}
 			}
 		}
-	}
 		else
 		{
 			//全部风格颜色修改
@@ -652,22 +1037,22 @@ void QtLangSet::slot_changeFgColor()
 			//即时设置风格
 			if (m_selectLexer != nullptr)
 			{
-				int row = ui.styleListWidget->count();
+				/*int row = ui.styleListWidget->count();
 
 				QListWidgetItem* item = nullptr;
 
 				for (int i = 0; i < row; ++i)
 				{
 					item = ui.styleListWidget->item(i);
-					int styleId = item->data(Qt::UserRole).toInt();
-					m_selectLexer->setColor(color, styleId);
-				}
+					int styleId = item->data(Qt::UserRole).toInt();*/
+					m_selectLexer->setColor(color, -1);
+				/*}*/
 
 				saveCurLangSettings();
 				emit viewLexerChange(m_selectLexer->lexerTag());
 			}
-	
-}
+			
+		}
 	}
 	
 }
@@ -675,9 +1060,33 @@ void QtLangSet::slot_changeFgColor()
 //修改背景色
 void QtLangSet::slot_changeBkColor()
 {
-	QColor color = QColorDialog::getColor(Qt::white, this, tr("Style Background Color"));
+	QColor color = QColorDialog::getColor(m_curStyleData.paper, this, tr("Style Background Color"));
 	if (color.isValid())
 	{
+		//全局修改,把所有语言的所有风格都设置
+		if (m_isGlobelItem)
+		{
+			if (m_curStyleData.paper != color)
+			{
+				m_curStyleData.paper = color;
+				fillBackgroundColor(color);
+				m_isStyleChange = true;
+
+				//即时设置风格
+				if (m_selectLexer != nullptr)
+				{
+					m_selectLexer->setPaper(color, m_selectStyleId);
+				}
+
+				if (ui.useGbBc->isChecked())
+				{
+					slot_useAlobalBkColor(true);
+				}
+			}
+
+		}
+		else if (!ui.modiryAllColor->isChecked())
+		{
 		//当前前景色是否变化
 		if (m_curStyleData.paper != color)
 		{
@@ -693,6 +1102,25 @@ void QtLangSet::slot_changeBkColor()
 			}
 		}
 	}
+		else
+		{
+			//全部风格颜色修改
+			//当前前景色是否变化
+			m_curStyleData.paper = color;
+			fillBackgroundColor(color);
+			m_isStyleChange = true;
+
+			//即时设置风格
+			if (m_selectLexer != nullptr)
+			{
+				m_selectLexer->setPaper(color, -1);
+				
+				saveCurLangSettings();
+				emit viewLexerChange(m_selectLexer->lexerTag());
+}
+
+		}
+	}
 }
 
 void QtLangSet::slot_saveClick()
@@ -700,37 +1128,164 @@ void QtLangSet::slot_saveClick()
 	saveCurLangSettings();
 }
 
-
-
 //恢复初始化设置
 void QtLangSet::slot_reset()
 {
 	if (m_selectLexer != nullptr)
 	{
-		if (QMessageBox::Yes != QMessageBox::question(this, tr("Reset Style"), tr("Are you sure to reset language %1 sytle").arg(m_selectLexer->lexerTag())))
+		if (!m_isGlobelItem)
 		{
-			return;
-		}
-		//如果存在自定义的配置,也删除掉
-		QString cfgPath = QString("notepad/%1").arg(m_selectLexer->lexerTag());
+			if (QMessageBox::Yes != QMessageBox::question(this, tr("Reset Style"), tr("Are you sure to reset language %1 sytle").arg(m_selectLexer->lexerTag())))
+			{
+				return;
+			}
 
-		QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
-		if (QFile::exists(qs.fileName()))
+			//一旦重置,当前修改无条件不保存。否则避免当前的刚刚重置,又被保存
+			m_isStyleChange = false;
+
+			//如果存在自定义的配置,也删除掉
+			QString cfgPath = QString("notepad/userstyle/%1").arg(m_selectLexer->lexerTag());
+
+			QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
+			if (QFile::exists(qs.fileName()))
+			{
+				QFile::remove(qs.fileName());
+			}
+
+			//一定要先保存,因为selectInitLangTag后可能会变化
+
+			int row = ui.styleListWidget->currentRow();
+
+			selectInitLangTag(m_selectLexer->lexerTag());
+
+			//手动刷新UI
+			QListWidgetItem* styleItem = ui.styleListWidget->item(row);
+
+			syncShowStyleItemToUI(styleItem);
+
+			emit viewLexerChange(m_selectLexer->lexerTag());
+		}
+		else
 		{
-			QFile::remove(qs.fileName());
+			//如果是全局重置,则把所有语言都重置
+			if (QMessageBox::Yes != QMessageBox::question(this, tr("Reset All Style"), tr("Are you sure to reset All language sytle")))
+			{
+				return;
+			}
+			restoreOriginLangAllStyle();
+			previewAllGoblalChange();
+
+			//手动刷新UI。全局目前只有一行全局设置
+
+			if (m_selectLexer != nullptr)
+			{
+				delete m_selectLexer;
+			}
+			m_selectLexer  = ScintillaEditView::createLexer(L_GLOBAL,"",true);
+
+			QListWidgetItem* styleItem = ui.styleListWidget->item(0);
+
+			syncShowStyleItemToUI(styleItem);
 		}
+	}
+}
 
-		//一定要先保存,因为selectInitLangTag后可能会变化
 
-		int row = ui.styleListWidget->currentRow();
+void QtLangSet::slot_useAlobalFgColor(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FG_COLOR);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FG_COLOR);
+		previewAllGoblalChange();
+	}
 
-		selectInitLangTag(m_selectLexer->lexerTag());
+}
 
-		//手动刷新UI
-		QListWidgetItem* styleItem = ui.styleListWidget->item(row);
+void QtLangSet::slot_useAlobalBkColor(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_BK_COLOR);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_BK_COLOR);
+		previewAllGoblalChange();
+	}
+}
+
+void QtLangSet::slot_useAlobalFont(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FONT);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FONT);
+		previewAllGoblalChange();
+	}
+}
+
+void QtLangSet::slot_useAlobalFontSize(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FONT_SIZE);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FONT_SIZE);
+		previewAllGoblalChange();
+	}
+}
 
-		syncShowStyleItemToUI(styleItem);
+void QtLangSet::slot_useAlobalFontBold(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FONT_BOLD);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FONT_BOLD);
+		previewAllGoblalChange();
+	}
+}
+
+void QtLangSet::slot_useAlobalFontUnderline(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FONT_UNDERLINE);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FONT_UNDERLINE);
+		previewAllGoblalChange();
+	}
+}
 
-		emit viewLexerChange(m_selectLexer->lexerTag());
+void QtLangSet::slot_useAlobalFontItalic(bool check)
+{
+	if (check)
+	{
+		updateAllLangeStyleWithGlobal(GLOBAL_FONT_ITALIC);
+		previewAllGoblalChange();
+	}
+	else
+	{
+		restoreOriginLangOneStyle(GLOBAL_FONT_ITALIC);
+		previewAllGoblalChange();
 	}
 }

+ 32 - 8
src/qtlangset.h

@@ -9,6 +9,17 @@
 
 class QsciLexer;
 
+
+enum GLOBAL_STYLE_SET {
+	GLOBAL_FONT=0, //字体
+	GLOBAL_FONT_SIZE, //字体大小
+	GLOBAL_FONT_BOLD,//粗体
+	GLOBAL_FONT_UNDERLINE,//下划线
+	GLOBAL_FONT_ITALIC,//倾斜
+	GLOBAL_FG_COLOR,//前景色
+	GLOBAL_BK_COLOR,
+};
+
 class QtLangSet : public QMainWindow
 {
 	Q_OBJECT
@@ -17,16 +28,13 @@ public:
 	QtLangSet(QString initTag, QWidget *parent = nullptr);
 	~QtLangSet();
 
+
 	void startSignSlot();
 
 	void selectInitLangTag(QString initLangTag);
 
-
 	static 	bool readLangSettings(QsciLexer * lexer, QString tag);
 
-#if 0
-	void setCurSelectLang(QString tag);
-#endif
 
 signals:
 	void viewStyleChange(QString tagName, int styleId, QColor & fgColor, QColor & bkColor, QFont & font, bool fontChange);
@@ -42,31 +50,44 @@ protected:
 private slots:
 
 	void slot_itemSelect(QListWidgetItem * item);
-	void slot_styleItemSelect(QListWidgetItem * item, QListWidgetItem *previous);
+	void slot_styleItemSelect(QListWidgetItem * item);
 	void slot_saveClick();
-
 	void slot_reset();
 	void slot_changeFgColor();
 	void slot_changeBkColor();
-
 	void slot_fontBoldChange(int state);
 	void slot_fontItalicChange(int state);
 	void slot_fontUnderlineChange(int state);
 	void slot_fontSizeChange(int v);
 	void slot_fontChange(const QFont & font);
-	
 	void slot_userLangItemSelect(QListWidgetItem * item);
+
+	void slot_useAlobalFgColor(bool);
+	void slot_useAlobalBkColor(bool check);
+	void slot_useAlobalFont(bool);
+	void slot_useAlobalFontSize(bool);
+	void slot_useAlobalFontBold(bool);
+	void slot_useAlobalFontUnderline(bool);
+	void slot_useAlobalFontItalic(bool);
+
 private:
 	void initLangList();
 	bool readLangSetFile(QString langName, QString & keyword, QString & motherLang, QString & extTypes);
 	void initUserDefineLangList();
 	void setStyleShow(QFont & font, QColor& fcColor, QColor &bkColor);
+	void saveLangeSet(QsciLexer * lexer);
 	bool saveCurLangSettings();
 	void fillForegroundColor(QColor & fcColor);
 	void fillBackgroundColor(QColor & bkColor);
 	void displayUserMotherLangsStyle(QString langTagName, UserLangMother motherLang);
 	void getCurUiFont(QFont & font);
+	void updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag);
+	void restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag);
+	void restoreOriginLangAllStyle();
+	void previewAllGoblalChange();
 
+	void getCurUseLexerTags(QVector<QString>& tag);
+	void enableFontChangeSensitive(bool isSensitive);
 
 private:
 	Ui::QtLangSetClass ui;
@@ -86,4 +107,7 @@ private:
 	QString m_initShowLexerTag;
 
 	QListWidgetItem * m_previousSysLangItem;
+
+	//是否是全局修改项
+	bool m_isGlobelItem;
 };

+ 454 - 255
src/qtlangset.ui

@@ -18,128 +18,128 @@
     <normaloff>:/Resources/edit/global/ndd.ico</normaloff>:/Resources/edit/global/ndd.ico</iconset>
   </property>
   <widget class="QWidget" name="centralWidget">
-   <layout class="QHBoxLayout" name="horizontalLayout_9">
+   <layout class="QHBoxLayout" name="horizontalLayout_8">
     <item>
-       <layout class="QVBoxLayout" name="verticalLayout">
-        <item>
-         <widget class="QLabel" name="label">
-          <property name="text">
-           <string>Language</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QListWidget" name="langListWidget">
-          <property name="minimumSize">
-           <size>
-            <width>100</width>
-            <height>0</height>
-           </size>
-          </property>
-          <property name="maximumSize">
-           <size>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Language</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QListWidget" name="langListWidget">
+        <property name="minimumSize">
+         <size>
+          <width>100</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
           <width>220</width>
-            <height>16777215</height>
-           </size>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_5">
-          <property name="text">
-           <string>User Define Language</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QListWidget" name="userLangListWidget">
-          <property name="minimumSize">
-           <size>
-            <width>100</width>
-            <height>0</height>
-           </size>
-          </property>
-          <property name="maximumSize">
-           <size>
+          <height>16777215</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="label_5">
+        <property name="text">
+         <string>User Define Language</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QListWidget" name="userLangListWidget">
+        <property name="minimumSize">
+         <size>
+          <width>100</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
           <width>220</width>
-            <height>150</height>
-           </size>
-          </property>
-         </widget>
-        </item>
-       </layout>
+          <height>150</height>
+         </size>
+        </property>
+       </widget>
       </item>
+     </layout>
+    </item>
+    <item>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
       <item>
-       <layout class="QVBoxLayout" name="verticalLayout_2">
-        <item>
-         <widget class="QLabel" name="label_2">
-          <property name="text">
-           <string>Style</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QListWidget" name="styleListWidget">
-          <property name="minimumSize">
-           <size>
-            <width>250</width>
-            <height>0</height>
-           </size>
-          </property>
-          <property name="maximumSize">
-           <size>
-            <width>500</width>
-            <height>16777215</height>
-           </size>
-          </property>
-         </widget>
-        </item>
-       </layout>
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>Style</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QListWidget" name="styleListWidget">
+        <property name="minimumSize">
+         <size>
+          <width>250</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>500</width>
+          <height>16777215</height>
+         </size>
+        </property>
+       </widget>
       </item>
+     </layout>
+    </item>
     <item>
-     <layout class="QVBoxLayout" name="verticalLayout_5">
+     <layout class="QVBoxLayout" name="verticalLayout_9">
       <item>
-         <widget class="QGroupBox" name="groupBox_2">
-          <property name="title">
-           <string>Color</string>
-          </property>
-          <layout class="QVBoxLayout" name="verticalLayout_6">
+       <widget class="QGroupBox" name="groupBox_2">
+        <property name="title">
+         <string>Color</string>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout_6">
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_6">
+           <item>
+            <widget class="QLabel" name="label_3">
+             <property name="text">
+              <string>Foreground:</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="label_fc">
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="minimumSize">
+              <size>
+               <width>32</width>
+               <height>32</height>
+              </size>
+             </property>
+             <property name="text">
+              <string>TextLabel</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QToolButton" name="toolButton">
+             <property name="text">
+              <string>Select</string>
+             </property>
+            </widget>
+           </item>
            <item>
-            <layout class="QHBoxLayout" name="horizontalLayout_6">
-             <item>
-              <widget class="QLabel" name="label_3">
-               <property name="text">
-                <string>Foreground:</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QLabel" name="label_fc">
-               <property name="sizePolicy">
-                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-                 <horstretch>0</horstretch>
-                 <verstretch>0</verstretch>
-                </sizepolicy>
-               </property>
-               <property name="minimumSize">
-                <size>
-                 <width>32</width>
-                 <height>32</height>
-                </size>
-               </property>
-               <property name="text">
-                <string>TextLabel</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QToolButton" name="toolButton">
-               <property name="text">
-                <string>Select</string>
-               </property>
-              </widget>
-             </item>
-             <item>
             <widget class="QCheckBox" name="modiryAllColor">
              <property name="text">
               <string>All Style</string>
@@ -147,86 +147,86 @@
             </widget>
            </item>
            <item>
-              <spacer name="horizontalSpacer">
-               <property name="orientation">
-                <enum>Qt::Horizontal</enum>
-               </property>
-               <property name="sizeHint" stdset="0">
-                <size>
-                 <width>40</width>
-                 <height>20</height>
-                </size>
-               </property>
-              </spacer>
-             </item>
-            </layout>
+            <spacer name="horizontalSpacer">
+             <property name="orientation">
+              <enum>Qt::Horizontal</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>40</width>
+               <height>20</height>
+              </size>
+             </property>
+            </spacer>
            </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_7">
            <item>
-            <layout class="QHBoxLayout" name="horizontalLayout_7">
-             <item>
-              <widget class="QLabel" name="label_4">
-               <property name="text">
-                <string>background:</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QLabel" name="label_bc">
-               <property name="sizePolicy">
-                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-                 <horstretch>0</horstretch>
-                 <verstretch>0</verstretch>
-                </sizepolicy>
-               </property>
-               <property name="minimumSize">
-                <size>
-                 <width>32</width>
-                 <height>32</height>
-                </size>
-               </property>
-               <property name="text">
-                <string>Same As Theme</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <spacer name="horizontalSpacer_2">
-               <property name="orientation">
-                <enum>Qt::Horizontal</enum>
-               </property>
-               <property name="sizeHint" stdset="0">
-                <size>
-                 <width>40</width>
-                 <height>20</height>
-                </size>
-               </property>
-              </spacer>
-             </item>
-            </layout>
+            <widget class="QLabel" name="label_4">
+             <property name="text">
+              <string>background:</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="label_bc">
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="minimumSize">
+              <size>
+               <width>32</width>
+               <height>32</height>
+              </size>
+             </property>
+             <property name="text">
+              <string>Same As Theme</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="horizontalSpacer_2">
+             <property name="orientation">
+              <enum>Qt::Horizontal</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>40</width>
+               <height>20</height>
+              </size>
+             </property>
+            </spacer>
            </item>
           </layout>
-         </widget>
-        </item>
-        <item>
-         <widget class="QGroupBox" name="groupBox_3">
-          <property name="title">
-           <string>Font</string>
-          </property>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <widget class="QGroupBox" name="groupBox_3">
+        <property name="title">
+         <string>Font</string>
+        </property>
         <layout class="QVBoxLayout" name="verticalLayout_8">
-             <item>
+         <item>
           <layout class="QHBoxLayout" name="horizontalLayout_2">
            <item>
             <widget class="QLabel" name="label_7">
-               <property name="text">
+             <property name="text">
               <string>Name:</string>
-               </property>
-              </widget>
-             </item>
-             <item>
+             </property>
+            </widget>
+           </item>
+           <item>
             <widget class="QFontComboBox" name="fontComboBox"/>
-             </item>
-            </layout>
            </item>
+          </layout>
+         </item>
          <item>
           <layout class="QHBoxLayout" name="horizontalLayout_10">
            <item>
@@ -254,22 +254,26 @@
              </item>
             </layout>
            </item>
-             <item>
+           <item>
             <layout class="QVBoxLayout" name="verticalLayout_7">
              <item>
               <layout class="QHBoxLayout" name="horizontalLayout_3">
                <item>
                 <widget class="QLabel" name="label_8">
-               <property name="text">
+                 <property name="text">
                   <string>Font Size:</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-                <widget class="QSpinBox" name="fontSpinBox"/>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QSpinBox" name="fontSpinBox">
+                 <property name="singleStep">
+                  <number>1</number>
+                 </property>
+                </widget>
+               </item>
+              </layout>
              </item>
-            </layout>
-           </item>
              <item>
               <widget class="QCheckBox" name="modifyAllFont">
                <property name="text">
@@ -277,73 +281,149 @@
                </property>
               </widget>
              </item>
-          </layout>
+            </layout>
            </item>
           </layout>
          </item>
         </layout>
-         </widget>
-        </item>
-        <item>
-       <widget class="QGroupBox" name="groupBox">
-        <property name="title">
-         <string>Keyword And Mother </string>
-          </property>
-        <layout class="QVBoxLayout" name="verticalLayout_4">
-         <item>
-          <widget class="QPlainTextEdit" name="keywordTe">
-           <property name="readOnly">
-            <bool>true</bool>
-          </property>
-          </widget>
-        </item>
-         <item>
-          <layout class="QHBoxLayout" name="horizontalLayout">
-           <item>
-            <widget class="QLabel" name="label_6">
-             <property name="text">
-              <string>Mother Language:</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QComboBox" name="motherLangCb">
-             <property name="enabled">
-              <bool>false</bool>
-             </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QStackedWidget" name="stackedWidget">
+        <property name="currentIndex">
+         <number>1</number>
+        </property>
+        <widget class="QWidget" name="page_normal">
+         <layout class="QGridLayout" name="gridLayout">
+          <item row="0" column="0">
+           <widget class="QGroupBox" name="groupBox">
+            <property name="title">
+             <string>Keyword And Mother </string>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_4">
              <item>
-              <property name="text">
-               <string>None</string>
-              </property>
+              <widget class="QPlainTextEdit" name="keywordTe">
+               <property name="readOnly">
+                <bool>true</bool>
+               </property>
+              </widget>
              </item>
              <item>
-              <property name="text">
-               <string>Cpp</string>
-              </property>
+              <layout class="QHBoxLayout" name="horizontalLayout">
+               <item>
+                <widget class="QLabel" name="label_6">
+                 <property name="text">
+                  <string>Mother Language:</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QComboBox" name="motherLangCb">
+                 <property name="enabled">
+                  <bool>false</bool>
+                 </property>
+                 <item>
+                  <property name="text">
+                   <string>None</string>
+                  </property>
+                 </item>
+                 <item>
+                  <property name="text">
+                   <string>Cpp</string>
+                  </property>
+                 </item>
+                </widget>
+               </item>
+              </layout>
              </item>
-            </widget>
-           </item>
-       </layout>
-      </item>
-      <item>
-          <layout class="QHBoxLayout" name="horizontalLayout_5">
-           <item>
-            <widget class="QLabel" name="label_9">
-             <property name="text">
-              <string>Ext File Type:</string>
-             </property>
-            </widget>
-           </item>
-           <item>
-            <widget class="QLineEdit" name="extFileType">
-             <property name="readOnly">
-              <bool>true</bool>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-        </layout>
+             <item>
+              <layout class="QHBoxLayout" name="horizontalLayout_5">
+               <item>
+                <widget class="QLabel" name="label_9">
+                 <property name="text">
+                  <string>Ext File Type:</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QLineEdit" name="extFileType">
+                 <property name="readOnly">
+                  <bool>true</bool>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+        <widget class="QWidget" name="page_global">
+         <layout class="QGridLayout" name="gridLayout_2">
+          <item row="0" column="0">
+           <widget class="QGroupBox" name="groupBox_4">
+            <property name="title">
+             <string>Global Style Set</string>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_5">
+             <item>
+              <widget class="QCheckBox" name="useGbFc">
+               <property name="text">
+                <string>Use Global Foreground Color</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbBc">
+               <property name="enabled">
+                <bool>false</bool>
+               </property>
+               <property name="text">
+                <string>Use Global Background Color</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbFont">
+               <property name="text">
+                <string>Use Global Font</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbFontSize">
+               <property name="text">
+                <string>Use Global FontSize</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbFontBold">
+               <property name="text">
+                <string>Use Global Bold Font</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbFontItalic">
+               <property name="text">
+                <string>Use Global Italic Font</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="useGbFontUnderline">
+               <property name="text">
+                <string>Use Global Underline Font</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
        </widget>
       </item>
       <item>
@@ -407,7 +487,7 @@
    <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>1068</x>
+     <x>971</x>
      <y>694</y>
     </hint>
     <hint type="destinationlabel">
@@ -423,7 +503,7 @@
    <slot>slot_saveClick()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>951</x>
+     <x>857</x>
      <y>694</y>
     </hint>
     <hint type="destinationlabel">
@@ -439,7 +519,7 @@
    <slot>slot_changeFgColor()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>919</x>
+     <x>832</x>
      <y>92</y>
     </hint>
     <hint type="destinationlabel">
@@ -455,8 +535,8 @@
    <slot>slot_reset()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>777</x>
-     <y>685</y>
+     <x>743</x>
+     <y>694</y>
     </hint>
     <hint type="destinationlabel">
      <x>814</x>
@@ -464,11 +544,130 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>useGbFc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFgColor(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>347</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbFont</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFont(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>435</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbFontBold</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFontBold(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>523</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbFontItalic</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFontItalic(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>567</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbFontUnderline</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFontUnderline(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>611</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbFontSize</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalFontSize(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>479</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>useGbBc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>QtLangSetClass</receiver>
+   <slot>slot_useAlobalBkColor(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>803</x>
+     <y>391</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>491</x>
+     <y>363</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>slot_saveClick()</slot>
   <slot>slot_changeFgColor()</slot>
   <slot>slot_changeBkColor()</slot>
   <slot>slot_reset()</slot>
+  <slot>slot_useAlobalFgColor(bool)</slot>
+  <slot>slot_useAlobalFont(bool)</slot>
+  <slot>slot_useAlobalFontSize(bool)</slot>
+  <slot>slot_useAlobalFontBold(bool)</slot>
+  <slot>slot_useAlobalFontUnderline(bool)</slot>
+  <slot>slot_useAlobalFontItalic(bool)</slot>
+  <slot>slot_useAlobalBkColor(bool)</slot>
  </slots>
 </ui>

+ 3 - 0
src/rcglobal.h

@@ -5,6 +5,8 @@
 #include <QTreeWidgetItem>
 #include <qscilexer.h>
 
+static const char* VersionStr = "v1.18.0";
+
 #define CMP_CODE_NOEQUAL
 
 enum RC_DIRECTION
@@ -59,6 +61,7 @@ enum CODE_ID {
 	KOI8_R,//俄罗斯
 	TSCII,//泰国
 	TIS_620,//泰文
+	BIG5,//繁体中文
 	CODE_END //最后一个标志,在UI上是显示一个UNKNOWN,这是一个特殊
 };
 

BIN
src/realcompare_zh.qm


Plik diff jest za duży
+ 662 - 493
src/realcompare_zh.ts


+ 272 - 133
src/scintillaeditview.cpp

@@ -5,7 +5,7 @@
 #include "ccnotepad.h"
 #include "styleset.h"
 #include "qtlangset.h"
-
+#include "findwin.h"
 #include <Scintilla.h>
 #include <SciLexer.h>
 #include <QImage>
@@ -53,12 +53,17 @@
 #include <Qsci/qscilexergo.h>
 #include <Qsci/qscilexertext.h>
 #include <Qsci/qscilexernsis.h>
+#include <Qsci/qscilexerglobal.h>
 #include <QScrollBar>
 #include <unordered_set>
+#include <QClipboard>
 #include <QDebug>
 
+
 #include <stdexcept>
-#include "findwin.h"
+#include <mutex>
+
+
 
 // initialize the static variable
 #define DEFAULT_FONT_NAME "Courier New" //"Microsoft YaHei"  
@@ -77,13 +82,6 @@ const int ScintillaEditView::_SC_MARGE_FOLDER = 2;
 
 const int MAX_PRE_NEXT_TIMES = 30;
 
-//const int ScintillaEditView::_markersArray[][NB_FOLDER_STATE] = {
-//  {SC_MARKNUM_FOLDEROPEN, SC_MARKNUM_FOLDER, SC_MARKNUM_FOLDERSUB, SC_MARKNUM_FOLDERTAIL, SC_MARKNUM_FOLDEREND,        SC_MARKNUM_FOLDEROPENMID,     SC_MARKNUM_FOLDERMIDTAIL},
-//  {SC_MARK_MINUS,         SC_MARK_PLUS,      SC_MARK_EMPTY,        SC_MARK_EMPTY,         SC_MARK_EMPTY,               SC_MARK_EMPTY,                SC_MARK_EMPTY},
-//  {SC_MARK_ARROWDOWN,     SC_MARK_ARROW,     SC_MARK_EMPTY,        SC_MARK_EMPTY,         SC_MARK_EMPTY,               SC_MARK_EMPTY,                SC_MARK_EMPTY},
-//  {SC_MARK_CIRCLEMINUS,   SC_MARK_CIRCLEPLUS,SC_MARK_VLINE,        SC_MARK_LCORNERCURVE,  SC_MARK_CIRCLEPLUSCONNECTED, SC_MARK_CIRCLEMINUSCONNECTED, SC_MARK_TCORNERCURVE},
-//  {SC_MARK_BOXMINUS,      SC_MARK_BOXPLUS,   SC_MARK_VLINE,        SC_MARK_LCORNER,       SC_MARK_BOXPLUSCONNECTED,    SC_MARK_BOXMINUSCONNECTED,    SC_MARK_TCORNER}
-//};
 #ifdef Q_OS_WIN
 LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = {
 {QString("normal"),		QString("Normal QString"),		QString("Normal text file"),								L_TXT,			SCLEX_NULL},
@@ -186,7 +184,7 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = {
 #endif
 
 ScintillaEditView::ScintillaEditView(QWidget *parent)
-	: QsciScintilla(parent), m_NoteWin(nullptr), m_preFirstLineNum(0), m_curPos(0), m_hasHighlight(false)
+	: QsciScintilla(parent), m_NoteWin(nullptr), m_preFirstLineNum(0), m_curPos(0), m_hasHighlight(false), m_bookmarkPng(nullptr)
 {
 	init();
 }
@@ -194,6 +192,21 @@ ScintillaEditView::ScintillaEditView(QWidget *parent)
 ScintillaEditView::~ScintillaEditView()
 {
 	releaseAllMark();
+
+	if (m_bookmarkPng != nullptr)
+	{
+		delete m_bookmarkPng;
+}
+}
+
+void ScintillaEditView::setLexer(QsciLexer * lexer)
+{
+	QsciScintilla::setLexer(lexer);
+
+	if (lexer->lexerId() == L_TXT)
+	{
+		showMargin(_SC_MARGE_FOLDER,false);
+	}
 }
 
 //void ScintillaEditView::resetDefaultFontStyle()
@@ -206,7 +219,11 @@ ScintillaEditView::~ScintillaEditView()
 
 void ScintillaEditView::setNoteWidget(QWidget * win)
 {
-	m_NoteWin = win;
+	CCNotePad* pv = dynamic_cast<CCNotePad*>(win);
+	if (pv != nullptr)
+	{
+		m_NoteWin = pv;
+}
 }
 
 
@@ -243,18 +260,18 @@ void ScintillaEditView::updateLineNumberWidth(int lineNumberMarginDynamicWidth)
 
 		if(lineNumberMarginDynamicWidth != 0)
 		{
-			auto firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE);
-			auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
-			auto lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, (long)lastVisibleLineVis);
+			int firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE);
+			int lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
+			int lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, (long)lastVisibleLineVis);
 
 			nbDigits = nbDigitsFromNbLines(lastVisibleLineDoc);
 			nbDigits = nbDigits < 4 ? 4 : nbDigits;
 		}
 		else
 		{
-		auto nbLines = execute(SCI_GETLINECOUNT);
+			int nbLines = execute(SCI_GETLINECOUNT);
 		nbDigits = nbDigitsFromNbLines(nbLines);
-			nbDigits = nbDigits < 5 ? 5 : nbDigits;
+			nbDigits = nbDigits < 4 ? 4 : nbDigits;
 		}
 		
 		auto pixelWidth = 6 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<sptr_t>("8"));
@@ -277,7 +294,7 @@ void ScintillaEditView::showMargin(int whichMarge, bool willBeShowed)
 		//DPIManager& dpiManager = NppParameters::getInstance()._dpiManager;
 		int width = 3;
 		if (whichMarge == _SC_MARGE_SYBOLE)
-			width = 8;
+			width = 14;
 		else if (whichMarge == _SC_MARGE_FOLDER)
 			width = 14;
 		execute(SCI_SETMARGINWIDTHN, whichMarge, willBeShowed ? width : 0);
@@ -296,7 +313,8 @@ sptr_t ScintillaEditView::execute(quint32 Msg, uptr_t wParam, sptr_t lParam) con
 
 //status : true 表示存在, false 表示不存在
 //tag,只有在用户自定义语法是,才需要给出。内部自带的语法不需要给出
-QsciLexer* ScintillaEditView::createLexer(int lexerId,QString tag)
+//isOrigin:是否原生lexer,即不读取用户修改过的配置风格
+QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigin)
 {
 	QsciLexer* ret = nullptr;
 
@@ -532,6 +550,10 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId,QString tag)
 		ret = new QsciLexerGO();
 		ret->setLexerTag("go");
 		break;
+	case L_GLOBAL:
+		ret = new QsciLexerGlobal();
+		ret->setLexerTag("AllGlobal");
+		break;
 	case L_TXT:
 		ret = new QsciLexerText();
 		ret->setLexerTag("txt");
@@ -550,7 +572,9 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId,QString tag)
 	default:
 		break;
 	}
-	if (ret != nullptr)
+
+
+	if (ret != nullptr && !isOrigin)
 	{
 		ret->setLexerId(lexerId);
 		QtLangSet::readLangSettings(ret, ret->lexerTag());
@@ -583,6 +607,7 @@ void ScintillaEditView::adjuctSkinStyle()
 {
 	setFoldMarginColors(StyleSet::foldfgColor, StyleSet::foldbgColor);
 	setMarginsBackgroundColor(StyleSet::marginsBackgroundColor);
+	setMarginBackgroundColor(_SC_MARGE_SYBOLE, StyleSet::bookmarkBkColor);
 }
 
 void ScintillaEditView::setIndentGuide(bool willBeShowed)
@@ -616,61 +641,54 @@ void ScintillaEditView::init()
 	}
 
 	//开启行号marge
-	//markerDefine(SC_MARGIN_NUMBER,_SC_MARGE_LINENUMBER);
 	setMarginLineNumbers(_SC_MARGE_LINENUMBER, true);
 	
-	//execute(SCI_SETMARGINMASKN, _SC_MARGE_FOLDER, SC_MARGIN_SYMBOL);
-	//execute(SCI_SETMARGINMASKN, _SC_MARGE_FOLDER, SC_MASK_FOLDERS);
+	//QColor foldfgColor(StyleSet::foldfgColor);
+	//QColor foldbgColor(StyleSet::foldbgColor);//默认0xff,0xff,0xff
 
-	QColor foldfgColor(StyleSet::foldfgColor);
-	QColor foldbgColor(StyleSet::foldbgColor);//默认0xff,0xff,0xff
-	//QColor activeFoldFgColor(0xFF, 0, 0);
 
 	//通过fold发现,尽量使用qscint的功能,因为他做了大量封装和简化
 	setFolding(BoxedTreeFoldStyle, _SC_MARGE_FOLDER);
-	setFoldMarginColors(foldfgColor, foldbgColor);
+	//setFoldMarginColors(foldfgColor, foldbgColor);合入adjuctSkinStyle
 
 	//当前fold高亮。QT下面有bug暂时不开启
 	//execute(SCI_MARKERENABLEHIGHLIGHT, true);
-
-	setMarginsBackgroundColor(StyleSet::marginsBackgroundColor); //0xea, 0xf7, 0xff //默认0xf0f0f0
-
+	//setMarginsBackgroundColor(StyleSet::marginsBackgroundColor); //0xea, 0xf7, 0xff //默认0xf0f0f0
 	//execute(SCI_MARKERSETBACK, _SC_MARGE_FOLDER, 0x808080);
 	//execute(SCI_MARKERSETBACKSELECTED, _SC_MARGE_FOLDER, 0xff0000);
 
 	showMargin(_SC_MARGE_LINENUMBER, true);
 
-	//行号、符号、折叠。中间符号留一个很小的间隔
+	//行号、符号、折叠。中间符号留一个很小的间隔。用于圆形的标记符号
 	showMargin(_SC_MARGE_SYBOLE, true);
-	
-	//showMargin(_SC_MARGE_FOLDER, true);
 
-	//设置选中背景色
-	//setSelectionBackgroundColor(QColor(117, 217, 117));
+	setMarginType(_SC_MARGE_SYBOLE, QsciScintilla::SymbolMarginColor);
+	//execute(SCI_MARKERSETALPHA, _SC_MARGE_SYBOLE, 200);
 
-	
+	m_bookmarkPng = new QPixmap(QString(":/Resources/img/bookmark.png"));
+	markerDefine(*m_bookmarkPng, _SC_MARGE_SYBOLE);
+	setMarginSensitivity(_SC_MARGE_SYBOLE, true);
+	connect(this, &QsciScintilla::marginClicked, this, &ScintillaEditView::slot_bookMarkClicked);
 
+	//setMarginBackgroundColor(_SC_MARGE_SYBOLE, StyleSet::marginsBackgroundColor);
+	adjuctSkinStyle();
+	
 	//开始括号匹配,比如html的<>,开启前后这类字段的匹配
 	setBraceMatching(SloppyBraceMatch);
 	setMatchedBraceForegroundColor(QColor(191, 141, 255));
 
-
-
-	//setMatchedBraceBackgroundColor(QColor(191, 141, 255));
-
 	//自动补全效果不好,不开启20211017
 	//setAutoCompletionSource(QsciScintilla::AcsAPIs);   //设置源,自动补全所有地方出现的
 	//setAutoCompletionCaseSensitivity(true);   //设置自动补全大小写敏感
 	//setAutoCompletionThreshold(1);    //设置每输入一个字符就会出现自动补全的提示
 
 	//设置字体
-	QFont font(DEFAULT_FONT_NAME, 11/*QsciLexer::s_defaultFontSize*/, QFont::Normal);
+	QFont font(DEFAULT_FONT_NAME, 11, QFont::Normal);
 	setFont(font);
 	setMarginsFont(font);
-	//execute(SCI_SETMARGINMASKN, _SC_MARGE_SYBOLE, (1 << MARK_BOOKMARK) | (1 << MARK_HIDELINESBEGIN) | (1 << MARK_HIDELINESEND) | (1 << MARK_HIDELINESUNDERLINE));
 	setMarginsForegroundColor(QColor(0x80, 0x80, 0x80)); //默认0x80, 0x80, 0x80
 	execute(SCI_SETTABWIDTH, 4);
-
+	//setMarginsBackgroundColor(QColor(0xff, 0xff, 0x80));
 	//setPaper(QColor(0xfc, 0xfc, 0xfc));//这个无效
 
 	//使用空格替换tab
@@ -743,6 +761,169 @@ void ScintillaEditView::init()
 	execute(SCI_SETSCROLLWIDTHTRACKING, true);
 
 }
+void ScintillaEditView::bookmarkNext(bool forwardScan)
+{
+	size_t lineno = this->getCurrentLineNumber();
+	int sci_marker = SCI_MARKERNEXT;
+	size_t lineStart = lineno + 1;	//Scan starting from next line
+	int lineRetry = 0;				//If not found, try from the beginning
+	if (!forwardScan)
+	{
+		lineStart = lineno - 1;		//Scan starting from previous line
+		lineRetry = int(this->execute(SCI_GETLINECOUNT));	//If not found, try from the end
+		sci_marker = SCI_MARKERPREVIOUS;
+	}
+	int nextLine = int(this->execute(sci_marker, lineStart, 1 << _SC_MARGE_SYBOLE));
+	if (nextLine < 0)
+		nextLine = int(this->execute(sci_marker, lineRetry, 1 << _SC_MARGE_SYBOLE));
+
+	if (nextLine < 0)
+		return;
+
+	this->execute(SCI_ENSUREVISIBLEENFORCEPOLICY, nextLine);
+	this->execute(SCI_GOTOLINE, nextLine);
+}
+
+void ScintillaEditView::bookmarkAdd(intptr_t lineno) const {
+	if (lineno == -1)
+		lineno = getCurrentLineNumber();
+	if (!bookmarkPresent(lineno))
+		this->execute(SCI_MARKERADD, lineno, _SC_MARGE_SYBOLE);
+}
+
+void ScintillaEditView::bookmarkDelete(size_t lineno) const {
+	if (lineno == -1)
+		lineno = this->getCurrentLineNumber();
+	while (bookmarkPresent(lineno))
+		this->execute(SCI_MARKERDELETE, lineno, _SC_MARGE_SYBOLE);
+}
+
+bool ScintillaEditView::bookmarkPresent(intptr_t lineno) const {
+	if (lineno == -1)
+		lineno = this->getCurrentLineNumber();
+	int state = this->execute(SCI_MARKERGET, lineno);
+	return ((state & (1 << _SC_MARGE_SYBOLE)) != 0);
+}
+
+void ScintillaEditView::bookmarkToggle(intptr_t lineno) const {
+	if (lineno == -1)
+		lineno = this->getCurrentLineNumber();
+
+	if (bookmarkPresent(lineno))
+		bookmarkDelete(lineno);
+	else
+		bookmarkAdd(lineno);
+}
+
+void ScintillaEditView::bookmarkClearAll() const {
+	this->execute(SCI_MARKERDELETEALL, _SC_MARGE_SYBOLE);
+}
+
+void ScintillaEditView::slot_bookMarkClicked(int margin, int line, Qt::KeyboardModifiers state)
+{
+	if (margin == _SC_MARGE_SYBOLE)
+	{
+		bookmarkToggle(line);
+	}
+}
+
+std::mutex mark_mutex;
+
+QString ScintillaEditView::getMarkedLine(int ln)
+{
+	auto lineLen = this->execute(SCI_LINELENGTH, ln);
+	auto lineBegin = this->execute(SCI_POSITIONFROMLINE, ln);
+
+	return this->getGenericTextAsQString(lineBegin, lineBegin + lineLen);
+}
+
+void ScintillaEditView::deleteMarkedline(int ln)
+{
+	int lineLen = static_cast<int32_t>(this->execute(SCI_LINELENGTH, ln));
+	int lineBegin = static_cast<int32_t>(this->execute(SCI_POSITIONFROMLINE, ln));
+	bookmarkDelete(ln);
+
+	QByteArray str2replace;
+
+	this->replaceTarget(str2replace, lineBegin, lineBegin + lineLen);
+}
+
+void str2Cliboard(QString& text)
+{
+	QClipboard* clip = QApplication::clipboard();
+	clip->setText(text);
+}
+
+void ScintillaEditView::cutMarkedLines()
+{
+	std::lock_guard<std::mutex> lock(mark_mutex);
+
+	int lastLine = this->lastZeroBasedLineNumber();
+	QString globalStr;
+
+	this->execute(SCI_BEGINUNDOACTION);
+	for (int i = lastLine; i >= 0; i--)
+	{
+		if (bookmarkPresent(i))
+		{
+			QString currentStr = getMarkedLine(i) + globalStr;
+			globalStr = currentStr;
+
+			deleteMarkedline(i);
+		}
+	}
+	this->execute(SCI_ENDUNDOACTION);
+	str2Cliboard(globalStr);
+}
+
+void ScintillaEditView::copyMarkedLines()
+{
+	int lastLine = this->lastZeroBasedLineNumber();
+	QString globalStr;
+	for (int i = lastLine; i >= 0; i--)
+	{
+		if (bookmarkPresent(i))
+		{
+			QString currentStr = getMarkedLine(i) + globalStr;
+			globalStr = currentStr;
+		}
+	}
+	str2Cliboard(globalStr);
+}
+
+void ScintillaEditView::replaceMarkedline(int ln, QByteArray& str)
+{
+	int lineBegin = static_cast<int32_t>(this->execute(SCI_POSITIONFROMLINE, ln));
+	int lineEnd = static_cast<int32_t>(this->execute(SCI_GETLINEENDPOSITION, ln));
+
+	this->replaceTarget(str, lineBegin, lineEnd);
+}
+
+void ScintillaEditView::pasteToMarkedLines()
+{
+	std::lock_guard<std::mutex> lock(mark_mutex);
+
+	QClipboard* clip = QApplication::clipboard();
+	const  QMimeData *mimeData = clip->mimeData();
+	if (!mimeData->hasText())
+	{
+		return;
+	}
+
+	int lastLine = this->lastZeroBasedLineNumber();
+	QString clipboardStr = clip->text();
+
+	this->execute(SCI_BEGINUNDOACTION);
+	for (int i = lastLine; i >= 0; i--)
+	{
+		if (bookmarkPresent(i))
+		{
+			QByteArray text = clipboardStr.toUtf8();
+			replaceMarkedline(i, text);
+		}
+	}
+	this->execute(SCI_ENDUNDOACTION);
+}
 
 //X方向滚动条值变化后的槽函数。一旦滚动则会出发这里,发送消息给中介,让中介去同步另外一方
 void ScintillaEditView::slot_scrollXValueChange(int value)
@@ -751,6 +932,37 @@ void ScintillaEditView::slot_scrollXValueChange(int value)
 	autoAdjustLineWidth(value);
 }
 
+void ScintillaEditView::deleteMarkedLines(bool isMarked)
+{
+	std::lock_guard<std::mutex> lock(mark_mutex);
+
+	int lastLine = this->lastZeroBasedLineNumber();
+
+	this->execute(SCI_BEGINUNDOACTION);
+	for (int i = lastLine; i >= 0; i--)
+	{
+		if (bookmarkPresent(i) == isMarked)
+			deleteMarkedline(i);
+	}
+	this->execute(SCI_ENDUNDOACTION);
+}
+
+void ScintillaEditView::inverseMarks()
+{
+	int lastLine = this->lastZeroBasedLineNumber();
+	for (int i = 0; i <= lastLine; ++i)
+	{
+		if (bookmarkPresent(i))
+		{
+			bookmarkDelete(i);
+		}
+		else
+		{
+			bookmarkAdd(i);
+		}
+	}
+}
+
 void ScintillaEditView::slot_linePosChanged(int /*line*/, int pos)
 {
 	//避免循环触发的slot_positionChanged
@@ -913,6 +1125,17 @@ void ScintillaEditView::highlightViewWithWord(QString & word2Hilite)
 	this->execute(SCI_SETTARGETRANGE, originalStartPos, originalEndPos);
 }
 
+void ScintillaEditView::contextUserDefineMenuEvent(QMenu* menu)
+{
+	//QAction* action;
+	if (menu != nullptr && (m_NoteWin !=nullptr))
+	{
+		menu->addAction(tr("Show File in Explorer"), m_NoteWin, &CCNotePad::slot_showFileInExplorer);
+	}
+	menu->show();
+}
+
+
 void ScintillaEditView::slot_delayWork()
 {
 	if (!hasSelectedText())
@@ -924,112 +1147,28 @@ void ScintillaEditView::slot_delayWork()
 	if (!word.isEmpty())
 	{
 		highlightViewWithWord(word);
-#if 0
-		QVector<int>resultPos;
-		resultPos.reserve(50);
-
-		int firstLine = execute(SCI_GETFIRSTVISIBLELINE);
-		int nbLineOnScreen = execute(SCI_LINESONSCREEN);
-		int nbLines = std::min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
-		int lastLine = firstLine + nbLines;
-
-
-		long startPos = execute(SCI_POSITIONFROMLINE, firstLine);
-		long endPos = execute(SCI_POSITIONFROMLINE, lastLine);
-
-		if (endPos == -1)
-		{	
-			endPos = execute(SCI_GETLENGTH);
 		}
-
-		int curpos = execute(SCI_GETCURRENTPOS);
-		int mainSelect = 1;
-
-		//struct Sci_TextToFind findOptions;
-		////20220226发现高亮全选如果范围过大,会导致卡死。借鉴notepad的只高亮可视化区域。但是滚动时也必须生效
-		////findOptions.chrg.cpMin = 0;
-		////findOptions.chrg.cpMax = execute(SCI_GETLENGTH);
-		//
-		//findOptions.chrg.cpMin = startPos;
-		//findOptions.chrg.cpMax = endPos;
-		//findOptions.lpstrText = wordStr.c_str();
-		//20220422 升级高版本scint后,发现Sci_TextToFind要崩溃,替换为SCI_SEARCHINTARGET
-		//int pos = execute(SCI_FINDTEXT, SCFIND_MATCHCASE | SCFIND_WHOLEWORD, reinterpret_cast<sptr_t>(&findOptions));
-
-		//std::string wordStr = word.toStdString();
-		QByteArray wordStr = word.toUtf8();
-
-		SendScintilla(SCI_SETTARGETSTART, startPos);
-		SendScintilla(SCI_SETTARGETEND, endPos);
-
-		SendScintilla(SCI_SETSEARCHFLAGS, SCFIND_MATCHCASE|SCFIND_WHOLEWORD);
-
-		long lens = wordStr.length();
-		long pos = SendScintilla(SCI_SEARCHINTARGET, lens, wordStr.data()/*,wordStr.c_str()*/);
-
-		while ((pos != -1)&&(pos < endPos))
-		{
-			resultPos.append(pos);
-
-			if (pos <= curpos)
-			{
-				mainSelect = resultPos.size();
 			}
 
-			SendScintilla(SCI_SETTARGETSTART, pos + lens);
-			SendScintilla(SCI_SETTARGETEND, endPos);
-			pos = SendScintilla(SCI_SEARCHINTARGET, wordStr.length(), wordStr.data()/*,wordStr.c_str()*/);
-			//findOptions.chrg.cpMin = findOptions.chrgText.cpMax;
-			//pos = execute(SCI_FINDTEXT, SCFIND_MATCHCASE | SCFIND_WHOLEWORD, reinterpret_cast<sptr_t>(&findOptions));
-		}
-
-		for (int i = 0, size = resultPos.size(); i < size; ++i)
-		{
-			//execute(SCI_ADDSELECTION, resultPos.at(i) + lens, resultPos.at(i) );
-
-			execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_SMART);
-
-			execute(SCI_INDICATORFILLRANGE, resultPos.at(i), lens);
-		}
-
-		//当前有高亮的字段
-		if (resultPos.size() > 0)
-		{
-			m_hasHighlight = true;
-		}
-
-		/*if (!resultPos.isEmpty())
-		{
-			execute(SCI_SETMAINSELECTION, mainSelect - 1);
-		}*/
-#endif
-	}
-}
-
 void ScintillaEditView::dragEnterEvent(QDragEnterEvent* event)
 {
-	//if (event->mimeData()->hasFormat("text/uri-list")) //只能打开文本文件
-	//{
-	//	event->accept(); //可以在这个窗口部件上拖放对象
-	//}
-	//else
-	//{
-	//	event->ignore();
-	//}
 	event->accept();
 	}
 
 void ScintillaEditView::dropEvent(QDropEvent* e)
 {
 	QList<QUrl> urls = e->mimeData()->urls();
-	if (urls.isEmpty())
-		return;
+	if (!urls.isEmpty())
+	{
 
 	CCNotePad* pv = dynamic_cast<CCNotePad*>(m_NoteWin);
 	if (pv != nullptr)
+	{
 		pv->receiveEditDrop(e);
-
-	//qDebug() << ui.leftSrc->geometry() << ui.rightSrc->geometry() << QCursor::pos() << this->mapFromGlobal(QCursor::pos());
+}
+		return;
+	}
+	QsciScintilla::dropEvent(e);
 }
 
 

+ 32 - 6
src/scintillaeditview.h

@@ -12,10 +12,10 @@
 typedef sptr_t(*SCINTILLA_FUNC) (sptr_t ptr, unsigned int, uptr_t, sptr_t);
 typedef sptr_t SCINTILLA_PTR;
 
-const int MARK_BOOKMARK = 24;
-const int MARK_HIDELINESBEGIN = 23;
-const int MARK_HIDELINESEND = 22;
-const int MARK_HIDELINESUNDERLINE = 21;
+//const int MARK_BOOKMARK = 24;
+//const int MARK_HIDELINESBEGIN = 23;
+//const int MARK_HIDELINESEND = 22;
+//const int MARK_HIDELINESUNDERLINE = 21;
 const int NB_FOLDER_STATE = 7;
 
 struct LanguageName {
@@ -49,6 +49,7 @@ enum TextCaseType
 
 
 class FindRecords;
+class CCNotePad;
 
 class ScintillaEditView : public QsciScintilla
 {
@@ -58,11 +59,13 @@ public:
 	ScintillaEditView(QWidget *parent);
 	~ScintillaEditView();
 
+	virtual void setLexer(QsciLexer *lexer = 0);
+
 	void setNoteWidget(QWidget* win);
 	//void resetDefaultFontStyle();
 	sptr_t execute(quint32 Msg, uptr_t wParam = 0, sptr_t lParam = 0) const;
 
-	static QsciLexer * createLexer(int lexerId, QString tag="");
+	static QsciLexer * createLexer(int lexerId, QString tag="", bool isOrigin=false);
 	
 	void appendMarkRecord(FindRecords *r);
 	void releaseAllMark();
@@ -101,6 +104,16 @@ public:
 		return execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS));
 	};
 
+	void bookmarkToggle(intptr_t lineno) const;
+	void bookmarkClearAll() const;
+	void bookmarkNext(bool forwardScan);
+	
+	void cutMarkedLines();
+	void copyMarkedLines();
+	void replaceMarkedline(int ln, QByteArray & str);
+	void pasteToMarkedLines();
+	void deleteMarkedLines(bool isMarked);
+	void inverseMarks();
 signals:
 	void delayWork();
 
@@ -113,6 +126,8 @@ private:
 	QString getEOLString();
 	intptr_t replaceTarget(QByteArray & str2replace, intptr_t fromTargetPos, intptr_t toTargetPos) const;
 	void appandGenericText(const QByteArray & text2Append) const;
+	QString getMarkedLine(int ln);
+	void deleteMarkedline(int ln);
 
 
 public:
@@ -128,6 +143,7 @@ protected:
 	void dragEnterEvent(QDragEnterEvent* event) override;
 	void dropEvent(QDropEvent* e) override;
 	void mouseDoubleClickEvent(QMouseEvent *e) override;
+	void contextUserDefineMenuEvent(QMenu * menu) override;
 
 public slots:
 	void updateLineNumberWidth(int lineNumberMarginDynamicWidth=0);
@@ -138,24 +154,32 @@ private:
 	void autoAdjustLineWidth(int xScrollValue);
 	void showMargin(int whichMarge, bool willBeShowed);
 	void init();
+	void bookmarkAdd(intptr_t lineno) const;
+	void bookmarkDelete(size_t lineno) const;
+	bool bookmarkPresent(intptr_t lineno) const;
+
 	void changeCase(const TextCaseType & caseToConvert, QString & strToConvert) const;
 	void clearIndicator(int indicatorNumber);
 
 	void highlightViewWithWord(QString & word2Hilite);
 
+
 	
 
 private slots:
 	void slot_delayWork();
 	void slot_scrollXValueChange(int value);
 	void slot_clearHightWord();
+	void slot_bookMarkClicked(int margin, int line, Qt::KeyboardModifiers state);
+
+
 
 private:
 
 	SCINTILLA_FUNC m_pScintillaFunc;
 	SCINTILLA_PTR  m_pScintillaPtr;
 
-	QWidget* m_NoteWin;
+	CCNotePad* m_NoteWin;
 	int m_preFirstLineNum;
 
 	QList<FindRecords *> m_curMarkList;
@@ -167,6 +191,8 @@ private:
 	//往前到下个位置
 	QList<int> m_nextPosRecord;
 
+	QPixmap* m_bookmarkPng;
+
 public:
 	static int s_tabLens;
 	static bool s_noUseTab;

+ 57 - 136
src/styleset.cpp

@@ -1,4 +1,5 @@
 #include "styleset.h"
+#include "ccnotepad.h"
 #include <QFile>
 #include <QPalette>
 #include <QApplication>
@@ -8,6 +9,9 @@
 QColor StyleSet::foldfgColor(0xe9, 0xe9, 0xe9, 100);
 QColor StyleSet::foldbgColor(0xff, 0xff, 0xff);
 QColor StyleSet::marginsBackgroundColor(0xf0f0f0);
+QColor StyleSet::bookmarkBkColor(0xececec);
+
+int StyleSet::m_curStyleId = 0;
 
 StyleSet::StyleSet()
 {}
@@ -40,45 +44,76 @@ void StyleSet::setCommonStyle(QColor foldfgColor_, QColor foldbgColor_, QColor m
 	file.close();
 }
 
+//void StyleSet::setBlackStyle()
+//{
+//	foldfgColor = QColor(57,58,60);
+//	foldbgColor = QColor(57, 58, 60);
+//	marginsBackgroundColor = QColor(57, 58, 60);
+//
+//	QFile file(":/qss/black.qss"); //qss文件路径:/lightblue.qss
+//	QString styleSheet;
+//	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
+//	{
+//		QPalette palette;
+//		palette.setColor(QPalette::Window, foldfgColor);
+//		palette.setColor(QPalette::Base, foldbgColor);
+//		palette.setColor(QPalette::Button, foldbgColor); 
+//		//palette.setColor(QPalette::WindowText, QColor(0xff, 0xff, 0xff));
+//		qApp->setPalette(palette);
+//
+//		styleSheet = file.readAll();
+//		//styleSheet.replace("#EAF7FF", "0x394041");
+//
+//		qApp->setStyleSheet(styleSheet);
+//	}
+//	file.close();
+//}
+
 void StyleSet::setSkin(int id)
 {
 	switch (id)
 	{
-	case 0:
+	case DEFAULT_SE:
 		setDefaultStyle();
 		break;
-	case 1:
+	case LIGHT_SE:
 		setLightStyle();
 		break;
-	case 2:
+	case THIN_BLUE_SE:
 		setThinBlueStyle();
 		break;
-	case 3:
+	case THIN_YELLOW_SE:
 		setThinYellowStyle();
 		break;
-	case 4:
+	case RICE_YELLOW_SE:
 		setRiceYellowStyle();
 		break;
-	case 5:
+	case SILVER_SE:
 		setSilverStyle();
 		break;
-	case 6:
+	case LAVENDER_SE:
 		setLavenderBlushStyle();
 		break;
-	case 7:
+	case MISTYROSE_SE:
 		setMistyRoseStyle();
 		break;
 	default:
+		id = 0;
 		setDefaultStyle();
 		break;
 	}
+
+	m_curStyleId = id;
 }
 
 void StyleSet::setDefaultStyle()
 {
+	m_curStyleId = DEFAULT_SE;
+
 	foldfgColor = QColor(0xe9, 0xe9, 0xe9, 100);
 	foldbgColor = QColor(0xff, 0xff, 0xff);
 	marginsBackgroundColor = QColor(0xf0f0f0);
+	bookmarkBkColor = QColor(0xececec);
 
 	QFile file(":/qss/mystyle.qss"); //qss文件路径:/lightblue.qss
 	QString styleSheet;
@@ -97,168 +132,54 @@ void StyleSet::setDefaultStyle()
 
 void StyleSet::setLightStyle()
 {
-#if 0
-	foldfgColor = QColor(0xea, 0xf7, 0xff, 100);
-	foldbgColor = QColor(0xeaf7ff);
-	marginsBackgroundColor = QColor(0xeaf7ff);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xea, 0xf7, 0xff));
-		palette.setColor(QPalette::Base, QColor(0xea, 0xf7, 0xff));
-		palette.setColor(QPalette::Button, QColor(0xea, 0xf7, 0xff));
-		qApp->setPalette(palette);
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = LIGHT_SE;
+	bookmarkBkColor = QColor(0xE0F3Fc);
 	setCommonStyle(QColor(0xea, 0xf7, 0xff, 100), QColor(0xeaf7ff), QColor(0xeaf7ff), "#EAF7FF");
 }
 
 void StyleSet::setThinBlueStyle()
 {
-#if 0
-	foldfgColor = QColor(0xd7, 0xe3, 0xf4, 100);
-	foldbgColor = QColor(0xd7e3f4);
-	marginsBackgroundColor = QColor(0xd7e3f4);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xd7, 0xe3, 0xf4));
-		palette.setColor(QPalette::Base, QColor(0xd7, 0xe3, 0xf4));
-		palette.setColor(QPalette::Button, QColor(0xd7, 0xe3, 0xf4));
-		qApp->setPalette(palette);
-
-		styleSheet.replace("#EAF7FF","#D7E3F4");
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = THIN_BLUE_SE;
+	bookmarkBkColor = QColor(0xE3e0F0);
 	setCommonStyle(QColor(0xd7, 0xe3, 0xf4, 100), QColor(0xd7e3f4), QColor(0xd7e3f4), "#D7E3F4");
 }
 
 //纸黄
 void StyleSet::setThinYellowStyle()
 {
-#if 0
-	foldfgColor = QColor(0xf9, 0xf0, 0xe1, 100);
-	foldbgColor = QColor(0xf9f0e1);
-	marginsBackgroundColor = QColor(0xf9f0e1);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xf9, 0xf0, 0xe1));
-		palette.setColor(QPalette::Base, QColor(0xf9, 0xf0, 0xe1));
-		palette.setColor(QPalette::Button, QColor(0xf9, 0xf0, 0xe1));
-		qApp->setPalette(palette);
-
-		styleSheet.replace("#EAF7FF", "#F9F0E1");
-
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = THIN_YELLOW_SE;
+	bookmarkBkColor = QColor(0xF4F0E0);
 	setCommonStyle(QColor(0xf9, 0xf0, 0xe1, 100), QColor(0xf9f0e1), QColor(0xf9f0e1), "#F9F0E1");
 }
 
 //宣纸黄
 void StyleSet::setRiceYellowStyle()
 {
-#if 0
-	foldfgColor = QColor(0xf6, 0xf3, 0xea, 100);
-	foldbgColor = QColor(0xf6f3ea);
-	marginsBackgroundColor = QColor(0xf6f3ea);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xf6, 0xf3, 0xea));
-		palette.setColor(QPalette::Base, QColor(0xf6, 0xf3, 0xea));
-		palette.setColor(QPalette::Button, QColor(0xf6, 0xf3, 0xea));
-		qApp->setPalette(palette);
-
-		styleSheet.replace("#EAF7FF", "#F6F3EA");
-
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = RICE_YELLOW_SE;
+	bookmarkBkColor = QColor(0xF0F0E8);
 	setCommonStyle(QColor(0xf6, 0xf3, 0xea, 100), QColor(0xf6f3ea), QColor(0xf6f3ea), "#F6F3EA");
 }
 
 //银色
 void StyleSet::setSilverStyle()
 {
-#if 0
-	foldfgColor = QColor(0xe9, 0xe8, 0xe4, 100);
-	foldbgColor = QColor(0xe9e8e4);
-	marginsBackgroundColor = QColor(0xe9e8e4);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xe9, 0xe8, 0xe4));
-		palette.setColor(QPalette::Base, QColor(0xe9, 0xe8, 0xe4));
-		palette.setColor(QPalette::Button, QColor(0xe9, 0xe8, 0xe4));
-		qApp->setPalette(palette);
-
-		styleSheet.replace("#EAF7FF", "#E9E8E4");
-
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = SILVER_SE;
+	bookmarkBkColor = QColor(0xE4E4E4);
 	setCommonStyle(QColor(0xe9, 0xe8, 0xe4, 100), QColor(0xe9e8e4), QColor(0xe9e8e4), "#E9E8E4");
 }
 
 //谈紫色#FFF0F5
 void StyleSet::setLavenderBlushStyle()
 {
-#if 0
-	foldfgColor = QColor(0xff, 0xf0, 0xf5, 100);
-	foldbgColor = QColor(0xFFF0F5);
-	marginsBackgroundColor = QColor(0xFFF0F5);
-
-	QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss
-	QString styleSheet;
-	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
-	{
-		styleSheet = file.readAll();
-		QPalette palette;
-		palette.setColor(QPalette::Window, QColor(0xff, 0xf0, 0xf5));
-		palette.setColor(QPalette::Base, QColor(0xff, 0xf0, 0xf5));
-		palette.setColor(QPalette::Button, QColor(0xff, 0xf0, 0xf5));
-		qApp->setPalette(palette);
-
-		styleSheet.replace("#EAF7FF", "#FFF0F5");
-
-		qApp->setStyleSheet(styleSheet);
-	}
-	file.close();
-#endif
+	m_curStyleId = LAVENDER_SE;
+	bookmarkBkColor = QColor(0xFCF0F0);
 	setCommonStyle(QColor(0xff, 0xf0, 0xf5, 100), QColor(0xFFF0F5), QColor(0xFFF0F5), "#FFF0F5");
 }
 
 //MistyRose
 void StyleSet::setMistyRoseStyle()
 {
+	m_curStyleId = MISTYROSE_SE;
+	bookmarkBkColor = QColor(0xFCE0E0);
 	setCommonStyle(QColor(0xff, 0xe4, 0xe1, 100), QColor(0xFFE4E1), QColor(0xFFE4E1), "#FFE4E1");
 }

+ 15 - 7
src/styleset.h

@@ -1,6 +1,16 @@
 #pragma once
 #include <QColor>
 
+enum StyleId {
+	DEFAULT_SE,
+	LIGHT_SE,
+	THIN_BLUE_SE,
+	THIN_YELLOW_SE,
+	RICE_YELLOW_SE,
+	SILVER_SE,
+	LAVENDER_SE,
+	MISTYROSE_SE
+};
 class StyleSet 
 {
 public:
@@ -11,19 +21,17 @@ public:
 
 	static void setSkin(int id);
 
+	static QColor foldfgColor;
+	static QColor foldbgColor;
+	static QColor marginsBackgroundColor;
+	static QColor bookmarkBkColor;
+	static int m_curStyleId;
 	static void setDefaultStyle();
 	static void setLightStyle();
-
 	static void setThinBlueStyle();
 	static void setThinYellowStyle();
 	static void setRiceYellowStyle();
-
 	static void setSilverStyle();
-
 	static void setLavenderBlushStyle();
 	static void setMistyRoseStyle();
-
-	static QColor foldfgColor;
-	static QColor foldbgColor;
-	static QColor marginsBackgroundColor;
 };

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików