瀏覽代碼

feat: enable scrolling

Sam Jaffe 1 年之前
父節點
當前提交
55e5d61fdc
共有 4 個文件被更改,包括 6 次插入1 次删除
  1. 1 1
      include/ncurses-wrapper/cli.h
  2. 2 0
      include/ncurses-wrapper/window.h
  3. 2 0
      ncurses-wrapper.xcodeproj/project.pbxproj
  4. 1 0
      src/window.cxx

+ 1 - 1
include/ncurses-wrapper/cli.h

@@ -25,7 +25,7 @@ private:
 public:
   template <typename... Flags>
   explicit Cli(std::string const &prompt, Flags const &...flags)
-      : window_(flags..., NoEcho, ExtendedKeys), prompt_(prompt) {}
+      : window_(flags..., NoEcho, Scrollable, ExtendedKeys), prompt_(prompt) {}
   
   void loop(std::function<void(curses::Window &, std::string)> on_enter);
   

+ 2 - 0
include/ncurses-wrapper/window.h

@@ -22,6 +22,7 @@ constexpr struct Bold_t {} Bold;
 
 constexpr struct NoEcho_t {} NoEcho; // Don't automatically print input characters
 constexpr struct WithColor_t {} WithColor;
+constexpr struct Scrollable_t {} Scrollable; // Enable scrolling
 constexpr struct ExtendedKeys_t {} ExtendedKeys; // Enable KEY_* keys as unique items
 
 class Window {
@@ -65,6 +66,7 @@ private:
 
   void init_with(NoEcho_t);
   void init_with(WithColor_t);
+  void init_with(Scrollable_t);
   void init_with(ExtendedKeys_t);
   
   NCURSES_ATTR_T to_attr(Bold_t) const;

+ 2 - 0
ncurses-wrapper.xcodeproj/project.pbxproj

@@ -19,6 +19,7 @@
 		CDEECC472C5050FD000C4392 /* libcurses.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CDEECC462C5050FD000C4392 /* libcurses.tbd */; };
 		CDEECC4E2C5069C0000C4392 /* cli.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CDEECC4C2C5069C0000C4392 /* cli.cxx */; };
 		CDEECC4F2C5069C0000C4392 /* cli.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEECC4D2C5069C0000C4392 /* cli.h */; };
+		CDEECC6F2C508A92000C4392 /* ncurses-wrapper in Headers */ = {isa = PBXBuildFile; fileRef = CD93A7D52C5015EF00754263 /* ncurses-wrapper */; settings = {ATTRIBUTES = (Public, ); }; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -118,6 +119,7 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CDEECC6F2C508A92000C4392 /* ncurses-wrapper in Headers */,
 				CD93A7EC2C501F6F00754263 /* color.h in Headers */,
 				CD93A7E42C5016F400754263 /* forward.h in Headers */,
 				CD93A7DD2C50161700754263 /* window.h in Headers */,

+ 1 - 0
src/window.cxx

@@ -17,6 +17,7 @@
 namespace curses {
 void Window::init_with(NoEcho_t) { noecho(); }
 void Window::init_with(WithColor_t) { start_color(); use_default_colors(); }
+void Window::init_with(Scrollable_t) { scrollok(self_, TRUE); }
 void Window::init_with(ExtendedKeys_t) { keypad(self_, TRUE); }
 }