From feec564a358df3d2194a4c804315c478a97e0896 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 15 Apr 2018 11:49:03 +0200 Subject: [PATCH] use openURL from LCLIntf, close #295 --- src/ce_common.pas | 58 ---------------------------------------------- src/ce_main.pas | 4 ++-- src/ce_synmemo.pas | 2 +- 3 files changed, 3 insertions(+), 61 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 26bb4a06..ff9893d5 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -312,12 +312,6 @@ type *) procedure deleteDups(strings: TStrings); - (** - * like LCLIntf eponymous function but includes a woraround that's gonna - * be in Lazarus from version 1.8 (anchor + file:/// protocol under win). - *) - function openUrl(const value: string): boolean; - procedure tryRaiseFromStdErr(proc: TProcess); // Converts all leading whites to spaces. Tabs takes width * spaces. @@ -1323,58 +1317,6 @@ begin end; end; -function openUrl(const value: string): boolean; -{$IFDEF WINDOWS} -function GetDefaultBrowserForCurrentUser: String; -begin - result := ''; - with TRegistry.Create do - try - RootKey := HKEY_CURRENT_USER; - if OpenKeyReadOnly('Software\Classes\http\shell\open\command') then - begin - result := ReadString(''); - CloseKey; - end; - finally - Free; - end; -end; -var - browser: string; - i: integer = 2; -{$ENDIF} -begin - {$IFNDEF WINDOWS} - result := LCLIntf.OpenURL(value); - {$ELSE} - if pos('file://', value) = 0 then - result := LCLIntf.OpenURL(value) - else - begin - browser := GetDefaultBrowserForCurrentUser; - if browser.isEmpty then - result := LCLIntf.OpenURL(value) - else - begin - if browser[1] = '"' then - begin - while browser[i] <> '"' do - begin - if i > browser.length then - break; - i += 1; - end; - if i <= browser.length then - browser := browser[1..i]; - end; - result := ShellExecuteW(0, 'open', PWideChar(WideString(browser)), - PWideChar(WideString(value)), nil, SW_SHOWNORMAL) > 32; - end; - end; - {$ENDIF} -end; - procedure tryRaiseFromStdErr(proc: TProcess); var str: string = ''; diff --git a/src/ce_main.pas b/src/ce_main.pas index 835268eb..50f03f58 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -9,7 +9,7 @@ uses StdCtrls, AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls, Graphics, strutils, Dialogs, Menus, ActnList, ExtCtrls, process, {$IFDEF WINDOWS}Windows, {$ENDIF} XMLPropStorage, SynExportHTML, fphttpclient, - fpjson, jsonparser, jsonscanner, + fpjson, jsonparser, jsonscanner, LCLIntf, ce_common, ce_ceproject, ce_synmemo, ce_writableComponent, ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_ceprojeditor, ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer, @@ -2007,7 +2007,7 @@ begin begin if dlgYesNo('An new release is available, do you wish to visit the release page ?' + lineEnding + '(' + url +')') = mrYes then - openUrl(url); + OpenURL(url); end; end; end; diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index d6be5399..af6150ff 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -9,7 +9,7 @@ uses SynEdit, SynPluginSyncroEdit, SynCompletion, SynEditKeyCmds, LazSynEditText, SynHighlighterLFM, SynEditHighlighter, SynEditMouseCmds, SynEditFoldedView, SynEditMarks, SynEditTypes, SynHighlighterJScript, SynBeautifier, dialogs, - md5, Spin, + md5, Spin, LCLIntf, //SynEditMarkupFoldColoring, Clipbrd, fpjson, jsonparser, LazUTF8, LazUTF8Classes, Buttons, StdCtrls, ce_common, ce_writableComponent, ce_d2syn, ce_txtsyn, ce_dialogs, ce_dastworx,