Browse Source

Paste From Clipboard

Arthur Yefimov 2 years ago
parent
commit
f8d9178651
6 changed files with 30 additions and 7 deletions
  1. 1 0
      Data/Texts/en.dat
  2. 1 0
      Data/Texts/ru.dat
  3. 8 4
      src/Editor.Mod
  4. 13 1
      src/FreeOberon.Mod
  5. 2 2
      src/Graph.Mod
  6. 5 0
      src/TermBox.Mod

+ 1 - 0
Data/Texts/en.dat

@@ -208,6 +208,7 @@ menuRedo "&Redo"
 menuCut "Cu&t"
 menuCut "Cu&t"
 menuCopy "&Copy"
 menuCopy "&Copy"
 menuPaste "&Paste"
 menuPaste "&Paste"
+menuPasteClipboard "Pas&te From OS Clipboard"
 menuClear "C&lear"
 menuClear "C&lear"
 menuSelectAll "Select &All"
 menuSelectAll "Select &All"
 menuUnselect "U&nselect"
 menuUnselect "U&nselect"

+ 1 - 0
Data/Texts/ru.dat

@@ -208,6 +208,7 @@ menuRedo "&Повтор"
 menuCut "&Вырезать"
 menuCut "&Вырезать"
 menuCopy "&Копировать"
 menuCopy "&Копировать"
 menuPaste "В&ставить"
 menuPaste "В&ставить"
+menuPasteClipboard "Вс&тавить из системного буфера"
 menuClear "&Удалить"
 menuClear "&Удалить"
 menuSelectAll "В&ыделить всё"
 menuSelectAll "В&ыделить всё"
 menuUnselect "С&нять выделение"
 menuUnselect "С&нять выделение"

+ 8 - 4
src/Editor.Mod

@@ -955,18 +955,22 @@ BEGIN e := c.app.windows;
   END
   END
 END EditClear;
 END EditClear;
 
 
-PROCEDURE EditPaste*(c: OV.Control);
+PROCEDURE PasteText*(app: OV.App; s: ARRAY OF CHAR);
 VAR e: Editor;
 VAR e: Editor;
 BEGIN
 BEGIN
