Skip to content

Commit

Permalink
feat: [editor] Add encoding detection and conversion support
Browse files Browse the repository at this point in the history
Add encoding detection and conversion functionality to the editor, including:

- Integrate chardet/uchardet/icu libraries for encoding detection
- Add GB18030-2022 encoding support with special character handling
- Implement encoding conversion between different character sets
- Add encoding selection UI in status bar
- Support reload file with different encodings
- Add encoding configuration file with supported encoding list

The changes improve text file handling by:
- Automatically detecting file encodings on open
- Supporting manual encoding selection via UI
- Preserving encoding when saving files
- Handling special cases for Chinese encodings
- Providing better user feedback about current encoding

Log: Add encoding detection and conversion support to editor
  • Loading branch information
Kakueeen committed Dec 2, 2024
1 parent fd5aeae commit 738d417
Show file tree
Hide file tree
Showing 23 changed files with 1,504 additions and 167 deletions.
5 changes: 4 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ Build-Depends:
libdtkcore5-bin,
libkf5syntaxhighlighting-dev,
libyaml-cpp-dev,
libcmark-dev
libcmark-dev,
libchardet-dev,
libuchardet-dev (>= 0.0.6),
libicu-dev
Standards-version: 3.9.8
Homepage: http://www.deepin.org

Expand Down
9 changes: 9 additions & 0 deletions src/plugins/codeeditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR true)

add_definitions(-DLIBRARY_INSTALL_PREFIX="${LIBRARY_INSTALL_PREFIX}")

find_package(ICU COMPONENTS i18n uc REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CMARK REQUIRED libcmark)
pkg_check_modules(CHARDET REQUIRED chardet)
pkg_check_modules(UCHARDET REQUIRED uchardet)

FILE(GLOB_RECURSE PROJECT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
Expand All @@ -31,6 +34,8 @@ add_library(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMARK_INCLUDE_DIRS}
${CHARDET_INCLUDE_DIRS}
${UCHARDET_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME}
Expand All @@ -42,6 +47,10 @@ target_link_libraries(${PROJECT_NAME}
${PkgUserModules}
${DtkWidget_LIBRARIES}
${CMARK_LIBRARIES}
${CHARDET_LIBRARIES}
${UCHARDET_LIBRARIES}
ICU::i18n
ICU::uc
)

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
2 changes: 1 addition & 1 deletion src/plugins/codeeditor/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "lexer/lexermanager.h"
#include "utils/editorutils.h"
#include "utils/resourcemanager.h"
#include "status/statusinfomanager.h"
#include "statusbar/statusinfomanager.h"
#include "symbol/symbollocator.h"
#include "symbol/symbolwidget.h"

Expand Down
1 change: 1 addition & 0 deletions src/plugins/codeeditor/codeeditor.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
<file>icons/deepin/builtin/light/icons/arrow_14px.svg</file>
<file>icons/deepin/builtin/light/icons/breakpoint_14px.svg</file>
<file>icons/deepin/builtin/light/icons/disabled_breakpoint_14px.svg</file>
<file>encodes/encodes.ini</file>
</qresource>
</RCC>
Loading

0 comments on commit 738d417

Please sign in to comment.