Browse Source

Initial commit

This is essentially a gutted fork of nncmpp that doesn't do anything.
Přemysl Janouch 1 year ago
commit
d0eee678b5
Signed by: Přemysl Janouch <p.janouch@gmail.com> GPG Key ID: B715679E3A361BE6
11 changed files with 1566 additions and 0 deletions
  1. 9
    0
      .gitignore
  2. 6
    0
      .gitmodules
  3. 116
    0
      CMakeLists.txt
  4. 15
    0
      LICENSE
  5. 86
    0
      README.adoc
  6. 17
    0
      cmake/FindNcursesw.cmake
  7. 10
    0
      cmake/FindUnistring.cmake
  8. 10
    0
      config.h.in
  9. 1295
    0
      hex.c
  10. 1
    0
      liberty
  11. 1
    0
      termo

+ 9
- 0
.gitignore View File

@@ -0,0 +1,9 @@
1
+# Build files
2
+/build
3
+
4
+# Qt Creator files
5
+/CMakeLists.txt.user*
6
+/hex.config
7
+/hex.files
8
+/hex.creator*
9
+/hex.includes

+ 6
- 0
.gitmodules View File

@@ -0,0 +1,6 @@
1
+[submodule "termo"]
2
+	path = termo
3
+	url = git://github.com/pjanouch/termo.git
4
+[submodule "liberty"]
5
+	path = liberty
6
+	url = git://github.com/pjanouch/liberty.git

+ 116
- 0
CMakeLists.txt View File

