Commit 77f805ad authored by Matthew Zeng's avatar Matthew Zeng
Browse files

Rename scroll -> scroll_other_buffer, update_details -> update_buffer_details



So the names are more precise and better reflect what they really are.

Also some scroll code refactoring.

Signed-off-by: default avatarMingde (Matthew) Zeng <matthewzmd@gmail.com>
parent 5333d737
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -73,17 +73,17 @@ class AppBuffer(Buffer):
        if result_type == "jump_link":
            self.buffer_widget.cleanup_links()

    def scroll(self, scroll_direction, scroll_type):
    def scroll_other_buffer(self, scroll_direction, scroll_type):
        if scroll_type == "page":
            if scroll_direction == "up":
                self.buffer_widget.scroll_up_page()
                self.scroll_up_page()
            else:
                self.buffer_widget.scroll_down_page()
                self.scroll_down_page()
        else:
            if scroll_direction == "up":
                self.buffer_widget.scroll_up()
                self.scroll_up()
            else:
                self.buffer_widget.scroll_down()
                self.scroll_down()

    def save_session_data(self):
        return "{0}:{1}:{2}:{3}".format(self.buffer_widget.scroll_offset,
+12 −5
Original line number Diff line number Diff line
@@ -110,16 +110,23 @@ class AppBuffer(BrowserBuffer):
        text = QApplication.clipboard().text()
        self.buffer_widget.eval_js("paste('{}');".format(text))

    def scroll(self, scroll_direction, scroll_type):
    def scroll_other_buffer(self, scroll_direction, scroll_type):
        if scroll_type == "page":
            if scroll_direction == "up":
                self.buffer_widget.eval_js("scroll_page(1);")
                self.scroll_up_page()
            else:
                self.buffer_widget.eval_js("scroll_page(-1);")
                self.scroll_down_page()
        else:
            if scroll_direction == "up":
                self.buffer_widget.eval_js("scroll_line(1);")
                self.scroll_up()
            else:
                self.scroll_down()

    def scroll_up(self):
        print("python scroll_up")
        self.buffer_widget.eval_js("scroll_line(1);")

    def scroll_down(self):
        self.buffer_widget.eval_js("scroll_line(-1);")

    def scroll_up_page(self):
+1 −1
Original line number Diff line number Diff line
@@ -648,7 +648,7 @@ class BrowserBuffer(Buffer):
        # We need send key event to QWebEngineView's focusProxy widget, not QWebEngineView.
        return [self.buffer_widget.focusProxy()]

    def scroll(self, scroll_direction, scroll_type):
    def scroll_other_buffer(self, scroll_direction, scroll_type):
        if scroll_type == "page":
            if scroll_direction == "up":
                self.scroll_up_page()
+3 −3
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ qt_text_dict = {
class Buffer(QGraphicsScene):
    __metaclass__ = abc.ABCMeta

    update_details = QtCore.pyqtSignal(str, str, str)
    update_buffer_details = QtCore.pyqtSignal(str, str, str)
    open_url_in_new_tab = QtCore.pyqtSignal(str)
    open_url_in_background_tab = QtCore.pyqtSignal(str)
    translate_text = QtCore.pyqtSignal(str)
@@ -171,7 +171,7 @@ class Buffer(QGraphicsScene):

    def change_title(self, title):
        self.title = title
        self.update_details.emit(self.buffer_id, title, self.url)
        self.update_buffer_details.emit(self.buffer_id, title, self.url)

    def close_buffer(self):
        self.request_close_buffer.emit(self.buffer_id)
@@ -200,7 +200,7 @@ class Buffer(QGraphicsScene):
    def cancel_input_message(self, result_type):
        pass

    def scroll(self, scroll_direction, scroll_type):
    def scroll_other_buffer(self, scroll_direction, scroll_type):
        pass

    def save_session_data(self):
+11 −7
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-06-15 14:10:12
;; Version: 0.5
;; Last-Updated: Tue Jun 16 19:06:47 2020 (-0400)
;; Last-Updated: Wed Jun 17 03:14:16 2020 (-0400)
;;           By: Mingde (Matthew) Zeng
;; URL: http://www.emacswiki.org/emacs/download/eaf.el
;; Keywords:
@@ -437,7 +437,13 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
  :type 'cons)

(defcustom eaf-terminal-keybinding
  '(("C--" . "zoom_out")
  '(("M-n" . "scroll_up")
    ("M-p" . "scroll_down")
    ("C-v" . "scroll_up_page")
    ("M-v" . "scroll_down_page")
    ("M-<" . "scroll_to_begin")
    ("M->" . "scroll_to_bottom")
    ("C--" . "zoom_out")
    ("C-=" . "zoom_in")
    ("C-0" . "zoom_reset")
    ("C-S-c" . "copy_text")
@@ -456,8 +462,6 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
    ("C-u" . "eaf-send-key-sequence")
    ("C-l" . "eaf-send-key-sequence")
    ("C-w" . "eaf-send-key-sequence")
    ("C-v" . "eaf-send-key-sequence")
    ("M-v" . "eaf-send-key-sequence")
    ("M-f" . "eaf-send-key-sequence")
    ("M-b" . "eaf-send-key-sequence")
    ("M-d" . "eaf-send-key-sequence")
@@ -2112,7 +2116,7 @@ Make sure that your smartphone is connected to the same WiFi network as this com
  (other-window +1)
  (if (derived-mode-p 'eaf-mode)
      (progn
        (eaf-call "scroll_buffer" (eaf-get-view-info) "up"
        (eaf-call "scroll_other_buffer" (eaf-get-view-info) "up"
                  (if arg "line" "page"))
        (other-window -1))
    (other-window -1)
@@ -2124,7 +2128,7 @@ Make sure that your smartphone is connected to the same WiFi network as this com
  (other-window +1)
  (if (derived-mode-p 'eaf-mode)
      (progn
        (eaf-call "scroll_buffer" (eaf-get-view-info) "down"
        (eaf-call "scroll_other_buffer" (eaf-get-view-info) "down"
                  (if arg "line" "page"))
        (other-window -1))
    (other-window -1)
@@ -2138,7 +2142,7 @@ Make sure that your smartphone is connected to the same WiFi network as this com
  (other-window +1)
  (if (derived-mode-p 'eaf-mode)
      (progn
        (eaf-call "scroll_buffer" (eaf-get-view-info)
        (eaf-call "scroll_other_buffer" (eaf-get-view-info)
                  (if (string-equal direction "up") "up" "down")
                  (if line "line" "page"))
        (other-window -1))
Loading