-  IF (c.app.windows # NIL) & (c.app.windows IS Editor) & (clipboard[0] # 0X)
-  THEN e := c.app.windows(Editor);
+  IF (app.windows # NIL) & (app.windows IS Editor) & (s[0] # 0X) THEN
+    e := app.windows(Editor);
     e.text.DeleteSelection;
     e.text.DeleteSelection;
-    e.text.Insert(clipboard, FALSE);
+    e.text.Insert(s, FALSE);
     IF e.text.y >= e.text.scrY + e.h - 2 THEN
     IF e.text.y >= e.text.scrY + e.h - 2 THEN
       MoveScreen(e, e.text.y - e.h + 3 - e.text.scrY)
       MoveScreen(e, e.text.y - e.h + 3 - e.text.scrY)
     END;
     END;
     PrintText(e)
     PrintText(e)
   END
   END
+END PasteText;
+
+PROCEDURE EditPaste*(c: OV.Control);
+BEGIN PasteText(c.app, clipboard) 
 END EditPaste;
 END EditPaste;
 
 
 PROCEDURE EditSelectAll*(c: OV.Control);
 PROCEDURE EditSelectAll*(c: OV.Control);

+ 13 - 1
src/FreeOberon.Mod

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 *)
-IMPORT T := TermBox, Files, Args, Utf8, Builder, Env, Debug,
+IMPORT T := TermBox, Files, Args, Utf8, Builder, Env, Debug, Graph,
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
 CONST
 CONST
   (* Direction of Selection *)
   (* Direction of Selection *)
@@ -650,6 +650,16 @@ BEGIN E := app.windows;
   END
   END
 END CascadeWindows;
 END CascadeWindows;
 
 
+PROCEDURE EditPasteClipboard*(c: OV.Control);
+VAR e: Editor.Editor;
+  s: ARRAY 50000 OF CHAR;
+BEGIN
+  IF (c.app.windows # NIL) & (c.app.windows IS Editor.Editor) THEN
+    T.GetClipboardText(s);
+    Editor.PasteText(app, s)
+  END
+END EditPasteClipboard;
+
 PROCEDURE InitIDE;
 PROCEDURE InitIDE;
 VAR w: OV.Window;
 VAR w: OV.Window;
   m, m2: OV.Menu;
   m, m2: OV.Menu;
@@ -692,6 +702,8 @@ BEGIN
   OV.Add(m, OV.NewMenu(s, 'Ctrl+C', OV.hCtrlC, Editor.EditCopy));
   OV.Add(m, OV.NewMenu(s, 'Ctrl+C', OV.hCtrlC, Editor.EditCopy));
   FoStrings.Get('menuPaste', s);
   FoStrings.Get('menuPaste', s);
   OV.Add(m, OV.NewMenu(s, 'Ctrl+V', OV.hCtrlV, Editor.EditPaste));
   OV.Add(m, OV.NewMenu(s, 'Ctrl+V', OV.hCtrlV, Editor.EditPaste));
+  FoStrings.Get('menuPasteClipboard', s);
+  OV.Add(m, OV.NewMenu(s, 'Ctrl+Shift+V', OV.hCtrlShiftV, EditPasteClipboard));
   FoStrings.Get('menuClear', s);
   FoStrings.Get('menuClear', s);
   OV.Add(m, OV.NewMenu(s, 'Ctrl+Del', OV.hCtrlDel, Editor.EditClear));
   OV.Add(m, OV.NewMenu(s, 'Ctrl+Del', OV.hCtrlDel, Editor.EditClear));
   FoStrings.Get('menuSelectAll', s);
   FoStrings.Get('menuSelectAll', s);

+ 2 - 2
src/Graph.Mod

@@ -1418,7 +1418,7 @@ RETURN f END LoadFont;
 (** Clipboard **)
 (** Clipboard **)
 
 
 PROCEDURE GetClipboardText*(win: Window; VAR s: ARRAY OF CHAR);
 PROCEDURE GetClipboardText*(win: Window; VAR s: ARRAY OF CHAR);
-TYPE P = POINTER [1] TO ARRAY 5000 OF SHORTCHAR;
+TYPE P = POINTER [1] TO ARRAY 50000 OF SHORTCHAR;
 VAR a: Al.ADRINT;
 VAR a: Al.ADRINT;
   p: P;
   p: P;
   q: ARRAY 20 OF SHORTCHAR;
   q: ARRAY 20 OF SHORTCHAR;
@@ -1427,7 +1427,7 @@ BEGIN
   (*IF a = 0 THEN a := Al.get_clipboard_text(win.display) END; (*Allegro bug*)*)
   (*IF a = 0 THEN a := Al.get_clipboard_text(win.display) END; (*Allegro bug*)*)
   (*Out.String('PASTE DEBUG. a = ');Out.Int(a, 0);Out.Ln;*)
   (*Out.String('PASTE DEBUG. a = ');Out.Int(a, 0);Out.Ln;*)
   IF a # 0 THEN p := SYSTEM.VAL(P, a); Utf8.Decode(p^, s);
   IF a # 0 THEN p := SYSTEM.VAL(P, a); Utf8.Decode(p^, s);
-    Al.free_with_context(a, 27, 'Graph.Mod', 'GetClipboardText')
+    Al.free_with_context(a, 1430, 'Graph.Mod', 'GetClipboardText')
     (*;Utf8.Encode('Привет', q);
     (*;Utf8.Encode('Привет', q);
     ;IF Al.set_clipboard_text(win.display, SYSTEM.VAL(Al.ADRINT, SYSTEM.ADR(q))) THEN END*)
     ;IF Al.set_clipboard_text(win.display, SYSTEM.VAL(Al.ADRINT, SYSTEM.ADR(q))) THEN END*)
   ELSE s[0] := 0X
   ELSE s[0] := 0X

+ 5 - 0
src/TermBox.Mod

@@ -801,6 +801,11 @@ BEGIN
   IF b # NIL THEN G.SetWindowIcon(screen, b) END
   IF b # NIL THEN G.SetWindowIcon(screen, b) END
 END InitIcon;
 END InitIcon;
 
 
+PROCEDURE GetClipboardText*(VAR s: ARRAY OF CHAR);
+BEGIN
+  IF screen # NIL THEN G.GetClipboardText(screen, s) ELSE s[0] := 0X END
+END GetClipboardText;
+
 PROCEDURE InitScreen;
 PROCEDURE InitScreen;
 VAR W, H, dw, dh: INTEGER;
 VAR W, H, dw, dh: INTEGER;
 BEGIN G.GetDesktopResolution(dw, dh);
 BEGIN G.GetDesktopResolution(dw, dh);