From 78e7f3ce529a4d9f0901b17badac8ce7badbb5a4 Mon Sep 17 00:00:00 2001 From: Pierre MARECHAL Date: Sun, 16 May 2010 21:46:06 +0200 Subject: [PATCH] bug 6977 fixed: ATOMS GUI: In the presentation frame, URLs and emails were not hyperlinked. Change-Id: I87ef571dbe049aa4389d21c4f9495f227553cedf --- scilab/CHANGES_5.3.X | 3 ++ .../modules/atoms/macros/atoms_gui/cbAtomsGui.sci | 51 ++++++++++++++++++++ .../modules/atoms/tests/nonreg_tests/bug_6977.tst | 25 ++++++++++ 3 files changed, 79 insertions(+) create mode 100644 scilab/modules/atoms/tests/nonreg_tests/bug_6977.tst diff --git a/scilab/CHANGES_5.3.X b/scilab/CHANGES_5.3.X index 2cd3093..93806ce 100644 --- a/scilab/CHANGES_5.3.X +++ b/scilab/CHANGES_5.3.X @@ -303,6 +303,9 @@ ATOMS: one, the ATOMS GUI claimed that the newest version was installed. +* bug 6977 fixed - ATOMS GUI: In the presentation frame, URLs and emails were + not hyperlinked. + Bug fixes: ========== diff --git a/scilab/modules/atoms/macros/atoms_gui/cbAtomsGui.sci b/scilab/modules/atoms/macros/atoms_gui/cbAtomsGui.sci index 322ff6ae..f916cf8 100644 --- a/scilab/modules/atoms/macros/atoms_gui/cbAtomsGui.sci +++ b/scilab/modules/atoms/macros/atoms_gui/cbAtomsGui.sci @@ -262,6 +262,9 @@ function updateDescFrame() "" + .. ""; + // Process URLs and Emails + htmlcode = processHTMLLinks(htmlcode); + // Update the main description set(Desc,"String",htmlcode); @@ -425,3 +428,51 @@ function showWarning(msg) set(msgText,"String",str); endfunction + +// ============================================================================= +// processHTMLLinks +// + Find URLs and emails +// + Convert them in HTML +// ============================================================================= + +function txtout = processHTMLLinks(txtin) + + regexUrl = "/((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\:\/\/)(www|[a-zA-Z0-9])[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(\/($|[a-zA-Z0-9\.\,\;\?\''\\\+&%\$#\=~_\-\/]+))*/"; + regexEmail = "/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/"; + txtout = ""; + + // Process URLs + + [mat_start,mat_end,mat_match] = regexp(txtin,regexUrl); + + if ~isempty(mat_match) then + mat_end = [ 0 mat_end ]; + for i=1:size(mat_match,"*") + txtout = txtout + part(txtin,[mat_end(i)+1:mat_start(i)-1]) .. + + "" .. + + mat_match(i) .. + + ""; + end + txtout = txtout + part(txtin,mat_end(size(mat_end,"*"))+1:length(txtin)); + txtin = txtout; + txtout = ""; + end + + // Process Emails + + [mat_start,mat_end,mat_match] = regexp(txtin,regexEmail); + + if ~isempty(mat_match) then + mat_end = [ 0 mat_end ]; + for i=1:size(mat_match,"*") + txtout = txtout + part(txtin,[mat_end(i)+1:mat_start(i)-1]) .. + + "" .. + + mat_match(i) .. + + ""; + end + txtout = txtout + part(txtin,mat_end(size(mat_end,"*"))+1:length(txtin)); + else + txtout = txtin; + end + +endfunction diff --git a/scilab/modules/atoms/tests/nonreg_tests/bug_6977.tst b/scilab/modules/atoms/tests/nonreg_tests/bug_6977.tst new file mode 100644 index 0000000..5d4df80 --- /dev/null +++ b/scilab/modules/atoms/tests/nonreg_tests/bug_6977.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Pierre MARECHAL +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- TEST WITH ATOMS --> +// <-- INTERACTIVE TEST --> +// +// <-- Non-regression test for bug 6977 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6977 +// +// <-- Short Description --> +// In the presentation frame: Make http entries hyperlinked (with target="_blank"). +// Presently, even a simple selection to copy/paste displayed URLs into the web +// browser is impossible. + +atomsGui(); + +// Select a module which description conntains an URL or an email. +// The text should be hyperlinked and the default browser (or email client) should +// be opened -- 1.7.9.5