@@ -0,0 +1,116 @@
1
+project (hex C)
2
+cmake_minimum_required (VERSION 2.8.5)
3
+
4
+# Moar warnings
5
+if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
6
+	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
7
+	set (CMAKE_C_FLAGS_DEBUG
8
+		"${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Wno-unused-function")
9
+endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
10
+
11
+# Version
12
+set (project_VERSION_MAJOR "0")
13
+set (project_VERSION_MINOR "1")
14
+set (project_VERSION_PATCH "0")
15
+
16
+set (project_VERSION "${project_VERSION_MAJOR}")
17
+set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
18
+set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
19
+
20
+# For custom modules
21
+set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
22
+
23
+# Dependencies
24
+find_package (Ncursesw REQUIRED)
25
+find_package (PkgConfig REQUIRED)
26
+find_package (Unistring REQUIRED)
27
+
28
+set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake)
29
+include (AddThreads)
30
+
31
+find_package (Termo QUIET NO_MODULE)
32
+option (USE_SYSTEM_TERMO
33
+	"Don't compile our own termo library, use the system one" ${Termo_FOUND})
34
+
35
+if (USE_SYSTEM_TERMO)
36
+	if (NOT Termo_FOUND)
37
+		message (FATAL_ERROR "System termo library not found")
38
+	endif (NOT Termo_FOUND)
39
+else (USE_SYSTEM_TERMO)
40
+	add_subdirectory (termo EXCLUDE_FROM_ALL)
41
+	# We don't have many good choices when we don't want to install it and want
42
+	# to support older versions of CMake; this is a relatively clean approach
43
+	# (other possibilities: setting a variable in the parent scope, using a
44
+	# cache variable, writing a special config file with build paths in it and
45
+	# including it here, or setting a custom property on the targets).
46
+	get_directory_property (Termo_INCLUDE_DIRS
47
+		DIRECTORY termo INCLUDE_DIRECTORIES)
48
+	set (Termo_LIBRARIES termo-static)
49
+endif (USE_SYSTEM_TERMO)
50
+
51
+include_directories (${UNISTRING_INCLUDE_DIRS}
52
+	${NCURSESW_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS})
53
+
54
+# Configuration
55
+include (CheckFunctionExists)
56
+set (CMAKE_REQUIRED_LIBRARIES ${NCURSESW_LIBRARIES})
57
+CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
58
+
59
+# Generate a configuration file
60
+configure_file (${PROJECT_SOURCE_DIR}/config.h.in
61
+	${PROJECT_BINARY_DIR}/config.h)
62
+include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
63
+
64
+# Build the main executable and link it
65
+add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c)
66
+target_link_libraries (${PROJECT_NAME} ${UNISTRING_LIBRARIES}
67
+	${NCURSESW_LIBRARIES} termo-static)
68
+add_threads (${PROJECT_NAME})
69
+
70
+# Installation
71
+include (GNUInstallDirs)
72
+install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
73
+install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
74
+
75
+# Generate documentation from program help
76
+find_program (HELP2MAN_EXECUTABLE help2man)
77
+if (NOT HELP2MAN_EXECUTABLE)
78
+	message (FATAL_ERROR "help2man not found")
79
+endif (NOT HELP2MAN_EXECUTABLE)
80
+
81
+foreach (page ${PROJECT_NAME})
82
+	set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
83
+	list (APPEND project_MAN_PAGES "${page_output}")
84
+	add_custom_command (OUTPUT ${page_output}
85
+		COMMAND ${HELP2MAN_EXECUTABLE} -N
86
+			"${PROJECT_BINARY_DIR}/${page}" -o ${page_output}
87
+		DEPENDS ${page}
88
+		COMMENT "Generating man page for ${page}" VERBATIM)
89
+endforeach (page)
90
+
91
+add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
92
+
93
+foreach (page ${project_MAN_PAGES})
94
+	string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
95
+	install (FILES "${page}"
96
+		DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
97
+endforeach (page)
98
+
99
+# CPack
100
+set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hex viewer")
101
+set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
102
+set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>")
103
+set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
104
+set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
105
+set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
106
+set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
107
+set (CPACK_GENERATOR "TGZ;ZIP")
108
+set (CPACK_PACKAGE_FILE_NAME
109
+	"${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
110
+set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}")
111
+set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
112
+set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
113
+set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
114
+
115
+set (CPACK_SET_DESTDIR TRUE)
116
+include (CPack)

+ 15
- 0
LICENSE View File

@@ -0,0 +1,15 @@
1
+ Copyright (c) 2016, Přemysl Janouch <p.janouch@gmail.com>
2
+ All rights reserved.
3
+ 
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted, provided that the above
6
+ copyright notice and this permission notice appear in all copies.
7
+ 
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11
+ SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13
+ OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14
+ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
+

+ 86
- 0
README.adoc View File

@@ -0,0 +1,86 @@
1
+hex
2
+===
3
+
4
+'hex' is yet another hex viewer.  As of now, there are no advantages to it.
5
+
6
+Plans
7
+-----
8
+In the future, it should be able to automatically interpret fields within files
9
+via a set of Lua scripts.
10
+
11
+Packages
12
+--------
13
+Regular releases are sporadic.  git master should be stable enough.  You can get
14
+a package with the latest development version from Archlinux's AUR, or from
15
+openSUSE Build Service for the rest of mainstream distributions.  Consult the
16
+list of repositories and their respective links at:
17
+
18
+https://build.opensuse.org/project/repositories/home:pjanouch:git
19
+
20
+Building and Running
21
+--------------------
22
+Build dependencies: CMake, pkg-config, help2man, liberty (included),
23
+                    termo (included) +
24
+Runtime dependencies: ncursesw, libunistring
25
+
26
+ $ git clone --recursive https://github.com/pjanouch/hex.git
27
+ $ mkdir hex/build
28
+ $ cd hex/build
29
+ $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
30
+ $ make
31
+
32
+To install the application, you can do either the usual:
33
+
34
+ # make install
35
+
36
+Or you can try telling CMake to make a package for you.  For Debian it is:
37
+
38
+ $ cpack -G DEB
39
+ # dpkg -i hex-*.deb
40
+
41
+Note that for versions of CMake before 2.8.9, you need to prefix `cpack` with
42
+`fakeroot` or file ownership will end up wrong.
43
+
44
+Having the program installed, optionally create a configuration file and run it.
45
+
46
+Configuration
47
+-------------
48
+Create _~/.config/hex/hex.conf_ with contents like the following:
49
+
50
+....
51
+colors = {
52
+	header     = ""
53
+	highlight  = "bold"
54
+	bar        = "reverse"
55
+	bar_active = "ul"
56
+	even       = ""
57
+	odd        = ""
58
+	selection  = "reverse"
59
+}
60
+....
61
+
62
+Terminal caveats
63
+----------------
64
+This application aspires to be as close to a GUI as possible.  It expects you
65
+to use the mouse (though it's not required).  Terminals are, however, somewhat
66
+tricky to get consistent results on, so be aware of the following:
67
+
68
+ - use a UTF-8 locale to get finer resolution progress bars and scrollbars
69
+ - Xterm needs `XTerm*metaSendsEscape: true` for the default bindings to work
70
+ - urxvt's 'vtwheel' plugin sabotages scrolling
71
+
72
+Contributing and Support
73
+------------------------
74
+Use this project's GitHub to report any bugs, request features, or submit pull
75
+requests.  If you want to discuss this project, or maybe just hang out with
76
+the developer, feel free to join me at irc://irc.janouch.name, channel #dev.
77
+
78
+License
79
+-------
80
+'hex' is written by Přemysl Janouch <p.janouch@gmail.com>.
81
+
82
+You may use the software under the terms of the ISC license, the text of which
83
+is included within the package, or, at your option, you may relicense the work
84
+under the MIT or the Modified BSD License, as listed at the following site:
85
+
86
+http://www.gnu.org/licenses/license-list.html

+ 17
- 0
cmake/FindNcursesw.cmake View File

@@ -0,0 +1,17 @@
1
+# Public Domain
2
+
3
+find_package (PkgConfig REQUIRED)
4
+pkg_check_modules (NCURSESW QUIET ncursesw)
5
+
6
+# OpenBSD doesn't provide a pkg-config file
7
+set (required_vars NCURSESW_LIBRARIES)
8
+if (NOT NCURSESW_FOUND)
9
+	find_library (NCURSESW_LIBRARIES NAMES ncursesw)
10
+	find_path (NCURSESW_INCLUDE_DIRS ncurses.h)
11
+	list (APPEND required_vars NCURSESW_INCLUDE_DIRS)
12
+endif (NOT NCURSESW_FOUND)
13
+
14
+include (FindPackageHandleStandardArgs)
15
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (NCURSESW DEFAULT_MSG ${required_vars})
16
+
17
+mark_as_advanced (NCURSESW_LIBRARIES NCURSESW_INCLUDE_DIRS)

+ 10
- 0
cmake/FindUnistring.cmake View File

@@ -0,0 +1,10 @@
1
+# Public Domain
2
+
3
+find_path (UNISTRING_INCLUDE_DIRS unistr.h)
4
+find_library (UNISTRING_LIBRARIES NAMES unistring libunistring)
5
+
6
+include (FindPackageHandleStandardArgs)
7
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (UNISTRING DEFAULT_MSG
8
+	UNISTRING_INCLUDE_DIRS UNISTRING_LIBRARIES)
9
+
10
+mark_as_advanced (UNISTRING_LIBRARIES UNISTRING_INCLUDE_DIRS)

+ 10
- 0
config.h.in View File

@@ -0,0 +1,10 @@
1
+#ifndef CONFIG_H
2
+#define CONFIG_H
3
+
4
+#define PROGRAM_NAME "${CMAKE_PROJECT_NAME}"
5
+#define PROGRAM_VERSION "${project_VERSION}"
6
+
7
+#cmakedefine HAVE_RESIZETERM
8
+
9
+#endif  // ! CONFIG_H
10
+

+ 1295
- 0
hex.c
File diff suppressed because it is too large
View File


+ 1
- 0
liberty

@@ -0,0 +1 @@
1
+Subproject commit f53b717f3bba27ca1c42486d3742c91967f3fe93

+ 1
- 0
termo

@@ -0,0 +1 @@
1
+Subproject commit a9b41e41b7789924465a7e5596a463ed93d8fc26

Loading…
Cancel
Save